Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define WIN32_LEAN_AND_MEAN
- #include <windows.h>
- #include <stdio.h>
- #include "MicroHook.h"
- typedef int (WINAPI* _MessageBoxA)(HWND,LPCTSTR,LPCTSTR,UINT);
- int WINAPI new_MessageBoxA(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType)
- {
- printf("MessageBoxA(0x%08X, \"%s\", \"%s\", %d)\n", hWnd, lpText, lpCaption, uType);
- return 1;
- }
- int main()
- {
- HMODULE user32 = LoadLibraryA("user32.dll");
- _MessageBoxA orig_MessageBoxA;
- orig_MessageBoxA = (_MessageBoxA)GetProcAddress(user32, "MessageBoxA");
- MH_CREATETRAMPOLINE(tramp_MessageBoxA, 5);
- MH_Detour((BYTE*)orig_MessageBoxA, (BYTE*)&new_MessageBoxA,
- (BYTE*)tramp_MessageBoxA, 5);
- printf("tramp_MessageBoxA 0x%08X\n", tramp_MessageBoxA);
- MessageBoxA(NULL, "Testing trampoline detour...", "MicroHook", MB_OK);
- MH_UnDetour((BYTE*)orig_MessageBoxA, (BYTE*)tramp_MessageBoxA, 5);
- MH_FREETRAMOLINE(tramp_MessageBoxA);
- MessageBoxA(NULL, "Testing trampoline undetour...", "MicroHook", MB_OK);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement