1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
| #include <iostream> #include <tchar.h> #include <Windows.h> using namespace std;
HINSTANCE __ModuleHandle = NULL; HHOOK __HookModule = NULL; LRESULT CALLBACK MessageProcedure(int Message, WPARAM wParam, LPARAM lParam)
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD ul_reason_for_call, LPVOID lpvReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: { __ModuleHandle = hinstDLL; break; } case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; }
HHOOK SetWindowsHookEx( int idHook, HOOKPROC lpfn, HINSTANCE hMod, DWORD dwThreadId ); HHOOK HookStart() { HHOOK ReturnValue;
ReturnValue = SetWindowsHookEx(2, MessageProcedure, __ModuleHandle, 0); __HookModule = ReturnValue; return ReturnValue; }
LRESULT CALLBACK MessageProcedure(int Message, WPARAM wParam, LPARAM lParam) { TCHAR v1[260] = { 0 }; TCHAR v2[50] = { 0 }; TCHAR* v3; memset(&v1, 0, 260);
if (Message >= 0 && ParamemterData2 >= 0 && (GetModuleFileName(0,v1,260), v3 = _tcsrchr(v1, 92), !_tcsicmp(v3 + 1, _T("notepad.exe")))) { GetKeyNameText(ParamemterData2, v2, 50); MessageBox(NULL, v2, _T("Filter"), 0); ResultValue = 1; } else { ResultValue = CallNextHookEx(NULL, Message, ParameterData1, ParamemterData2); } return ResultValue; }
HHOOK HookStop() { HHOOK ReturnValue;
ReturnValue = __HookModule; if (__HookModule) { ReturnValue = (HHOOK)UnhookWindowsHookEx(__HookModule); __HookModule = 0; } return ReturnValue; }
EXPORTS HookStart @1 HookStop @2
|