Advertisement
captmicro

Unknown

Nov 17th, 2010
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.98 KB | None | 0 0
  1. #define WIN32_LEAN_AND_MEAN
  2. #include <windows.h>
  3. #include <stdio.h>
  4. #include "MicroHook.h"
  5.  
  6. typedef int (WINAPI* _MessageBoxA)(HWND,LPCTSTR,LPCTSTR,UINT);
  7. int WINAPI new_MessageBoxA(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType)
  8. {
  9.     printf("MessageBoxA(0x%08X, \"%s\", \"%s\", %d)\n", hWnd, lpText, lpCaption, uType);
  10.     return 1;
  11. }
  12.  
  13. int main()
  14. {
  15.     HMODULE user32 = LoadLibraryA("user32.dll");
  16.  
  17.     _MessageBoxA orig_MessageBoxA;
  18.     orig_MessageBoxA = (_MessageBoxA)GetProcAddress(user32, "MessageBoxA");
  19.    
  20.     MH_CREATETRAMPOLINE(tramp_MessageBoxA, 5);
  21.         MH_Detour((BYTE*)orig_MessageBoxA, (BYTE*)&new_MessageBoxA,
  22.             (BYTE*)tramp_MessageBoxA, 5);
  23.         printf("tramp_MessageBoxA 0x%08X\n", tramp_MessageBoxA);
  24.         MessageBoxA(NULL, "Testing trampoline detour...", "MicroHook", MB_OK);
  25.         MH_UnDetour((BYTE*)orig_MessageBoxA, (BYTE*)tramp_MessageBoxA, 5);
  26.     MH_FREETRAMOLINE(tramp_MessageBoxA);
  27.  
  28.     MessageBoxA(NULL, "Testing trampoline undetour...", "MicroHook", MB_OK);
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement