Skip to content

Commit

Permalink
added game version check
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteCorum committed Sep 11, 2024
1 parent 6dcffae commit 338fa3d
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 45 deletions.
98 changes: 54 additions & 44 deletions DragonBurn/Core/Init.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,50 +89,60 @@ namespace Init
// return rate;
//}

// Checks cs2 version
//static int CheckCS2Version()
//{
// DWORD pid = ProcessMgr.GetProcessID("cs2.exe");
// long long curVer = -1;
// std::string processPath;
// HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid);
// if (hProcess)
// {
// wchar_t buffer[MAX_PATH];
// if (GetModuleFileNameEx(hProcess, NULL, buffer, MAX_PATH))
// processPath = WStringToString(buffer);
// else
// return 0;
// CloseHandle(hProcess);
// }
// else
// return 0;

// int pos = processPath.rfind("bin");
// if (pos != std::string::npos)
// processPath = processPath.substr(0, pos + 3);
// else
// return 0;
// processPath += "\\built_from_cl.txt";

// std::ifstream file(processPath);
// if (file.is_open())
// {
// std::string line;
// if (std::getline(file, line))
// curVer = stoi(line);
// else
// return 0;
// file.close();
// }
// else
// return 0;

// if (Offset.CS2ver == curVer)
// return 2;
// else
// return 1;
//}
static int CheckCS2Version()
{
DWORD pid = ProcessMgr.GetProcessID("cs2.exe");
long curVer;
const std::string cloudVersionUrl = "https://raw.githubusercontent.com/ByteCorum/DragonBurn/data/cs2-version";
long cloudVersion;
std::string processPath;
std::string buff;

if (!Web::Get(cloudVersionUrl, buff))
return 2;
cloudVersion = stoi(buff);
if (cloudVersion == -1)
return 3;

HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid);
if (hProcess)
{
wchar_t buffer[MAX_PATH];
if (GetModuleFileNameEx(hProcess, NULL, buffer, MAX_PATH))
processPath = WStringToString(buffer);
else
return 0;
CloseHandle(hProcess);
}
else
return 0;

int pos = processPath.rfind("bin");
if (pos != std::string::npos)
processPath = processPath.substr(0, pos + 3);
else
return 0;

processPath += "\\built_from_cl.txt";

std::ifstream file(processPath);
if (file.is_open())
{
std::string line;
if (std::getline(file, line))
curVer = stoi(line);
else
return 0;
file.close();
}
else
return 0;

if (cloudVersion == curVer)
return 3;
else
return 1;
}

// Check if the game window is activated
static bool isGameWindowActive() {
Expand Down
2 changes: 2 additions & 0 deletions DragonBurn/Helpers/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ namespace Log
std::cout << "[!]" << ctx << '\n';

if (pause)
SetConsoleTextAttribute(hConsole, 8);
system("pause");
}

inline void Error(std::string ctx, bool fatal = true)
{
SetConsoleTextAttribute(hConsole, 12);
std::cout << "[X]" << ctx << '\n';
SetConsoleTextAttribute(hConsole, 8);
system("pause");
if(fatal)
exit(0);
Expand Down
34 changes: 33 additions & 1 deletion DragonBurn/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,38 @@ void Cheat()
Sleep(20000);
}

Log::PreviousLine();
Log::Fine("Connected to CS2");
Log::Info("Linking to CS2");

#if DEBUG == false
switch (Init::Client::CheckCS2Version())
{
case 0:
Log::PreviousLine();
Log::Error("Failed to get the current game version");
break;

case 1:
Log::PreviousLine();
Log::Warning("Offsets are outdated, we'll update them asap. With current offsets, cheat may work unstable", true);
break;

case 2:
Log::PreviousLine();
Log::Error("Failed to get cloud version");
break;

case 3:
break;

default:
Log::PreviousLine();
Log::Error("Failed to get the current game version");
break;
}
#endif

auto ProcessStatus = ProcessMgr.Attach("cs2.exe");
switch (ProcessStatus)
{
Expand Down Expand Up @@ -150,7 +182,7 @@ void Cheat()
}

Log::PreviousLine();
Log::Fine("Connected to CS2");
Log::Fine("Linked to CS2");

char documentsPath[MAX_PATH];
if (SHGetFolderPathA(NULL, CSIDL_PERSONAL, NULL, 0, documentsPath) != S_OK)
Expand Down

0 comments on commit 338fa3d

Please sign in to comment.