- UID
- 15835
- 帖子
- 2025
- 主題
- 46
- 精華
- 0
- 積分
- 144
- 楓幣
- 2209
- 威望
- 125
- 存款
- 0
- 贊助金額
- 0
- 推廣
- 0
- GP
- 164
- 閱讀權限
- 100
- 性別
- 保密
- 在線時間
- 371 小時
- 註冊時間
- 2012-10-23
- 最後登入
- 2022-4-21
|
大家好像都比較愛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[length+1];
for(offset = 0; offset < length; offset++)
if(str[3*offset] != '?')
AoB[offset] = (Hex2Dec(str[3*offset]) << 4) + Hex2Dec(str[3*offset+1]);
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[3*offset] == '?')
continue;
if (*(PBYTE)(addr + offset) != AoB[offset])
break;
}
if (offset==length && !--Index )
{
delete AoB;
return addr;
}
}
delete AoB;
return 0;
}
example:
crcMain = AobScan("8A 11 80 C2 01", 0, 0x00401000, DumpEnd);
|
|