Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find out which debugger is debugging my .NET app?

I already know about Debugger.IsAttached for determining if my app is currently being debugged at runtime. How can I determine more about the debugger itself?

For example, how can I distinguish between my app being debugged from Visual Studio and my app being debugged by WinDbg?

In my scenario, the app is not started from Visual Studio. A debugger may be attached to an already running process.

like image 270
Scott Isaacs Avatar asked Nov 14 '22 00:11

Scott Isaacs


1 Answers

One way I can think of doing this would be to enumerate the existing processes on the machine and then enumerate the handles for each process. So if you find an instance of WinDbg.exe running and it has a handle to your process then you are most likely being debugged by WinDbg.exe.

Keep in mind though that the debugger might have attached "non-invasively" so you might actually have more than one debugger attached. Or you could be being debugged remotely, or via a kernel debugger attached via serial-port or USB.

For a lot of good information about the debugger you can check out anti-debuggig techniques.

like image 62
jcopenha Avatar answered Dec 10 '22 05:12

jcopenha