GetModuleBase

04/01/2017 12:19 gοd#1
Needed this for a short project, didn't want to play the copycat so I wrote my own little code. Prolly it looks like any other though.
Code:
uint32_t GetModuleBase(DWORD dwProcessID, std::wstring ModuleName) {
	HANDLE hModuleSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessID);
	MODULEENTRY32 ModuleEntry32;
	ModuleEntry32.dwSize = sizeof(ModuleEntry32);

	if (!Module32First(hModuleSnapshot, &ModuleEntry32)) {
		return 0;
	}

	do {
		if (std::wstring(ModuleEntry32.szModule) == ModuleName) {
			return (uint32_t)ModuleEntry32.modBaseAddr;
		}
	} while (Module32Next(hModuleSnapshot, &ModuleEntry32));
	return 0;
}
08/25/2017 06:26 Requi#2
You're not closing the handle you opened. Anticheat says "Hello".
Also C-style casts :eek: