I’m writing a DLL, and I would like to, post-compilation, add some strings to it as an embedded resource.
To do that, I’m using a Python script that looks similar to the following:
hRes = win32api.BeginUpdateResource(myFile, 0)
win32api.UpdateResource(hRes, win32con.RT_STRING, 409, buf, 1033)
win32api.EndUpdateResource(hRes, 0)
And that appears to work, I can see the strings in the PE with my hex-editor.
The problem occurs when my Dll tries to use LoadString() to pull that string back out.
The call is something like:
LoadString(myDll, 409, someBuf, lenOfBuf);
And my program is appearing to de-reference a bad pointer in the LoadString() call.
Does my problem lie with how I’m adding the string, or pulling it out? And can anyone point me towards example code that does both steps?
Edit: I’d prefer to use the Win32 APIs for this.
Silly me, I just needed to use the STRINGTABLE structure instead of just dumping in raw strings.