public LogMeForm() { InitializeComponent(); CreateHandle(); //callingHandle property should garantee creation, but lets be sure loggerForm = new MessageLogForm(new VirtualWindow(Handle)); //new MessageLogForm(null); loggerForm.Log("init: " + Handle.ToString()); //loggerForm. new VirtualWindow(Handle); loggerForm.Show(); }
private void ServerThread(object messageForm) { MessageLogForm messageLog = (MessageLogForm)messageForm; NamedPipeServerStream pipeServer = new NamedPipeServerStream("spyminuspipe", PipeDirection.InOut, 254, PipeTransmissionMode.Message, PipeOptions.Asynchronous); messageLog.Log("Waiting for connections...."); pipeServer.WaitForConnection(); messageLog.Log(string.Format("Client connected on thread[{0}].", Thread.CurrentThread.ManagedThreadId)); do { NativeMethods.CWPSTRUCT cwp = ReadCWPStruct(pipeServer); messageLog.Log(cwp); } while (pipeServer.IsConnected); pipeServer.Close(); messageLog.Log("===pipe closed==="); }
protected override void WndProc(ref Message m) { Console.WriteLine($"{m.HWnd} - {m.Msg} - {m.LParam} - {m.WParam} - {m.Result}"); //todo: log own messages. problem //inifnite loop, logging is creating messages we want to ignore //the act of logging message creates more messages... //if (source of message not from Log()) { loggerForm?.Log($"{m.HWnd} - {m.Msg} - {m.LParam} - {m.WParam} - {m.Result}"); base.WndProc(ref m); }