Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I detect a debugger or other tool that might be analysing my software?

A very simple situation. I'm working on an application in Delphi 2007 which is often compiled as 'Release' but still runs under a debugger. And occasionally it will run under SilkTest too, for regression testing. While this is quite fun I want to do something special...

I want to detect if my application is running within a debugger/regression-tester and if that's the case, I want the application to know which tool is used! (Thus, when the application crashes, I could report this information in it's error report.)

Any suggestions, solutions?

like image 776
Wim ten Brink Avatar asked Sep 18 '09 08:09

Wim ten Brink


People also ask

What are debugging tools in software testing?

Debugging tool is a computer program used to test and debug other programs. There are a lot of public domain software like gdb and dbx that you can use for debugging. Also, they offer console-based command-line interfaces. Some of the automated debugging tools include code-based tracers, profilers, interpreters, etc.

How do you test and debug a program?

But there are various differences between testing and debugging. Testing is the process using which we find errors and bugs. Debugging is the process using which we correct the bugs that we found during the testing process.


2 Answers

You can check the parent process that started your application. With CreateToolhelp32Snapshot/Process32First/Process32Next get the parent PID (PROCESSENTRY32.th32ParentProcessID or TProcessEntry32.th32ParentProcessID) for your application PID. Then get the filename for the parent PID to compare with the applications you want to check for, like SilkTest.

Check this article for code usage.

In addition to IsDebuggerPresent and CheckRemoteDebuggerPresent, you can also query PEB.BeingDebugged (PEB is Process Environment Block, to get PEB you must query TEB, which is the Thread Enviroment Block).

like image 93
pani Avatar answered Nov 02 '22 14:11

pani


You're probably looking for the IsDebuggerPresent function.

like image 30
Greg Hewgill Avatar answered Nov 02 '22 13:11

Greg Hewgill