From d6a0398a284db9d1712e95314302167ecb02624c Mon Sep 17 00:00:00 2001 From: notcpuid Date: Thu, 2 Nov 2023 15:10:30 +0300 Subject: [PATCH 1/6] use native api instead of standard winapi fix update_offsets.py add multiprocessor compilations change linking method --- memory-external/memory-external.vcxproj | 8 +++++-- memory-external/memory/memory.hpp | 29 +++++++++++++++++++++---- offsets/update_offsets.py | 12 +++++----- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/memory-external/memory-external.vcxproj b/memory-external/memory-external.vcxproj index 9f314e2..7aeb126 100644 --- a/memory-external/memory-external.vcxproj +++ b/memory-external/memory-external.vcxproj @@ -177,12 +177,14 @@ NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true stdcpp20 + true + MultiThreaded Console true true - true + false gdiplus.lib;wininet.lib;%(AdditionalDependencies) @@ -195,12 +197,14 @@ NDEBUG;_UC;_CONSOLE;%(PreprocessorDefinitions) true stdcpp20 + MultiThreaded + true Console true true - true + false gdiplus.lib;wininet.lib;%(AdditionalDependencies) diff --git a/memory-external/memory/memory.hpp b/memory-external/memory/memory.hpp index baf8bd0..8704b50 100644 --- a/memory-external/memory/memory.hpp +++ b/memory-external/memory/memory.hpp @@ -9,6 +9,21 @@ #include #include +typedef NTSTATUS(WINAPI* pNtReadVirtualMemory)(HANDLE ProcessHandle, PVOID BaseAddress, PVOID Buffer, ULONG NumberOfBytesToRead, PULONG NumberOfBytesRead); +typedef NTSTATUS(WINAPI* pNtWriteVirtualMemory)(HANDLE ProcessHandle, PVOID BaseAddress, PVOID Buffer, ULONG NumberOfBytesToWrite, PULONG NumberOfBytesWritten); + +class pMemory { + +public: + pMemory() { + pfnNtReadVirtualMemory = (pNtReadVirtualMemory)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtReadVirtualMemory"); + pfnNtWriteVirtualMemory = (pNtWriteVirtualMemory)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtWriteVirtualMemory"); + } + + pNtReadVirtualMemory pfnNtReadVirtualMemory; + pNtWriteVirtualMemory pfnNtWriteVirtualMemory; +}; + struct ProcessModule { uintptr_t base, size; @@ -50,7 +65,9 @@ public: bool read_raw(uintptr_t address, void* buffer, size_t size) { SIZE_T bytesRead; - if (ReadProcessMemory(this->handle_, reinterpret_cast(address), buffer, size, &bytesRead)) + pMemory cMemory; + + if (cMemory.pfnNtReadVirtualMemory(this->handle_, (PVOID)(address), buffer, static_cast(size), (PULONG)&bytesRead)) { return bytesRead == size; } @@ -60,20 +77,24 @@ public: template void write(uintptr_t address, T value) { - WriteProcessMemory(handle_, (void*)address, &value, sizeof(T), 0); + pMemory cMemory; + cMemory.pfnNtWriteVirtualMemory(handle_, (void*)address, &value, sizeof(T), 0); } template T read(uintptr_t address) { T buffer{}; - ReadProcessMemory(handle_, (void*)address, &buffer, sizeof(T), 0); + pMemory cMemory; + + cMemory.pfnNtReadVirtualMemory(handle_, (void*)address, &buffer, sizeof(T), 0); return buffer; } void write_bytes(uintptr_t addr, std::vector patch) { - WriteProcessMemory(handle_, (void*)addr, &patch[0], patch.size(), 0); + pMemory cMemory; + cMemory.pfnNtWriteVirtualMemory(handle_, (void*)addr, &patch[0], patch.size(), 0); } uintptr_t read_multi_address(uintptr_t ptr, std::vector offsets) diff --git a/offsets/update_offsets.py b/offsets/update_offsets.py index 568d86b..3338983 100644 --- a/offsets/update_offsets.py +++ b/offsets/update_offsets.py @@ -5,7 +5,7 @@ import re source_url = "https://github.com/a2x/cs2-dumper/raw/main/generated/offsets.json" commits_url = "https://api.github.com/repos/a2x/cs2-dumper/commits" -dest_path = "./offsets/offsets.json" +dest_path = "./offsets.json" # Fetch the source JSON source_response = requests.get(source_url) @@ -33,12 +33,12 @@ if dest_data["build_number"] == int(build_number): dest_data["build_number"] = int(build_number) -dest_data["dwBuildNumber"] = source_data["Engine2Dll"]["data"]["dwBuildNumber"]["value"] -dest_data["dwLocalPlayer"] = source_data["ClientDll"]["data"]["dwLocalPlayerPawn"]["value"] -dest_data["dwEntityList"] = source_data["ClientDll"]["data"]["dwEntityList"]["value"] -dest_data["dwViewMatrix"] = source_data["ClientDll"]["data"]["dwViewMatrix"]["value"] +dest_data["dwBuildNumber"] = source_data["engine_2dll"]["data"]["dwBuildNumber"]["value"] +dest_data["dwLocalPlayer"] = source_data["client_dll"]["data"]["dwLocalPlayerPawn"]["value"] +dest_data["dwEntityList"] = source_data["client_dll"]["data"]["dwEntityList"]["value"] +dest_data["dwViewMatrix"] = source_data["client_dll"]["data"]["dwViewMatrix"]["value"] with open(dest_path, 'w') as dest_file: json.dump(dest_data, dest_file, indent=4) -print("Offsets updated in the local file.") # We dont exit so we know that the game has been updated and that we have to commit the new offsets +print("Offsets updated in the local file.") # We dont exit so we know that the game has been updated and that we have to commit the new offsets \ No newline at end of file From 7af463814eca9b79b272a1143a235ebb16969da3 Mon Sep 17 00:00:00 2001 From: Budd Dwyer <62247530+BuddDwyer-0x00@users.noreply.github.com> Date: Fri, 3 Nov 2023 17:20:52 +0200 Subject: [PATCH 2/6] Update offsets.json --- offsets/offsets.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/offsets/offsets.json b/offsets/offsets.json index b4c5268..b7c7239 100644 --- a/offsets/offsets.json +++ b/offsets/offsets.json @@ -1,10 +1,10 @@ { "build_number": 13965, - "dwLocalPlayer": 25067864, - "dwEntityList": 24745408, - "dwViewMatrix": 25720624, - "dwBuildNumber": 4748564, - "dwPlantedC4": 25739232, + "dwLocalPlayer": 25140232, + "dwEntityList": 24815848, + "dwViewMatrix": 25792624, + "dwBuildNumber": 4752660, + "dwPlantedC4": 25811704, "m_flC4Blow": 3760, "m_flNextBeep": 3756, "m_flTimerLength": 3768, @@ -12,14 +12,14 @@ "m_iAccount": 64, "m_vecAbsOrigin": 200, "m_pGameSceneNode": 784, - "m_flFlashOverlayAlpha": 5188, - "m_bIsDefusing": 5008, + "m_flFlashOverlayAlpha": 5204, + "m_bIsDefusing": 5024, "m_szName": 3096, - "m_pClippingWeapon": 4752, - "m_ArmorValue": 5360, + "m_pClippingWeapon": 4768, + "m_ArmorValue": 5376, "m_iHealth": 812, "m_hPlayerPawn": 1980, "m_sSanitizedPlayerName": 1824, "m_iTeamNum": 959, - "m_vecOrigin": 4628 -} \ No newline at end of file + "m_vecOrigin": 4644 +} From 23380778868f01af9771fb8aa3d441ea1163bf6d Mon Sep 17 00:00:00 2001 From: IMXNOOBX <69653071+IMXNOOBX@users.noreply.github.com> Date: Sat, 4 Nov 2023 12:05:10 +0100 Subject: [PATCH 3/6] Update update_offsets.py Fixed an issue introduced by the last pull request --- offsets/update_offsets.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/offsets/update_offsets.py b/offsets/update_offsets.py index 3338983..e31722f 100644 --- a/offsets/update_offsets.py +++ b/offsets/update_offsets.py @@ -5,7 +5,7 @@ import re source_url = "https://github.com/a2x/cs2-dumper/raw/main/generated/offsets.json" commits_url = "https://api.github.com/repos/a2x/cs2-dumper/commits" -dest_path = "./offsets.json" +dest_path = "./offsets/offsets.json" # Fetch the source JSON source_response = requests.get(source_url) @@ -41,4 +41,4 @@ dest_data["dwViewMatrix"] = source_data["client_dll"]["data"]["dwViewMatrix"]["v with open(dest_path, 'w') as dest_file: json.dump(dest_data, dest_file, indent=4) -print("Offsets updated in the local file.") # We dont exit so we know that the game has been updated and that we have to commit the new offsets \ No newline at end of file +print("Offsets updated in the local file.") # We dont exit so we know that the game has been updated and that we have to commit the new offsets From 8c87d10f8dd282c9dd1160d0acb31c8c5f4820b6 Mon Sep 17 00:00:00 2001 From: IMXNOOBX <69653071+IMXNOOBX@users.noreply.github.com> Date: Sat, 4 Nov 2023 21:44:58 +0100 Subject: [PATCH 4/6] Update update_offsets.py --- offsets/update_offsets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/offsets/update_offsets.py b/offsets/update_offsets.py index e31722f..91baf31 100644 --- a/offsets/update_offsets.py +++ b/offsets/update_offsets.py @@ -33,7 +33,7 @@ if dest_data["build_number"] == int(build_number): dest_data["build_number"] = int(build_number) -dest_data["dwBuildNumber"] = source_data["engine_2dll"]["data"]["dwBuildNumber"]["value"] +dest_data["dwBuildNumber"] = source_data["engine2_dll"]["data"]["dwBuildNumber"]["value"] dest_data["dwLocalPlayer"] = source_data["client_dll"]["data"]["dwLocalPlayerPawn"]["value"] dest_data["dwEntityList"] = source_data["client_dll"]["data"]["dwEntityList"]["value"] dest_data["dwViewMatrix"] = source_data["client_dll"]["data"]["dwViewMatrix"]["value"] From 51180a1ba1e9de9863af2b6adde8d5703661e1e9 Mon Sep 17 00:00:00 2001 From: ifBars <114284668+ifBars@users.noreply.github.com> Date: Sat, 4 Nov 2023 14:47:21 -0600 Subject: [PATCH 5/6] Update offsets.json to game build 13967 --- offsets/offsets.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/offsets/offsets.json b/offsets/offsets.json index b7c7239..f3f7d1b 100644 --- a/offsets/offsets.json +++ b/offsets/offsets.json @@ -1,10 +1,10 @@ { - "build_number": 13965, - "dwLocalPlayer": 25140232, - "dwEntityList": 24815848, - "dwViewMatrix": 25792624, + "build_number": 13967, + "dwLocalPlayer": 25144424, + "dwEntityList": 24820056, + "dwViewMatrix": 25206992, "dwBuildNumber": 4752660, - "dwPlantedC4": 25811704, + "dwPlantedC4": 25226056, "m_flC4Blow": 3760, "m_flNextBeep": 3756, "m_flTimerLength": 3768, @@ -12,11 +12,11 @@ "m_iAccount": 64, "m_vecAbsOrigin": 200, "m_pGameSceneNode": 784, - "m_flFlashOverlayAlpha": 5204, - "m_bIsDefusing": 5024, + "m_flFlashOverlayAlpha": 5212, + "m_bIsDefusing": 5032, "m_szName": 3096, - "m_pClippingWeapon": 4768, - "m_ArmorValue": 5376, + "m_pClippingWeapon": 4776, + "m_ArmorValue": 5384, "m_iHealth": 812, "m_hPlayerPawn": 1980, "m_sSanitizedPlayerName": 1824, From 9f20221872dd5795a76453302ca91c5eb609d975 Mon Sep 17 00:00:00 2001 From: ifBars <114284668+ifBars@users.noreply.github.com> Date: Sat, 4 Nov 2023 15:02:28 -0600 Subject: [PATCH 6/6] Update auto_updater.cpp - Fix armor not updating correctly --- memory-external/classes/auto_updater.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/memory-external/classes/auto_updater.cpp b/memory-external/classes/auto_updater.cpp index 2578589..36542ca 100644 --- a/memory-external/classes/auto_updater.cpp +++ b/memory-external/classes/auto_updater.cpp @@ -219,10 +219,10 @@ namespace updater { offsets::m_bIsDefusing = data["m_bIsDefusing"]; if (data["m_szName"].is_number()) offsets::m_szName = data["m_szName"]; - if (data["m_pClippingWeapon "].is_number()) - offsets::m_pClippingWeapon = data["m_pClippingWeapon "]; - if (data["m_ArmorValue "].is_number()) - offsets::m_ArmorValue = data["m_ArmorValue "]; + if (data["m_pClippingWeapon"].is_number()) + offsets::m_pClippingWeapon = data["m_pClippingWeapon"]; + if (data["m_ArmorValue"].is_number()) + offsets::m_ArmorValue = data["m_ArmorValue"]; if (data["m_iHealth"].is_number()) offsets::m_iHealth = data["m_iHealth"]; if (data["m_hPlayerPawn"].is_number())