Hi, i've made a little tool to read / write to wow memory but on some computers GetModuleBase fails! It gets wrong Module Base while others work fine. C++ Redistributable is static linked. This is my function:
Code:
UINT_PTR GetModuleBase(LPTSTR lpModuleName, DWORD dwProcessId)
{
MODULEENTRY32 lpModuleEntry = {0};
HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessId);
if(!hSnapShot)
return NULL;
lpModuleEntry.dwSize = sizeof(lpModuleEntry);
BOOL bModule = Module32First(hSnapShot, &lpModuleEntry);
while(bModule)
{
if(!_tcscmp(lpModuleEntry.szModule, lpModuleName))
{
CloseHandle(hSnapShot);
return (UINT_PTR)lpModuleEntry.modBaseAddr;
}
bModule = Module32Next(hSnapShot, &lpModuleEntry);
}
CloseHandle(hSnapShot);
return NULL;
}
Can somebody explain why it doesn't work for some users.. it displays 0x400000 als mainmodule on some computers which is WRONG.