www.pudn.com > API_VC_HOOK-.rar > AutoHook.c


#if _MSC_VER > 1000 
#pragma once 
#endif 
 
#define  WIN32_LEAN_AND_MEAN 
#include  
#include "ApiHooks.h" 
 
 
int  (WINAPI *OriginalMessageBoxA)(HWND  hWnd,LPCTSTR  lpText,LPCTSTR  lpCaption, 
     UINT  uType); 
     
int WINAPI NewMessageBoxA(HWND  hWnd,LPCTSTR  lpText,LPCTSTR  lpCaption, 
    UINT  uType) { 
    return(OriginalMessageBoxA(hWnd, lpText, lpCaption, 
		   uType & MB_ICONINFORMATION  
		   ? uType ^ (MB_ICONINFORMATION | MB_ICONEXCLAMATION) 
	       : uType)); 
} 
 
 
API_HOOK ApiHookChain[3] = { 
	{DYNAMIC_HOOKS}, 
	{"USER32.DLL","MessageBoxA",HOOK_EXACT, NULL, NULL, NewMessageBoxA}, 
	{HOOKS_END} 
}; 
 
 
int MsgBox() { 
	 return(MessageBoxA(NULL, "This is illegal", "Warning", MB_ICONINFORMATION)); 
} 
	 
 
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
                     LPSTR     lpCmdLine, int nCmdShow) 
{ 
	OriginalMessageBoxA = MessageBoxA; 
	MsgBox(); 
    EstablishApiHooks((LPCSTR)ApiHookChain, GetCurrentProcessId()); 
	return(MsgBox()); 
}