How to check whether a program is debugged

Source: Internet
Author: User
How to detect Program Debugging is actually very easy, just a few lines Code That's it. It is often used in anti-cracking software, but it is ineffective for some debuggers (such as the improved ollydbg-ollyice ).
Below is the C + ASM code. You can try it.
# Include <stdio. h>
# Include <conio. h>
Int isdebugged ()
{
_ ASM
{
MoV eax, FS: [30 h] // get the address of the process environment block corresponding to the thread environment Block
Movzx eax, byte PTR [eax + 2 H] // obtain the value of the bebingdebugged flag
Or Al, Al // test the value of the bebingdebugged flag
JZ flag1
MoV eax, 1
JMP end
Flag1:
MoV eax, 0 // The XOR eax and eax statements are recommended.
End:
}
}

Int main ()
{
If (isdebugged ())
{
Printf ("with a debugger! /N ");
}
Else
{
Printf ("No debugger! /N ");
}
Getch ();
Return 0;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.