Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ figure out if the debugger is attached

Tags:

I use stackwalk64 to generate stacktraces for C++ in visual studio 2008 using the latest symchk.exe and dbghlp.dll. This works fine when I'm running the standalone exe. However, when the debugger is attached I deadlock visual studio. I previously had a workaround where I downloaded all of the system32 symbols to disk and this worked well, but a recent update seems to have broken my workaround even though I updated the symbols. Ideally I would like to determine if the visual studio debugger is attached (it will only ever be the VS debugger) so I can turn off my stack traces in that case. Thanks for any help.

like image 584
Steve Avatar asked Jan 27 '11 15:01

Steve


People also ask

How do I know if debugger is attached?

Kernel-mode code can determine the status of kernel debugging by using the following variables and routines: The KD_DEBUGGER_ENABLED global kernel variable indicates whether kernel debugging is enabled. The KD_DEBUGGER_NOT_PRESENT global kernel variable indicates whether a kernel debugger is currently attached.

How do I remove debugger attached in VS code?

Just Delete the . vscode file from the directory you are working in and reopen the window the debugger will be gone.

How do I connect a Windows service to a debugger?

In the Options dialog box, choose Debugging, Symbols, select the Microsoft Symbol Servers check box, and then choose the OK button. The Processes dialog box appears. Select the Show processes from all users check box. In the Available Processes section, choose the process for your service, and then choose Attach.

How do I Deattach debugger in Visual Studio?

When debugging is complete, you can detach the debugger from the process by clicking Debug, and then clicking Stop Debugging in Visual Studio.


1 Answers

Use IsDebuggerPresent and possibly CheckRemoteDebuggerPresent

like image 165
Hasturkun Avatar answered Oct 02 '22 16:10

Hasturkun