summaryrefslogtreecommitdiff
path: root/csgo-loader/csgo-client/Security/RuntimeSecurity.cpp
blob: 305a44fb42ef3b9976be4fa6baf0b6cfc01cd704 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <Security/RuntimeSecurity.hpp>
#include <UserExperience/UserInterface.hpp>

// Global accessor to security instance.
Security::RuntimeSecurityPtr Protection = std::make_unique<Security::RuntimeSecurity>();

namespace Security
{
	decltype(&MessageBoxA) oMessageBox;
	int __stdcall Hooked_MessageBox(HWND Window, char *Message, char *Caption, uint32_t Type)
	{
		MEMORY_BASIC_INFORMATION Query;
		if(!VirtualQuery(_ReturnAddress(), &Query, sizeof MEMORY_BASIC_INFORMATION))
			ERROR_ASSERT("[00DF:00002C00] An integrity check failed.");

		return oMessageBox(Window, Message, Caption, Type);
	}

	bool RuntimeSecurity::Start()
	{
		if(MH_Initialize() != MH_OK)
			return false;

		MH_CreateHook(&MessageBoxA, Hooked_MessageBox, (void **)&oMessageBox);
		MH_EnableHook(&MessageBoxA);

		return true;
	}
}