corrego
corrego

Reputation: 327

is there a way to check if the debugger is currently attached?

I'm developing a visual studio plugin, and I need to check if the debugger is attached (i.e., the application is currently running) to prevent the user from performing certain actions. I looked online but I was unable to find anything useful.

Is there a way to accomplish this?

Thanks!

EDIT: It seems the question is not clear enough. What I'm trying to achieve is: my plugin is running inside visual studio. I need to check if that instance of visual studio is currently attached debugging an application, so my plugin can act accordingly.

Upvotes: 4

Views: 711

Answers (4)

Ben Brammer
Ben Brammer

Reputation: 998

BOOL WINAPI IsDebuggerPresent(void)

or

BOOL WINAPI CheckRemoteDebuggerPresent(__in HANDLE hProcess, __inout PBOOL pbDebuggerPresent)

from a plugin,

IDebugEngine2::EnumPrograms

Upvotes: 0

corrego
corrego

Reputation: 327

Found it: Use the DTE2.Debugger property, and the CurrentMode property. This way you can tell if you are currently debugging something or not.

Upvotes: 2

typ1232
typ1232

Reputation: 5607

to prevent the user from performing certain actions

There are lots of methods to check for a debugger, but it sounds like would want to implement a debugger check to protect your software.

There is debugging - you can prevent it with anti-debugging, but then again your user can use anti-anti debugging depending on what you do. and so on. You will be on the short end of this chain because you have to ship the appication and the user can circumvent all your messures you implemented.

Here are some ressources if you still want to go that way. But please don't believe your application will not be debuggable because of that!

http://www.symantec.com/connect/articles/windows-anti-debug-reference http://old.honeynet.org/scans/scan33/nico/

Upvotes: 0

noonand
noonand

Reputation: 2855

You don't mention what language you're using but here's how to do it in C#

if(Debugger.IsAttached) 
{ 
  // Do something
}

Upvotes: 1

Related Questions