vendredi 13 mars 2015

GetModuleHandleEx does not work when called from DLL, only from EXE


I have some Win32 code that tries to load a module with



HMODULE hModule = NULL;
// "mydll" can be even "user32.dll"/"user32"
BOOL result = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, "mydll", &hModule);


When I run this in the debugger from another DLL it fails in the GetModuleHandleEx call with



0xC0000005: Access violation executing location 0x0000FDEE.


Even though the debugger shows that the module is loaded. However If I put exactly the same call in the EXE code, then it works fine.


The documentation does not seem to indicate this cannot be called from DLLs (see http://ift.tt/1CeCRQc)


NOTE: same happens for GetModuleHandle :(


Is there any reason why this does not work from DLL?




Aucun commentaire:

Enregistrer un commentaire