From 7de90fcf1b26fc698a42ae73a981298c168b23e0 Mon Sep 17 00:00:00 2001 From: ByteCorum <164874887+ByteCorum@users.noreply.github.com> Date: Fri, 13 Sep 2024 18:19:21 +0100 Subject: [PATCH] memory handling using kernel driver --- .gitignore | 1 + DragonBurn/Core/Cheats.cpp | 12 +- DragonBurn/Core/GlobalVars.cpp | 2 +- DragonBurn/Core/Globals.hpp | 5 +- DragonBurn/Core/Init.h | 2 +- DragonBurn/Core/MemoryMgr.cpp | 181 ++++++++++++++++ DragonBurn/Core/MemoryMgr.h | 93 +++++++++ DragonBurn/Core/ProcessManager.hpp | 285 -------------------------- DragonBurn/DragonBurn.vcxproj | 9 +- DragonBurn/DragonBurn.vcxproj.filters | 9 +- DragonBurn/Features/Aimbot.cpp | 2 +- DragonBurn/Features/BombTimer.h | 14 +- DragonBurn/Features/ESP.h | 8 +- DragonBurn/Features/Misc.cpp | 6 +- DragonBurn/Features/RCS.cpp | 2 +- DragonBurn/Features/SpectatorList.h | 18 +- DragonBurn/Features/TriggerBot.cpp | 28 +-- DragonBurn/Game/Bone.cpp | 6 +- DragonBurn/Game/Entity.cpp | 32 +-- DragonBurn/Game/Game.cpp | 18 +- DragonBurn/Game/Game.h | 2 +- DragonBurn/Offsets/Offsets.h | 2 +- DragonBurn/main.cpp | 35 ++-- 23 files changed, 383 insertions(+), 389 deletions(-) create mode 100644 DragonBurn/Core/MemoryMgr.cpp create mode 100644 DragonBurn/Core/MemoryMgr.h delete mode 100644 DragonBurn/Core/ProcessManager.hpp diff --git a/.gitignore b/.gitignore index 6e3b126..7c1c954 100644 --- a/.gitignore +++ b/.gitignore @@ -402,6 +402,7 @@ FodyWeavers.xsd # JetBrains Rider *.sln.iml +ProcessManager.txt DragonBurn/imgui.ini DragonBurn/settings.yml DragonBurn/prefs.ini diff --git a/DragonBurn/Core/Cheats.cpp b/DragonBurn/Core/Cheats.cpp index e4d48ab..6c70538 100644 --- a/DragonBurn/Core/Cheats.cpp +++ b/DragonBurn/Core/Cheats.cpp @@ -37,7 +37,7 @@ void Cheats::Run() return; // Update matrix - if(!ProcessMgr.ReadMemory(gGame.GetMatrixAddress(), gGame.View.Matrix,64)) + if(!memoryManager.ReadMemory(gGame.GetMatrixAddress(), gGame.View.Matrix,64)) return; // Update EntityList Entry @@ -46,9 +46,9 @@ void Cheats::Run() DWORD64 LocalControllerAddress = 0; DWORD64 LocalPawnAddress = 0; - if (!ProcessMgr.ReadMemory(gGame.GetLocalControllerAddress(), LocalControllerAddress)) + if (!memoryManager.ReadMemory(gGame.GetLocalControllerAddress(), LocalControllerAddress)) return; - if (!ProcessMgr.ReadMemory(gGame.GetLocalPawnAddress(), LocalPawnAddress)) + if (!memoryManager.ReadMemory(gGame.GetLocalPawnAddress(), LocalPawnAddress)) return; // LocalEntity @@ -79,7 +79,7 @@ void Cheats::Run() { CEntity Entity; DWORD64 EntityAddress = 0; - if (!ProcessMgr.ReadMemory(gGame.GetEntityListEntry() + (i + 1) * 0x78, EntityAddress)) + if (!memoryManager.ReadMemory(gGame.GetEntityListEntry() + (i + 1) * 0x78, EntityAddress)) continue; if (EntityAddress == LocalEntity.Controller.Address) { @@ -167,7 +167,7 @@ void Cheats::Run() { bool HasHelmet; ImVec2 ArmorBarPos; - ProcessMgr.ReadMemory(Entity.Controller.Address + Offset.PlayerController.HasHelmet, HasHelmet); + memoryManager.ReadMemory(Entity.Controller.Address + Offset.PlayerController.HasHelmet, HasHelmet); if (ESPConfig::ShowHealthBar) ArmorBarPos = { Rect.x - 10.f,Rect.y }; else @@ -321,7 +321,7 @@ void RenderCrosshair(ImDrawList* drawList, const CEntity& LocalEntity) // return; bool isScoped; - ProcessMgr.ReadMemory(LocalEntity.Pawn.Address + Offset.Pawn.isScoped, isScoped); + memoryManager.ReadMemory(LocalEntity.Pawn.Address + Offset.Pawn.isScoped, isScoped); if (!MiscCFG::SniperCrosshair || LocalEntity.Controller.TeamID == 0 || !TriggerBot::CheckScopeWeapon(LocalEntity) || isScoped || MenuConfig::ShowMenu) return; diff --git a/DragonBurn/Core/GlobalVars.cpp b/DragonBurn/Core/GlobalVars.cpp index ee12da8..08befa5 100644 --- a/DragonBurn/Core/GlobalVars.cpp +++ b/DragonBurn/Core/GlobalVars.cpp @@ -3,7 +3,7 @@ bool globalvars::UpdateGlobalvars() { DWORD64 m_DglobalVars = 0; - if (!ProcessMgr.ReadMemory(gGame.GetGlobalVarsAddress(), m_DglobalVars)) + if (!memoryManager.ReadMemory(gGame.GetGlobalVarsAddress(), m_DglobalVars)) return false; this->address = m_DglobalVars; diff --git a/DragonBurn/Core/Globals.hpp b/DragonBurn/Core/Globals.hpp index aa6725a..3ef3910 100644 --- a/DragonBurn/Core/Globals.hpp +++ b/DragonBurn/Core/Globals.hpp @@ -1,13 +1,14 @@ #pragma once #include -#include "ProcessManager.hpp" +#include "MemoryMgr.h" + template inline bool GetDataAddressWithOffset(const DWORD64& Address, DWORD Offset, T& Data) { if (Address == 0) return false; - if (!ProcessMgr.ReadMemory(Address + Offset, Data)) + if (!memoryManager.ReadMemory(Address + Offset, Data)) return false; return true; diff --git a/DragonBurn/Core/Init.h b/DragonBurn/Core/Init.h index 4a6db79..561ccfa 100644 --- a/DragonBurn/Core/Init.h +++ b/DragonBurn/Core/Init.h @@ -91,7 +91,7 @@ namespace Init static int CheckCS2Version() { - DWORD pid = ProcessMgr.GetProcessID("cs2.exe"); + DWORD pid = MemoryMgr::GetProcessID(L"cs2.exe"); long curVer; const std::string cloudVersionUrl = "https://raw.githubusercontent.com/ByteCorum/DragonBurn/data/cs2-version"; long cloudVersion; diff --git a/DragonBurn/Core/MemoryMgr.cpp b/DragonBurn/Core/MemoryMgr.cpp new file mode 100644 index 0000000..b6c2fd1 --- /dev/null +++ b/DragonBurn/Core/MemoryMgr.cpp @@ -0,0 +1,181 @@ +#include "MemoryMgr.h" + +MemoryMgr::MemoryMgr() +{ + ProcessID = 0; + kernelDriver = nullptr; +} + +MemoryMgr::~MemoryMgr() +{ + Detach(); + DisconnectDriver(); + + ProcessID = 0; + kernelDriver = nullptr; +} + +bool MemoryMgr::ConnectDriver(const LPCWSTR name) +{ + kernelDriver = CreateFile(name, GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); + if (kernelDriver == INVALID_HANDLE_VALUE) + return false; + + return true; +} + +bool MemoryMgr::DisconnectDriver() +{ + if (kernelDriver != nullptr) + { + return CloseHandle(kernelDriver); + } + else + return false; +} + +bool MemoryMgr::Attach(const DWORD pid) +{ + Request req; + req.pid = reinterpret_cast(pid); + ProcessID = pid; + + return DeviceIoControl(kernelDriver, kernelCodes::ATTACH, &req, sizeof(req), &req, sizeof(req), nullptr, nullptr); +} + +bool MemoryMgr::Detach() +{ + if (kernelDriver != nullptr && ProcessID != 0) + { + Request req; + req.pid = reinterpret_cast(ProcessID); + ProcessID = 0; + + return DeviceIoControl(kernelDriver, kernelCodes::DETACH, &req, sizeof(req), &req, sizeof(req), nullptr, nullptr); + } + else + return false; +} + +//template +//bool MemoryMgr::ReadMemory(DWORD64 address, ReadType& value) +//{ +// if (kernelDriver != nullptr && ProcessID != 0) +// { +// Request req; +// +// req.target = reinterpret_cast(address); +// req.buffer = &value; +// req.size = sizeof(ReadType); +// +// return DeviceIoControl(kernelDriver, kernelCodes::READ, &req, sizeof(req), &req, sizeof(req), nullptr, nullptr); +// } +// else +// return false; +//} + +//template +//bool MemoryMgr::ReadMemory(DWORD64 address, ReadType& value, int size) +//{ +// if (kernelDriver != nullptr && ProcessID != 0) +// { +// Request req; +// +// req.target = reinterpret_cast(address); +// req.buffer = &value; +// req.size = size; +// +// return DeviceIoControl(kernelDriver, kernelCodes::READ, &req, sizeof(req), &req, sizeof(req), nullptr, nullptr); +// } +// else +// return false; +//} + +DWORD64 MemoryMgr::TraceAddress(DWORD64 baseAddress, std::vector offsets) +{ + if (kernelDriver != nullptr && ProcessID != 0) + { + DWORD64 address = 0; + + if (offsets.size() == 0) + return baseAddress; + + if (!ReadMemory(baseAddress, address)) + return 0; + + for (int i = 0; i < offsets.size() - 1; i++) + { + if (!ReadMemory(address + offsets[i], address)) + return 0; + } + return address == 0 ? 0 : address + offsets[offsets.size() - 1]; + } + else + return 0; +} + +DWORD MemoryMgr::GetProcessID(const wchar_t* processName) +{ + DWORD processId = 0; + HANDLE snapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL); + + if (snapShot == INVALID_HANDLE_VALUE) + return processId; + + PROCESSENTRY32W entry = {}; + entry.dwSize = sizeof(decltype(entry)); + + if (Process32FirstW(snapShot, &entry) == TRUE) // Check if the first handle is the one we want + { + if (_wcsicmp(processName, entry.szExeFile) == 0) + processId = entry.th32ProcessID; + + else + { + while (Process32NextW(snapShot, &entry) == TRUE) + { + if (_wcsicmp(processName, entry.szExeFile) == 0) + { + processId = entry.th32ProcessID; + break; + } + } + } + } + + CloseHandle(snapShot); + return processId; +} + +DWORD64 MemoryMgr::GetModuleBase(const DWORD pid, const wchar_t* moduleName) { + DWORD64 moduleBase = 0; + + // Snap-shot of process' modules (dlls). + HANDLE snapShot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, pid); + if (snapShot == INVALID_HANDLE_VALUE) + return moduleBase; + + MODULEENTRY32W entry = {}; + entry.dwSize = sizeof(decltype(entry)); + + if (Module32FirstW(snapShot, &entry) == TRUE) + { + if (wcsstr(moduleName, entry.szModule) != nullptr) + moduleBase = reinterpret_cast(entry.modBaseAddr); + + else + { + while (Module32NextW(snapShot, &entry) == TRUE) + { + if (wcsstr(moduleName, entry.szModule) != nullptr) + { + moduleBase = reinterpret_cast(entry.modBaseAddr); + break; + } + } + } + } + + CloseHandle(snapShot); + return moduleBase; +} diff --git a/DragonBurn/Core/MemoryMgr.h b/DragonBurn/Core/MemoryMgr.h new file mode 100644 index 0000000..b034e45 --- /dev/null +++ b/DragonBurn/Core/MemoryMgr.h @@ -0,0 +1,93 @@ +#pragma once +#include +#include +#include +#include +#include + +namespace kernelCodes +{ + inline const ULONG ATTACH = CTL_CODE(FILE_DEVICE_UNKNOWN, 0x4462, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); + inline const ULONG READ = CTL_CODE(FILE_DEVICE_UNKNOWN, 0x4472, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); + inline const ULONG WRITE = CTL_CODE(FILE_DEVICE_UNKNOWN, 0x4482, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); + inline const ULONG DETACH = CTL_CODE(FILE_DEVICE_UNKNOWN, 0x4492, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); +} + +class MemoryMgr +{ +public: + MemoryMgr(); + ~MemoryMgr(); + + bool ConnectDriver(const LPCWSTR); + bool DisconnectDriver(); + + bool Attach(const DWORD); + bool Detach(); + + template + bool ReadMemory(DWORD64 address, ReadType& value) + { + if (kernelDriver != nullptr && ProcessID != 0) + { + Request req; + + req.target = reinterpret_cast(address); + req.buffer = &value; + req.size = sizeof(ReadType); + + return DeviceIoControl(kernelDriver, kernelCodes::READ, &req, sizeof(req), &req, sizeof(req), nullptr, nullptr); + } + else + return false; + } + + template + bool ReadMemory(DWORD64 address, ReadType& value, int size) + { + if (kernelDriver != nullptr && ProcessID != 0) + { + Request req; + + req.target = reinterpret_cast(address); + req.buffer = &value; + req.size = size; + + return DeviceIoControl(kernelDriver, kernelCodes::READ, &req, sizeof(req), &req, sizeof(req), nullptr, nullptr); + } + else + return false; + } + + DWORD64 TraceAddress(DWORD64, std::vector); + + static DWORD GetProcessID(const wchar_t*); + static DWORD64 GetModuleBase(const DWORD, const wchar_t*); + +private: + DWORD ProcessID; + HANDLE kernelDriver; + + struct Request + { + HANDLE pid; + + PVOID target; + PVOID buffer; + + SIZE_T size; + SIZE_T rtrn_size; + }; + + //static struct + //{ + // static const ULONG ATTACH = CTL_CODE(FILE_DEVICE_UNKNOWN, 0x4462, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); + // static const ULONG READ = CTL_CODE(FILE_DEVICE_UNKNOWN, 0x4472, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); + // static const ULONG WRITE = CTL_CODE(FILE_DEVICE_UNKNOWN, 0x4482, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); + // static const ULONG DETACH = CTL_CODE(FILE_DEVICE_UNKNOWN, 0x4492, METHOD_BUFFERED, FILE_SPECIAL_ACCESS); + //}Codes; + +}; + +inline MemoryMgr memoryManager; + diff --git a/DragonBurn/Core/ProcessManager.hpp b/DragonBurn/Core/ProcessManager.hpp deleted file mode 100644 index e494c04..0000000 --- a/DragonBurn/Core/ProcessManager.hpp +++ /dev/null @@ -1,285 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include -#define _is_invalid(v) if(v==NULL) return false -#define _is_invalid(v,n) if(v==NULL) return n -#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0) - -typedef struct _CLIENT_ID -{ - PVOID UniqueProcess; - PVOID UniqueThread; -} CLIENT_ID, * PCLIENT_ID; - -typedef struct _UNICODE_STRING { - USHORT Length; - USHORT MaximumLength; - PWCH Buffer; -} UNICODE_STRING, *UNICODE_STRING_Ptr; - -typedef struct _SYSTEM_HANDLE_TABLE_ENTRY_INFO -{ - ULONG ProcessId; - BYTE ObjectTypeNumber; - BYTE Flags; - USHORT Handle; - PVOID Object; - ACCESS_MASK GrantedAccess; -} SYSTEM_HANDLE_TABLE_ENTRY_INFO, * PSYSTEM_HANDLE_TABLE_ENTRY_INFO; - - -typedef struct _OBJECT_ATTRIBUTES { - ULONG Length; - HANDLE RootDirectory; - UNICODE_STRING_Ptr ObjectName; - ULONG Attributes; - PVOID SecurityDescriptor; - PVOID SecurityQualityOfService; -} OBJECT_ATTRIBUTES, * OBJECT_ATTRIBUTES_Ptr; - -typedef struct _SYSTEM_HANDLE_INFORMATION -{ - ULONG HandleCount; - SYSTEM_HANDLE_TABLE_ENTRY_INFO Handles[1]; -} SYSTEM_HANDLE_INFORMATION, * PSYSTEM_HANDLE_INFORMATION; -typedef NTSYSAPI NTSTATUS(NTAPI* FUNC_NtOpenProcess)(PHANDLE ProcessHandle,ACCESS_MASK DesiredAccess,OBJECT_ATTRIBUTES_Ptr ObjectAttributes,PCLIENT_ID ClientId); -typedef NTSTATUS(NTAPI* FUNC_NtQuerySystemInformation)(ULONG SystemInformationClass,PVOID SystemInformation,ULONG SystemInformationLength,PULONG ReturnLength); -typedef NTSTATUS(NTAPI* FUNC_RtlAdjustPrivilege)(ULONG Privilege,BOOLEAN Enable,BOOLEAN CurrentThread,PBOOLEAN Enabled); -typedef NTSTATUS(NTAPI* FUNC_NtDuplicateObject)(HANDLE SourceProcessHandle,HANDLE SourceHandle,HANDLE TargetProcessHandle,PHANDLE TargetHandle,ACCESS_MASK DesiredAccess,ULONG Attributes,ULONG Options); - - -enum StatusCode -{ - SUCCEED, - FAILE_PROCESSID, - FAILE_HPROCESS, - FAILE_MODULE, -}; - - -class ProcessManager -{ -private: - bool Attached = false; - -public: - - HANDLE hProcess = 0; - DWORD ProcessID = 0; - DWORD64 ModuleAddress = 0; - -public: - ~ProcessManager() - { - //if (hProcess) - //CloseHandle(hProcess); - } - SYSTEM_HANDLE_INFORMATION* t_SYSTEM_HANDLE_INFORMATION; - HANDLE Source_Process = NULL; - HANDLE target_handle = NULL; - - StatusCode Attach(std::string ProcessName) - { - ProcessID = this->GetProcessID(ProcessName); - _is_invalid(ProcessID, FAILE_PROCESSID); - ModuleAddress = reinterpret_cast(this->GetProcessModuleHandle(ProcessName)); - _is_invalid(ModuleAddress, FAILE_MODULE); - auto ObjectAttributes = [](UNICODE_STRING_Ptr ObjectName, HANDLE RootDirectory, ULONG Attributes, PSECURITY_DESCRIPTOR SecurityDescriptor)->_OBJECT_ATTRIBUTES { - OBJECT_ATTRIBUTES object; - object.Length = sizeof(OBJECT_ATTRIBUTES); - object.Attributes = Attributes; - object.RootDirectory = RootDirectory; - object.SecurityDescriptor = SecurityDescriptor; - object.ObjectName = ObjectName; - return object; - }; - - FUNC_RtlAdjustPrivilege f_RtlAdjustPrivilege = (FUNC_RtlAdjustPrivilege)GetProcAddress(GetModuleHandleA("ntdll"), "RtlAdjustPrivilege"); - FUNC_NtDuplicateObject f_NtDuplicateObject = (FUNC_NtDuplicateObject)GetProcAddress(GetModuleHandleA("ntdll"), "NtDuplicateObject"); - FUNC_NtOpenProcess f_NtOpenProcess = (FUNC_NtOpenProcess)GetProcAddress(GetModuleHandleA("ntdll"), "NtOpenProcess"); - FUNC_NtQuerySystemInformation f_NtQuerySystemInformation = (FUNC_NtQuerySystemInformation)GetProcAddress(GetModuleHandleA("ntdll"), "NtQuerySystemInformation"); - - - - - _OBJECT_ATTRIBUTES R_Attributes = ObjectAttributes(NULL,NULL,NULL,NULL); - CLIENT_ID t_CLIENT_ID= { 0 }; - boolean OldPriv; - - f_RtlAdjustPrivilege(20, TRUE, FALSE, &OldPriv); - - DWORD Sizeof_SYSTEM_HANDLE_INFORMATION = sizeof(SYSTEM_HANDLE_INFORMATION); - - NTSTATUS NTAPIReturn = NULL; - - do { - delete[] t_SYSTEM_HANDLE_INFORMATION; - - Sizeof_SYSTEM_HANDLE_INFORMATION *= 1.5; - - try - { - t_SYSTEM_HANDLE_INFORMATION = (PSYSTEM_HANDLE_INFORMATION) new byte[Sizeof_SYSTEM_HANDLE_INFORMATION]; - } - catch (std::bad_alloc) - { - - return FAILE_HPROCESS; - break; - } - Sleep(1); - - } while ((NTAPIReturn = f_NtQuerySystemInformation(16, t_SYSTEM_HANDLE_INFORMATION, Sizeof_SYSTEM_HANDLE_INFORMATION, NULL)) == (NTSTATUS)0xC0000004); - - if (!NT_SUCCESS(NTAPIReturn)) - { - return FAILE_HPROCESS; - } - - for (int i = 0; i < t_SYSTEM_HANDLE_INFORMATION->HandleCount; ++i) { - static int n = i; - if (n > 100) { - return FAILE_HPROCESS; - } - - if (t_SYSTEM_HANDLE_INFORMATION->Handles[i].ObjectTypeNumber != 0x7) - continue; - if ((HANDLE)t_SYSTEM_HANDLE_INFORMATION->Handles[i].Handle == INVALID_HANDLE_VALUE) - continue; - - t_CLIENT_ID.UniqueProcess = (DWORD*)t_SYSTEM_HANDLE_INFORMATION->Handles[i].ProcessId; - - NTAPIReturn = f_NtOpenProcess(&Source_Process,PROCESS_DUP_HANDLE,&R_Attributes,&t_CLIENT_ID); - - if (Source_Process == INVALID_HANDLE_VALUE || !NT_SUCCESS(NTAPIReturn)) - continue; - NTAPIReturn = f_NtDuplicateObject(Source_Process,(HANDLE)t_SYSTEM_HANDLE_INFORMATION->Handles[i].Handle, (HANDLE)(LONG_PTR)-1,&target_handle,PROCESS_ALL_ACCESS,0,0); - - if (target_handle == INVALID_HANDLE_VALUE || !NT_SUCCESS(NTAPIReturn)) - continue; - - if (GetProcessId(target_handle) == ProcessID) { - hProcess = target_handle; - Attached = true; - delete[] t_SYSTEM_HANDLE_INFORMATION; - break; - } - else - { - CloseHandle(target_handle); - CloseHandle(Source_Process); - continue; - } - - - } - - return SUCCEED; - } - - void Detach() - { - if (hProcess) - CloseHandle(hProcess); - hProcess = 0; - ProcessID = 0; - ModuleAddress = 0; - Attached = false; - } - - - bool IsActive() - { - if (!Attached) - return false; - DWORD ExitCode{}; - GetExitCodeProcess(hProcess, &ExitCode); - return ExitCode == STILL_ACTIVE; - } - - template - bool ReadMemory(DWORD64 Address, ReadType& Value, int Size) - { - _is_invalid(hProcess,false); - _is_invalid(ProcessID, false); - - if (ReadProcessMemory(hProcess, reinterpret_cast(Address), &Value, Size, 0)) - return true; - return false; - } - - template - bool ReadMemory(DWORD64 Address, ReadType& Value) - { - _is_invalid(hProcess, false); - _is_invalid(ProcessID, false); - - if (ReadProcessMemory(hProcess, reinterpret_cast(Address), &Value, sizeof(ReadType), 0)) - return true; - return false; - } - - DWORD64 TraceAddress(DWORD64 BaseAddress, std::vector Offsets) - { - _is_invalid(hProcess,0); - _is_invalid(ProcessID,0); - DWORD64 Address = 0; - - if (Offsets.size() == 0) - return BaseAddress; - - if (!ReadMemory(BaseAddress, Address)) - return 0; - - for (int i = 0; i < Offsets.size() - 1; i++) - { - if (!ReadMemory(Address + Offsets[i], Address)) - return 0; - } - return Address == 0 ? 0 : Address + Offsets[Offsets.size() - 1]; - } - -public: - - DWORD GetProcessID(std::string ProcessName) - { - PROCESSENTRY32 ProcessInfoPE; - ProcessInfoPE.dwSize = sizeof(PROCESSENTRY32); - HANDLE hSnapshot = CreateToolhelp32Snapshot(15, 0); - Process32First(hSnapshot, &ProcessInfoPE); - USES_CONVERSION; - do { - if (strcmp(W2A(ProcessInfoPE.szExeFile), ProcessName.c_str()) == 0) - { - CloseHandle(hSnapshot); - return ProcessInfoPE.th32ProcessID; - } - } while (Process32Next(hSnapshot, &ProcessInfoPE)); - CloseHandle(hSnapshot); - return 0; - } - - HMODULE GetProcessModuleHandle(std::string ModuleName) - { - MODULEENTRY32 ModuleInfoPE; - ModuleInfoPE.dwSize = sizeof(MODULEENTRY32); - HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, this->ProcessID); - Module32First(hSnapshot, &ModuleInfoPE); - USES_CONVERSION; - do { - if (strcmp(W2A(ModuleInfoPE.szModule), ModuleName.c_str()) == 0) - { - CloseHandle(hSnapshot); - return ModuleInfoPE.hModule; - } - } while (Module32Next(hSnapshot, &ModuleInfoPE)); - CloseHandle(hSnapshot); - return 0; - } - -}; - -inline ProcessManager ProcessMgr; \ No newline at end of file diff --git a/DragonBurn/DragonBurn.vcxproj b/DragonBurn/DragonBurn.vcxproj index 28beef9..27d30d4 100644 --- a/DragonBurn/DragonBurn.vcxproj +++ b/DragonBurn/DragonBurn.vcxproj @@ -88,7 +88,7 @@ $(SolutionDir)\built\ - built\ + $(SolutionDir)\built\ceche false Libs\json $(ExternalIncludePath) @@ -97,7 +97,7 @@ $(SolutionDir)\built\ - built\ + $(SolutionDir)\built\ceche false Libs\json $(ExternalIncludePath) @@ -146,6 +146,7 @@ Console true %(AdditionalDependencies) + AsInvoker @@ -164,6 +165,7 @@ true true %(AdditionalDependencies) + AsInvoker @@ -175,7 +177,6 @@ - @@ -209,6 +210,7 @@ + @@ -245,6 +247,7 @@ + diff --git a/DragonBurn/DragonBurn.vcxproj.filters b/DragonBurn/DragonBurn.vcxproj.filters index f166d0a..fdd243e 100644 --- a/DragonBurn/DragonBurn.vcxproj.filters +++ b/DragonBurn/DragonBurn.vcxproj.filters @@ -144,9 +144,6 @@ Core - - Core - Core @@ -186,6 +183,9 @@ Resources + + Core + @@ -266,6 +266,9 @@ Features\Aim + + Core + diff --git a/DragonBurn/Features/Aimbot.cpp b/DragonBurn/Features/Aimbot.cpp index 124b8d2..a4e2e6b 100644 --- a/DragonBurn/Features/Aimbot.cpp +++ b/DragonBurn/Features/Aimbot.cpp @@ -29,7 +29,7 @@ void AimControl::AimBot(const CEntity& Local, Vec3 LocalPos, std::vector& if (AimControl::ScopeOnly) { bool isScoped; - ProcessMgr.ReadMemory(Local.Pawn.Address + Offset.Pawn.isScoped, isScoped); + memoryManager.ReadMemory(Local.Pawn.Address + Offset.Pawn.isScoped, isScoped); if (!isScoped and TriggerBot::CheckScopeWeapon(Local)) { HasTarget = false; diff --git a/DragonBurn/Features/BombTimer.h b/DragonBurn/Features/BombTimer.h index cde54cb..7c71ad9 100644 --- a/DragonBurn/Features/BombTimer.h +++ b/DragonBurn/Features/BombTimer.h @@ -24,13 +24,13 @@ namespace bmb { int site; uintptr_t cPlantedC4; - //ProcessMgr.ReadMemory(gGame.GetClientDLLAddress() + Offset.PlantedC4, cPlantedC4); - if (!ProcessMgr.ReadMemory(gGame.GetClientDLLAddress() + Offset.PlantedC4, cPlantedC4)) + //memoryManager.ReadMemory(gGame.GetClientDLLAddress() + Offset.PlantedC4, cPlantedC4); + if (!memoryManager.ReadMemory(gGame.GetClientDLLAddress() + Offset.PlantedC4, cPlantedC4)) return 0; - if (!ProcessMgr.ReadMemory(cPlantedC4, cPlantedC4)) + if (!memoryManager.ReadMemory(cPlantedC4, cPlantedC4)) return 0; - if (!ProcessMgr.ReadMemory(cPlantedC4 + Offset.C4.m_nBombSite, site)) + if (!memoryManager.ReadMemory(cPlantedC4 + Offset.C4.m_nBombSite, site)) return 0; return site; @@ -50,7 +50,7 @@ namespace bmb float DefuseTime; auto plantedAddress = gGame.GetClientDLLAddress() + Offset.PlantedC4 - 0x8; - ProcessMgr.ReadMemory(plantedAddress, isBombPlanted); + memoryManager.ReadMemory(plantedAddress, isBombPlanted); auto time = currentTimeMillis(); @@ -60,8 +60,8 @@ namespace bmb plantTime = time; } - //ProcessMgr.ReadMemory(Offset.PlantedC4 + Offset.C4.m_flDefuseCountDown, IsBeingDefused); - //ProcessMgr.ReadMemory(Offset.PlantedC4 + Offset.C4.m_flDefuseCountDown, DefuseTime); + //memoryManager.ReadMemory(Offset.PlantedC4 + Offset.C4.m_flDefuseCountDown, IsBeingDefused); + //memoryManager.ReadMemory(Offset.PlantedC4 + Offset.C4.m_flDefuseCountDown, DefuseTime); if (!isPlanted && !MenuConfig::ShowMenu) return; diff --git a/DragonBurn/Features/ESP.h b/DragonBurn/Features/ESP.h index 05497fe..7c6e8ee 100644 --- a/DragonBurn/Features/ESP.h +++ b/DragonBurn/Features/ESP.h @@ -89,9 +89,9 @@ namespace ESP const char* RenderWeaponIcon(const CEntity& Entity) { uintptr_t ClippingWeapon, WeaponData, WeaponNameAddress; - ProcessMgr.ReadMemory(Entity.Pawn.Address + Offset.Pawn.pClippingWeapon, ClippingWeapon); - ProcessMgr.ReadMemory(ClippingWeapon + Offset.WeaponBaseData.WeaponDataPTR, WeaponData); - ProcessMgr.ReadMemory(WeaponData + Offset.WeaponBaseData.szName, WeaponNameAddress); + memoryManager.ReadMemory(Entity.Pawn.Address + Offset.Pawn.pClippingWeapon, ClippingWeapon); + memoryManager.ReadMemory(ClippingWeapon + Offset.WeaponBaseData.WeaponDataPTR, WeaponData); + memoryManager.ReadMemory(WeaponData + Offset.WeaponBaseData.szName, WeaponNameAddress); std::string weaponName = "Invalid Weapon Name"; if (!WeaponNameAddress) @@ -219,7 +219,7 @@ namespace ESP { bool isScoped; ImVec2 IconPos = { Rect.x, Rect.y }; - ProcessMgr.ReadMemory(Entity.Pawn.Address + Offset.Pawn.isScoped, isScoped); + memoryManager.ReadMemory(Entity.Pawn.Address + Offset.Pawn.isScoped, isScoped); if (isScoped) { ImGui::GetBackgroundDrawList()->AddText(ImGui::GetIO().Fonts->Fonts[1], 13.0f, ImVec2{ IconPos.x - 1, IconPos.y - 1 }, ImColor(0, 0, 0, 255), "s"); diff --git a/DragonBurn/Features/Misc.cpp b/DragonBurn/Features/Misc.cpp index 402266d..0695e50 100644 --- a/DragonBurn/Features/Misc.cpp +++ b/DragonBurn/Features/Misc.cpp @@ -60,8 +60,8 @@ namespace Misc uintptr_t pBulletServices; int totalHits; - ProcessMgr.ReadMemory(LocalPlayer.Pawn.Address + Offset.Pawn.BulletServices, pBulletServices); - ProcessMgr.ReadMemory(pBulletServices + Offset.Pawn.TotalHit, totalHits); + memoryManager.ReadMemory(LocalPlayer.Pawn.Address + Offset.Pawn.BulletServices, pBulletServices); + memoryManager.ReadMemory(pBulletServices + Offset.Pawn.TotalHit, totalHits); if (totalHits != PreviousTotalHits) { if (totalHits == 0 && PreviousTotalHits != 0) @@ -97,7 +97,7 @@ namespace Misc } //int JumpBtn; - //if (!ProcessMgr.ReadMemory(gGame.GetJumpBtnAddress(), JumpBtn)) + //if (!memoryManager.ReadMemory(gGame.GetJumpBtnAddress(), JumpBtn)) // return; bool spacePressed = GetAsyncKeyState(VK_SPACE); diff --git a/DragonBurn/Features/RCS.cpp b/DragonBurn/Features/RCS.cpp index 7e154d3..49e26c2 100644 --- a/DragonBurn/Features/RCS.cpp +++ b/DragonBurn/Features/RCS.cpp @@ -47,7 +47,7 @@ void RCS::UpdateAngles(const CEntity& Local, Vec2& Angles) Vec2 PunchAngle; if (Local.Pawn.AimPunchCache.Count <= 0 && Local.Pawn.AimPunchCache.Count > 0xFFFF) return; - if (!ProcessMgr.ReadMemory(Local.Pawn.AimPunchCache.Data + (Local.Pawn.AimPunchCache.Count - 1) * sizeof(Vec3), PunchAngle)) + if (!memoryManager.ReadMemory(Local.Pawn.AimPunchCache.Data + (Local.Pawn.AimPunchCache.Count - 1) * sizeof(Vec3), PunchAngle)) return; Angles.x = PunchAngle.x; diff --git a/DragonBurn/Features/SpectatorList.h b/DragonBurn/Features/SpectatorList.h index 7203d63..bd24c5b 100644 --- a/DragonBurn/Features/SpectatorList.h +++ b/DragonBurn/Features/SpectatorList.h @@ -35,10 +35,10 @@ namespace SpecList uintptr_t getAddressBase(uintptr_t entityList, uintptr_t playerPawn) { uintptr_t listEntrySecond; - ProcessMgr.ReadMemory(entityList + 0x8 * ((playerPawn & 0x7FFF) >> 9) + 16, listEntrySecond); + memoryManager.ReadMemory(entityList + 0x8 * ((playerPawn & 0x7FFF) >> 9) + 16, listEntrySecond); uintptr_t isPawn; - ProcessMgr.ReadMemory(listEntrySecond + 120 * (playerPawn & 0x1FF), isPawn); + memoryManager.ReadMemory(listEntrySecond + 120 * (playerPawn & 0x1FF), isPawn); return listEntrySecond == 0 ? 0 : isPawn; } @@ -49,26 +49,26 @@ namespace SpecList return; uintptr_t LocalPlayer; - ProcessMgr.ReadMemory(gGame.GetClientDLLAddress() + Offset.LocalPlayerController, LocalPlayer); + memoryManager.ReadMemory(gGame.GetClientDLLAddress() + Offset.LocalPlayerController, LocalPlayer); uintptr_t localPlayerPawn; - ProcessMgr.ReadMemory(LocalPlayer + Offset.PlayerController.m_hPawn, localPlayerPawn); + memoryManager.ReadMemory(LocalPlayer + Offset.PlayerController.m_hPawn, localPlayerPawn); uintptr_t CSlocalPlayerPawn; - ProcessMgr.ReadMemory(gGame.GetEntityListEntry() + 120 * (localPlayerPawn & 0x1FF), CSlocalPlayerPawn); + memoryManager.ReadMemory(gGame.GetEntityListEntry() + 120 * (localPlayerPawn & 0x1FF), CSlocalPlayerPawn); uint32_t spectatorPawn; - ProcessMgr.ReadMemory(Entity.Controller.Address + Offset.PlayerController.m_hPawn, spectatorPawn); + memoryManager.ReadMemory(Entity.Controller.Address + Offset.PlayerController.m_hPawn, spectatorPawn); uintptr_t entityList; - ProcessMgr.ReadMemory(gGame.GetEntityListAddress(),entityList); + memoryManager.ReadMemory(gGame.GetEntityListAddress(),entityList); uintptr_t pawn = getAddressBase(entityList, spectatorPawn); uintptr_t observed; - ProcessMgr.ReadMemory(pawn + Offset.PlayerController.m_pObserverServices, observed); + memoryManager.ReadMemory(pawn + Offset.PlayerController.m_pObserverServices, observed); uint64_t observedTarget; - ProcessMgr.ReadMemory(observed + Offset.PlayerController.m_hObserverTarget, observedTarget); + memoryManager.ReadMemory(observed + Offset.PlayerController.m_hObserverTarget, observedTarget); uintptr_t spectatorTarget = getAddressBase(entityList, observedTarget); diff --git a/DragonBurn/Features/TriggerBot.cpp b/DragonBurn/Features/TriggerBot.cpp index 61ad89a..caf9db4 100644 --- a/DragonBurn/Features/TriggerBot.cpp +++ b/DragonBurn/Features/TriggerBot.cpp @@ -15,20 +15,20 @@ void TriggerBot::Run(const CEntity& LocalEntity) if (LocalEntity.Controller.AliveStatus == 0) return; - if (!ProcessMgr.ReadMemory(LocalEntity.Pawn.Address + Offset.Pawn.m_bWaitForNoAttack, WaitForNoAttack)) + if (!memoryManager.ReadMemory(LocalEntity.Pawn.Address + Offset.Pawn.m_bWaitForNoAttack, WaitForNoAttack)) return; - if (!ProcessMgr.ReadMemory(LocalEntity.Pawn.Address + Offset.Pawn.iIDEntIndex, uHandle)) + if (!memoryManager.ReadMemory(LocalEntity.Pawn.Address + Offset.Pawn.iIDEntIndex, uHandle)) return; if (uHandle == -1) return; - ListEntry = ProcessMgr.TraceAddress(gGame.GetEntityListAddress(), { 0x8 * (uHandle >> 9) + 0x10,0x0 }); + ListEntry = memoryManager.TraceAddress(gGame.GetEntityListAddress(), { 0x8 * (uHandle >> 9) + 0x10,0x0 }); if (ListEntry == 0) return; - if (!ProcessMgr.ReadMemory(ListEntry + 0x78 * (uHandle & 0x1FF), PawnAddress)) + if (!memoryManager.ReadMemory(ListEntry + 0x78 * (uHandle & 0x1FF), PawnAddress)) return; if (!Entity.UpdatePawn(PawnAddress)) @@ -43,7 +43,7 @@ void TriggerBot::Run(const CEntity& LocalEntity) if (ScopeOnly) { bool isScoped; - ProcessMgr.ReadMemory(LocalEntity.Pawn.Address + Offset.Pawn.isScoped, isScoped); + memoryManager.ReadMemory(LocalEntity.Pawn.Address + Offset.Pawn.isScoped, isScoped); if (!isScoped and CheckScopeWeapon(LocalEntity)) { return; @@ -86,14 +86,14 @@ bool TriggerBot::CheckScopeWeapon(const CEntity& LocalEntity) DWORD64 WeaponNameAddress = 0; char Buffer[256]{}; - WeaponNameAddress = ProcessMgr.TraceAddress(LocalEntity.Pawn.Address + Offset.Pawn.pClippingWeapon, { 0x10,0x20 ,0x0 }); + WeaponNameAddress = memoryManager.TraceAddress(LocalEntity.Pawn.Address + Offset.Pawn.pClippingWeapon, { 0x10,0x20 ,0x0 }); if (WeaponNameAddress == 0) return false; DWORD64 CurrentWeapon; short weaponIndex; - ProcessMgr.ReadMemory(LocalEntity.Pawn.Address + Offset.Pawn.pClippingWeapon, CurrentWeapon); - ProcessMgr.ReadMemory(CurrentWeapon + Offset.EconEntity.AttributeManager + Offset.WeaponBaseData.Item + Offset.WeaponBaseData.ItemDefinitionIndex, weaponIndex); + memoryManager.ReadMemory(LocalEntity.Pawn.Address + Offset.Pawn.pClippingWeapon, CurrentWeapon); + memoryManager.ReadMemory(CurrentWeapon + Offset.EconEntity.AttributeManager + Offset.WeaponBaseData.Item + Offset.WeaponBaseData.ItemDefinitionIndex, weaponIndex); if (weaponIndex == -1) return false; @@ -110,14 +110,14 @@ bool TriggerBot::CheckWeapon(const CEntity& LocalEntity) DWORD64 WeaponNameAddress = 0; char Buffer[256]{}; - WeaponNameAddress = ProcessMgr.TraceAddress(LocalEntity.Pawn.Address + Offset.Pawn.pClippingWeapon, { 0x10,0x20 ,0x0 }); + WeaponNameAddress = memoryManager.TraceAddress(LocalEntity.Pawn.Address + Offset.Pawn.pClippingWeapon, { 0x10,0x20 ,0x0 }); if (WeaponNameAddress == 0) return false; DWORD64 CurrentWeapon; short weaponIndex; - ProcessMgr.ReadMemory(LocalEntity.Pawn.Address + Offset.Pawn.pClippingWeapon, CurrentWeapon); - ProcessMgr.ReadMemory(CurrentWeapon + Offset.EconEntity.AttributeManager + Offset.WeaponBaseData.Item + Offset.WeaponBaseData.ItemDefinitionIndex, weaponIndex); + memoryManager.ReadMemory(LocalEntity.Pawn.Address + Offset.Pawn.pClippingWeapon, CurrentWeapon); + memoryManager.ReadMemory(CurrentWeapon + Offset.EconEntity.AttributeManager + Offset.WeaponBaseData.Item + Offset.WeaponBaseData.ItemDefinitionIndex, weaponIndex); if (weaponIndex == -1) return false; @@ -130,7 +130,7 @@ bool TriggerBot::CheckWeapon(const CEntity& LocalEntity) } //void TriggerBot::TargetCheck(const CEntity& LocalEntity) noexcept { -// if (!ProcessMgr.ReadMemory(LocalEntity.Pawn.Address + Offset.Pawn.iIDEntIndex, uHandle) || uHandle == -1) { +// if (!memoryManager.ReadMemory(LocalEntity.Pawn.Address + Offset.Pawn.iIDEntIndex, uHandle) || uHandle == -1) { // //CrosshairsCFG::isAim = false; // return; // } @@ -138,7 +138,7 @@ bool TriggerBot::CheckWeapon(const CEntity& LocalEntity) // const unsigned long long ENTITY_OFFSET = 0x78; // const unsigned long long ENTITY_INDEX_MASK = 0x1FF; // -// DWORD64 ListEntry = ProcessMgr.TraceAddress(gGame.GetEntityListAddress(), { 0x8 * (uHandle >> 9) + 0x10, 0x0 }); +// DWORD64 ListEntry = memoryManager.TraceAddress(gGame.GetEntityListAddress(), { 0x8 * (uHandle >> 9) + 0x10, 0x0 }); // if (ListEntry == 0) { // //CrosshairsCFG::isAim = false; // return; @@ -146,7 +146,7 @@ bool TriggerBot::CheckWeapon(const CEntity& LocalEntity) // // DWORD64 PawnAddress; // const DWORD64 ENTITY_ADDRESS_OFFSET = ENTITY_OFFSET * (uHandle & ENTITY_INDEX_MASK); -// if (!ProcessMgr.ReadMemory(ListEntry + ENTITY_ADDRESS_OFFSET, PawnAddress)) { +// if (!memoryManager.ReadMemory(ListEntry + ENTITY_ADDRESS_OFFSET, PawnAddress)) { // //CrosshairsCFG::isAim = false; // return; // } diff --git a/DragonBurn/Game/Bone.cpp b/DragonBurn/Game/Bone.cpp index 98a6578..ea4a43c 100644 --- a/DragonBurn/Game/Bone.cpp +++ b/DragonBurn/Game/Bone.cpp @@ -8,16 +8,16 @@ bool CBone::UpdateAllBoneData(const DWORD64& EntityPawnAddress) { DWORD64 GameSceneNode = 0; DWORD64 BoneArrayAddress = 0; - if (!ProcessMgr.ReadMemory(EntityPawnAddress + Offset.Pawn.GameSceneNode, GameSceneNode)) { + if (!memoryManager.ReadMemory(EntityPawnAddress + Offset.Pawn.GameSceneNode, GameSceneNode)) { return false; } - if (!ProcessMgr.ReadMemory(GameSceneNode + Offset.Pawn.BoneArray, BoneArrayAddress)) { + if (!memoryManager.ReadMemory(GameSceneNode + Offset.Pawn.BoneArray, BoneArrayAddress)) { return false; } constexpr size_t NUM_BONES = 30; BoneJointData BoneArray[NUM_BONES]{}; - if (!ProcessMgr.ReadMemory(BoneArrayAddress, BoneArray, NUM_BONES * sizeof(BoneJointData))) { + if (!memoryManager.ReadMemory(BoneArrayAddress, BoneArray, NUM_BONES * sizeof(BoneJointData))) { return false; } diff --git a/DragonBurn/Game/Entity.cpp b/DragonBurn/Game/Entity.cpp index 25294e8..7484ecf 100644 --- a/DragonBurn/Game/Entity.cpp +++ b/DragonBurn/Game/Entity.cpp @@ -153,7 +153,7 @@ bool PlayerController::GetPlayerName() { char Buffer[MAX_PATH]{}; - if (!ProcessMgr.ReadMemory(Address + Offset.Entity.iszPlayerName, Buffer, MAX_PATH)) + if (!memoryManager.ReadMemory(Address + Offset.Entity.iszPlayerName, Buffer, MAX_PATH)) return false; //if (!this->SteamID) @@ -193,14 +193,14 @@ bool PlayerPawn::GetWeaponName() DWORD64 WeaponNameAddress = 0; char Buffer[256]{}; - WeaponNameAddress = ProcessMgr.TraceAddress(this->Address + Offset.Pawn.pClippingWeapon, { 0x10,0x20 ,0x0 }); + WeaponNameAddress = memoryManager.TraceAddress(this->Address + Offset.Pawn.pClippingWeapon, { 0x10,0x20 ,0x0 }); if (WeaponNameAddress == 0) return false; DWORD64 CurrentWeapon; short weaponIndex; - ProcessMgr.ReadMemory(this->Address + Offset.Pawn.pClippingWeapon, CurrentWeapon); - ProcessMgr.ReadMemory(CurrentWeapon + Offset.EconEntity.AttributeManager + Offset.WeaponBaseData.Item + Offset.WeaponBaseData.ItemDefinitionIndex, weaponIndex); + memoryManager.ReadMemory(this->Address + Offset.Pawn.pClippingWeapon, CurrentWeapon); + memoryManager.ReadMemory(CurrentWeapon + Offset.EconEntity.AttributeManager + Offset.WeaponBaseData.Item + Offset.WeaponBaseData.ItemDefinitionIndex, weaponIndex); if (weaponIndex == -1) return false; @@ -238,13 +238,13 @@ DWORD64 PlayerController::GetPlayerPawnAddress() if (!GetDataAddressWithOffset(Address, Offset.Entity.PlayerPawn, this->Pawn)) return 0; - if (!ProcessMgr.ReadMemory(gGame.GetEntityListAddress(), EntityPawnListEntry)) + if (!memoryManager.ReadMemory(gGame.GetEntityListAddress(), EntityPawnListEntry)) return 0; - if (!ProcessMgr.ReadMemory(EntityPawnListEntry + 0x10 + 8 * ((Pawn & 0x7FFF) >> 9), EntityPawnListEntry)) + if (!memoryManager.ReadMemory(EntityPawnListEntry + 0x10 + 8 * ((Pawn & 0x7FFF) >> 9), EntityPawnListEntry)) return 0; - if (!ProcessMgr.ReadMemory(EntityPawnListEntry + 0x78 * (Pawn & 0x1FF), EntityPawnAddress)) + if (!memoryManager.ReadMemory(EntityPawnListEntry + 0x78 * (Pawn & 0x1FF), EntityPawnAddress)) return 0; return EntityPawnAddress; @@ -268,7 +268,7 @@ bool PlayerPawn::GetArmor() bool PlayerPawn::GetAmmo() { DWORD64 ClippingWeapon = 0; - if (!ProcessMgr.ReadMemory(Address + Offset.Pawn.pClippingWeapon, ClippingWeapon)) + if (!memoryManager.ReadMemory(Address + Offset.Pawn.pClippingWeapon, ClippingWeapon)) return false; return GetDataAddressWithOffset(ClippingWeapon, Offset.WeaponBaseData.Clip1, this->Ammo); @@ -278,9 +278,9 @@ bool PlayerPawn::GetMaxAmmo() { DWORD64 ClippingWeapon = 0; DWORD64 WeaponData = 0; - if (!ProcessMgr.ReadMemory(Address + Offset.Pawn.pClippingWeapon, ClippingWeapon)) + if (!memoryManager.ReadMemory(Address + Offset.Pawn.pClippingWeapon, ClippingWeapon)) return false; - if (!ProcessMgr.ReadMemory(ClippingWeapon + Offset.WeaponBaseData.WeaponDataPTR, WeaponData)) + if (!memoryManager.ReadMemory(ClippingWeapon + Offset.WeaponBaseData.WeaponDataPTR, WeaponData)) return false; return GetDataAddressWithOffset(WeaponData, Offset.WeaponBaseData.MaxClip, this->MaxAmmo); @@ -289,7 +289,7 @@ bool PlayerPawn::GetMaxAmmo() bool PlayerPawn::GetFov() { DWORD64 CameraServices = 0; - if (!ProcessMgr.ReadMemory(Address + Offset.Pawn.CameraServices, CameraServices)) + if (!memoryManager.ReadMemory(Address + Offset.Pawn.CameraServices, CameraServices)) return false; return GetDataAddressWithOffset(CameraServices, Offset.Pawn.iFovStart, this->Fov); } @@ -301,18 +301,18 @@ bool PlayerPawn::GetFFlags() bool PlayerPawn::GetDefusing() { - return ProcessMgr.ReadMemory(Address + Offset.C4.m_bBeingDefused, this->isDefusing); + return memoryManager.ReadMemory(Address + Offset.C4.m_bBeingDefused, this->isDefusing); } bool PlayerPawn::GetFlashDuration() { - return ProcessMgr.ReadMemory(Address + Offset.Pawn.flFlashDuration, this->FlashDuration); + return memoryManager.ReadMemory(Address + Offset.Pawn.flFlashDuration, this->FlashDuration); } bool PlayerPawn::GetVelocity() { Vec3 Velocity; - if (!ProcessMgr.ReadMemory(Address + Offset.Pawn.AbsVelocity, Velocity)) + if (!memoryManager.ReadMemory(Address + Offset.Pawn.AbsVelocity, Velocity)) return false; this->Speed = sqrt(Velocity.x * Velocity.x + Velocity.y * Velocity.y); return true; @@ -339,8 +339,8 @@ bool Client::GetSensitivity() { DWORD64 dwSensitivity; float flSensitivity; - ProcessMgr.ReadMemory(gGame.GetClientDLLAddress() + Offset.Sensitivity, dwSensitivity); - if (ProcessMgr.ReadMemory(dwSensitivity + 0x40, flSensitivity)) + memoryManager.ReadMemory(gGame.GetClientDLLAddress() + Offset.Sensitivity, dwSensitivity); + if (memoryManager.ReadMemory(dwSensitivity + 0x40, flSensitivity)) { this->Sensitivity = flSensitivity; return true; diff --git a/DragonBurn/Game/Game.cpp b/DragonBurn/Game/Game.cpp index 494c8b5..26bc74c 100644 --- a/DragonBurn/Game/Game.cpp +++ b/DragonBurn/Game/Game.cpp @@ -2,8 +2,8 @@ bool CGame::InitAddress() { - this->Address.ClientDLL = reinterpret_cast(ProcessMgr.GetProcessModuleHandle("client.dll")); - this->Address.ServerDLL = reinterpret_cast(ProcessMgr.GetProcessModuleHandle("server.dll")); + this->Address.ClientDLL = MemoryMgr::GetModuleBase(MemoryMgr::GetProcessID(L"cs2.exe"),L"client.dll"); + this->Address.ServerDLL = MemoryMgr::GetModuleBase(MemoryMgr::GetProcessID(L"cs2.exe"),L"server.dll"); this->Address.EntityList = GetClientDLLAddress() + Offset.EntityList; this->Address.Matrix = GetClientDLLAddress() + Offset.Matrix; @@ -94,9 +94,9 @@ DWORD64 CGame::GetLeftBtnAddress() bool CGame::UpdateEntityListEntry() { DWORD64 EntityListEntry = 0; - if (!ProcessMgr.ReadMemory(gGame.GetEntityListAddress(), EntityListEntry)) + if (!memoryManager.ReadMemory(gGame.GetEntityListAddress(), EntityListEntry)) return false; - if (!ProcessMgr.ReadMemory(EntityListEntry + 0x10, EntityListEntry)) + if (!memoryManager.ReadMemory(EntityListEntry + 0x10, EntityListEntry)) return false; this->Address.EntityListEntry = EntityListEntry; @@ -106,14 +106,14 @@ bool CGame::UpdateEntityListEntry() //bool CGame::GetForceJump(int& value) //{ -// if (!ProcessMgr.ReadMemory(this->Address.ForceJump, value)) +// if (!memoryManager.ReadMemory(this->Address.ForceJump, value)) // return false; // // return true; //} //bool CGame::GetForceCrouch(int& value) //{ -// if (!ProcessMgr.ReadMemory(this->Address.ForceCrouch, value)) +// if (!memoryManager.ReadMemory(this->Address.ForceCrouch, value)) // return false; // // return true; @@ -124,13 +124,13 @@ bool CGame::UpdateEntityListEntry() // switch (MovingType) // { // case 0: -// if (!ProcessMgr.ReadMemory(this->Address.ForceForward, Value)) return false; +// if (!memoryManager.ReadMemory(this->Address.ForceForward, Value)) return false; // break; // case 1: -// if (!ProcessMgr.ReadMemory(this->Address.ForceLeft, Value)) return false; +// if (!memoryManager.ReadMemory(this->Address.ForceLeft, Value)) return false; // break; // case 2: -// if (!ProcessMgr.ReadMemory(this->Address.ForceRight, Value)) return false; +// if (!memoryManager.ReadMemory(this->Address.ForceRight, Value)) return false; // break; // default: // return false; diff --git a/DragonBurn/Game/Game.h b/DragonBurn/Game/Game.h index 2bfc7f1..5a0262d 100644 --- a/DragonBurn/Game/Game.h +++ b/DragonBurn/Game/Game.h @@ -1,6 +1,6 @@ #pragma once #include -#include "../Core/ProcessManager.hpp" +#include "../Core/MemoryMgr.h" #include "../Offsets/Offsets.h" #include "View.hpp" diff --git a/DragonBurn/Offsets/Offsets.h b/DragonBurn/Offsets/Offsets.h index 8534c59..cb7cffb 100644 --- a/DragonBurn/Offsets/Offsets.h +++ b/DragonBurn/Offsets/Offsets.h @@ -1,6 +1,6 @@ #pragma once #include -#include "../Core/ProcessManager.hpp" +#include "../Core/MemoryMgr.h" #include #include "../Helpers/WebApi.h" diff --git a/DragonBurn/main.cpp b/DragonBurn/main.cpp index 969909d..5566bf1 100644 --- a/DragonBurn/main.cpp +++ b/DragonBurn/main.cpp @@ -103,9 +103,22 @@ void Cheat() break; } + + Log::Info("Connecting to kernel mode driver"); + if (memoryManager.ConnectDriver(L"\\\\.\\DragonBurn_kernelmode")) + { + Log::PreviousLine(); + Log::Fine("Successfully connected to kernel mode driver"); + } + else + { + Log::PreviousLine(); + Log::Error("Failed to connect to kernel mode driver"); + } + std::cout << '\n'; bool preStart = false; - while (ProcessMgr.GetProcessID("cs2.exe") == 0) + while (MemoryMgr::GetProcessID(L"cs2.exe") == 0) { Log::PreviousLine(); Log::Info("Waiting for CS2"); @@ -151,26 +164,10 @@ void Cheat() } #endif - auto ProcessStatus = ProcessMgr.Attach("cs2.exe"); - switch (ProcessStatus) + if (!memoryManager.Attach(MemoryMgr::GetProcessID(L"cs2.exe"))) { - case 1: - Log::PreviousLine(); - Log::Error("Game not found"); - break; - - case 2: Log::PreviousLine(); - Log::Error("Failed to hook process, please run the cheat as Administrator"); - break; - - case 3: - Log::PreviousLine(); - Log::Error("Failed to get module address"); - break; - - default: - break; + Log::Error("Failed to attach to the process"); } if (!gGame.InitAddress())