#include <windows.h>
#include <psapi.h>
// Minimal DllMain - required for a DLL
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
{
return TRUE;
}
// Exported function that mimics K32GetModuleInformation
extern "C" __declspec(dllexport) BOOL WINAPI K32GetModuleInformation(
HANDLE hProcess,
HMODULE hModule,
LPMODULEINFO lpmodinfo,
DWORD cb)
{
// Load PSAPI.dll dynamically
HMODULE hPSAPI = LoadLibrary("psapi.dll");
if (!hPSAPI)
return FALSE;
// Get the address of GetModuleInformation in PSAPI.dll
typedef BOOL (WINAPI *PFNGETMODULEINFORMATION)(HANDLE, HMODULE, LPMODULEINFO, DWORD);
PFNGETMODULEINFORMATION pGetModuleInformation = (PFNGETMODULEINFORMATION)GetProcAddress(hPSAPI, "GetModuleInformation");
if (!pGetModuleInformation)
return FALSE;
// Forward the call
return pGetModuleInformation(hProcess, hModule, lpmodinfo, cb);
}