summaryrefslogtreecommitdiff
path: root/csgo-loader/csgo-client/RemoteCode/RemoteInjectionClient.hpp
blob: 2e5d216282b80d2cd5bb05fdaa2646df642db531 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#pragma once

#include <RemoteCode/RemoteProcess.hpp>
#include <UserExperience/UserInterface.hpp>

namespace RemoteCode
{
	// Used for TransactionStart
	using ImportedModule = char[64];
	using ImportList     = std::vector<ImportedModule>;

	// Used for TransactionContinue
	struct ExportedFunction
	{
		// I've never seen modules / functions with names
		// that were larger than 64 characters.
		char		m_Module[64];
		char		m_Function[64];

		// Address of exported module / function
		uintptr_t	m_ModuleAddress;
		uintptr_t	m_FunctionAddress;
	};

	using ExportList = std::vector<ExportedFunction>;

	// Used for TransactionCommit
	struct RemoteInjectionHeader
	{
		// Used to decrypt the cheat header (first 1000 bytes of image sent back).
		uint8_t   m_HeaderKey;

		// Used to call entrypoint/TLS callbacks.
		uintptr_t m_EntryPoint;
		uintptr_t m_TlsDirectory;
	};
	
	struct RemoteInjectionCode
	{
		RemoteInjectionHeader m_Header;

		// Actual injection code.
		ByteArray m_Code;
	};

	// Implementation of client mapping code
	class RemoteInjectionClient
	{
		RemoteInjectionHeader	m_Header;
		RemoteProcess			m_Process;

	public:
		// Receive hash of selected cheat.
		// Reply with size of image to allocate.
		ByteArray Start(ByteArray &Response);

		// Receive client header, send over list of imported functions
		ByteArray TransactionStart(ByteArray &Response);

		// Receive list of modules & export addresses
		ByteArray TransactionContinue(ByteArray &Response);
	
		// Write the file to the 
		void TransactionCommit(ByteArray &Response);

		RemoteProcess GetProcess() { return m_Process; }
		RemoteInjectionHeader GetHeader() { return m_Header; }
	};
}