Tuesday, August 16, 2005

Enumerating Managed Processes With .Net 2.0 and the MdbgCore.dll Assembly

Inside and Out... : Enumerating Managed Processes

"System.Diagnostics.Process class is a managed wrap over a subset of the ToolHelp API - as it enumerates only the process list. Not only that, it will list all the running processes, irrespective of whether they are running unmanaged code or running managed code. What if you wish to identify which of these processes are running managed code?

Unfortunately, neither the ToolHelp API, nor the Process class allow us to identify managed processes from the list they provide us. ...

The same identification can now also be done using managed code. Under %SDKRoot%\v2.0\bin folder, you will find, amongst others, MdbgCore.dll - the core of the managed debugger. If you ILASM this file (yes, its an assembly), you will see the managed wraps of the unmanaged interfaces mentioned above ...

The starting point is Microsoft.Samples.Debugging.CorPublish.CorPublish. This lets us enumerate the managed processes, returning an instance of Microsoft.Samples.Debugging.CorPublish.CorPublishProcess type. Below is a sample that exemplifies doing the same ..."


I saw this and thought it was pretty nifty...

COME ON 11/7, hurry up and get here...

No comments: