class MODULEENTRY32(ctypes.Structure):
_fields_ = [("dwSize", ctypes.c_long),
("th32ModuleID", ctypes.c_long),
("th32ProcessID", ctypes.c_long),
("GlblcntUsage", ctypes.c_long),
("ProccntUsage", ctypes.c_long),
("modBaseAddr", ctypes.c_long),
("modBaseSize", ctypes.c_long),
("hModule", ctypes.c_void_p),
("szModule", ctypes.c_char*256),
("szExePath", ctypes.c_char*260)]
def get_module_base_address(pid, moduleName):
hModuleSnap = ctypes.c_void_p(0)
me32 = MODULEENTRY32()
me32.dwSize = ctypes.sizeof(MODULEENTRY32)
hModuleSnap = create_tool_help32_snapshot(TH32CS_SNAPMODULE, pid)
mod = module32_first(hModuleSnap, ctypes.pointer(me32))
if not mod:
print("Error getting {} base address".format(moduleName), getLastError())
mem.close_handle(hModuleSnap)
return False
while mod:
if me32.szModule.decode() == moduleName:
mem.close_handle(hModuleSnap)
return me32.modBaseAddr
else:
mod = module32_next(hModuleSnap, ctypes.pointer(me32))
def main():
client_panorama = get_module_base_address(csgo_pid, "client.dll")