How to get the starting/base address of a process in C++?

Here’s another way, written in Visual Studio 2015 but should be backwards compatible. void GetBaseAddressByName(DWORD processId, const _TCHAR *processName) { _TCHAR szProcessName[MAX_PATH] = _TEXT(“<unknown>”); HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processId); if (NULL != hProcess) { HMODULE hMod; DWORD cbNeeded; if (EnumProcessModulesEx(hProcess, &hMod, sizeof(hMod), &cbNeeded, LIST_MODULES_32BIT | LIST_MODULES_64BIT)) { GetModuleBaseName(hProcess, hMod, szProcessName, sizeof(szProcessName) / … Read more