// HookTEST.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "HookLib.c" #include "windows.h" #include BOOL WINAPI myfunc(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType); typedef BOOL (WINAPI *_MessageBoxA)( HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType ); int main(int argc, char* argv[]) { IAT_HOOK("user32.dll", "MessageBoxA", (DWORD)&myfunc); MessageBoxA(NULL, "HOOKED", "HOOKED", MB_OK); printf("Unhooking now...\n\n"); IAT_UNHOOK(); MessageBoxA(NULL, "NOT HOOKED", "NOT HOOKED", MB_OK); system("PAUSE"); return 0; } BOOL WINAPI myfunc(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType) { printf("Hooked !!\n\n"); BOOL bRet; _MessageBoxA __MessageBoxA = NULL; __MessageBoxA = (_MessageBoxA)IAT_FUNC_INFO.func; __asm { push uType push lpCaption push lpText push hWnd call __MessageBoxA mov bRet, eax } return bRet; /* ret = __MessageBoxA(hWnd, lpText, lpCaption, uType); return ret; */ }