Updated offsets to the latest game update and created offsets file for fast and easy update manually
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
#include "config.hpp"
|
||||
|
||||
namespace config {
|
||||
using json = nlohmann::json;
|
||||
const std::string file_path = "offsets.json";
|
||||
|
||||
bool file_exsits(const std::string& name) {
|
||||
std::ifstream f(name.c_str());
|
||||
return f.good();
|
||||
}
|
||||
|
||||
bool read() {
|
||||
if (!file_exsits(file_path)) {
|
||||
save();
|
||||
return false;
|
||||
}
|
||||
|
||||
std::ifstream f(file_path);
|
||||
|
||||
json data;
|
||||
try {
|
||||
data = json::parse(f);
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
save();
|
||||
}
|
||||
|
||||
if (data.empty())
|
||||
return false;
|
||||
|
||||
if (data["dwLocalPlayer"].is_number())
|
||||
dwLocalPlayer = data["dwLocalPlayer"];
|
||||
if (data["dwEntityList"].is_number())
|
||||
dwEntityList = data["dwEntityList"];
|
||||
if (data["dwViewMatrix"].is_number())
|
||||
dwViewMatrix = data["dwViewMatrix"];
|
||||
|
||||
if (data["dwPawnHealth"].is_number())
|
||||
dwPawnHealth = data["dwPawnHealth"];
|
||||
if (data["dwPlayerPawn"].is_number())
|
||||
dwPlayerPawn = data["dwPlayerPawn"];
|
||||
if (data["dwSanitizedName"].is_number())
|
||||
dwSanitizedName = data["dwSanitizedName"];
|
||||
if (data["m_iTeamNum"].is_number())
|
||||
m_iTeamNum = data["m_iTeamNum"];
|
||||
if (data["m_vecOrigin"].is_number())
|
||||
m_vecOrigin = data["m_vecOrigin"];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void save() {
|
||||
json data;
|
||||
|
||||
data["dwLocalPlayer"] = dwLocalPlayer;
|
||||
data["dwEntityList"] = dwEntityList;
|
||||
data["dwViewMatrix"] = dwViewMatrix;
|
||||
|
||||
data["dwPawnHealth"] = dwPawnHealth;
|
||||
data["dwPlayerPawn"] = dwPlayerPawn;
|
||||
data["dwSanitizedName"] = dwSanitizedName;
|
||||
data["m_iTeamNum"] = m_iTeamNum;
|
||||
data["m_vecOrigin"] = m_vecOrigin;
|
||||
|
||||
std::ofstream output(file_path);
|
||||
output << std::setw(4) << data << std::endl;
|
||||
output.close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
#include <fstream>
|
||||
#include "json.hpp"
|
||||
|
||||
namespace config {
|
||||
extern bool read();
|
||||
extern void save();
|
||||
|
||||
inline std::ptrdiff_t dwLocalPlayer = 0x1715418;
|
||||
inline std::ptrdiff_t dwEntityList = 0x1624C78;
|
||||
inline std::ptrdiff_t dwViewMatrix = 0x01715dc0;
|
||||
|
||||
inline std::ptrdiff_t dwPawnHealth = 0x808;
|
||||
inline std::ptrdiff_t dwPlayerPawn = 0x5dc;
|
||||
inline std::ptrdiff_t dwSanitizedName = 0x720;
|
||||
inline std::ptrdiff_t m_iTeamNum = 0x3bf;
|
||||
inline std::ptrdiff_t m_vecOrigin = 0x12AC;
|
||||
}
|
||||
@@ -5,5 +5,7 @@ namespace g {
|
||||
inline HDC hdcBuffer = NULL;
|
||||
inline HBITMAP hbmBuffer = NULL;
|
||||
|
||||
bool outdated_offsets = false;
|
||||
|
||||
RECT gameBounds;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,33 +2,23 @@
|
||||
#include "../memory/memory.hpp"
|
||||
#include "classes/globals.hpp"
|
||||
#include "../classes/render.hpp"
|
||||
|
||||
// last offset update 9/5/2023
|
||||
#define dwLocalPlayer 0x1675770
|
||||
#define dwEntityList 0x167ABA8
|
||||
#define dwViewMatrix 0x1714C70
|
||||
|
||||
#define dwPawnHealth 0x808
|
||||
#define dwPlayerPawn 0x5dc
|
||||
#define dwSanitizedName 0x720
|
||||
#define m_iTeamNum 0x3bf
|
||||
#define m_vecOrigin 0x12AC
|
||||
#include "../classes/config.hpp"
|
||||
|
||||
namespace hack {
|
||||
std::shared_ptr<pProcess> process;
|
||||
ProcessModule base_module;
|
||||
|
||||
void loop() {
|
||||
uintptr_t localPlayer = process->read<uintptr_t>(base_module.base + dwLocalPlayer);
|
||||
uintptr_t localPlayer = process->read<uintptr_t>(base_module.base + config::dwLocalPlayer);
|
||||
if (!localPlayer) return;
|
||||
|
||||
int localTeam = process->read<int>(localPlayer + m_iTeamNum);
|
||||
int localTeam = process->read<int>(localPlayer + config::m_iTeamNum);
|
||||
|
||||
view_matrix_t view_matrix = process->read<view_matrix_t>(base_module.base + dwViewMatrix);
|
||||
view_matrix_t view_matrix = process->read<view_matrix_t>(base_module.base + config::dwViewMatrix);
|
||||
|
||||
Vector3 localOrigin = process->read<Vector3>(localPlayer + m_vecOrigin);
|
||||
Vector3 localOrigin = process->read<Vector3>(localPlayer + config::m_vecOrigin);
|
||||
|
||||
uintptr_t entity_list = process->read<uintptr_t>(base_module.base + dwEntityList);
|
||||
uintptr_t entity_list = process->read<uintptr_t>(base_module.base + config::dwEntityList);
|
||||
|
||||
for (int i = 1; i < 32; i++) {
|
||||
uintptr_t list_entry = process->read<uintptr_t>(entity_list + (8 * (i & 0x7FFF) >> 9) + 16);
|
||||
@@ -37,11 +27,11 @@ namespace hack {
|
||||
|
||||
if (!player) continue;
|
||||
|
||||
int playerHealth = process->read<int>(player + dwPawnHealth);
|
||||
int playerHealth = process->read<int>(player + config::dwPawnHealth);
|
||||
if (playerHealth <= 0 || playerHealth > 100) continue;
|
||||
|
||||
// https://github.com/UnnamedZ03/CS2-external-base/blob/main/source/CSSPlayer.hpp#L132
|
||||
std::uint32_t playerpawn = process->read<std::uint32_t>(player + dwPlayerPawn);
|
||||
std::uint32_t playerpawn = process->read<std::uint32_t>(player + config::dwPlayerPawn);
|
||||
|
||||
uintptr_t list_entry2 = process->read<uintptr_t>(entity_list + 0x8 * ((playerpawn & 0x7FFF) >> 9) + 16);
|
||||
if (!list_entry2) continue;
|
||||
@@ -49,10 +39,10 @@ namespace hack {
|
||||
|
||||
if (pCSPlayerPawn == localPlayer) continue;
|
||||
|
||||
int playerTeam = process->read<int>(player + m_iTeamNum);
|
||||
int playerTeam = process->read<int>(player + config::m_iTeamNum);
|
||||
|
||||
std::string playerName = "Invalid Name";
|
||||
DWORD64 playerNameAddress = process->read<DWORD64>(player + dwSanitizedName);
|
||||
DWORD64 playerNameAddress = process->read<DWORD64>(player + config::dwSanitizedName);
|
||||
if (playerNameAddress) {
|
||||
char buf[256];
|
||||
process->read_raw(playerNameAddress, buf, sizeof(buf));
|
||||
@@ -60,7 +50,7 @@ namespace hack {
|
||||
}
|
||||
|
||||
// https://github.com/UnnamedZ03/CS2-external-base/blob/main/source/CSSPlayer.hpp#L132
|
||||
Vector3 origin = process->read<Vector3>(pCSPlayerPawn + m_vecOrigin);
|
||||
Vector3 origin = process->read<Vector3>(pCSPlayerPawn + config::m_vecOrigin);
|
||||
|
||||
//if ((localOrigin - origin).length2d() > 1000) return;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
SetLayeredWindowAttributes(hWnd, RGB(255, 255, 255), 0, LWA_COLORKEY);
|
||||
|
||||
std::cout << "[overlay] Window created successfully" << std::endl;
|
||||
Beep(500, 100);
|
||||
break;
|
||||
}
|
||||
case WM_ERASEBKGND: // We handle this message to avoid flickering
|
||||
@@ -72,6 +73,13 @@ int main() {
|
||||
|
||||
std::cout << "[cs2] Attached to cs2.exe" << std::endl;
|
||||
|
||||
std::cout << "[config] Reading offsets from configuration." << std::endl;
|
||||
if (config::read())
|
||||
std::cout << "[config] Sucessfully read offsets file" << std::endl;
|
||||
else
|
||||
std::cout << "[config] Error reading offsets file, reseting to the default state" << std::endl;
|
||||
|
||||
|
||||
do {
|
||||
hack::base_module = hack::process->GetModule("client.dll");
|
||||
if (hack::base_module.base == 0) {
|
||||
@@ -115,12 +123,25 @@ int main() {
|
||||
|
||||
// Message loop
|
||||
MSG msg;
|
||||
while (!(GetAsyncKeyState(VK_END) & 0x8000) && GetMessage(&msg, NULL, 0, 0))
|
||||
while (GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
|
||||
if (GetAsyncKeyState(VK_END) & 0x8000) break;
|
||||
|
||||
if (g::outdated_offsets) {
|
||||
std::cout << "[cs2] EntityList was null. this might be because cs2 has been updated" << std::endl;
|
||||
std::cout << "[cs2] Consider updating offsets manually in the file offsets.json" << std::endl;
|
||||
std::cout << "[cs2] You can find the latest offsets by the comunity in: https://www.unknowncheats.me/forum/counter-strike-2-a/576077-counter-strike-2-reversal-structs-offsets.html" << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
|
||||
Beep(700, 100); Beep(700, 100);
|
||||
|
||||
std::cout << "[overlay] Destroying overlay window." << std::endl;
|
||||
DeleteDC(g::hdcBuffer);
|
||||
DeleteObject(g::hbmBuffer);
|
||||
|
||||
@@ -138,11 +138,14 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="classes\config.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="memory\memory.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="classes\config.hpp" />
|
||||
<ClInclude Include="classes\globals.hpp" />
|
||||
<ClInclude Include="classes\json.hpp" />
|
||||
<ClInclude Include="classes\render.hpp" />
|
||||
<ClInclude Include="classes\vector.hpp" />
|
||||
<ClInclude Include="hacks\hack.hpp" />
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
<ClCompile Include="memory\memory.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="classes\config.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="memory\memory.hpp">
|
||||
@@ -38,5 +41,11 @@
|
||||
<ClInclude Include="classes\render.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="classes\json.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="classes\config.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user