aobscan
大家好像都比較愛vb?仿CE的aobscan寫一個
方便直接在自己程式更新用的
無防呆,寫得差勿見怪
BYTE Hex2Dec(BYTE hex)
{
return (hex & 0x0F) + ( (hex & 0x10) ? 0 : 9);
}
/* str : aob string
* index : if index>=0 the (index+1)-th match address
* if index < 0, mean the index-th match from the end
* start : the start address of search range
* end : the end address of search range
*/
DWORD AobScan(string str, int index, DWORD start, DWORD end)
{
DWORD vecter = index<0 ? -1 : 1;
DWORD offset, length = (str.length()+1)/3;
BYTE *AoB = new BYTE;
for(offset = 0; offset < length; offset++)
if(str != '?')
AoB = (Hex2Dec(str) << 4) + Hex2Dec(str);
DWORD boundary = (index<0 ? start : end) + vecter;
int Index = index<0 ? ~index+1 : index+1;
for (DWORD addr = index<0 ? end : start; addr != boundary; addr+=vecter)
{
for (offset = 0; offset < length; offset++)
{
if (str == '?')
continue;
if (*(PBYTE)(addr + offset) != AoB)
break;
}
if (offset==length && !--Index )
{
delete AoB;
return addr;
}
}
delete AoB;
return 0;
}
example:
crcMain = AobScan("8A 11 80 C2 01", 0, 0x00401000, DumpEnd);
於是我又開啟了CODEBLOCKS
頁:
[1]