Added an auto updater, and updated to the latest game version
This commit is contained in:
@@ -3,7 +3,9 @@
|
|||||||
##
|
##
|
||||||
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||||
|
|
||||||
|
# Ignore all the offsets.json files but the one in the folder offsets for the auto updater
|
||||||
offsets.json
|
offsets.json
|
||||||
|
!offsets/offsets.json
|
||||||
|
|
||||||
# User-specific files
|
# User-specific files
|
||||||
*.rsuser
|
*.rsuser
|
||||||
|
|||||||
@@ -0,0 +1,132 @@
|
|||||||
|
#include "auto_updater.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace updater {
|
||||||
|
bool check_and_update(bool prompt_update) {
|
||||||
|
json commit;
|
||||||
|
if (!get_last_commit_date(commit)) {
|
||||||
|
std::cout << "[updater] error getting last commit information from github" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string last_commit_date = commit["date"];
|
||||||
|
std::string last_commit_author_name = commit["name"];
|
||||||
|
|
||||||
|
std::cout << "[updater] Last github repository update was made by " << last_commit_author_name << " the " << last_commit_date << std::endl;
|
||||||
|
|
||||||
|
// Parse the GitHub date string and convert it to a std::tm structure
|
||||||
|
std::tm commit_date = {};
|
||||||
|
std::istringstream(last_commit_date) >> std::get_time(&commit_date, "%Y-%m-%dT%H:%M:%SZ");
|
||||||
|
|
||||||
|
auto currentTime = std::chrono::system_clock::now();
|
||||||
|
|
||||||
|
std::chrono::seconds diff = std::chrono::duration_cast<std::chrono::seconds>(currentTime - std::chrono::system_clock::from_time_t(std::mktime(&commit_date)));
|
||||||
|
|
||||||
|
// Prompt the user if he wants to update the offsets.json if there was a commit in the last 5 days
|
||||||
|
if (diff.count() <= (5 * 24 * 3600)) {
|
||||||
|
std::cout << "[updater] There has been an update in the repository in the last 5 days!" << std::endl;
|
||||||
|
if (prompt_update)
|
||||||
|
std::cout << "[updater] Do you want to download the latest offsets? (y/n): ";
|
||||||
|
|
||||||
|
char response;
|
||||||
|
std::cin >> response;
|
||||||
|
|
||||||
|
if (!prompt_update || (response == 'Y' || response == 'y')) {
|
||||||
|
if (download_file(raw_updated_offets.c_str(), "offsets.json")) {
|
||||||
|
std::cout << "[updater] Successfully downloaded latest offsets.json file\n" << std::endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
std::cout << "[updater] Error failed to download file, try downloading manually from " << raw_updated_offets << "\n" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool get_last_commit_date(json& commit) {
|
||||||
|
HINTERNET hInternet, hConnect;
|
||||||
|
|
||||||
|
hInternet = InternetOpen("AutoUpdater", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
|
||||||
|
if (!hInternet) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
hConnect = InternetOpenUrlA(hInternet, github_repo_api.c_str(), NULL, 0, INTERNET_FLAG_RELOAD, 0);
|
||||||
|
if (!hConnect) {
|
||||||
|
InternetCloseHandle(hInternet);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
char buffer[4096];
|
||||||
|
DWORD bytesRead;
|
||||||
|
std::string commitData;
|
||||||
|
|
||||||
|
while (InternetReadFile(hConnect, buffer, sizeof(buffer), &bytesRead) && bytesRead > 0) {
|
||||||
|
commitData.append(buffer, bytesRead);
|
||||||
|
}
|
||||||
|
|
||||||
|
json data;
|
||||||
|
try {
|
||||||
|
data = json::parse(commitData);
|
||||||
|
}
|
||||||
|
catch (const std::exception& e) {
|
||||||
|
std::cout << "[updater] exception while parsing json response from github" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (data.is_array()) {
|
||||||
|
json last_commit = data[0];
|
||||||
|
json last_commit_author = last_commit["commit"]["author"];
|
||||||
|
|
||||||
|
commit = last_commit_author;
|
||||||
|
}
|
||||||
|
|
||||||
|
InternetCloseHandle(hConnect);
|
||||||
|
InternetCloseHandle(hInternet);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool download_file(const char* url, const char* localPath) {
|
||||||
|
HINTERNET hInternet, hConnect;
|
||||||
|
|
||||||
|
hInternet = InternetOpen("AutoUpdater", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
|
||||||
|
if (!hInternet) {
|
||||||
|
std::cerr << "InternetOpen failed." << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
hConnect = InternetOpenUrlA(hInternet, url, NULL, 0, INTERNET_FLAG_RELOAD, 0);
|
||||||
|
if (!hConnect) {
|
||||||
|
std::cerr << "InternetOpenUrlA failed." << std::endl;
|
||||||
|
InternetCloseHandle(hInternet);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ofstream outFile(localPath, std::ios::binary);
|
||||||
|
if (!outFile) {
|
||||||
|
std::cerr << "Failed to create local file." << std::endl;
|
||||||
|
InternetCloseHandle(hConnect);
|
||||||
|
InternetCloseHandle(hInternet);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
char buffer[4096];
|
||||||
|
DWORD bytesRead;
|
||||||
|
|
||||||
|
while (InternetReadFile(hConnect, buffer, sizeof(buffer), &bytesRead) && bytesRead > 0) {
|
||||||
|
outFile.write(buffer, bytesRead);
|
||||||
|
}
|
||||||
|
|
||||||
|
outFile.close();
|
||||||
|
InternetCloseHandle(hConnect);
|
||||||
|
InternetCloseHandle(hInternet);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <WinINet.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <ctime>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <sstream>
|
||||||
|
#include <filesystem>
|
||||||
|
#include "json.hpp"
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
|
||||||
|
namespace updater {
|
||||||
|
|
||||||
|
bool check_and_update(bool prompt_update);
|
||||||
|
bool get_last_commit_date(json& commit);
|
||||||
|
bool download_file(const char* url, const char* localPath);
|
||||||
|
|
||||||
|
inline std::string github_repo_api = "https://api.github.com/repos/IMXNOOBX/cs2-external-esp/commits";
|
||||||
|
inline std::string raw_updated_offets = "https://github.com/IMXNOOBX/cs2-external-esp/raw/main/offsets/offsets.json";
|
||||||
|
}
|
||||||
@@ -6,13 +6,13 @@ namespace config {
|
|||||||
extern bool read();
|
extern bool read();
|
||||||
extern void save();
|
extern void save();
|
||||||
|
|
||||||
inline std::ptrdiff_t dwLocalPlayer = 0x17153E8;
|
inline std::ptrdiff_t dwLocalPlayer = 0x17DB108;
|
||||||
inline std::ptrdiff_t dwEntityList = 0x167BCC8;
|
inline std::ptrdiff_t dwEntityList = 0x178C888;
|
||||||
inline std::ptrdiff_t dwViewMatrix = 0x1715D90;
|
inline std::ptrdiff_t dwViewMatrix = 0x187A6E0;
|
||||||
|
|
||||||
inline std::ptrdiff_t dwPawnHealth = 0x808;
|
inline std::ptrdiff_t dwPawnHealth = 0x808;
|
||||||
inline std::ptrdiff_t dwPlayerPawn = 0x5dc;
|
inline std::ptrdiff_t dwPlayerPawn = 0x7FC;
|
||||||
inline std::ptrdiff_t dwSanitizedName = 0x720;
|
inline std::ptrdiff_t dwSanitizedName = 0x720;
|
||||||
inline std::ptrdiff_t m_iTeamNum = 0x3bf;
|
inline std::ptrdiff_t m_iTeamNum = 0x3bf;
|
||||||
inline std::ptrdiff_t m_vecOrigin = 0x12AC;
|
inline std::ptrdiff_t m_vecOrigin = 0x1204;
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "hacks/hack.hpp"
|
#include "hacks/hack.hpp"
|
||||||
#include "classes/globals.hpp"
|
#include "classes/globals.hpp"
|
||||||
#include "classes/render.hpp"
|
#include "classes/render.hpp"
|
||||||
|
#include "classes/auto_updater.hpp"
|
||||||
|
|
||||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
@@ -63,24 +64,27 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
SetConsoleTitle("cs2-external-esp");
|
SetConsoleTitle("cs2-external-esp");
|
||||||
|
std::cout << "[info] Github Repository: https://github.com/IMXNOOBX/cs2-external-esp" << std::endl;
|
||||||
|
std::cout << "[info] Unknowncheats thread: https://www.unknowncheats.me/forum/counter-strike-2-releases/600259-cs2-external-esp.html\n" << std::endl;
|
||||||
|
|
||||||
hack::process = std::make_shared<pProcess>();
|
hack::process = std::make_shared<pProcess>();
|
||||||
|
|
||||||
|
updater::check_and_update(true);
|
||||||
|
|
||||||
std::cout << "[cs2] Waiting for cs2.exe..." << std::endl;
|
std::cout << "[cs2] Waiting for cs2.exe..." << std::endl;
|
||||||
|
|
||||||
while (!hack::process->AttachProcess("cs2.exe"))
|
while (!hack::process->AttachProcess("cs2.exe"))
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
|
|
||||||
std::cout << "[cs2] Attached to cs2.exe" << std::endl;
|
std::cout << "[cs2] Attached to cs2.exe\n" << std::endl;
|
||||||
|
|
||||||
std::cout << "[warn] If the esp doesnt work, consider updating offsets manually in the file offsets.json" << std::endl;
|
|
||||||
std::cout << "[warn] 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;
|
|
||||||
|
|
||||||
std::cout << "[config] Reading offsets from configuration." << std::endl;
|
std::cout << "[config] Reading offsets from configuration." << std::endl;
|
||||||
if (config::read())
|
if (config::read())
|
||||||
std::cout << "[config] Sucessfully read offsets file" << std::endl;
|
std::cout << "[config] Sucessfully read offsets file\n" << std::endl;
|
||||||
else
|
else
|
||||||
std::cout << "[config] Error reading offsets file, reseting to the default state" << std::endl;
|
std::cout << "[config] Error reading offsets file, reseting to the default state\n" << std::endl;
|
||||||
|
|
||||||
|
std::cout << "[warn] If the esp doesnt work, consider updating offsets manually in the file offsets.json" << std::endl;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
hack::base_module = hack::process->GetModule("client.dll");
|
hack::base_module = hack::process->GetModule("client.dll");
|
||||||
|
|||||||
@@ -134,15 +134,17 @@
|
|||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>gdiplus.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>gdiplus.lib;wininet.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="classes\auto_updater.cpp" />
|
||||||
<ClCompile Include="classes\config.cpp" />
|
<ClCompile Include="classes\config.cpp" />
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
<ClCompile Include="memory\memory.cpp" />
|
<ClCompile Include="memory\memory.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="classes\auto_updater.hpp" />
|
||||||
<ClInclude Include="classes\config.hpp" />
|
<ClInclude Include="classes\config.hpp" />
|
||||||
<ClInclude Include="classes\globals.hpp" />
|
<ClInclude Include="classes\globals.hpp" />
|
||||||
<ClInclude Include="classes\json.hpp" />
|
<ClInclude Include="classes\json.hpp" />
|
||||||
|
|||||||
@@ -24,6 +24,9 @@
|
|||||||
<ClCompile Include="classes\config.cpp">
|
<ClCompile Include="classes\config.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="classes\auto_updater.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="memory\memory.hpp">
|
<ClInclude Include="memory\memory.hpp">
|
||||||
@@ -47,5 +50,8 @@
|
|||||||
<ClInclude Include="classes\config.hpp">
|
<ClInclude Include="classes\config.hpp">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="classes\auto_updater.hpp">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"dwEntityList": 24692872,
|
||||||
|
"dwLocalPlayer": 25014536,
|
||||||
|
"dwPawnHealth": 2056,
|
||||||
|
"dwPlayerPawn": 2044,
|
||||||
|
"dwSanitizedName": 1824,
|
||||||
|
"dwViewMatrix": 25667296,
|
||||||
|
"m_iTeamNum": 959,
|
||||||
|
"m_vecOrigin": 4628
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user