2

I am trying to figure out exactly how I can capture all window messages of a process/window, from the time it was launched in c#. The process would not be my own so I would need to use some kind of hook. My goal is to start capturing all messages in real time from before the initial window creation, to the applications exit and output all messages to a textbox or file. So basically from the moment the application was executed.

Since I want to capture it from the time it was launched, I probably wont have a window handle as their will be no handle yet. So I am geussing it could be tricky.

Is their an application that does this that I can use for reference? I only want all messages from on application.

user1632018
  • 2,485
  • 10
  • 52
  • 87

1 Answers1

1

My goal is to start capturing all messages in real time from before the initial window creation, to the applications exit and output all messages to a textbox or file.

Sounds like you want the "Real-Time' monitoring of Registry, File System, Process & etc activity.

Process Monitor does all this already and you can hook into it using EasyHook

Since I want to capture it from the time it was launched, I probably wont have a window handle as their will be no handle yet. So I am geussing it could be tricky.

This Code Project article has a method for preventing execution of any program that does not appear on the list of software that is allowed to run on a particular machine. Perhaps you could adapt it to suit your needs. http://www.codeproject.com/Articles/11985/Hooking-the-native-API-and-controlling-process-cre

If you want a low level approach I recommend reading up on Hooks and Dlls.

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321