資源共享吧豪華貴族SVIP
- 資源幣
- 12
- 積分
- 114
- 貢獻(xiàn)
- 0
- 在線時(shí)間
- 73 小時(shí)
- 注冊(cè)時(shí)間
- 2021-9-2
- 最后登錄
- 2024-10-22
|
- //獲取模塊基址
- PVOID GetModuleBaseAddr(const char* szWindowName, const char* szModuleName)
- {
- DWORD pid = GetProcessId(szWindowName);
- HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS,NULL,pid);
- MODULEENTRY32 me32;
- ZeroMemory(&me32, sizeof(me32));
- me32.dwSize = sizeof(me32);
- HANDLE hModuleSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pid);
- unsigned long long baseAddr = 0;
- while (Module32Next(hModuleSnap, &me32))
- {
- if (strstr(me32.szModule, szModuleName))
- {
- break;
- }
- }
- printf("%16s模塊基址=%#p,%16s模塊大小=%#x\n",szModuleName, me32.modBaseAddr, szModuleName,me32.modBaseSize);
- CloseHandle(hModuleSnap);
- CloseHandle(hProcess);
- return me32.modBaseAddr;
- }
- DWORD GetProcessId(const char* szWindowName)
- {
- HWND hwnd = FindWindowA(NULL, szWindowName);
- DWORD pid = 0;
- GetWindowThreadProcessId(hwnd, &pid);
- return pid;
- }
復(fù)制代碼
|
|