Example #1
0
 private int GetMessageHookProc(int code, IntPtr wParam, IntPtr lParam)
 {
     if (code >= 0)
     {
         if ((long)wParam > 0L)
         {
             Message structure = (Message)Marshal.PtrToStructure(lParam, typeof(Message));
             if ((this.NotifyGetMessageEvent(ref structure) & MessagePreviewResult.NoDispatch) == MessagePreviewResult.NoDispatch)
             {
                 if (RadMessageFilter.callNextHookWhenNoDispatch)
                 {
                     structure.HWnd = new IntPtr(-1);
                     structure.Msg  = -1;
                     Marshal.StructureToPtr((object)structure, lParam, true);
                 }
             }
         }
     }
     try
     {
         return(RadMessageFilter.CallNextHookEx(this.getMessageHookAddress, code, wParam, lParam));
     }
     catch (AccessViolationException ex)
     {
     }
     return(0);
 }
Example #2
0
 private int SystemMessageHookProc(int code, IntPtr wParam, IntPtr lParam)
 {
     if (code >= 0)
     {
         this.NotifyMessageFilterEvent((SystemMessage)code, lParam);
     }
     return(RadMessageFilter.CallNextHookEx(this.systemMessageHookAddress, code, wParam, lParam));
 }
Example #3
0
 private int CallWndProcHookProc(int code, IntPtr wParam, IntPtr lParam)
 {
     if (code >= 0)
     {
         this.NotifyCallWndProcEvent(wParam, lParam);
     }
     return(RadMessageFilter.CallNextHookEx(this.callWndProcHookAddress, code, wParam, lParam));
 }
Example #4
0
        private void Install(InstalledHook toInstall)
        {
            int currentThreadId = AppDomain.GetCurrentThreadId();

            if ((toInstall & InstalledHook.CallWndProc) != InstalledHook.None && (this.installedHook & InstalledHook.CallWndProc) == InstalledHook.None)
            {
                this.callWndProcHookAddress = RadMessageFilter.SetWindowsHookEx(RadMessageFilter.HookType.WH_CALLWNDPROC, this.callWndProcDelegate, IntPtr.Zero, currentThreadId);
                this.installedHook         |= InstalledHook.CallWndProc;
            }
            if ((toInstall & InstalledHook.GetMessage) != InstalledHook.None && (this.installedHook & InstalledHook.GetMessage) == InstalledHook.None)
            {
                this.getMessageHookAddress = RadMessageFilter.SetWindowsHookEx(RadMessageFilter.HookType.WH_GETMESSAGE, this.getMessageDelegate, IntPtr.Zero, currentThreadId);
                this.installedHook        |= InstalledHook.GetMessage;
            }
            if ((toInstall & InstalledHook.SystemMessage) == InstalledHook.None || (this.installedHook & InstalledHook.SystemMessage) != InstalledHook.None)
            {
                return;
            }
            this.systemMessageHookAddress = RadMessageFilter.SetWindowsHookEx(RadMessageFilter.HookType.WH_MSGFILTER, this.systemMessageDelegate, IntPtr.Zero, currentThreadId);
            this.installedHook           |= InstalledHook.SystemMessage;
        }
Example #5
0
 private void Uninstall(InstalledHook toUninstall)
 {
     if ((toUninstall & InstalledHook.CallWndProc) != InstalledHook.None && (this.installedHook & InstalledHook.CallWndProc) != InstalledHook.None)
     {
         RadMessageFilter.UnhookWindowsHookEx(this.callWndProcHookAddress);
         this.callWndProcHookAddress = IntPtr.Zero;
         this.installedHook         &= ~InstalledHook.CallWndProc;
     }
     if ((toUninstall & InstalledHook.GetMessage) != InstalledHook.None && (this.installedHook & InstalledHook.GetMessage) != InstalledHook.None)
     {
         RadMessageFilter.UnhookWindowsHookEx(this.getMessageHookAddress);
         this.getMessageHookAddress = IntPtr.Zero;
         this.installedHook        &= ~InstalledHook.GetMessage;
     }
     if ((toUninstall & InstalledHook.SystemMessage) == InstalledHook.None || (this.installedHook & InstalledHook.SystemMessage) == InstalledHook.None)
     {
         return;
     }
     RadMessageFilter.UnhookWindowsHookEx(this.systemMessageHookAddress);
     this.systemMessageHookAddress = IntPtr.Zero;
     this.installedHook           &= ~InstalledHook.SystemMessage;
 }