IsDebuggerPresent原理及其 c++实现

在IsDebuggerPresent下断,步入得到如下代码:

750E38F0 | 64 A1 18 00 00 00        | mov eax,dword ptr fs:[18]               | eax:std::cout
750E38F6 | 8B 40 30                 | mov eax,dword ptr ds:[eax+30]           | eax:std::cout
750E38F9 | 0F B6 40 02              | movzx eax,byte ptr ds:[eax+2]           | eax:std::cout
750E38FD | C3                       | ret                                     |
750E38FE | CC                       | int3                                    |
750E38FF | CC                       | int3                                    |
750E3900 | CC                       | int3                                    |
750E3901 | CC                       | int3                                    |
750E3902 | CC                       | int3                                    |

在fs:[18]下断点得出

其中fs:[18] =7EFDD000

eax+30就是这里

再来看看7EFDE000里的值

ds:[eax+2]   = 1 .所以是调试状态
 
那么c++一行代码直接可以修改这个值,使IsDebuggerPresent失效了
*((unsigned char *)(*(DWORD*)(__readfsdword(0x18) + 0x30)) + 0x2) = 0;
 
原文地址:https://www.cnblogs.com/zhangdongsheng/p/9757271.html