#include <iostream>
#include "HijackTingMix.h"
#include <Psapi.h>

int main()
{
	/*BYTE pMemBuffer[] = { 0xD5, 0xB4, 0x67, 0x92, 0x77, 0x67, 0x92, 0x77, 0x67 , 0x67, 0x92, 0x77, 0x67,0x58, 0x58,0x67, 0x92, 0x77, 0x67 , };
	const char* pattern = "67 92 77 67";*/

	BYTE pMemBuffer[] = { 0xD5, 0xB4 };
	const char* pattern = "B4";

	ULONG_PTR startAddress = (ULONG_PTR)pMemBuffer; //起始地址
	ULONG_PTR endAddress = startAddress + sizeof(pMemBuffer); //结束地址

	//MODULEINFO moduleInfo = { 0 };
	//GetModuleInformation((HANDLE)-1, GetModuleHandle(NULL), &moduleInfo, sizeof(moduleInfo));
	//startAddress = (ULONG_PTR)moduleInfo.lpBaseOfDll;
	//endAddress = startAddress + moduleInfo.SizeOfImage;
	//0xFFFFFFFFFFFFFFFF
	printf("startAddress:%IX--endSize：%d\n", startAddress, sizeof(pMemBuffer));
	// 调用内存搜索算法
	std::vector<ULONG_PTR> resultList;
	clock_t nBeginTime = clock();
	//PatternFindEx(resultList, (HANDLE)-1, 0, pattern, 0);
	//SundayPatternFind(resultList, (HANDLE)-1, startAddress, endAddress, pattern, 0);
	SSE2PatternFind(resultList, (HANDLE)-1, startAddress, endAddress, pattern, 0);

	printf("共搜到：%d个地址-->搜索时间：%d ms\n", resultList.size(), clock() - nBeginTime);
	for (ULONG_PTR i = 0; i < resultList.size(); ++i)
	{
		//printf("第%d个：%IX--值：%X--位置：%d\n", i + 1, resultList[i], *(BYTE*)resultList[i], resultList[i] - startAddress + 1);
		printf("第%d个：%IX\n", i + 1, resultList[i]);
	}
	system("pause");
	return 0;
}