汇编检测OD代码

repnz指令说明:重复执行其后面的指令,CX或ECX存放最多比较次数,DI或EDI存放查找表首地址,AL或AX或EAX存放想查找的内容。当(CX或ECX)= 0 或 ZF=1 退出重复,否则,(CX或ECX)自减一,执行其后的串指令。CX或ECX为0结束是因为已经查表完毕,没有匹配到;ZF=1说明 “比较的结果为0”,也就是查找到一样的内容,说明匹配到想要查找的内容。

 

BOOL DetectBreakpoints()

{

       BOOL bFoundOD;

       bFoundOD=FALSE;

       __asm

       {

                jmp     CodeEnd    

   CodeStart:   mov     eax,ecx  ;被保护的程序段

                nop

                push    eax

                push    ecx

                pop     ecx

                pop     eax

   CodeEnd:    

                cld               ;检测代码开始

                mov     edi,offset CodeStart

                mov     edx,offset CodeStart

                mov     ecx,offset CodeEnd

                sub     ecx,edx

                mov     al,0CCH

                repne   scasb

                jnz      ODNotFound

                mov bFoundOD,1

       ODNotFound:                     

       }

       return bFoundOD;

}

posted on 2017-07-22 15:36  cagebird  阅读(789)  评论(0编辑  收藏  举报

导航