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?
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