The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: georgek01 on March 26, 2008, 06:46:45 AM

Title: EnumResourceNames and hModule
Post by: georgek01 on March 26, 2008, 06:46:45 AM
Hello!

I would like to use EnumResourceNames to enumerate a module's resource names. The first parameter hModule is a handle to the module.

I was looking at GetModuleHandle, but this requires the module to be mapped into the address space of the calling process, but I don't necessarily want to have to load it into memory first.

My question is, how do I get the handle to an EXE if it has not has been mapped into the address space of the calling process?
Title: Re: EnumResourceNames and hModule
Post by: georgek01 on March 26, 2008, 09:32:14 AM
I have the following code working up to a point.


EnumRes proc

invoke LoadLibraryEx,addr ListBuffer,NULL,LOAD_LIBRARY_AS_DATAFILE
.if eax == NULL ; execution passes this point...
invoke ErrMsg,hMain,121,0,NULL
mov eax,1
ret
.endif

mov hResource,eax

invoke EnumResourceNames,hResource,RT_STRING,addr EnumResProc,0
.if eax == 0 ; error (998) occurs here, see below
invoke ErrMsg,hMain,122,0,NULL
mov eax,1
ret
.endif

xor eax, eax
ret
EnumRes endp

EnumResProc proc hModule:HANDLE, lpType:DWORD, lpName:DWORD, lParam:LPARAM

invoke MessageBox,NULL,lpName,addr szAppName,MB_OK

mov eax,TRUE
ret
EnumResProc endp


The following error is returned though:

Error Code: 998
Error: Invalid access to memory location