summaryrefslogtreecommitdiff
path: root/csgo-loader/csgo-client/RemoteCode/RemoteInjectionClient.cpp
blob: b8ff03d02d51a6276a133b9a93eda05f04f9af90 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <RemoteCode/RemoteInjectionClient.hpp> 

namespace RemoteCode
{
	// Select a game to inject the cheat for
	bool RemoteInjectionClient::Start(UserExperience::SelectedGame Game)
	{
		if(Game >= UserExperience::SelectedGame::GAME_MAX)
			return false;

		// TODO: Add any other games :-)
		switch(Game)
		{
		case UserExperience::SelectedGame::GAME_CSGO:
		case UserExperience::SelectedGame::GAME_CSGO_BETA:
			strcpy_s(m_ProcessName, "csgo.exe");
			break;
		}

		return true;
	}

	// Allocates a page in the game memory, which will be used to
	// write and execute the DLL.
	uintptr_t RemoteInjectionClient::AllocateImagePage(size_t SizeOfImage)
	{
		if(!m_Process)
			return uintptr_t{};

		// Allocate enough space to map the image
		m_AllocationBase = m_Process.Allocate(SizeOfImage);

		return (uintptr_t)m_AllocationBase;
	}

	// Initializes m_Process with the game process.
	bool RemoteInjectionClient::OpenGameHandle()
	{
		return m_Process.Start(m_ProcessName);
	}

	// Writes the cheat binary to the allocated page.
	void RemoteInjectionClient::WriteToMap(ByteArray &CheatBin)
	{
		// is this loss?
		m_Process.Write(m_AllocationBase, CheatBin.data(), CheatBin.size());
	}
}