pub fn is_debugger_present() -> Result<bool, Error>Expand description
Checks if a debugger is currently attached to the process.
This function performs platform-specific checks to detect whether a debugger is actively attached to the current process.
§Platform-specific Behavior
- Windows: Uses
IsDebuggerPresent. When thedeep-detectfeature is enabled, additionally checksCheckRemoteDebuggerPresentandNtQueryInformationProcess. - Linux/Android: Checks the
TracerPidfield in/proc/self/status. - macOS: Uses
proc_pidinfoto retrieveproc_bsdinfoand checks thepbi_flagsfield. - Other platforms: Compilation error.
§Return Value
Returns Ok(true) if a debugger is detected, Ok(false) if no debugger is present,
or Err(std::io::Error) if the check could not be performed due to a system error.
§Examples
match anti_debug::is_debugger_present() {
Ok(true) => println!("Debugger detected!"),
Ok(false) => println!("No debugger present"),
Err(e) => println!("Error checking for debugger: {}", e),
}§Notes
- This detection can be bypassed by skilled attackers using advanced anti-anti-debugging techniques
- Some debuggers may not be detected depending on their attachment method
- The check is performed at the moment the function is called and may not reflect subsequent attachment/detachment of debuggers