#include <iostream>
#include <string>
#include <windows.h>
#include "HijackTingMix.h"

int main()
{
	std::string unicode = "40002300240025005E0026002A00280029005E00250023004000D88F09673000310032002D4E87653000310032003400360036003800";
	std::cout << HexToUnicodeString(unicode) << std::endl;

	const wchar_t* unicode_str = L"@#$%^&*()^%#@还有012中文0124668";
	std::cout << "unicode转换后的十六进制：" << UnicodeStringToHex(unicode_str) << std::endl;
	printf("unicode字符串地址：%Ix\n", unicode_str);
	std::vector<ULONG_PTR> retList;
	PatternFindEx(retList, GetCurrentProcess(), GetModuleHandle(NULL), UnicodeStringToHex(unicode_str), 0);

	for (auto i : retList)
	{
		std::cout << "特征码搜索地址：" << std::hex << i << std::endl;
	}
	//std::cout << "替换后返回的首字节：" << ReplaceMemoryData(retList[0], UnicodeStringToHex(L"这是一条测试消息ansi") + "00") << std::endl;
	std::cout << "替换后返回的首字节：" << WriteMemoryData((ULONG_PTR)(PVOID)unicode_str, UnicodeStringToHex(L"这是一条测试消息unicode") + "????0000") << std::endl;
	std::cout << "unicode替换后:" << wstring2string(unicode_str) << std::endl;
	std::cout << "unicode替换后:" << ReadMemoryData(retList[0], true) << std::endl;

	std::string Ansi = "40 23 24 25 5E 26 2A 28295E252340BBB9D3D0D6D0CEC430313234363638";
	std::cout << HexToAnsiString(Ansi) << std::endl;

	const char* Ansi_str = "中#$%^&*()^%#@还有中文0124668";
	std::cout << "Ansi转换后的十六进制：" << AnsiStringToHex(Ansi_str) << std::endl;
	printf("Ansi字符串地址：%Ix\n", Ansi_str);

	std::vector<ULONG_PTR> retList1;
	PatternFindEx(retList1, GetCurrentProcess(), GetModuleHandle(NULL), "D6 D0 23 ?? 25 5E ?? ?? ?? ?? ?? 25 23 40 BB ?? D3 D0 ?? ?? ?? C4 ?? 31 32 34 ?? 36 38", 0);

	for (auto i : retList1)
	{
		std::cout << "特征码搜索地址：" << std::hex << i << std::endl;
	}
	//std::cout << "替换后返回的首字节：" << WriteMemoryData(retList1[0], AnsiStringToHex("这是一条测试消息ansi") + "00") << std::endl;
	std::cout << "替换后返回的首字节：" << WriteMemoryData((ULONG_PTR)(PVOID)Ansi_str, AnsiStringToHex("这是一条测试消息ansi") + "00") << std::endl;

	std::cout << "Ansi替换后:" << Ansi_str << std::endl;
	std::cout << "Ansi替换后:" << ReadMemoryData(retList1[0], false) << std::endl;

	std::string str = "Hello, World!";
	for (char& c : str) {
		c = std::toupper(c);
	}
	std::cout << str << std::endl; // 输出: hello, world!

	system("pause");
	return 0;
}