How To Get Current Module (dll) Handle

I need to get the name of current module (dll). I dont have the HMODULE or the name of the module.

Thanx n Advance
Who is Participating?
Daniel Van Der WerkenIndependent ConsultantCommented:
adnan562Author Commented:
Thanx Dan7el

But using GetModuleHandle() u need to know the name of module, which i mentioned i dont have.
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

U can get the HMODULE with
BOOL WINAPI GetModuleHandleEx(  DWORD dwFlags,  LPCTSTR lpModuleName,  HMODULE* phModule);

this function retrieve the module from a function pointer contained into the dll:

void    *functionPtr = ...;
HMODULE  handle = NULL;
char     path[MAX_PATH] = "";
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, functionPtr, &handle );
GetModuleFileNameA(handle , path, __countof(path));

adnan562Author Commented:

GetModuleHandleEx is for XP.
Any solution for windows 2000
adnan562Author Commented:
Hi MechanTOurS

Thnx alot MechanTOurS

Although it dint work for me, caz I am hooking into another process memory but it was of great help thats why I am accepting your answer.

adnan562Author Commented:
Hi all,

I found a solution many thanx to cmk.

See this forum at CodeProject

All Courses

From novice to tech pro — start learning today.