debugbreak icon indicating copy to clipboard operation
debugbreak copied to clipboard

add IsDebuggerPresent equivalent?

Open malytomas opened this issue 7 years ago • 1 comments

Hi, would it be possible to add an equivalent of IsDebuggerPresent to test if the process is actually being debugged? Thanks

malytomas avatar Jan 21 '19 10:01 malytomas

Easy enough to add it yourself:


#if defined WGUI_OS_WINDOWS

#include <Windows.h>

WGUI_IS_DBG_ATTACHED_FN()
{
   return IsDebuggerPresent();
}

#elif defined WGUI_OS_LINUX

#include <sys/ptrace.h>

WGUI_IS_DBG_ATTACHED_FN()
{
   if (ptrace(PTRACE_TRACEME, 0, 1, 0) < 0)
   {
      return true;
   }

   return false;
}

#endif

That works for windows and linux. I'm sure other platforms like MacOS are just as simple

kayoscode avatar Jan 18 '25 13:01 kayoscode