C++ DLL GetModuleFile

extern BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved);

HMODULE GetModuleFromAddr(PVOID p)

{

MEMORY_BASIC_INFORMATION m = {0};

VirtualQuery(p, &m, sizeof(MEMORY_BASIC_INFORMATION));

return (HMODULE) m.AllocationBase;

}

HMODULE m_hDll = GetModuleFromAddr(DllMain);

char szModulePath[255] = {0};

GetModuleFileName(m_hDll, szModulePath, 255);

你可能感兴趣的:(dll,vc++)