added client version control

+ nlohmann/json library was included in the project.
+ VersionControl class was created and it checks if the client is up to date.
+ CLIENT_VERSION macro defined.
This commit is contained in:
Jadis0x
2024-06-02 13:27:13 +03:00
parent 3c474a398e
commit a1c4c9c830
7 changed files with 24938 additions and 10 deletions

View File

@@ -58,6 +58,7 @@
<ClCompile Include="user\features\misc\misc.cpp" />
<ClCompile Include="user\hooks\hooks.cpp" />
<ClCompile Include="user\main.cpp" />
<ClCompile Include="user\network\VersionControl.cpp" />
<ClCompile Include="user\players\players.cpp" />
<ClCompile Include="user\settings\settings.cpp" />
<ClCompile Include="user\utils\utils.cpp" />
@@ -83,6 +84,7 @@
<ClInclude Include="include\imgui\imstb_rectpack.h" />
<ClInclude Include="include\imgui\imstb_textedit.h" />
<ClInclude Include="include\imgui\imstb_truetype.h" />
<ClInclude Include="include\json.hpp" />
<ClInclude Include="include\Minhook\include\MinHook.h" />
<ClInclude Include="include\Minhook\src\buffer.h" />
<ClInclude Include="include\Minhook\src\HDE\hde32.h" />
@@ -99,6 +101,7 @@
<ClInclude Include="user\features\misc\misc.h" />
<ClInclude Include="user\hooks\hooks.hpp" />
<ClInclude Include="user\main.h" />
<ClInclude Include="user\network\VersionControl.h" />
<ClInclude Include="user\players\players.h" />
<ClInclude Include="user\settings\settings.hpp" />
<ClInclude Include="user\utils\utils.hpp" />

View File

@@ -82,6 +82,9 @@
<ClCompile Include="user\features\esp\esp.cpp">
<Filter>user\features\esp</Filter>
</ClCompile>
<ClCompile Include="user\network\VersionControl.cpp">
<Filter>user\network</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="user\main.h">
@@ -201,6 +204,12 @@
<ClInclude Include="user\features\esp\esp.hpp">
<Filter>user\features\esp</Filter>
</ClInclude>
<ClInclude Include="user\network\VersionControl.h">
<Filter>user\network</Filter>
</ClInclude>
<ClInclude Include="include\json.hpp">
<Filter>include</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="appdata">
@@ -245,5 +254,8 @@
<Filter Include="user\features\esp">
<UniqueIdentifier>{8f74b1c2-1d3c-4a14-8a6f-7bf00e07d57e}</UniqueIdentifier>
</Filter>
<Filter Include="user\network">
<UniqueIdentifier>{faef4024-c359-4051-90fc-8735a4acbe8f}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>

24765
include/json.hpp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -353,6 +353,9 @@ void DrawMiscTab() {
}
void DrawPlayersTab() {
ImGui::Checkbox("Fly", &settings::fly);
ImGui::SliderFloat("Speed: ", &settings::fly_speed, 5.f, 20.f);
ImGui::Checkbox("Change player speed", &settings::change_player_speed);
ImGui::SliderInt("Multiplier", &settings::new_speed, 0, 10);

View File

@@ -15,10 +15,14 @@
#include "Wrapper.h"
#include "ClientHelper.h"
#include "hooks/hooks.hpp"
#include "color.hpp"
#include "UnityCore.h"
#include "color.hpp"
#include "features/misc/misc.h"
#include "utils/utils.hpp"
#include "network/VersionControl.h"
#define CLIENT_VERSION "4.1"
// Set the name of your log file here
extern const LPCWSTR LOG_FILE = L"DevourClient.txt";
@@ -42,7 +46,9 @@ void Run()
// If you would like to output to a new console window, use il2cppi_new_console() to open one and redirect stdout
il2cppi_new_console();
std::cout << dye::green("\n\tDevourClient v2.0\n\t") << __DATE__ << " - " << __TIME__ << std::endl;
std::cout << dye::green("\n\tDevourClient v") << dye::green(CLIENT_VERSION) << "\n\t" << __DATE__ << " - " << __TIME__ << std::endl;
std::cout << "\tDevour Version ";
if (app::Application_get_version != nullptr)
@@ -59,6 +65,39 @@ void Run()
std::cout << "[DevourClient]: " << "Note: " << dye::light_red("if you payed for this you most likely got scammed.\n\n");
std::cout << "[DevourClient]: Logged in as " << dye::yellow(steamName) << " (" << steamUserID << ")\n\n";
// DevourClient version control
VersionControl client(CLIENT_VERSION, L"https://api.github.com/repos/ALittlePatate/DevourClient/releases/latest");
il2cppi_log_write("[DevourClient]: Update check successful, client is up-to-date.\n");
std::cout << "[DevourClient]: " << dye::light_aqua("Checking for updates..\n");
client.CheckForUpdate();
if (client.IsUpToDate()) {
il2cppi_log_write("[DevourClient]: Update check successful, client is up-to-date.\n");
std::cout << "[DevourClient]: " << dye::light_green("Client is up to date.") << "\n\n";
}
else {
il2cppi_log_write("[DevourClient]: Client is out of date!\n");
std::cout << "[DevourClient]: " << dye::red_on_black("Client is out of date!") << "\n\n";
const char* latestDownloadLink = client.GetLatestDownloadLink();
app::String* str = reinterpret_cast<app::String*>(il2cpp_string_new(latestDownloadLink));
const int result = MessageBox(NULL, L"Version is not up to date! Would you like to download the new version?", L"DevourClient", MB_YESNO | MB_ICONERROR);
switch (result)
{
case IDYES:
app::Application_OpenURL(str, nullptr);
break;
case IDNO:
MessageBox(NULL, L"You can download the new version at any time to benefit from new features, improvements, and bug fixes", L"DevourClient", MB_OK | MB_ICONEXCLAMATION);
break;
default:
break;
}
}
std::cout << "[DevourClient]: " << dye::aqua("Initializing..\n");
il2cppi_log_write("Initializing..");
@@ -86,14 +125,6 @@ void Run()
return;
}
// create settings.ini
std::string filename = "settings.ini";
std::string key = "open_menu";
std::string defaultValue = "INSERT"; // default value
// null file??
std::string keyValue = ReadValueFromIni(filename, key, defaultValue);
std::cout << "[DevourClient]: " << dye::light_green("Done!:)\n\n");
std::string scene = SceneName();

View File

@@ -0,0 +1,95 @@
#include "pch-il2cpp.h"
#include "VersionControl.h"
#include <Windows.h>
#include <iostream>
#include <wininet.h>
#include "json.hpp"
#pragma comment(lib, "wininet.lib")
using json = nlohmann::json;
VersionControl::VersionControl(const char* version_tag, const wchar_t* url)
{
current_version_tag = version_tag;
requestUrl = url;
isUpToDate = false;
latestDownloadLink = nullptr;
}
const char* VersionControl::GetCurrentVersionTag()
{
return current_version_tag;
}
bool VersionControl::IsUpToDate()
{
return isUpToDate;
}
const char* VersionControl::GetLatestDownloadLink()
{
return latestDownloadLink;
}
void VersionControl::SetIsUpToDate(bool value)
{
isUpToDate = value;
}
void VersionControl::CheckForUpdate()
{
HINTERNET hInternet = InternetOpen(L"DevourClient_Version_Control", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
if (hInternet) {
HINTERNET hConnect = InternetOpenUrl(hInternet, requestUrl, NULL, 0, INTERNET_FLAG_RELOAD, 0);
if (hConnect) {
std::vector<char> buffer(4096);
DWORD bytesRead;
std::string responseData;
while (InternetReadFile(hConnect, &buffer[0], buffer.size(), &bytesRead) && bytesRead > 0) {
responseData.append(&buffer[0], bytesRead);
}
json data = json::parse(responseData);
if (data.find("tag_name") != data.end() && data["tag_name"].is_string()) {
std::string latestTagName = data["tag_name"];
if (strcmp(latestTagName.c_str(), current_version_tag) == 0) {
SetIsUpToDate(true);
}
else {
SetIsUpToDate(false);
}
}
if (data.find("assets") != data.end() && data["assets"].is_array() && !data["assets"].empty()) {
if (data["assets"][0].find("browser_download_url") != data["assets"][0].end() && data["assets"][0]["browser_download_url"].is_string()) {
std::string downloadUrl = data["assets"][0]["browser_download_url"];
latestDownloadLink = _strdup(downloadUrl.c_str());
}
}
InternetCloseHandle(hConnect);
}
else {
std::cout << "[DevourClient]: URL opening error! Skipping update check..." << std::endl;
}
}
else {
std::cout << "[DevourClient]: Unable to establish an internet connection! Skipping update check..." << std::endl;
}
}
VersionControl::~VersionControl()
{
current_version_tag = nullptr;
requestUrl = nullptr;
}

View File

@@ -0,0 +1,19 @@
#pragma once
class VersionControl {
public:
VersionControl(const char* version_tag, const wchar_t* url);
~VersionControl();
const char* GetCurrentVersionTag();
void CheckForUpdate();
bool IsUpToDate();
const char* GetLatestDownloadLink();
private:
const char* latestDownloadLink;
bool isUpToDate;
const char* current_version_tag;
const wchar_t* requestUrl;
private:
void SetIsUpToDate(bool value);
};