GetModuleHandle in a DLL
-
Hi "Then the loader maps the executable module at memory address 0x00400000 and the DLL module at 0x10000000." http://www.codeproject.com/KB/DLL/RebaseDll.aspx[^] I built a dll and export a function which is called GetModuleHandle(NULL); Then an MFC application which is included this dll. In Mfc app calling GetModuleHandle(NULL); returns 0x00400000. OK. But when i called an exported function in the dll, it returned 0x00400000 too. But I expected to see 0x10000000. So can we say GetModuleHandle(NULL) always returns EXE's load address even it is in a DLL?
-
Hi "Then the loader maps the executable module at memory address 0x00400000 and the DLL module at 0x10000000." http://www.codeproject.com/KB/DLL/RebaseDll.aspx[^] I built a dll and export a function which is called GetModuleHandle(NULL); Then an MFC application which is included this dll. In Mfc app calling GetModuleHandle(NULL); returns 0x00400000. OK. But when i called an exported function in the dll, it returned 0x00400000 too. But I expected to see 0x10000000. So can we say GetModuleHandle(NULL) always returns EXE's load address even it is in a DLL?
sawerr wrote:
I built a dll and export a function which is called GetModuleHandle(NULL);
GetModuleHandle is a Win32 API function. Did you export the same named function in a different namespace? From the GetModuleHandle() docs, lpModuleName parameter: "If this parameter is NULL, GetModuleHandle returns a handle to the file used to create the calling process (.exe file)."
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
sawerr wrote:
I built a dll and export a function which is called GetModuleHandle(NULL);
GetModuleHandle is a Win32 API function. Did you export the same named function in a different namespace? From the GetModuleHandle() docs, lpModuleName parameter: "If this parameter is NULL, GetModuleHandle returns a handle to the file used to create the calling process (.exe file)."
Mark Salsbery Microsoft MVP - Visual C++ :java: