protected int CoreHookProc(int code, IntPtr wParam, IntPtr lParam) { if (code < 0 || this.OnHookInvoked(new HookEventArgs(code, wParam, lParam))) { return(WindowsHook.CallNextHookEx(this.hook, code, wParam, lParam)); } return(code); }
public void Install() { using (Process currentProcess = Process.GetCurrentProcess()) { using (ProcessModule mainModule = currentProcess.MainModule) this.hook = WindowsHook.SetWindowsHookEx(this.hookType, this.hookFunc, WindowsHook.GetModuleHandle(mainModule.ModuleName), 0); } }
public void Uninstall() { WindowsHook.UnhookWindowsHookEx(this.hook); this.hook = IntPtr.Zero; }