冰楓論壇

標題: aobscan [打印本頁]

作者: kkmomo    時間: 2014-12-15 15:02
標題: 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[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);


作者: zaq947    時間: 2015-1-27 15:16
於是我又開啟了CODEBLOCKS




歡迎光臨 冰楓論壇 (https://bingfong.com/) Powered by 冰楓