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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With