Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- -----------------------------------------
- * Game hacking QTS ( Quickie Tip Series )
- * no. 30 - Finding a dll module and obtaining its size
- -----------------------------------------
- * Author: SEGnosis
- * Thanks to:
- * bitterbanana - No known site
- * Drunken Cheetah - No known site
- * fatboy88 - No known site
- * Geek4Ever - No known site
- * learn_more - www.uc-forum.com
- * Novocaine - http://ilsken.net/blog/?page_id=64
- * Philly0494 - No known site
- * Roverturbo - www.uc-forum.com
- * SilentKarma - www.halocoders.com - offline
- * Strife - www.uc-forum.com
- * Wieter20 - No known site
- */
- //----------------------------------//
- // This function takes in the dll name and returns the base address
- // It will wait until the module exists, so put it in a thread
- DWORD GetModuleAddress(char* szModule)
- {
- DWORD dwAddress;
- while(true)
- {
- dwAddress = (DWORD)GetModuleHandle(szModule);
- if(dwAddress != NULL)
- break;
- else
- Sleep(250);
- }
- return dwAddress;
- }
- // This function takes in a module name
- // It then iterates through the modules and returns the matching module's size
- DWORD GetModuleSize(char* module)
- {
- DWORD dwSize;
- HANDLE hSnap;
- MODULEENTRY32 xModule;
- hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId());
- xModule.dwSize = sizeof(MODULEENTRY32);
- if (Module32First(hSnap, &xModule) != FALSE)
- {
- while (Module32Next(hSnap, &xModule))
- {
- if (strcmp((char*)xModule.szModule, module) == 0)
- {
- dwSize = xModule.modBaseSize;
- break;
- }
- }
- }
- CloseHandle(hSnap);
- return dwSize;
- }
- //----------------------------------//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement