diff --git a/R3nzSkin_Injector/Injector.cpp b/R3nzSkin_Injector/Injector.cpp index 5ed2873c..46d781ca 100644 --- a/R3nzSkin_Injector/Injector.cpp +++ b/R3nzSkin_Injector/Injector.cpp @@ -10,6 +10,7 @@ #include "Injector.hpp" #include "R3nzUI.hpp" +#include "xorstr.hpp" #include "lazy_importer.hpp" using namespace System; @@ -18,6 +19,8 @@ using namespace System::Threading; using namespace System::Globalization; using namespace System::Net; +#define xor_clrstr_w(x) msclr::interop::marshal_as(static_cast(_XorStrW(x))) + proclist_t WINAPI Injector::findProcesses(const std::wstring& name) noexcept { auto process_snap{ LI_FN(CreateToolhelp32Snapshot)(TH32CS_SNAPPROCESS, 0) }; @@ -57,7 +60,7 @@ bool WINAPI Injector::isInjected(const std::uint32_t pid) noexcept for (auto i{ 0u }; i < (cbNeeded / sizeof(HMODULE)); ++i) { TCHAR szModName[MAX_PATH]; if (LI_FN(K32GetModuleBaseNameW)(hProcess, hMods[i], szModName, sizeof(szModName) / sizeof(TCHAR))) { - if (std::wcscmp(szModName, L"R3nzSkin.dll") == 0) { + if (std::wcscmp(szModName, _XorStrW(L"R3nzSkin.dll")) == 0) { LI_FN(CloseHandle)(hProcess); return true; } @@ -89,10 +92,10 @@ bool WINAPI Injector::inject(const std::uint32_t pid) noexcept if (delta > 0) std::this_thread::sleep_for(std::chrono::seconds(delta)); - const auto dll_path{ std::wstring(current_dir) + L"\\R3nzSkin.dll" }; + const auto dll_path{ std::wstring(current_dir) + _XorStrW(L"\\R3nzSkin.dll") }; if (const auto f{ std::ifstream(dll_path) }; !f.is_open()) { - LI_FN(MessageBoxW)(nullptr, L"R3nzSkin.dll file could not be found.\nTry reinstalling the cheat.", L"R3nzSkin", MB_ICONERROR | MB_OK); + LI_FN(MessageBoxW)(nullptr, _XorStrW(L"R3nzSkin.dll file could not be found.\nTry reinstalling the cheat."), _XorStrW(L"R3nzSkin"), MB_ICONERROR | MB_OK); LI_FN(CloseHandle)(handle); return false; } @@ -111,7 +114,7 @@ bool WINAPI Injector::inject(const std::uint32_t pid) noexcept } HANDLE thread{}; - LI_FN(NtCreateThreadEx).nt_cached()(&thread, GENERIC_ALL, nullptr, handle, reinterpret_cast(LI_FN(GetProcAddress).get()(LI_FN(GetModuleHandleW).get()(L"kernel32.dll"), "LoadLibraryW")), dll_path_remote, FALSE, NULL, NULL, NULL, NULL); + LI_FN(NtCreateThreadEx).nt_cached()(&thread, GENERIC_ALL, nullptr, handle, reinterpret_cast(LI_FN(GetProcAddress).get()(LI_FN(GetModuleHandleW).get()(_XorStrW(L"kernel32.dll")), _XorStr("LoadLibraryW"))), dll_path_remote, FALSE, NULL, NULL, NULL, nullptr); if (!thread || thread == INVALID_HANDLE_VALUE) { LI_FN(VirtualFreeEx).get()(handle, dll_path_remote, 0u, MEM_RELEASE); @@ -131,7 +134,7 @@ void WINAPI Injector::enableDebugPrivilege() noexcept HANDLE token{}; if (OpenProcessToken(LI_FN(GetCurrentProcess).get()(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token)) { LUID value; - if (LookupPrivilegeValueW(nullptr, SE_DEBUG_NAME, &value)) { + if (LookupPrivilegeValueW(nullptr, _XorStrW(SE_DEBUG_NAME), &value)) { TOKEN_PRIVILEGES tp{}; tp.PrivilegeCount = 1; tp.Privileges[0].Luid = value; @@ -147,58 +150,58 @@ void Injector::autoUpdate() auto client = gcnew WebClient(); ServicePointManager::Expect100Continue = true; ServicePointManager::SecurityProtocol = SecurityProtocolType::Tls12; - client->Headers->Add(L"User-Agent", L"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0"); + client->Headers->Add(xor_clrstr_w(L"User-Agent"), xor_clrstr_w(L"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0")); try { - auto json = msclr::interop::marshal_as(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*\"([^\"]+)"); + auto json = msclr::interop::marshal_as(client->DownloadString(xor_clrstr_w(L"https://api.github.com/repos/R3nzTheCodeGOD/R3nzSkin/releases/latest"))); + std::regex tagnameRegex(_XorStr("\"tag_name\"\\s*:\\s*\"([^\"]+)")); + std::regex urlRegex(_XorStr("\"browser_download_url\"\\s*:\\s*\"([^\"]+)")); + std::regex dateRegex(_XorStr("\"created_at\"\\s*:\\s*\"([^\"]+)")); if (std::smatch tagnameMatch; std::regex_search(json, tagnameMatch, tagnameRegex)) { auto version = gcnew String(tagnameMatch[1].str().c_str()); if (std::smatch dateMatch; std::regex_search(json, dateMatch, dateRegex)) { - if (!System::IO::File::Exists(L"R3nzSkin.dll")) + if (!System::IO::File::Exists(xor_clrstr_w(L"R3nzSkin.dll"))) { - throw gcnew Exception(L"Failed to find R3nzSkin.dll in the current directory"); + throw gcnew Exception(xor_clrstr_w(L"Failed to find R3nzSkin.dll in the current directory")); } - auto date_of_github_release = DateTime::ParseExact(gcnew String(dateMatch[1].str().c_str()), L"yyyy-MM-ddTHH:mm:ssZ", CultureInfo::InvariantCulture).ToString(L"dd.MM.yyyy HH:00"); - auto date_of_current_release = System::IO::File::GetLastWriteTime(L"R3nzSkin.dll").ToString(L"dd.MM.yyyy HH:00"); + const auto date_of_github_release = DateTime::ParseExact(gcnew String(dateMatch[1].str().c_str()), xor_clrstr_w(L"yyyy-MM-ddTHH:mm:ssZ"), CultureInfo::InvariantCulture).ToString(xor_clrstr_w(L"dd.MM.yyyy HH:00")); + const auto date_of_current_release = System::IO::File::GetLastWriteTime(xor_clrstr_w(L"R3nzSkin.dll")).ToString(xor_clrstr_w(L"dd.MM.yyyy HH:00")); if (date_of_current_release != date_of_github_release) { - auto date_of_github_release_class = DateTime::ParseExact(date_of_github_release, L"dd.MM.yyyy HH:00", CultureInfo::InvariantCulture); - auto date_of_current_release_class = DateTime::ParseExact(date_of_current_release, L"dd.MM.yyyy HH:00", CultureInfo::InvariantCulture); + const auto date_of_github_release_class = DateTime::ParseExact(date_of_github_release, xor_clrstr_w(L"dd.MM.yyyy HH:00"), CultureInfo::InvariantCulture); + const auto date_of_current_release_class = DateTime::ParseExact(date_of_current_release, xor_clrstr_w(L"dd.MM.yyyy HH:00"), CultureInfo::InvariantCulture); if (date_of_current_release_class > date_of_github_release_class) { return; } - auto result = MessageBox::Show(L"New version is available on GitHub\nWould you like to download it now?", L"R3nzSkin", MessageBoxButtons::YesNo, MessageBoxIcon::Information); + const auto result = MessageBox::Show(xor_clrstr_w(L"New version is available on GitHub\nWould you like to download it now?"), xor_clrstr_w(L"R3nzSkin"), MessageBoxButtons::YesNo, MessageBoxIcon::Information); if (result == DialogResult::Yes) { if (std::smatch urlMatch; std::regex_search(json, urlMatch, urlRegex)) { auto url = gcnew String(urlMatch[1].str().c_str()); - auto file = String::Format(L"R3nzSkin_{0}.zip", version); + auto file = String::Format(xor_clrstr_w(L"R3nzSkin_{0}.zip"), version); client->DownloadFile(url, file); - System::IO::Compression::ZipFile::ExtractToDirectory(file, L"R3nzSkin"); + System::IO::Compression::ZipFile::ExtractToDirectory(file, xor_clrstr_w(L"R3nzSkin")); System::IO::File::Delete(file); - System::IO::File::Delete(L"R3nzSkin.dll"); - System::IO::File::Move(L"R3nzSkin\\R3nzSkin_Injector.exe", String::Format(L"R3nzSkin_Injector_{0}.exe", version)); - System::IO::File::Move(L"R3nzSkin\\R3nzSkin.dll", L"R3nzSkin.dll"); - System::IO::Directory::Delete(L"R3nzSkin"); + System::IO::File::Delete(xor_clrstr_w(L"R3nzSkin.dll")); + System::IO::File::Move(xor_clrstr_w(L"R3nzSkin\\R3nzSkin_Injector.exe"), String::Format(xor_clrstr_w(L"R3nzSkin_Injector_{0}.exe"), version)); + System::IO::File::Move(xor_clrstr_w(L"R3nzSkin\\R3nzSkin.dll"), xor_clrstr_w(L"R3nzSkin.dll")); + System::IO::Directory::Delete(xor_clrstr_w(L"R3nzSkin")); auto process_info = gcnew System::Diagnostics::ProcessStartInfo(); - process_info->Arguments = L"/C choice /C Y /N /D Y /T 1 & del \"" + System::Diagnostics::Process::GetCurrentProcess()->MainModule->FileName + L"\""; + process_info->Arguments = xor_clrstr_w(L"/C choice /C Y /N /D Y /T 1 & del \"") + System::Diagnostics::Process::GetCurrentProcess()->MainModule->FileName + xor_clrstr_w(L"\""); process_info->CreateNoWindow = true; - process_info->FileName = L"cmd.exe"; + process_info->FileName = xor_clrstr_w(L"cmd.exe"); process_info->WindowStyle = System::Diagnostics::ProcessWindowStyle::Hidden; System::Diagnostics::Process::Start(process_info); - System::Diagnostics::Process::Start(String::Format(L"R3nzSkin_Injector_{0}.exe", version)); + System::Diagnostics::Process::Start(String::Format(xor_clrstr_w(L"R3nzSkin_Injector_{0}.exe"), version)); Environment::Exit(0); } @@ -209,7 +212,7 @@ void Injector::autoUpdate() } catch (Exception^ e) { - MessageBox::Show(String::Format(L"{0} - {1}", e->Message, e->StackTrace->Substring(5)), L"R3nzSkin", MessageBoxButtons::OK, MessageBoxIcon::Error); + MessageBox::Show(String::Format(xor_clrstr_w(L"{0} - {1}"), e->Message, e->StackTrace->Substring(5)), xor_clrstr_w(L"R3nzSkin"), MessageBoxButtons::OK, MessageBoxIcon::Error); Environment::Exit(0); } } @@ -218,8 +221,8 @@ void Injector::run() noexcept { enableDebugPrivilege(); while (true) { - const auto& league_client_processes{ Injector::findProcesses(L"LeagueClient.exe") }; - const auto& league_processes{ Injector::findProcesses(L"League of Legends.exe") }; + const auto& league_client_processes{ Injector::findProcesses(_XorStrW(L"LeagueClient.exe")) }; + const auto& league_processes{ Injector::findProcesses(_XorStrW(L"League of Legends.exe")) }; R3nzSkinInjector::gameState = (league_processes.size() > 0) ? true : false; R3nzSkinInjector::clientState = (league_client_processes.size() > 0) ? true : false; diff --git a/R3nzSkin_Injector/R3nzSkin_Injector.vcxproj b/R3nzSkin_Injector/R3nzSkin_Injector.vcxproj index 1b6ec2be..697c01d0 100644 --- a/R3nzSkin_Injector/R3nzSkin_Injector.vcxproj +++ b/R3nzSkin_Injector/R3nzSkin_Injector.vcxproj @@ -207,6 +207,7 @@ CppForm + diff --git a/R3nzSkin_Injector/R3nzSkin_Injector.vcxproj.filters b/R3nzSkin_Injector/R3nzSkin_Injector.vcxproj.filters index 177d2a19..6829ea41 100644 --- a/R3nzSkin_Injector/R3nzSkin_Injector.vcxproj.filters +++ b/R3nzSkin_Injector/R3nzSkin_Injector.vcxproj.filters @@ -35,6 +35,9 @@ Source Files + + Source Files + diff --git a/R3nzSkin_Injector/R3nzUI.hpp b/R3nzSkin_Injector/R3nzUI.hpp index 1d16fe8c..3039fa1d 100644 --- a/R3nzSkin_Injector/R3nzUI.hpp +++ b/R3nzSkin_Injector/R3nzUI.hpp @@ -1,5 +1,7 @@ #pragma once +#include "xorstr.hpp" + namespace R3nzSkinInjector { using namespace System; @@ -17,7 +19,7 @@ namespace R3nzSkinInjector { static auto clientState{ false }; delegate String^ MyDelegate(); - ref class LambdaWrapper + ref class LambdaWrapper sealed { public: String^ InvokeLambda() @@ -46,43 +48,50 @@ namespace R3nzSkinInjector { } }; - public ref class R3nzUI : public System::Windows::Forms::Form { - public: - R3nzUI(void) { InitializeComponent(); loadSettings(); renameProgram(); } + public ref class R3nzUI sealed : public Form + { public: - void updateScreen() { + R3nzUI() + { + InitializeComponent(); loadSettings(); renameProgram(); + } + + void updateScreen() + { while (true) { if (clientState) { - this->label4->Text = L"Found"; - this->label4->ForeColor = System::Drawing::Color::FromArgb(255, 252, 220, 107); + this->clientStatusLabel->Text = L"Found"; + this->clientStatusLabel->ForeColor = Color::FromArgb(255, 252, 220, 107); } else { - this->label4->Text = L"Not Found"; - this->label4->ForeColor = System::Drawing::Color::FromArgb(255, 245, 8, 83); + this->clientStatusLabel->Text = L"Not Found"; + this->clientStatusLabel->ForeColor = Color::FromArgb(255, 245, 8, 83); } if (gameState) { - this->label3->Text = L"Found"; - this->label3->ForeColor = System::Drawing::Color::FromArgb(255, 252, 220, 107); + this->gameStatusLabel->Text = L"Found"; + this->gameStatusLabel->ForeColor = Color::FromArgb(255, 252, 220, 107); if (cheatState) { - this->label2->Text = L"Injected"; - this->label2->ForeColor = System::Drawing::Color::FromArgb(255, 252, 220, 107); + this->dllStatusLabel->Text = L"Injected"; + this->dllStatusLabel->ForeColor = Color::FromArgb(255, 252, 220, 107); } else { - this->label2->Text = L"Not Injected"; - this->label2->ForeColor = System::Drawing::Color::FromArgb(255, 245, 8, 83); + this->dllStatusLabel->Text = L"Not Injected"; + this->dllStatusLabel->ForeColor = Color::FromArgb(255, 245, 8, 83); } } else { - this->label3->Text = L"Not Found"; - this->label3->ForeColor = System::Drawing::Color::FromArgb(255, 245, 8, 83); - this->label2->Text = L"Not Injected"; - this->label2->ForeColor = System::Drawing::Color::FromArgb(255, 245, 8, 83); + this->gameStatusLabel->Text = L"Not Found"; + this->gameStatusLabel->ForeColor = Color::FromArgb(255, 245, 8, 83); + this->dllStatusLabel->Text = L"Not Injected"; + this->dllStatusLabel->ForeColor = Color::FromArgb(255, 245, 8, 83); } Thread::Sleep(1000); } } - void saveSettings() { + + void saveSettings() + { auto appDataPath = Environment::GetFolderPath(Environment::SpecialFolder::MyDocuments); auto settingsFolder = Path::Combine(appDataPath, L"R3nzSkin"); auto settingsFilePath = Path::Combine(settingsFolder, L"R3nzSkinInjector"); @@ -91,9 +100,11 @@ namespace R3nzSkinInjector { Directory::CreateDirectory(settingsFolder); } - File::WriteAllText(settingsFilePath, System::Convert::ToString(this->toolstripmenuItem2->Checked)); + File::WriteAllText(settingsFilePath, Convert::ToString(this->toolstripmenuItem2->Checked)); } - void loadSettings() { + + void loadSettings() + { auto appDataPath = Environment::GetFolderPath(Environment::SpecialFolder::MyDocuments); auto settingsFolder = Path::Combine(appDataPath, L"R3nzSkin"); auto settingsFilePath = Path::Combine(settingsFolder, L"R3nzSkinInjector"); @@ -103,194 +114,196 @@ namespace R3nzSkinInjector { } if (File::Exists(settingsFilePath)) { - this->toolstripmenuItem2->Checked = System::Boolean::Parse(File::ReadAllText(settingsFilePath)); + this->toolstripmenuItem2->Checked = Boolean::Parse(File::ReadAllText(settingsFilePath)); } } + void renameProgram() { auto wrapper = gcnew LambdaWrapper(); // Executable - System::IO::File::Move(Application::ExecutablePath, String::Format("{0}\\{1}.exe", Application::StartupPath, wrapper->InvokeLambda())); + File::Move(Application::ExecutablePath, String::Format("{0}\\{1}.exe", Application::StartupPath, wrapper->InvokeLambda())); // Title this->Text = wrapper->InvokeLambda(); } protected: ~R3nzUI() { if (components) delete components; } - private: System::Windows::Forms::Button^ button1; - private: System::Windows::Forms::Label^ label1; - private: System::Windows::Forms::Label^ label2; - private: System::Windows::Forms::Label^ label3; - private: System::Windows::Forms::GroupBox^ groupBox1; - private: System::Windows::Forms::GroupBox^ groupBox2; - private: System::Windows::Forms::Label^ label4; - private: System::Windows::Forms::GroupBox^ groupBox3; - private: System::Windows::Forms::GroupBox^ groupBox4; - private: System::Windows::Forms::LinkLabel^ linkLabel1; - private: System::ComponentModel::Container^ components; - private: System::Windows::Forms::NotifyIcon^ notifyIcon; - private: System::Windows::Forms::ContextMenu^ contextMenu; - private: System::Windows::Forms::MenuItem^ menuItem; - private: System::Windows::Forms::MenuItem^ menuItem2; - private: System::Windows::Forms::MenuStrip^ menuStrip; - private: System::Windows::Forms::ToolStripMenuItem^ toolstripmenuItem; - private: System::Windows::Forms::ToolStripMenuItem^ toolstripmenuItem2; + private: + Button^ startButton; + Label^ injectorStatusLabel; + Label^ dllStatusLabel; + Label^ gameStatusLabel; + Label^ clientStatusLabel; + GroupBox^ injectorStatusGroupBox; + GroupBox^ leagueClientStatusGroupBox; + GroupBox^ leagueGameStatusGroupBox; + GroupBox^ dllStatusGroupBox; + LinkLabel^ copyrightLabel; + System::ComponentModel::Container^ components; + NotifyIcon^ notifyIcon; + Windows::Forms::ContextMenu^ contextMenu; + MenuItem^ menuItem; + MenuItem^ menuItem2; + MenuStrip^ menuStrip; + ToolStripMenuItem^ toolstripmenuItem; + ToolStripMenuItem^ toolstripmenuItem2; #pragma region Windows Form Designer generated code - void InitializeComponent(void) + void InitializeComponent() { - auto resources = (gcnew System::ComponentModel::ComponentResourceManager(R3nzUI::typeid)); - this->button1 = (gcnew System::Windows::Forms::Button()); - this->label1 = (gcnew System::Windows::Forms::Label()); - this->label2 = (gcnew System::Windows::Forms::Label()); - this->label3 = (gcnew System::Windows::Forms::Label()); - this->groupBox1 = (gcnew System::Windows::Forms::GroupBox()); - this->groupBox2 = (gcnew System::Windows::Forms::GroupBox()); - this->label4 = (gcnew System::Windows::Forms::Label()); - this->groupBox3 = (gcnew System::Windows::Forms::GroupBox()); - this->groupBox4 = (gcnew System::Windows::Forms::GroupBox()); - this->linkLabel1 = (gcnew System::Windows::Forms::LinkLabel()); - this->notifyIcon = (gcnew System::Windows::Forms::NotifyIcon()); - this->contextMenu = (gcnew System::Windows::Forms::ContextMenu()); - this->menuItem = (gcnew System::Windows::Forms::MenuItem()); - this->menuItem2 = (gcnew System::Windows::Forms::MenuItem()); - this->menuStrip = (gcnew System::Windows::Forms::MenuStrip()); - this->toolstripmenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); - this->toolstripmenuItem2 = (gcnew System::Windows::Forms::ToolStripMenuItem()); - this->groupBox1->SuspendLayout(); - this->groupBox2->SuspendLayout(); - this->groupBox3->SuspendLayout(); - this->groupBox4->SuspendLayout(); + auto resources = gcnew ComponentResourceManager(R3nzUI::typeid); + this->startButton = gcnew Button(); + this->injectorStatusLabel = gcnew Label(); + this->dllStatusLabel = gcnew Label(); + this->gameStatusLabel = gcnew Label(); + this->injectorStatusGroupBox = gcnew GroupBox(); + this->leagueClientStatusGroupBox = gcnew GroupBox(); + this->clientStatusLabel = gcnew Label(); + this->leagueGameStatusGroupBox = gcnew GroupBox(); + this->dllStatusGroupBox = gcnew GroupBox(); + this->copyrightLabel = gcnew LinkLabel(); + this->notifyIcon = gcnew NotifyIcon(); + this->contextMenu = gcnew Windows::Forms::ContextMenu(); + this->menuItem = gcnew MenuItem(); + this->menuItem2 = gcnew MenuItem(); + this->menuStrip = gcnew MenuStrip(); + this->toolstripmenuItem = gcnew ToolStripMenuItem(); + this->toolstripmenuItem2 = gcnew ToolStripMenuItem(); + this->injectorStatusGroupBox->SuspendLayout(); + this->leagueClientStatusGroupBox->SuspendLayout(); + this->leagueGameStatusGroupBox->SuspendLayout(); + this->dllStatusGroupBox->SuspendLayout(); this->SuspendLayout(); // - // button1 - // - this->button1->BackColor = System::Drawing::Color::FromArgb(static_cast(static_cast(245)), static_cast(static_cast(8)), static_cast(static_cast(83))); - this->button1->Cursor = System::Windows::Forms::Cursors::Hand; - this->button1->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - this->button1->Font = (gcnew System::Drawing::Font(L"Arial", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast(162))); - this->button1->Location = System::Drawing::Point(12, 28); - this->button1->Name = L"button1"; - this->button1->Size = System::Drawing::Size(250, 50); - this->button1->TabIndex = 0; - this->button1->Text = L"Start"; - this->button1->UseVisualStyleBackColor = false; - this->button1->Click += gcnew System::EventHandler(this, &R3nzUI::button1_Click); + // startButton // - // label1 + this->startButton->BackColor = Color::FromArgb(245, 8, 83); + this->startButton->Cursor = Cursors::Hand; + this->startButton->FlatStyle = FlatStyle::Flat; + this->startButton->Font = gcnew Drawing::Font(L"Arial", 12, FontStyle::Bold, GraphicsUnit::Point, static_cast(162)); + this->startButton->Location = Point(12, 28); + this->startButton->Name = L"startButton"; + this->startButton->Size = Drawing::Size(250, 50); + this->startButton->TabIndex = 0; + this->startButton->Text = L"Start"; + this->startButton->UseVisualStyleBackColor = false; + this->startButton->Click += gcnew EventHandler(this, &R3nzUI::startButton_Click); // - this->label1->AutoSize = true; - this->label1->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - this->label1->Font = (gcnew System::Drawing::Font(L"Arial", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast(162))); - this->label1->ForeColor = System::Drawing::Color::FromArgb(static_cast(static_cast(245)), static_cast(static_cast(8)), static_cast(static_cast(83))); - this->label1->Location = System::Drawing::Point(6, 16); - this->label1->Name = L"label1"; - this->label1->Size = System::Drawing::Size(68, 18); - this->label1->TabIndex = 1; - this->label1->Text = L"Stopped"; + // injectorStatusLabel // - // label2 + this->injectorStatusLabel->AutoSize = true; + this->injectorStatusLabel->FlatStyle = FlatStyle::Flat; + this->injectorStatusLabel->Font = gcnew Drawing::Font(L"Arial", 11.25F, FontStyle::Bold, GraphicsUnit::Point, static_cast(162)); + this->injectorStatusLabel->ForeColor = Color::FromArgb(245, 8, 83); + this->injectorStatusLabel->Location = Point(6, 16); + this->injectorStatusLabel->Name = L"injectorStatusLabel"; + this->injectorStatusLabel->Size = Drawing::Size(68, 18); + this->injectorStatusLabel->TabIndex = 1; + this->injectorStatusLabel->Text = L"Stopped"; // - this->label2->AutoSize = true; - this->label2->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - this->label2->Font = (gcnew System::Drawing::Font(L"Arial", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast(162))); - this->label2->ForeColor = System::Drawing::Color::FromArgb(static_cast(static_cast(245)), static_cast(static_cast(8)), static_cast(static_cast(83))); - this->label2->Location = System::Drawing::Point(6, 16); - this->label2->Name = L"label2"; - this->label2->Size = System::Drawing::Size(94, 18); - this->label2->TabIndex = 2; - this->label2->Text = L"Not Injected"; + // dllStatusLabel // - // label3 + this->dllStatusLabel->AutoSize = true; + this->dllStatusLabel->FlatStyle = FlatStyle::Flat; + this->dllStatusLabel->Font = gcnew Drawing::Font(L"Arial", 11.25F, FontStyle::Bold, GraphicsUnit::Point, static_cast(162)); + this->dllStatusLabel->ForeColor = Color::FromArgb(245, 8, 83); + this->dllStatusLabel->Location = Point(6, 16); + this->dllStatusLabel->Name = L"dllStatusLabel"; + this->dllStatusLabel->Size = Drawing::Size(94, 18); + this->dllStatusLabel->TabIndex = 2; + this->dllStatusLabel->Text = L"Not Injected"; // - this->label3->AutoSize = true; - this->label3->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - this->label3->Font = (gcnew System::Drawing::Font(L"Arial", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast(162))); - this->label3->ForeColor = System::Drawing::Color::FromArgb(static_cast(static_cast(245)), static_cast(static_cast(8)), static_cast(static_cast(83))); - this->label3->Location = System::Drawing::Point(6, 16); - this->label3->Name = L"label3"; - this->label3->Size = System::Drawing::Size(82, 18); - this->label3->TabIndex = 3; - this->label3->Text = L"Not Found"; + // gameStatusLabel // - // groupBox1 + this->gameStatusLabel->AutoSize = true; + this->gameStatusLabel->FlatStyle = FlatStyle::Flat; + this->gameStatusLabel->Font = gcnew Drawing::Font(L"Arial", 11.25F, FontStyle::Bold, GraphicsUnit::Point, static_cast(162)); + this->gameStatusLabel->ForeColor = Color::FromArgb(245, 8, 83); + this->gameStatusLabel->Location = Point(6, 16); + this->gameStatusLabel->Name = L"gameStatusLabel"; + this->gameStatusLabel->Size = Drawing::Size(82, 18); + this->gameStatusLabel->TabIndex = 3; + this->gameStatusLabel->Text = L"Not Found"; // - this->groupBox1->Controls->Add(this->label1); - this->groupBox1->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - this->groupBox1->Font = (gcnew System::Drawing::Font(L"Arial", 6.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast(162))); - this->groupBox1->ForeColor = System::Drawing::Color::White; - this->groupBox1->Location = System::Drawing::Point(12, 79); - this->groupBox1->Name = L"groupBox1"; - this->groupBox1->Size = System::Drawing::Size(250, 45); - this->groupBox1->TabIndex = 5; - this->groupBox1->TabStop = false; - this->groupBox1->Text = L"Injector Status"; + // gameStatusLabel // - // groupBox2 + this->injectorStatusGroupBox->Controls->Add(this->injectorStatusLabel); + this->injectorStatusGroupBox->FlatStyle = FlatStyle::Flat; + this->injectorStatusGroupBox->Font = gcnew Drawing::Font(L"Arial", 6.75F, FontStyle::Bold, GraphicsUnit::Point, static_cast(162)); + this->injectorStatusGroupBox->ForeColor = Color::White; + this->injectorStatusGroupBox->Location = Point(12, 79); + this->injectorStatusGroupBox->Name = L"gameStatusLabel"; + this->injectorStatusGroupBox->Size = Drawing::Size(250, 45); + this->injectorStatusGroupBox->TabIndex = 5; + this->injectorStatusGroupBox->TabStop = false; + this->injectorStatusGroupBox->Text = L"Injector Status"; // - this->groupBox2->Controls->Add(this->label4); - this->groupBox2->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - this->groupBox2->Font = (gcnew System::Drawing::Font(L"Arial", 6.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast(162))); - this->groupBox2->ForeColor = System::Drawing::Color::White; - this->groupBox2->Location = System::Drawing::Point(12, 130); - this->groupBox2->Name = L"groupBox2"; - this->groupBox2->Size = System::Drawing::Size(250, 45); - this->groupBox2->TabIndex = 7; - this->groupBox2->TabStop = false; - this->groupBox2->Text = L"LeagueClient Status"; + // leagueClientStatusGroupBox // - // label4 + this->leagueClientStatusGroupBox->Controls->Add(this->clientStatusLabel); + this->leagueClientStatusGroupBox->FlatStyle = FlatStyle::Flat; + this->leagueClientStatusGroupBox->Font = gcnew Drawing::Font(L"Arial", 6.75F, FontStyle::Bold, GraphicsUnit::Point, static_cast(162)); + this->leagueClientStatusGroupBox->ForeColor = Color::White; + this->leagueClientStatusGroupBox->Location = Point(12, 130); + this->leagueClientStatusGroupBox->Name = L"leagueClientStatusGroupBox"; + this->leagueClientStatusGroupBox->Size = Drawing::Size(250, 45); + this->leagueClientStatusGroupBox->TabIndex = 7; + this->leagueClientStatusGroupBox->TabStop = false; + this->leagueClientStatusGroupBox->Text = L"LeagueClient Status"; // - this->label4->AutoSize = true; - this->label4->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - this->label4->Font = (gcnew System::Drawing::Font(L"Arial", 11.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast(162))); - this->label4->ForeColor = System::Drawing::Color::FromArgb(static_cast(static_cast(245)), static_cast(static_cast(8)), static_cast(static_cast(83))); - this->label4->Location = System::Drawing::Point(6, 16); - this->label4->Name = L"label4"; - this->label4->Size = System::Drawing::Size(82, 18); - this->label4->TabIndex = 0; - this->label4->Text = L"Not Found"; + // leagueGameStatusGroupBox + // + this->leagueGameStatusGroupBox->Controls->Add(this->gameStatusLabel); + this->leagueGameStatusGroupBox->FlatStyle = FlatStyle::Flat; + this->leagueGameStatusGroupBox->Font = gcnew Drawing::Font(L"Arial", 6.75F, FontStyle::Bold, GraphicsUnit::Point, static_cast(162)); + this->leagueGameStatusGroupBox->ForeColor = Color::White; + this->leagueGameStatusGroupBox->Location = Point(12, 181); + this->leagueGameStatusGroupBox->Name = L"leagueGameStatusGroupBox"; + this->leagueGameStatusGroupBox->Size = Drawing::Size(250, 45); + this->leagueGameStatusGroupBox->TabIndex = 8; + this->leagueGameStatusGroupBox->TabStop = false; + this->leagueGameStatusGroupBox->Text = L"LeagueGame Status"; // - // groupBox3 + // dllStatusGroupBox + // + this->dllStatusGroupBox->Controls->Add(this->dllStatusLabel); + this->dllStatusGroupBox->FlatStyle = FlatStyle::Flat; + this->dllStatusGroupBox->Font = gcnew Drawing::Font(L"Arial", 6.75F, FontStyle::Bold, GraphicsUnit::Point, static_cast(162)); + this->dllStatusGroupBox->ForeColor = Color::White; + this->dllStatusGroupBox->Location = Point(12, 232); + this->dllStatusGroupBox->Name = L"dllStatusGroupBox"; + this->dllStatusGroupBox->Size = Drawing::Size(250, 45); + this->dllStatusGroupBox->TabIndex = 9; + this->dllStatusGroupBox->TabStop = false; + this->dllStatusGroupBox->Text = L"R3nzSkin Status"; // - this->groupBox3->Controls->Add(this->label3); - this->groupBox3->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - this->groupBox3->Font = (gcnew System::Drawing::Font(L"Arial", 6.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast(162))); - this->groupBox3->ForeColor = System::Drawing::Color::White; - this->groupBox3->Location = System::Drawing::Point(12, 181); - this->groupBox3->Name = L"groupBox3"; - this->groupBox3->Size = System::Drawing::Size(250, 45); - this->groupBox3->TabIndex = 8; - this->groupBox3->TabStop = false; - this->groupBox3->Text = L"LeagueGame Status"; + // clientStatusLabel // - // groupBox4 + this->clientStatusLabel->AutoSize = true; + this->clientStatusLabel->FlatStyle = FlatStyle::Flat; + this->clientStatusLabel->Font = gcnew Drawing::Font(L"Arial", 11.25F, FontStyle::Bold, GraphicsUnit::Point, static_cast(162)); + this->clientStatusLabel->ForeColor = Color::FromArgb(245, 8, 83); + this->clientStatusLabel->Location = Point(6, 16); + this->clientStatusLabel->Name = L"clientStatusLabel"; + this->clientStatusLabel->Size = Drawing::Size(82, 18); + this->clientStatusLabel->TabIndex = 0; + this->clientStatusLabel->Text = L"Not Found"; // - this->groupBox4->Controls->Add(this->label2); - this->groupBox4->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - this->groupBox4->Font = (gcnew System::Drawing::Font(L"Arial", 6.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast(162))); - this->groupBox4->ForeColor = System::Drawing::Color::White; - this->groupBox4->Location = System::Drawing::Point(12, 232); - this->groupBox4->Name = L"groupBox4"; - this->groupBox4->Size = System::Drawing::Size(250, 45); - this->groupBox4->TabIndex = 9; - this->groupBox4->TabStop = false; - this->groupBox4->Text = L"R3nzSkin Status"; + // copyrightLabel // - // linkLabel1 - // - this->linkLabel1->AutoSize = true; - this->linkLabel1->Cursor = System::Windows::Forms::Cursors::Hand; - this->linkLabel1->LinkBehavior = System::Windows::Forms::LinkBehavior::NeverUnderline; - this->linkLabel1->LinkColor = System::Drawing::Color::Silver; - this->linkLabel1->Location = System::Drawing::Point(20, 284); - this->linkLabel1->Name = L"linkLabel1"; - this->linkLabel1->Size = System::Drawing::Size(207, 14); - this->linkLabel1->TabIndex = 11; - this->linkLabel1->TabStop = true; - this->linkLabel1->Text = L"Copyright (c) 2021-2023 R3nzTheCodeGOD"; - this->linkLabel1->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; - this->linkLabel1->LinkClicked += gcnew System::Windows::Forms::LinkLabelLinkClickedEventHandler(this, &R3nzUI::linkLabel1_LinkClicked); + this->copyrightLabel->AutoSize = true; + this->copyrightLabel->Cursor = Cursors::Hand; + this->copyrightLabel->LinkBehavior = LinkBehavior::NeverUnderline; + this->copyrightLabel->LinkColor = Color::Silver; + this->copyrightLabel->Location = Point(20, 284); + this->copyrightLabel->Name = L"copyrightLabel"; + this->copyrightLabel->Size = Drawing::Size(207, 14); + this->copyrightLabel->TabIndex = 11; + this->copyrightLabel->TabStop = true; + this->copyrightLabel->Text = L"Copyright (c) 2021-2023 R3nzTheCodeGOD"; + this->copyrightLabel->TextAlign = ContentAlignment::MiddleCenter; + this->copyrightLabel->LinkClicked += gcnew LinkLabelLinkClickedEventHandler(this, &R3nzUI::copyrightLabel_LinkClicked); // // contextMenu // @@ -300,58 +313,58 @@ namespace R3nzSkinInjector { // this->menuItem2->Index = 0; this->menuItem2->Text = L"Start"; - this->menuItem2->Click += gcnew System::EventHandler(this, &R3nzUI::menuItem2_OnClick); + this->menuItem2->Click += gcnew EventHandler(this, &R3nzUI::menuItem2_OnClick); this->menuItem->Index = 1; this->menuItem->Text = L"Exit"; - this->menuItem->Click += gcnew System::EventHandler(this, &R3nzUI::menuItem_OnClick); + this->menuItem->Click += gcnew EventHandler(this, &R3nzUI::menuItem_OnClick); // // notifyIcon // this->notifyIcon->Text = L"R3nzSkin"; - this->notifyIcon->Icon = (cli::safe_cast(resources->GetObject(L"$this.Icon"))); + this->notifyIcon->Icon = cli::safe_cast(resources->GetObject(L"$this.Icon")); this->notifyIcon->Visible = false; this->notifyIcon->ContextMenu = this->contextMenu; - this->notifyIcon->MouseDoubleClick += gcnew System::Windows::Forms::MouseEventHandler(this, &R3nzUI::notifyIcon_MouseDoubleClick); + this->notifyIcon->MouseDoubleClick += gcnew MouseEventHandler(this, &R3nzUI::notifyIcon_MouseDoubleClick); // // menuStrip // this->toolstripmenuItem->Text = L"Preferences"; this->toolstripmenuItem2->Text = L"Hide to tray"; - this->toolstripmenuItem2->Click += gcnew System::EventHandler(this, &R3nzUI::toolstripmenuItem2_OnClick); + this->toolstripmenuItem2->Click += gcnew EventHandler(this, &R3nzUI::toolstripmenuItem2_OnClick); this->toolstripmenuItem->DropDownItems->Add(this->toolstripmenuItem2); this->menuStrip->Items->Add(this->toolstripmenuItem); // // R3nzUI // - this->AutoScaleDimensions = System::Drawing::SizeF(7, 14); - this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; - this->BackColor = System::Drawing::Color::FromArgb(static_cast(static_cast(32)), static_cast(static_cast(30)), static_cast(static_cast(30))); - this->ClientSize = System::Drawing::Size(273, 307); + this->AutoScaleDimensions = SizeF(7, 14); + this->AutoScaleMode = Windows::Forms::AutoScaleMode::Font; + this->BackColor = Color::FromArgb(32, 30, 30); + this->ClientSize = Drawing::Size(273, 307); this->Controls->Add(this->menuStrip); - this->Controls->Add(this->linkLabel1); - this->Controls->Add(this->groupBox4); - this->Controls->Add(this->groupBox3); - this->Controls->Add(this->groupBox2); - this->Controls->Add(this->groupBox1); - this->Controls->Add(this->button1); - this->Cursor = System::Windows::Forms::Cursors::Arrow; - this->Font = (gcnew System::Drawing::Font(L"Arial", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast(162))); - this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D; - this->Icon = (cli::safe_cast(resources->GetObject(L"$this.Icon"))); + this->Controls->Add(this->copyrightLabel); + this->Controls->Add(this->dllStatusGroupBox); + this->Controls->Add(this->leagueGameStatusGroupBox); + this->Controls->Add(this->leagueClientStatusGroupBox); + this->Controls->Add(this->injectorStatusGroupBox); + this->Controls->Add(this->startButton); + this->Cursor = Cursors::Arrow; + this->Font = gcnew Drawing::Font(L"Arial", 8.25F, FontStyle::Bold, GraphicsUnit::Point, static_cast(162)); + this->FormBorderStyle = Windows::Forms::FormBorderStyle::Fixed3D; + this->Icon = cli::safe_cast(resources->GetObject(L"$this.Icon")); this->MaximizeBox = false; this->Name = L"R3nzUI"; - this->RightToLeft = System::Windows::Forms::RightToLeft::No; + this->RightToLeft = Windows::Forms::RightToLeft::No; this->Text = L""; - this->Load += gcnew System::EventHandler(this, &R3nzUI::R3nzUI_Load); - this->Resize += gcnew System::EventHandler(this, &R3nzUI::R3nzUI_Resize); - this->groupBox1->ResumeLayout(false); - this->groupBox1->PerformLayout(); - this->groupBox2->ResumeLayout(false); - this->groupBox2->PerformLayout(); - this->groupBox3->ResumeLayout(false); - this->groupBox3->PerformLayout(); - this->groupBox4->ResumeLayout(false); - this->groupBox4->PerformLayout(); + this->Load += gcnew EventHandler(this, &R3nzUI::R3nzUI_Load); + this->Resize += gcnew EventHandler(this, &R3nzUI::R3nzUI_Resize); + this->injectorStatusGroupBox->ResumeLayout(false); + this->injectorStatusGroupBox->PerformLayout(); + this->leagueClientStatusGroupBox->ResumeLayout(false); + this->leagueClientStatusGroupBox->PerformLayout(); + this->leagueGameStatusGroupBox->ResumeLayout(false); + this->leagueGameStatusGroupBox->PerformLayout(); + this->dllStatusGroupBox->ResumeLayout(false); + this->dllStatusGroupBox->PerformLayout(); this->menuStrip->ResumeLayout(false); this->menuStrip->PerformLayout(); this->ResumeLayout(false); @@ -359,41 +372,44 @@ namespace R3nzSkinInjector { } #pragma endregion private: - System::Void R3nzUI_Load(System::Object^ sender, System::EventArgs^ e) + Void R3nzUI_Load(Object^ sender, EventArgs^ e) { - System::AppDomain::CurrentDomain->UnhandledException += gcnew System::UnhandledExceptionEventHandler(this, &R3nzUI::R3nzUI_ExceptionHandler); + AppDomain::CurrentDomain->UnhandledException += gcnew UnhandledExceptionEventHandler(this, &R3nzUI::R3nzUI_ExceptionHandler); } private: - System::Void R3nzUI_ExceptionHandler(System::Object^ sender, System::UnhandledExceptionEventArgs^ e) + Void R3nzUI_ExceptionHandler(Object^ sender, UnhandledExceptionEventArgs^ e) { - const auto exception = dynamic_cast(e->ExceptionObject)->Message; + const auto exception = dynamic_cast(e->ExceptionObject)->Message; MessageBox::Show(exception); } private: - System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) + Void startButton_Click(Object^ sender, EventArgs^ e) { btnState = !btnState; - if (btnState) { - this->button1->BackColor = System::Drawing::Color::FromArgb(255, 252, 220, 107); - this->label1->ForeColor = System::Drawing::Color::FromArgb(255, 252, 220, 107); - this->button1->Text = L"Stop"; - this->label1->Text = L"Working"; + if (btnState) + { + this->startButton->BackColor = Color::FromArgb(255, 252, 220, 107); + this->injectorStatusLabel->ForeColor = Color::FromArgb(255, 252, 220, 107); + this->startButton->Text = L"Stop"; + this->injectorStatusLabel->Text = L"Working"; this->menuItem2->Text = L"Stop"; - } else { - this->button1->BackColor = System::Drawing::Color::FromArgb(255, 245, 8, 83); - this->label1->ForeColor = System::Drawing::Color::FromArgb(255, 245, 8, 83); - this->button1->Text = L"Start"; - this->label1->Text = L"Stopped"; + } + else + { + this->startButton->BackColor = Color::FromArgb(255, 245, 8, 83); + this->injectorStatusLabel->ForeColor = Color::FromArgb(255, 245, 8, 83); + this->startButton->Text = L"Start"; + this->injectorStatusLabel->Text = L"Stopped"; this->menuItem2->Text = L"Start"; } } private: - System::Void linkLabel1_LinkClicked(System::Object^ sender, System::Windows::Forms::LinkLabelLinkClickedEventArgs^ e) + Void copyrightLabel_LinkClicked(Object^ sender, LinkLabelLinkClickedEventArgs^ e) { - System::Diagnostics::Process::Start(L"https://github.com/R3nzTheCodeGOD/R3nzSkin"); + Diagnostics::Process::Start(L"https://github.com/R3nzTheCodeGOD/R3nzSkin"); } private: - System::Void R3nzUI_Resize(System::Object^ sender, System::EventArgs^ e) + Void R3nzUI_Resize(Object^ sender, EventArgs^ e) { if (this->WindowState == FormWindowState::Minimized) { @@ -405,7 +421,7 @@ namespace R3nzSkinInjector { } } private: - System::Void notifyIcon_MouseDoubleClick(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) + Void notifyIcon_MouseDoubleClick(Object^ sender, MouseEventArgs^ e) { if (this->toolstripmenuItem2->Checked) { @@ -415,17 +431,17 @@ namespace R3nzSkinInjector { } } private: - System::Void menuItem_OnClick(System::Object^ sender, System::EventArgs^ e) + Void menuItem_OnClick(Object^ sender, EventArgs^ e) { this->Close(); } private: - System::Void menuItem2_OnClick(System::Object^ sender, System::EventArgs^ e) + Void menuItem2_OnClick(Object^ sender, EventArgs^ e) { - this->button1_Click(nullptr, nullptr); + this->startButton_Click(nullptr, nullptr); } private: - System::Void toolstripmenuItem2_OnClick(System::Object^ sender, System::EventArgs^ e) + Void toolstripmenuItem2_OnClick(Object^ sender, EventArgs^ e) { this->toolstripmenuItem2->Checked = !this->toolstripmenuItem2->Checked; this->saveSettings(); diff --git a/R3nzSkin_Injector/main.cpp b/R3nzSkin_Injector/main.cpp index 94fba817..c443cf36 100644 --- a/R3nzSkin_Injector/main.cpp +++ b/R3nzSkin_Injector/main.cpp @@ -7,7 +7,6 @@ #include "R3nzUI.hpp" #include "Injector.hpp" -#include "lazy_importer.hpp" using namespace System; using namespace System::Windows::Forms; diff --git a/R3nzSkin_Injector/xorstr.hpp b/R3nzSkin_Injector/xorstr.hpp new file mode 100644 index 00000000..d03bcc75 --- /dev/null +++ b/R3nzSkin_Injector/xorstr.hpp @@ -0,0 +1,78 @@ +#pragma once +#include + +namespace XorCompileTime +{ + constexpr auto time = __TIME__; + constexpr auto seed = static_cast(time[7]) + static_cast(time[6]) * 10 + static_cast(time[4]) * 60 + static_cast(time[3]) * 600 + static_cast(time[1]) * 3600 + static_cast(time[0]) * 36000; + + template + struct RandomGenerator + { + private: + static constexpr unsigned a = 0x41a7; // 7^5 + static constexpr unsigned m = 0x7fffffff; // 2^31 - 1 + + static constexpr unsigned s = RandomGenerator< N - 1 >::value; + static constexpr unsigned lo = a * (s & 0xFFFF); // Multiply lower 16 bits by 16807 + static constexpr unsigned hi = a * (s >> 16); // Multiply higher 16 bits by 16807 + static constexpr unsigned lo2 = lo + ((hi & 0x7FFF) << 16); // Combine lower 15 bits of hi with lo's upper bits + static constexpr unsigned hi2 = hi >> 15; // Discard lower 15 bits of hi + static constexpr unsigned lo3 = lo2 + hi; + + public: + static constexpr unsigned max = m; + static constexpr unsigned value = lo3 > m ? lo3 - m : lo3; + }; + + template<> + struct RandomGenerator<0> + { + static constexpr unsigned value = seed; + }; + + template + struct RandomInt + { + static constexpr auto value = RandomGenerator::value % M; + }; + + template + struct RandomChar + { + static const char value = static_cast(1 + RandomInt::value); + }; + + template + struct XorString + { + private: + const char _key; + std::array _encrypted; + + constexpr Char enc(Char c) const + { + return c ^ _key; + } + + Char dec(Char c) const + { + return c ^ _key; + } + + public: + template + constexpr __forceinline XorString(const Char* str, std::index_sequence< Is... >) : _key(RandomChar::value), _encrypted{ enc(str[Is])... } {} + + __forceinline decltype(auto) decrypt() + { + for (size_t i = 0; i < N; ++i) { + _encrypted[i] = dec(_encrypted[i]); + } + _encrypted[N] = '\0'; + return _encrypted.data(); + } + }; + #define _XorStr(s) []{ constexpr XorCompileTime::XorString expr(s, std::make_index_sequence()); return expr; }().decrypt() + #define _XorStrW(s) []{ constexpr XorCompileTime::XorString expr(s, std::make_index_sequence()); return expr; }().decrypt() +} \ No newline at end of file