protected override void ApplyHook(string args) { MessageHook hook = null; Subclasser subclass = null; /* We will have been injected into the remote process using CreateRemoteThread meaning we will * not be on the UI thread. Therefore we need to subclass the main window of the process and * then trigger our message hook after the first message has been received as we will be on * the UI thread. */ subclass = new Subclasser(System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle, delegate(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam) { //Unsubclass the window as we are performing a hook subclass.Restore(); if (hook == null) { hook = new MessageHook(new LocalHook()); hook.SetHook(); hook.MessageReceived += MessageReceived; } return false; }); subclass.Hook(); }
protected override void ApplyHook(string args) { MessageHook hook = null; Subclasser subclass = null; /* We will have been injected into the remote process using CreateRemoteThread meaning we will * not be on the UI thread. Therefore we need to subclass the main window of the process and * then trigger our message hook after the first message has been received as we will be on * the UI thread. */ subclass = new Subclasser(System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle, delegate(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam) { //Unsubclass the window as we are performing a hook subclass.Restore(); if (hook == null) { hook = new MessageHook(new LocalHook()); hook.SetHook(); hook.MessageReceived += MessageReceived; } return(false); }); subclass.Hook(); }