Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <iostream>
- using namespace std;
- typedef BOOL (__stdcall * FlushInstructionCache_t)(HANDLE hProcess,LPCVOID lpBaseAddress,SIZE_T dwSize);
- FlushInstructionCache_t pFlushInstructionCache;
- void* detourFunc(BYTE *src, const BYTE *dst, const int len)
- {
- BYTE *jmp = (BYTE*)malloc(len+5);
- DWORD dwback;
- VirtualProtect(src, len, PAGE_READWRITE, &dwback);
- memcpy(jmp, src, len); jmp += len;
- jmp[0] = 0xE9;
- *(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
- src[0] = 0xE9;
- *(DWORD*)(src+1) = (DWORD)(dst - src) - 5;
- VirtualProtect(src, len, dwback, &dwback);
- return (jmp-len);
- }
- BOOL __stdcall hkFlushInstructionCache(HANDLE hProcess,LPCVOID lpBaseAddress,SIZE_T dwSize)
- {
- cout << "FlushInstructionCache" << endl;
- return pFlushInstructionCache(hProcess, lpBaseAddress, dwSize);
- }
- int main()
- {
- DWORD dwFlushInstructionCache = (DWORD)GetProcAddress(GetModuleHandleA("kernel32.dll"), "FlushInstructionCache");
- pFlushInstructionCache = (FlushInstructionCache_t)detourFunc((BYTE*)dwFlushInstructionCache, (BYTE*)&hkFlushInstructionCache, 3); //para = size
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement