The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: mikky on May 31, 2010, 08:48:44 PM

Title: getting module base of a .dll in windows7
Post by: mikky on May 31, 2010, 08:48:44 PM
hi
i have some problems finding the module base address of a dll
i want to train a game, and i need to find the module base for 'XXX.dll'

here's the code routine that works on windows xp:

GetModuleBaseAddress proc iProcID:DWORD, DLLName:DWORD
LOCAL hSnap:DWORD
LOCAL xModule:MODULEENTRY32
invoke CreateToolhelp32Snapshot, TH32CS_SNAPMODULE, iProcID
mov hSnap,eax
mov xModule.dwSize, sizeof xModule
invoke Module32First, hSnap, addr xModule
test eax, eax
jnz getdll
mov eax, 0
ret
getdll:
invoke Module32Next, hSnap, addr xModule
test eax, eax
jnz checkdll
mov eax, 0
ret
checkdll:
invoke lstrcmpi, DLLName, addr xModule.szModule
test eax, eax
jnz getdll
mov eax, xModule.modBaseAddr
ret
GetModuleBaseAddress endp


now the problem is that this doesn't work on windows7. why?
am i doing something wrong?
is there any other way to obtain the module base of a dll in windows7?

thank you very much
Title: Re: getting module base of a .dll in windows7
Post by: Slugsnack on June 01, 2010, 12:04:51 AM
or you know you could use GetModuleHandle(). btw you probably shouldn't post any more queries on game training, etc. on these forums. it is not encouraged and against the forum rules
Title: Re: getting module base of a .dll in windows7
Post by: oex on June 01, 2010, 12:26:40 AM
Quote from: Slugsnack on June 01, 2010, 12:04:51 AM
btw you probably shouldn't post any more queries on game training, etc. on these forums. it is not encouraged and against the forum rules

Please excuse my ignorance but why are game training queries banned? It is late here and all I can think is maybe it is a SMC reference?