From a5acd4c9a3b24c9d5af3a8f504e5af053fa7fa09 Mon Sep 17 00:00:00 2001 From: boris Date: Thu, 20 Dec 2018 21:38:04 +1300 Subject: yo is this loss --- .../csgo-client/RemoteCode/RemoteProcess.hpp | 49 ++++++++++++---------- 1 file changed, 26 insertions(+), 23 deletions(-) (limited to 'csgo-loader/csgo-client/RemoteCode/RemoteProcess.hpp') diff --git a/csgo-loader/csgo-client/RemoteCode/RemoteProcess.hpp b/csgo-loader/csgo-client/RemoteCode/RemoteProcess.hpp index b1c716b..d86ecfa 100644 --- a/csgo-loader/csgo-client/RemoteCode/RemoteProcess.hpp +++ b/csgo-loader/csgo-client/RemoteCode/RemoteProcess.hpp @@ -2,35 +2,32 @@ #include #include +#include #include #include -namespace RemoteCode { +namespace RemoteCode +{ // The module wrapper. class RemoteProcess; - class RemoteModule { + class RemoteModule + { HANDLE m_Module; - int32_t m_SizeOfModule; - - // All the module data will be read upon class initialisation. - ByteArray m_ModuleData; public: - // The constructor (reads all module data into m_ModuleData). - RemoteModule(HANDLE Module, RemoteProcess &Process); - - // TODO: Add support for wild-cards (not currently implemented) - uintptr_t Scan(ByteArray &Pattern); + RemoteModule() = default; + RemoteModule(HANDLE Module); + ~RemoteModule() { CloseHandle(m_Module); } // Allow us to access the module by just passing the // handle as a parameter. operator HANDLE() { return m_Module; } - operator HINSTANCE() { return (HINSTANCE)m_Module; } }; // The process wrapper. - class RemoteProcess { + class RemoteProcess + { HANDLE m_Process; int32_t m_ProcessId; @@ -42,12 +39,14 @@ namespace RemoteCode { RemoteProcess() = default; // For portability, will ignore exceptions. - RemoteProcess(const char *ProcessName) { + RemoteProcess(const char *ProcessName) + { Start(ProcessName); } // Release the handle when the process goes out of scope. - ~RemoteProcess() { + ~RemoteProcess() + { if(m_Process) CloseHandle(m_Process); } @@ -57,25 +56,29 @@ namespace RemoteCode { // Writes to the process memory. template - void Write(void *Address, T Data) { + void Write(void *Address, T Data) + { WriteMemoryWrapper_Internal(Address, (void *)&Data, sizeof T); } - void Write(void *Address, uint8_t *Data, size_t SizeOfData) { - WriteMemoryWrapper_Internal(Address, (void *)Data, SizeOfData); + void Write(void *Address, uint8_t *Data, size_t SizeOfData) + { + WriteMemoryWrapper_Internal(Address, (void *)&Data, SizeOfData); } - + // Reads from the process memory. template - T Read(void *Address) { + T Read(void *Address) + { T Buffer{}; ReadMemoryWrapper_Internal(Address, (void *)&Buffer, sizeof T); - + return Buffer; } - void Read(void *Address, uint8_t *Data, size_t SizeOfData) { - ReadMemoryWrapper_Internal(Address, (void *)Data, SizeOfData); + void Read(void *Address, uint8_t *Data, size_t SizeOfData) + { + ReadMemoryWrapper_Internal(Address, &Data, SizeOfData); } // Allocates a memory region in the process. -- cgit v1.2.3