Exemple #1
0
        public Main()
        {
            InitializeComponent();
            this.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);

            state = FormState.Idle;

            mouseGrabber = new EventGrabber
            {
                MinEventType = SetWinEventHookEventType.EVENT_SYSTEM_CAPTURESTART,
                MaxEventType = SetWinEventHookEventType.EVENT_SYSTEM_CAPTURESTART
            };
            mouseGrabber.Started += new EventHandler(mouseGrabber_Started);
            mouseGrabber.Stopped += new EventHandler(mouseGrabber_Stopped);
            mouseGrabber.Grabbed += new EventHandler<EventGrabber.GrabbedEventArgs>(mouseGrabber_Grabbed);

            targetGrabber = new EventGrabber();
            targetGrabber.Stopped += new EventHandler(targetGrabber_Stopped);
            targetGrabber.Grabbed += new EventHandler<EventGrabber.GrabbedEventArgs>(targetGrabber_Grabbed);

            targetMonitor = new ProcessMonitor();
            targetMonitor.Stopped += new EventHandler(targetMonitor_Ended);
            targetMonitor.Exited += new EventHandler<ProcessMonitor.ExitedEventArgs>(targetMonitor_Ended);

            systemCursor = new SystemCursor();

            terminationGuard = new TerminationGuard();
            try
            {
                if (!terminationGuard.TrySet())
                {
                    systemCursor.TryReloadAll();
                }
            }
            catch
            { }
        }
Exemple #2
0
        // target raised event
        private void targetGrabber_Grabbed(object sender, EventGrabber.GrabbedEventArgs e)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new EventHandler<EventGrabber.GrabbedEventArgs>(targetGrabber_Grabbed),
                    new object[] { sender, e });
            }
            else
            {
                var itemDate = DateTime.Now.ToString(@"HH\:mm\:ss.fffffff");
                var itemEventType = e.EventType.ToString("F").PadRight(31);
                var itemObject = (e.StandardObject.HasValue ?
                    e.StandardObject.Value.ToString("F") :
                    e.ObjectId.ToString("X8")).
                    PadRight(23);

                var item = string.Format(@"{0}    {1}    {2}", itemDate, itemEventType, itemObject);
                aslbxMessages.Items.Add(item);
            }
        }
Exemple #3
0
        // mouse click on target window
        private void mouseGrabber_Grabbed(object sender, EventGrabber.GrabbedEventArgs e)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new EventHandler<EventGrabber.GrabbedEventArgs>(mouseGrabber_Grabbed),
                    new object[] { sender, e });
            }
            else
            {
                // set up target events monitoring
                targetGrabber.ThreadId = e.ThreadId;
                targetGrabber.ProcessId = e.ProcessId;
                targetGrabber.Start();

                // stop mouse monitoring
                mouseGrabber.Stop();

                // set up target availability monitoring
                targetMonitor.ProcessId = e.ProcessId;
                targetMonitor.Start();

                state = FormState.TargetActive;

                tbxWindowId.Text = e.Window.ToInt64().ToString();
                tbxProcessId.Text = e.ProcessId.ToString();
                tbxThreadId.Text = e.ThreadId.ToString();
                btnToggleHook.Text = "Unhook";

                // restore global cursor
                systemCursor.TryRestoreAll();
            }
        }