Andrew Russell
Andrew Russell

Reputation: 27225

Is there a way to detect if the debugger has been used, from within the program being debugged?

I have an internal consistency check in my program that verifies whether two runs of the same code, with the same inputs, give identical results. The idea is to detect unaccounted-for inputs, during development. If the check fails, it breaks into the debugger.

This is all fine and dandy until some other action in the debugger - especially Edit and Continue - modifies one run in the middle of execution. I want to detect this and disable the consistency check.

Obviously because the check itself requires the debugger, I can't do something simple like check Debugger.IsAttached.

Upvotes: 1

Views: 123

Answers (1)

Joel B
Joel B

Reputation: 882

The only thing I can think of is to use some sort of timing (which seems like a terrible idea). If the time it takes to complete a task is several magnitudes higher than usual, it could be a sign that something is being tampered with. This could result in lots of false positives if things like disk reading/writing are involved. Again, not a great idea, but just a thought

Upvotes: 1

Related Questions