#include <stdio.h> char code[] = { 0x64,0x10,0x00,0x00,0x20,0x64,0x00,0x01,0x00,0x80, 0x01,0x90,0x08,0x07,0x20,0x64,0xa0,0x00,0x03,0x80, 0x01,0x90,0x08,0x07,0x20,0x64,0x00,0x08,0x00,0x03, 0x01,0x07,0x20,0x64,0x64,0x00,0x00,0x00,0x03,0x80, 0x01,0x90,0x08,0x64,0x64,0x00,0x00,0x00,0x03,0x80, 0x01,0x90,0x08,0x64,0x00,0x00,0x00,0x00,0x00,0x80, 0x01,0x90,0x64,0x00,0x00,0x00,0x07,0x20,0x03,0x80, 0x01,0x64,0x00,0x00,0x00,0x20,0x07,0x20,0x64,0xa0, 0x01,0x90,0x64,0xa0,0x00,0x03,0x80,0x00,0x03,0x80, 0x01,0x64,0x00,0x01,0x00,0x64,0x01,0x00,0x00,0x80 }; int main() { int* cp = (int*)code; char* cp1 = code; for(int i = 0; i < 100; i++) { if(*cp == 0x64) { printf("%0x ",&cp[i]); } cp = (int*)(cp1+i+1);//在最后4个字节的时候,需要判断否则超出的100个字节 } return 0; }
查找data中的所有int类型值可能为0x64的地址,由于我们不知道哪四个字节组成才是int,所以只能计算每次地址偏移一个字节的int类型是否为x64.其他类型也是一样方法