#pragma once
/*
	Bliblioteka modification detector
	Autor: Regz.pl
 
	Przykład:
		modification_detector::add(&GetTickCount);
		modification_detector::add(&GetTickCount64);
		modification_detector::add(&QueryPerformanceCounter);
		modification_detector::add(&QueryPerformanceFrequency);
 
		while(true)
		{
			if(modification_detector::check())
				MessageBox(NULL, "Wykryto modyfikację kodu", "Błąd", MB_OK);
 
			Sleep(25);
		}
 
	Test:
		Uruchom Cheat Engine i uruchom speedhack a funkcja check zwróci prawdę.
*/
 
#include <windows.h>
#include <map>
 
namespace modification_detector
{
	static std::map<void*, void*> functions {};
 
	void add(void* pointer, int size = 5)
	{
		auto insert = functions.insert({ pointer,  new byte[size] });
 
		if(insert.second)
		{
			memcpy(functions[pointer], pointer, sizeof(functions[pointer]));
		}
	}
 
	int check()
	{
		for (auto function : functions)
		{
			if (memcmp(function.first, function.second, sizeof(function.second)) != 0)
				return 1;
		}
		return 0;
	}
}