#define _CRT_SECURE_NO_WARNINGS
#include <Windows.h>
#include <stdio.h>
//BYTE m_code[] = { 0x8B,0x14,0x8D,0xC8,0xF1,0x69,0x00,0x52 };
//12 34 56 78
int main()
{
SetConsoleTitleA("CheatEngine / Ollydbg 字节数组转换添加0xXX工具 Made By Xiaodi");
printf("\n\n功能举例:\n\n假设Ollydbg或者CheatEngine工具找到字节数组(特征码)为:8B 14 8D C8 F1 69 00 52\n\n在C/C++语言中需要调用:\n\nBYTE m_code[] = { 0x8B,0x14,0x8D,0xC8,0xF1,0x69,0x00,0x52 } 的时候可以自动转换添加0x和逗号.\n\n\n");
char Body[10];
//获取字节数组
char str[1024];
printf("\n\n请输入需要转换的字节数组(或特征码):\n\n");
gets(str);
printf("\n\n------------------------------------------------------------------------------\n\n您输入的字节数组为: %s 长度为:%d\n\n", str,strlen(str)); //输出所有的值,注意a
int i = 0;
for (; i < strlen(str); i++) {
//如果是空格
if (str[i] == ' ') {
//printf("%c%c\n\n", str[i-2],str[i-1]);
sprintf(Body, "0x%c%c", str[i - 2], str[i - 1]);
printf("%s,", &Body);
}
}
sprintf(Body, "0x%c%c", str[i - 2], str[i - 1]);
printf("%s", &Body);
printf("\n\n转换完成!!!\n\n\n------------------------------------------\n ", &Body);
getchar();
getchar();
return 0;
}