The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: georgek01 on March 25, 2008, 01:24:54 PM

Title: UpdateResource is not updating
Post by: georgek01 on March 25, 2008, 01:24:54 PM
Hello!

I'm trying to update a string resource in an EXE. The code looks as follows:


invoke BeginUpdateResource,addr ListBuffer,FALSE
.if eax == NULL
   invoke ErrMsg,hMain,1,101,NULL
   mov eax,1
   ret 
.endif

mov hResource,eax

invoke MultiByteToWideChar,CP_ACP,MB_PRECOMPOSED,addr ListBuffer,sizeof ListBuffer,addr buffer,sizeof buffer

invoke UpdateResource,hResource,RT_STRING,addr szContent,LANG_ENGLISH,addr buffer,sizeof buffer
.if eax == 0
   invoke ErrMsg,hMain,2,101,NULL
   mov eax,1
   ret 
.endif

invoke EndUpdateResource,hResource,FALSE
.if eax == 0
   invoke ErrMsg,hMain,6,101,NULL
   mov eax,1
   ret 
.endif


No errors occur and the resource is not updated. Any ideas perhaps why?
Title: Re: UpdateResource is not updating
Post by: evlncrn8 on March 25, 2008, 02:30:14 PM
GetLastError value doesnt change?
Title: Re: UpdateResource is not updating
Post by: georgek01 on March 25, 2008, 02:38:44 PM
This is the error display procedure.


ErrMsg proc hW:HWND, icode:DWORD, itype:DWORD, phead:DWORD

local lbuffer:DWORD
local mbuffer[256]:BYTE
local dwError:DWORD

.if itype == 0
invoke GetLastError
.else
invoke GetLastError
.endif

mov dwError,eax

lea eax, [lbuffer]
invoke FormatMessage,FORMAT_MESSAGE_ALLOCATE_BUFFER + FORMAT_MESSAGE_FROM_SYSTEM,0,[dwError],LANG_NEUTRAL,eax,0,0
invoke wsprintf,addr mbuffer,addr szErrorFormat,[dwError],[lbuffer],icode
invoke MessageBox,hW,addr mbuffer,addr szApp,MB_ICONERROR+MB_OK
invoke LocalFree,[lbuffer]

xor eax, eax
ret
ErrMsg endp


If an error occurs, invoke ErrMsg,hMain,6,101,NULL calls the procedure that then displays the appropriate error message.

At all check points, eax contains the required return value (either !=NULL or !=0).

Title: Re: UpdateResource is not updating
Post by: Kernel on March 27, 2008, 07:11:15 PM
Quote from: georgek01 on March 25, 2008, 01:24:54 PMinvoke UpdateResource,hResource,RT_STRING,addr szContent,LANG_ENGLISH,addr buffer,sizeof buffer
Sry, if it doesn't help, and I don't remember when and what,
coz some months went by since I played with updating resources.
But try SUBLANG_ENGLISH_US instead of LANG_ENGLISH.