use native api instead of standard winapi
fix update_offsets.py add multiprocessor compilations change linking method
This commit is contained in:
@@ -177,12 +177,14 @@
|
|||||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>gdiplus.lib;wininet.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>gdiplus.lib;wininet.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
@@ -195,12 +197,14 @@
|
|||||||
<PreprocessorDefinitions>NDEBUG;_UC;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NDEBUG;_UC;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>gdiplus.lib;wininet.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>gdiplus.lib;wininet.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
|||||||
@@ -9,6 +9,21 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <Psapi.h>
|
#include <Psapi.h>
|
||||||
|
|
||||||
|
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
|
struct ProcessModule
|
||||||
{
|
{
|
||||||
uintptr_t base, size;
|
uintptr_t base, size;
|
||||||
@@ -50,7 +65,9 @@ public:
|
|||||||
bool read_raw(uintptr_t address, void* buffer, size_t size)
|
bool read_raw(uintptr_t address, void* buffer, size_t size)
|
||||||
{
|
{
|
||||||
SIZE_T bytesRead;
|
SIZE_T bytesRead;
|
||||||
if (ReadProcessMemory(this->handle_, reinterpret_cast<LPCVOID>(address), buffer, size, &bytesRead))
|
pMemory cMemory;
|
||||||
|
|
||||||
|
if (cMemory.pfnNtReadVirtualMemory(this->handle_, (PVOID)(address), buffer, static_cast<ULONG>(size), (PULONG)&bytesRead))
|
||||||
{
|
{
|
||||||
return bytesRead == size;
|
return bytesRead == size;
|
||||||
}
|
}
|
||||||
@@ -60,20 +77,24 @@ public:
|
|||||||
template<class T>
|
template<class T>
|
||||||
void write(uintptr_t address, T value)
|
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<class T>
|
template<class T>
|
||||||
T read(uintptr_t address)
|
T read(uintptr_t address)
|
||||||
{
|
{
|
||||||
T buffer{};
|
T buffer{};
|
||||||
ReadProcessMemory(handle_, (void*)address, &buffer, sizeof(T), 0);
|
pMemory cMemory;
|
||||||
|
|
||||||
|
cMemory.pfnNtReadVirtualMemory(handle_, (void*)address, &buffer, sizeof(T), 0);
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_bytes(uintptr_t addr, std::vector<uint8_t> patch)
|
void write_bytes(uintptr_t addr, std::vector<uint8_t> 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<uintptr_t> offsets)
|
uintptr_t read_multi_address(uintptr_t ptr, std::vector<uintptr_t> offsets)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import re
|
|||||||
|
|
||||||
source_url = "https://github.com/a2x/cs2-dumper/raw/main/generated/offsets.json"
|
source_url = "https://github.com/a2x/cs2-dumper/raw/main/generated/offsets.json"
|
||||||
commits_url = "https://api.github.com/repos/a2x/cs2-dumper/commits"
|
commits_url = "https://api.github.com/repos/a2x/cs2-dumper/commits"
|
||||||
dest_path = "./offsets/offsets.json"
|
dest_path = "./offsets.json"
|
||||||
|
|
||||||
# Fetch the source JSON
|
# Fetch the source JSON
|
||||||
source_response = requests.get(source_url)
|
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["build_number"] = int(build_number)
|
||||||
|
|
||||||
dest_data["dwBuildNumber"] = source_data["Engine2Dll"]["data"]["dwBuildNumber"]["value"]
|
dest_data["dwBuildNumber"] = source_data["engine_2dll"]["data"]["dwBuildNumber"]["value"]
|
||||||
dest_data["dwLocalPlayer"] = source_data["ClientDll"]["data"]["dwLocalPlayerPawn"]["value"]
|
dest_data["dwLocalPlayer"] = source_data["client_dll"]["data"]["dwLocalPlayerPawn"]["value"]
|
||||||
dest_data["dwEntityList"] = source_data["ClientDll"]["data"]["dwEntityList"]["value"]
|
dest_data["dwEntityList"] = source_data["client_dll"]["data"]["dwEntityList"]["value"]
|
||||||
dest_data["dwViewMatrix"] = source_data["ClientDll"]["data"]["dwViewMatrix"]["value"]
|
dest_data["dwViewMatrix"] = source_data["client_dll"]["data"]["dwViewMatrix"]["value"]
|
||||||
|
|
||||||
with open(dest_path, 'w') as dest_file:
|
with open(dest_path, 'w') as dest_file:
|
||||||
json.dump(dest_data, dest_file, indent=4)
|
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
|
||||||
Reference in New Issue
Block a user