Exemplo n.º 1
0
        /// <summary>
        /// Translates Winows message into usable format and extracts all information
        /// </summary>
        public WH_CALLWNDPROCRET(HookArguments Msg) : base(Msg)
        {
            this.Code   = Msg.nCode;
            this.wParam = Msg.wParam;
            this.lParam = Msg.lParam;
            this.Caller = Msg.Process;
            this.Time   = Msg.TimeStamp;


            Attachment = MarshalHelper.GetStructFromProcess <CWPRETSTRUCT>(Caller, lParam);
        }
Exemplo n.º 2
0
        void MessageHandler_WndProc(ref Message m, ref bool Intercept)
        {
            if (HookTriggered == null)
            {
                return;
            }


            var InfoBoat = (COPYDATASTRUCT)Marshal.PtrToStructure(m.LParam, typeof(COPYDATASTRUCT));
            var HookInfo = (AllHookMSG)Marshal.PtrToStructure(InfoBoat.lpData, typeof(AllHookMSG));

            var time    = new System.DateTime(1970, 1, 1).AddSeconds(HookInfo.Time).ToLocalTime().AddMilliseconds(HookInfo.MilliSecond);
            var process = Process.GetProcessById((int)HookInfo.Process);


            var PassData = new HookArguments();

            PassData.lParam    = HookInfo.lParam;
            PassData.wParam    = HookInfo.wParam;
            PassData.nCode     = HookInfo.nCode;
            PassData.Process   = process;
            PassData.TimeStamp = time;

            // Filter own copydata communication
            if (HookInfo.HookType == (int)HookType.WH_CALLWNDPROC)
            {
                CWPSTRUCT IsWMCOPY = MarshalHelper.GetStructFromProcess <CWPSTRUCT>(process, PassData.lParam);
                if (IsWMCOPY.message == (int)WindowsMessages.WM_COPYDATA)
                {
                    return;
                }
            }

            if (HookInfo.HookType == (int)HookType.WH_CALLWNDPROCRET)
            {
                CWPRETSTRUCT IsWMCOPY = MarshalHelper.GetStructFromProcess <CWPRETSTRUCT>(process, PassData.lParam);
                if (IsWMCOPY.message == (int)WindowsMessages.WM_COPYDATA)
                {
                    return;
                }
            }

            HookTriggered(PassData, ref Intercept);

            if (Intercept == true && HookType == System.Hooks.HookType.WH_GETMESSAGE)
            {
                var Returner = new WH_GETMESSAGE(PassData);
                Returner.Message = Message.Create(Returner.Caller.MainWindowHandle, 0, IntPtr.Zero, IntPtr.Zero);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Translates Winows message into usable format and extracts all information
        /// </summary>
        public WH_GETMESSAGE(HookArguments Msg) : base(Msg)
        {
            if (Msg == null)
            {
                return;
            }

            this.Code   = Msg.nCode;
            this.wParam = Msg.wParam;
            this.lParam = Msg.lParam;
            this.Caller = Msg.Process;
            this.Time   = Msg.TimeStamp;

            var message = MarshalHelper.GetStructFromProcess <MSG>(Caller, lParam);

            _msg = Message.Create(message.hwnd, (int)message.message, message.wParam, message.lParam);
        }
Exemplo n.º 4
0
        CREATESTRUCT getCreateStruct()
        {
            var CreateWindow = MarshalHelper.GetStructFromProcess <CREATEWND>(Caller, lParam);

            return(MarshalHelper.GetStructFromProcess <CREATESTRUCT>(Caller, CreateWindow.lpcs));
        }