@msdn=http://search.microsoft.com/search/results.aspx?qu=$$$ @pinvoke=http://pinvoke.net/$$$.htm Summary: The IsDebuggerPresent API !!!!VB.Net Signature: Private Declare Function IsDebuggerPresent Lib "kernel32" () As Integer !!!!C# Signature: [DllImport("kernel32.dll")] static extern bool IsDebuggerPresent(); !!!!Boo Signature: [DllImport("kernel32.dll", SetLastError : true)] def IsDebuggerPresent() as bool: pass !!!!User-Defined Types: 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 !!!!Notes: 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. !!!!Tips & Tricks: 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. !!!!Sample Code: // debug checking in debug builds would make it impossible to debug in Visual Studio #if !DEBUG if (IsDebuggerPresent() == true) { Application.Exit(); } #endif !!!!Alternative Managed API: Do you know one? Please contribute it! Documentation: IsDebuggerPresent@msdn on MSDN
Edit kernel32.IsDebugg...
You do not have permission to change this page. If you feel this is in error, please send feedback with the contact link on the main page.