/****************************************************************
代碼功能:對(duì)其它函數(shù)以及自身函數(shù)中的軟斷點(diǎn)(OD)進(jìn)行檢測(cè)
編寫作者:Coderui
編寫日期:2008年06月16日
編寫語(yǔ)言:C/C++
編譯環(huán)境:VC++ 6.0
聯(lián)系郵箱:coderui@163.com
作者博客:http://hi.baidu.com/coderui
****************************************************************/
void Software();??? //聲明
void Software_End();??? //聲明
//--------------------------檢測(cè)其它函數(shù)---------------------------------
typedef void (*PTRProtected_Code_Start)();
typedef void (*PTRProtected_Code_End)();
PTRProtected_Code_Start pStart;
PTRProtected_Code_End pEnd;
//--------------------------檢測(cè)其它函數(shù)---------------------------------
//--------------------------檢測(cè)自己函數(shù)---------------------------------
typedef void (*PTRSoftware)();
typedef void (*PTRSoftware_End)();
PTRSoftware pSoftware;
PTRSoftware_End pSoftware_End;
//--------------------------檢測(cè)自己函數(shù)---------------------------------
//--------------------------檢測(cè)其它函數(shù)---------------------------------
void Protected_Code_Start()
{
CString one = L"第一個(gè)函數(shù)";
AfxMessageBox(one);
_asm
{
//?? int 3;
//?? mov eax,0xcc;
}
}
void Protected_Code_End()
{
CString two = L"第二個(gè)函數(shù)";
AfxMessageBox(two);
_asm
{
//?? int 3;
}
}
//--------------------------檢測(cè)其它函數(shù)---------------------------------
//--------------------------檢測(cè)自己函數(shù)---------------------------------
void Software()
{
//編寫作者:Coderui
//----------檢測(cè)其它函數(shù)----------
pStart = Protected_Code_Start;
pEnd = Protected_Code_End;
DWORD i;
DWORD nSize = (DWORD)pEnd - (DWORD)pStart;
BYTE *p = (BYTE*)Protected_Code_Start;
for(i = 0; i < nSize; i++)
{
?? if(*p++ == 0xcc)
?? {
??? exit(0);
?? }
}
//----------檢測(cè)其它函數(shù)----------
//編寫作者:Coderui
//----------檢測(cè)自己函數(shù)----------
pSoftware = Software;
pSoftware_End = Software_End;
DWORD j;
DWORD nLen = (DWORD)pSoftware_End - (DWORD)pSoftware;
BYTE *q = (BYTE*)pSoftware;
for(j = 0; j < nLen; j++)
{
?? if((*q++ ^ 0x55) == 0x99)//0x99 == 0xCC XOR 0x55
?? {
??? exit(0);
?? }
}
//----------檢測(cè)自己函數(shù)----------
}
void Software_End()
{
CString three = L"第三個(gè)函數(shù)";
AfxMessageBox(three);
_asm
{
//?? int 3;
}
}
//--------------------------檢測(cè)自己函數(shù)---------------------------------