模仿易语言 寻找字节集
#include <windows.h>
#include <iostream>
#include <stdio.h>
using namespace std;
ULONG GetByteCode(PVOID Buff, const char* by, int strL)
{
char* p = (char*)Buff;
int a = 0;
for (int i=0; i < 4096; i++)
{
for (int j = 0; j < strL; j++)
{
if (by[j] != '?')
{
if (p[i + j] != by[j])
{
a = 0;
break;
}
}
a++;
}
if (a == strL)
{
return i;
}
}
return -1;
}
int main()
{
byte dllp[4096] ={0};
byte ch[] = { 0x80,0x00,0x00,00,0xe9,0x63,0xe8,0xe7,0xff,0xc3,0x00,0x00};
memcpy(dllp,ch,sizeof(ch));
byte str[] = {0xE9,'?','?','?','?',0xC3,0 };
ULONGLONG a= GetByteCode(dllp, (char*)str,6);
cout << "字符在=:" << a << endl;
getchar();
return 0;
}