Recent Posts
Recent Comments
HINSTANCE hHookDll=NULL; HHOOK hHook=NULL; LRESULT CALLBACK GetMsgProc(int code, WPARAM wParam, LPARAM lParam) { MSG *msg=(MSG*)lParam; switch(msg->message) { default: ; } return CallNextHookEx(hHook, code, wParam, lParam); } extern "C" BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason, LPVOID reserved) { switch(reason) { case DLL_PROCESS_ATTACH: { if(hHookDll==NULL){hHookDll=hInst;} break; } case DLL_PROCESS_DETACH: { if(hHook!=NULL) { UnhookWindowsHookEx(hHook); hHook=NULL; } break; } case DLL_THREAD_ATTACH:{break;} case DLL_THREAD_DETACH:{break;} default: ; } return 1; } void start_hook() { if(hHookDll==NULL){hHook=SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc, hHookDll, GetCurrentThreadId());} } void stop_hook() { if(hHook!=NULL) { UnhookWindowsHookEx(hHook); hHook=NULL; } }
SetWindowsHookEx 의 4번째 인자를 0 으로 설정할경우 전역 후킹이 됩니다.
Comments