Created
August 13, 2013 22:39
-
-
Save bewebste/6226400 to your computer and use it in GitHub Desktop.
Function to tell whether a debugger is attached
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BOOL BWProcessIsBeingTraced() | |
{ | |
int mib[4]; | |
size_t bufSize = 0; | |
struct kinfo_proc kp; | |
mib[0] = CTL_KERN; | |
mib[1] = KERN_PROC; | |
mib[2] = KERN_PROC_PID; | |
mib[3] = getpid(); | |
bufSize = sizeof (kp); | |
if (sysctl(mib, 4, &kp, &bufSize, NULL, 0) < 0) | |
{ | |
return 0; | |
} | |
return ((kp.kp_proc.p_flag & P_TRACED) != 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment