[DllImport("kernel32.dll")]
static extern bool IsDebuggerPresent();
None.
VB Usage:
Private Declare Function IsDebuggerPresent Lib "kernel32" () As Integer
Try
If IsDebuggerPresent = 1 Then
MsgBox("Debugger is present!") 'Debugger was detected
Else
MsgBox("Debugger isn't present!") Debugger was not detected
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
This is a quick way to help protect your applications from being reverse engineered at runtime. Call this when your application starts and exit if it returns true.
Call this before your application starts to protect it from runtime analysis. This is a weak form of protection, and is trivially bypassed. For a more robust mechanism, use a .NET obfuscator tool.
// debug checking in debug builds would make it impossible to debug in Visual Studio
#if !DEBUG
if (IsDebuggerPresent() == true) {
Application.Exit();
}
#endif
Do you know one? Please contribute it!