Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

How do I correctly use String Tables, UpdateResource etc.?

Hello, I have now been for a few hours trying to update a String resource in another .exe file, but with no success so far.

Here is what I want to do:
IWantToUpdateAStringHere.exe (basically does: MessageBox(String1FromSt, String2FromST))

StringTable with 2 entries:
IDS_Hello 102 "Hello"
IDS_World 103 "World"

When I run this file I get a MessageBox that says has Hello as the title and World as the text.

Now I want to edit these resources by updating a string in the StringTable from another .exe, so that I could, for example, get the output Hello Test. But I always end up either creating a new StringTable and not updating the actual resource, or I overwrite the entire resource, and the actual program crashes.

I have been trying to find a proper example of how to do this, but I am not able to find a solution for String Tables.

Here is the code I use in the update.exe file:

Code
HANDLE hUpdateRes = BeginUpdateResource(TEXT("Test.exe"), FALSE);
TCHAR sz[] = TEXT("Test");
BOOL result = UpdateResource(hUpdateRes, RT_STRING, L"IDS_Hello", MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), (void*)sz, (lstrlen(sz) + 4));
BOOL commit = EndUpdateResource(hUpdateRes, FALSE);

Thanks in advance for any help!
Been a while since I've messed about with resources in general, but IIRC when replacing existing resource data in PEs the replacement has to be the same length as the original. Assuming the null terminator counts as the sixth character, you could just use "test \0" with the space (might have to use an identifier or typecast for it) along with the null terminator. Also, ensure type and encoding match both the original and replacement. (Just an idea. Don't know if that would cause any sort of issue, but just by how it sounds it very well may.)
[Image: chain.png]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by LynxJan 3, 2022 04:47 PM 1 184 Jan 3, 2022 04:47 PM
Last Post: yuumi
[C] by MordiciaNov 15, 2019 07:21 PM 3 211 Nov 15, 2019 07:21 PM
Last Post: Mordicia
[C] by ❖Onyx❖Oct 18, 2019 04:48 PM 11 343 Oct 18, 2019 04:48 PM
Last Post: SKIDROOTKIT