Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
Add Auto-Update
Browse files Browse the repository at this point in the history
  • Loading branch information
hotline1337 committed Jun 6, 2023
1 parent 32f0db3 commit 983c172
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 11 deletions.
8 changes: 4 additions & 4 deletions R3nzSkin/R3nzSkin.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,29 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ChinaServer|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ChinaServer|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RiotGamesServers|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PreferredToolArchitecture>x86</PreferredToolArchitecture>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RiotGamesServers|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
Expand Down
2 changes: 1 addition & 1 deletion R3nzSkin_Injector/R3nzSkin_Injector.rc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ BEGIN
BEGIN
BLOCK "041f04b0"
BEGIN
VALUE "CompanyName", "R3nz Software Inc."
VALUE "CompanyName", "R3nzSoftware Inc."
VALUE "FileDescription", "R3nSkin DLL Injector"
VALUE "FileVersion", "1.0.0.0"
VALUE "InternalName", "R3nzSkin.exe"
Expand Down
8 changes: 4 additions & 4 deletions R3nzSkin_Injector/R3nzSkin_Injector.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RiotGamesServers|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>true</CLRSupport>
Expand All @@ -40,20 +40,20 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RiotGamesServers|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>true</CLRSupport>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='ChinaServer|Win32'">
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CLRSupport>true</CLRSupport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ChinaServer|x64'" Label="Configuration">
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CLRSupport>true</CLRSupport>
Expand Down
52 changes: 50 additions & 2 deletions R3nzSkin_Injector/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,73 @@
#include <ctime>
#include <cstdlib>
#include <thread>
#include <regex>
#include <msclr/marshal_cppstd.h>

#include "R3nzUI.hpp"
#include "Injector.hpp"
#include "lazy_importer.hpp"

using namespace System;
using namespace System::Windows::Forms;
using namespace System::Threading;
using namespace System::Globalization;
using namespace System::Net;

void auto_update()
{
WebClient^ client = gcnew WebClient();
client->Headers->Add(L"User-Agent", L"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0");

try
{
std::string json = msclr::interop::marshal_as<std::string>(client->DownloadString(L"https://api.github.com/repos/R3nzTheCodeGOD/R3nzSkin/releases/latest"));
std::regex tagnameRegex("\"tag_name\"\\s*:\\s*\"([^\"]+)");
std::regex urlRegex("\"browser_download_url\"\\s*:\\s*\"([^\"]+)");
std::regex dateRegex("\"created_at\"\\s*:\\s*\"([^\"]+)");

std::smatch tagnameMatch, urlMatch, dateMatch;
if (std::regex_search(json, tagnameMatch, tagnameRegex))
{
auto version = gcnew String(tagnameMatch[1].str().c_str());
if (std::regex_search(json, dateMatch, dateRegex))
{
auto date_of_new_release = DateTime::ParseExact(gcnew String(dateMatch[1].str().c_str()), L"yyyy-MM-ddTHH:mm:ssZ", CultureInfo::InvariantCulture).ToString(L"dd.MM.yyyy");
auto date_of_current_release = System::IO::File::GetLastWriteTime(L"R3nzSkin.dll").ToString(L"dd.MM.yyyy");
if (date_of_current_release != date_of_new_release)
{
auto result = LI_FN(MessageBoxW)(nullptr, L"New version is available on GitHub\nWould you like to download it now?", L"R3nzSkin", MB_YESNO | MB_ICONINFORMATION);
if (result == IDYES)
{
if (std::regex_search(json, urlMatch, urlRegex))
{
auto url = gcnew String(urlMatch[1].str().c_str());
client->DownloadFile(url, String::Format(L"R3nzSkin_{0}.zip", version));
Environment::Exit(0);
}
}
}
}
}
}
catch (Exception^ e)
{
MessageBox::Show(e->Message, L"R3nzSkin", MessageBoxButtons::OK, MessageBoxIcon::Error);
}
}

int main([[maybe_unused]] array<String^>^ args)
{
auto_update();
std::srand(static_cast<unsigned int>(std::time(nullptr)));
Injector::renameExe();

Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
R3nzSkinInjector::R3nzUI form;

auto thread{ std::thread(Injector::run) };
auto screenThread{ gcnew Thread(gcnew ThreadStart(% form, &R3nzSkinInjector::R3nzUI::updateScreen)) };
auto screenThread{ gcnew Thread(gcnew ThreadStart(%form, &R3nzSkinInjector::R3nzUI::updateScreen)) };
screenThread->Start();

Application::Run(%form);
Expand Down

0 comments on commit 983c172

Please sign in to comment.