News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Update Resource

Started by starzboy, January 25, 2009, 07:48:38 PM

Previous topic - Next topic

starzboy

Hi
I was playing with update resource and i got stuck on a little problem.
I use update resource to load and update resource into another exe.
But the problem is that this new resource gets added to the file under the same resource name but under a different language.
i used LANG_ENGLISH and SUBLANG_ENGLISH_US   , which showed did not work.

invoke   BeginUpdateResource,addr FilePath,NULL
mov   dword ptr ds:[hUpdate],eax
invoke   UpdateResource,dword ptr ds:[hUpdate],RT_RCDATA,chr$("10"),LANG_ENGLISH,dword ptr ds:[hData],10h
invoke   EndUpdateResource,dword ptr ds:[hUpdate],NULL

Can you please show where i am going wrong ?

ragdog

Hi


Add2Res          PROTO :DWORD,:DWORD,:DWORD
MAKELANGID       PROTO :USHORT,:USHORT

.data
szFileToInc      db "play.exe",0
szXmfile         db "sound.xm",0
dwFileSize      dd 0
.data?

hInstance   dd ?
hFile             dd ?
lpBuffer          dd ?
hUpdateRes       dd ?
.code

invoke Add2Res,addr szFileToInc,500,addr szXmfile
;,lpszFile        == file to add in resource
;,lpszResId       == Resource id
; lpszUpdateFile == file 2 update the resource

Add2Res Proc lpszUpdateFile:DWORD,lpszResId:DWORD,lpszFile:DWORD
LOCAL dwBytesRead :DWORD
LOCAL LanguageId  :DWORD


invoke CreateFile,lpszFile, GENERIC_READ,0,NULL,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL
   cmp eax, INVALID_HANDLE_VALUE
    jz _exit
       mov hFile,eax
       
    invoke GetFileSize,hFile,0
       mov dwFileSize,eax

invoke GlobalAlloc,GPTR,dwFileSize
    mov lpBuffer,eax
     invoke ReadFile,hFile,lpBuffer,dwFileSize,ADDR dwBytesRead,NULL
         
     invoke MAKELANGID,LANG_ENGLISH,SUBLANG_DEFAULT
    mov LanguageId,eax
       
     invoke BeginUpdateResource,lpszUpdateFile,FALSE
         or eax,eax
         jz _exit
    mov hUpdateRes,eax
invoke UpdateResource,hUpdateRes,RT_RCDATA,lpszResId,LanguageId, lpBuffer,dwFileSize
invoke EndUpdateResource,hUpdateRes,FALSE
invoke GlobalFree,lpBuffer
_exit:
ret

Add2Res endp

MAKELANGID proc usPrimaryLanguage:USHORT, usSubLanguage:USHORT

movzx eax, usPrimaryLanguage
movzx ebx, usSubLanguage
shl ebx, 10
or eax, ebx
ret

MAKELANGID endp


Greets

starzboy

Hey, thanks for the reply.
Now the resource file is added correctly into the second file.
I can see the data via reshacker, but 2nd file is not able to load the resource, it fails to load it.
Why does this happen ?

ragdog

Hi

Hmm
Can you upload this source or PM me ?
If you not post here.

Greets