使用钩子函数:
BOOL WINAPI hkReadProcessMemory( HANDLE hProcess, LPCVOID lpBaseAddress, LPVOID lpBuffer, SIZE_T nSize, SIZE_T *lpNumberOfBytesRead)
{
if (GetCurrentProcess() == hProcess) {
// your process
}
return oReadProcessMemory( hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesRead);
}
函数的 typedef:
typedef BOOL (WINAPI* _NtReadProcessMemory)( HANDLE hProcess, LPCVOID lpBaseAddress, LPVOID lpBuffer, SIZE_T nSize, SIZE_T *lpNumberOfBytesRead);
声明旧函数:
_NtReadProcessMemory oReadProcessMemory = (_NtReadProcessMemory)
GetProcAddress(GetModuleHandle(L"ntdll"), "NtReadProcessMemory");
安装绕道:
BOOL bHook = Mhook_SetHook((PVOID*)&oReadProcessMemory,
hkReadProcessMemory));
显然,您需要将此 DLL 注入到系统上运行的所有进程中。
Mhook:(绕行库)http://codefromthe70s.org/mhook22.aspx