internal virtual IntPtr Callback(int nCode, IntPtr wParam, IntPtr lParam) { HookCallback?.Invoke(nCode, wParam, lParam); if (CallNextHook) { return(CallNextHookEx(hhk, nCode, wParam, lParam)); } else { return((IntPtr)1); } }
private IntPtr WndProc(IntPtr hWnd, uint message, IntPtr wParam, IntPtr lParam) { const int WM_NULL = 0; const int WM_DESTROY = 2; const int WM_COPYDATA = 0x004A; switch (message) { case WM_COPYDATA: var data = Marshal.PtrToStructure <COPYDATASTRUCT>(lParam); Debug.WriteLine("{3} Hook message = {0} ({0:X2}), wParam = {1} ({1:X4}), lParam = {2} ({2:X8})", data.dwData, wParam.ToInt32(), data.lpData.ToInt32(), DateTime.Now.ToShortTimeString()); return(hookCallback.Invoke(data.dwData, wParam, data.lpData)); case WM_DESTROY: PostQuitMessage(0); return(IntPtr.Zero); default: Debug.WriteLine("{0} Window message = {1} ({1:X2})", DateTime.Now.ToShortTimeString(), message); break; } return(DefWindowProc(hWnd, message, wParam, lParam)); }