1010
1111#include " Injector.hpp"
1212#include " R3nzUI.hpp"
13+ #include " xorstr.hpp"
1314#include " lazy_importer.hpp"
1415
1516using namespace System ;
@@ -18,6 +19,8 @@ using namespace System::Threading;
1819using namespace System ::Globalization;
1920using namespace System ::Net;
2021
22+ #define xor_clrstr_w (x ) msclr::interop::marshal_as<String^>(static_cast <std::wstring>(_XorStrW(x)))
23+
2124proclist_t WINAPI Injector::findProcesses (const std::wstring& name) noexcept
2225{
2326 auto process_snap{ LI_FN (CreateToolhelp32Snapshot)(TH32CS_SNAPPROCESS, 0 ) };
@@ -57,7 +60,7 @@ bool WINAPI Injector::isInjected(const std::uint32_t pid) noexcept
5760 for (auto i{ 0u }; i < (cbNeeded / sizeof (HMODULE)); ++i) {
5861 TCHAR szModName[MAX_PATH];
5962 if (LI_FN (K32GetModuleBaseNameW)(hProcess, hMods[i], szModName, sizeof (szModName) / sizeof (TCHAR))) {
60- if (std::wcscmp (szModName, L" R3nzSkin.dll" ) == 0 ) {
63+ if (std::wcscmp (szModName, _XorStrW ( L" R3nzSkin.dll" ) ) == 0 ) {
6164 LI_FN (CloseHandle)(hProcess);
6265 return true ;
6366 }
@@ -89,10 +92,10 @@ bool WINAPI Injector::inject(const std::uint32_t pid) noexcept
8992 if (delta > 0 )
9093 std::this_thread::sleep_for (std::chrono::seconds (delta));
9194
92- const auto dll_path{ std::wstring (current_dir) + L" \\ R3nzSkin.dll" };
95+ const auto dll_path{ std::wstring (current_dir) + _XorStrW ( L" \\ R3nzSkin.dll" ) };
9396
9497 if (const auto f{ std::ifstream (dll_path) }; !f.is_open ()) {
95- LI_FN (MessageBoxW)(nullptr , L" R3nzSkin.dll file could not be found.\n Try reinstalling the cheat." , L" R3nzSkin" , MB_ICONERROR | MB_OK);
98+ LI_FN (MessageBoxW)(nullptr , _XorStrW ( L" R3nzSkin.dll file could not be found.\n Try reinstalling the cheat." ), _XorStrW ( L" R3nzSkin" ) , MB_ICONERROR | MB_OK);
9699 LI_FN (CloseHandle)(handle);
97100 return false ;
98101 }
@@ -111,7 +114,7 @@ bool WINAPI Injector::inject(const std::uint32_t pid) noexcept
111114 }
112115
113116 HANDLE thread{};
114- LI_FN (NtCreateThreadEx).nt_cached ()(&thread, GENERIC_ALL, nullptr , handle, reinterpret_cast <LPTHREAD_START_ROUTINE>(LI_FN (GetProcAddress).get ()(LI_FN (GetModuleHandleW).get ()(L" kernel32.dll" ), " LoadLibraryW" )), dll_path_remote, FALSE , NULL , NULL , NULL , NULL );
117+ LI_FN (NtCreateThreadEx).nt_cached ()(&thread, GENERIC_ALL, nullptr , handle, reinterpret_cast <LPTHREAD_START_ROUTINE>(LI_FN (GetProcAddress).get ()(LI_FN (GetModuleHandleW).get ()(_XorStrW ( L" kernel32.dll" )), _XorStr ( " LoadLibraryW" ))) , dll_path_remote, FALSE , NULL , NULL , NULL , nullptr );
115118
116119 if (!thread || thread == INVALID_HANDLE_VALUE) {
117120 LI_FN (VirtualFreeEx).get ()(handle, dll_path_remote, 0u , MEM_RELEASE);
@@ -131,7 +134,7 @@ void WINAPI Injector::enableDebugPrivilege() noexcept
131134 HANDLE token{};
132135 if (OpenProcessToken (LI_FN (GetCurrentProcess).get ()(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token)) {
133136 LUID value;
134- if (LookupPrivilegeValueW (nullptr , SE_DEBUG_NAME, &value)) {
137+ if (LookupPrivilegeValueW (nullptr , _XorStrW ( SE_DEBUG_NAME) , &value)) {
135138 TOKEN_PRIVILEGES tp{};
136139 tp.PrivilegeCount = 1 ;
137140 tp.Privileges [0 ].Luid = value;
@@ -147,58 +150,58 @@ void Injector::autoUpdate()
147150 auto client = gcnew WebClient ();
148151 ServicePointManager::Expect100Continue = true ;
149152 ServicePointManager::SecurityProtocol = SecurityProtocolType::Tls12;
150- client->Headers ->Add (L" User-Agent" , L" Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0" );
153+ 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" ) );
151154
152155 try
153156 {
154- auto json = msclr::interop::marshal_as<std::string>(client->DownloadString (L" https://api.github.com/repos/R3nzTheCodeGOD/R3nzSkin/releases/latest" ));
155- std::regex tagnameRegex (" \" tag_name\"\\ s*:\\ s*\" ([^\" ]+)" );
156- std::regex urlRegex (" \" browser_download_url\"\\ s*:\\ s*\" ([^\" ]+)" );
157- std::regex dateRegex (" \" created_at\"\\ s*:\\ s*\" ([^\" ]+)" );
157+ auto json = msclr::interop::marshal_as<std::string>(client->DownloadString (xor_clrstr_w ( L" https://api.github.com/repos/R3nzTheCodeGOD/R3nzSkin/releases/latest" ) ));
158+ std::regex tagnameRegex (_XorStr ( " \" tag_name\"\\ s*:\\ s*\" ([^\" ]+)" ) );
159+ std::regex urlRegex (_XorStr ( " \" browser_download_url\"\\ s*:\\ s*\" ([^\" ]+)" ) );
160+ std::regex dateRegex (_XorStr ( " \" created_at\"\\ s*:\\ s*\" ([^\" ]+)" ) );
158161
159162 if (std::smatch tagnameMatch; std::regex_search (json, tagnameMatch, tagnameRegex))
160163 {
161164 auto version = gcnew String (tagnameMatch[1 ].str ().c_str ());
162165 if (std::smatch dateMatch; std::regex_search (json, dateMatch, dateRegex))
163166 {
164- if (!System::IO::File::Exists (L" R3nzSkin.dll" ))
167+ if (!System::IO::File::Exists (xor_clrstr_w ( L" R3nzSkin.dll" ) ))
165168 {
166- throw gcnew Exception (L" Failed to find R3nzSkin.dll in the current directory" );
169+ throw gcnew Exception (xor_clrstr_w ( L" Failed to find R3nzSkin.dll in the current directory" ) );
167170 }
168- 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" );
169- auto date_of_current_release = System::IO::File::GetLastWriteTime (L" R3nzSkin.dll" ).ToString (L" dd.MM.yyyy HH:00" );
171+ 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" ) );
172+ 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" ) );
170173 if (date_of_current_release != date_of_github_release)
171174 {
172- auto date_of_github_release_class = DateTime::ParseExact (date_of_github_release, L" dd.MM.yyyy HH:00" , CultureInfo::InvariantCulture);
173- auto date_of_current_release_class = DateTime::ParseExact (date_of_current_release, L" dd.MM.yyyy HH:00" , CultureInfo::InvariantCulture);
175+ const auto date_of_github_release_class = DateTime::ParseExact (date_of_github_release, xor_clrstr_w ( L" dd.MM.yyyy HH:00" ) , CultureInfo::InvariantCulture);
176+ const auto date_of_current_release_class = DateTime::ParseExact (date_of_current_release, xor_clrstr_w ( L" dd.MM.yyyy HH:00" ) , CultureInfo::InvariantCulture);
174177 if (date_of_current_release_class > date_of_github_release_class)
175178 {
176179 return ;
177180 }
178181
179- auto result = MessageBox::Show (L" New version is available on GitHub\n Would you like to download it now?" , L" R3nzSkin" , MessageBoxButtons::YesNo, MessageBoxIcon::Information);
182+ const auto result = MessageBox::Show (xor_clrstr_w ( L" New version is available on GitHub\n Would you like to download it now?" ), xor_clrstr_w ( L" R3nzSkin" ) , MessageBoxButtons::YesNo, MessageBoxIcon::Information);
180183 if (result == DialogResult::Yes)
181184 {
182185 if (std::smatch urlMatch; std::regex_search (json, urlMatch, urlRegex))
183186 {
184187 auto url = gcnew String (urlMatch[1 ].str ().c_str ());
185- auto file = String::Format (L" R3nzSkin_{0}.zip" , version);
188+ auto file = String::Format (xor_clrstr_w ( L" R3nzSkin_{0}.zip" ) , version);
186189 client->DownloadFile (url, file);
187190
188- System::IO::Compression::ZipFile::ExtractToDirectory (file, L" R3nzSkin" );
191+ System::IO::Compression::ZipFile::ExtractToDirectory (file, xor_clrstr_w ( L" R3nzSkin" ) );
189192 System::IO::File::Delete (file);
190- System::IO::File::Delete (L" R3nzSkin.dll" );
191- System::IO::File::Move (L" R3nzSkin\\ R3nzSkin_Injector.exe" , String::Format (L" R3nzSkin_Injector_{0}.exe" , version));
192- System::IO::File::Move (L" R3nzSkin\\ R3nzSkin.dll" , L" R3nzSkin.dll" );
193- System::IO::Directory::Delete (L" R3nzSkin" );
193+ System::IO::File::Delete (xor_clrstr_w ( L" R3nzSkin.dll" ) );
194+ System::IO::File::Move (xor_clrstr_w ( L" R3nzSkin\\ R3nzSkin_Injector.exe" ) , String::Format (xor_clrstr_w ( L" R3nzSkin_Injector_{0}.exe" ) , version));
195+ System::IO::File::Move (xor_clrstr_w ( L" R3nzSkin\\ R3nzSkin.dll" ), xor_clrstr_w ( L" R3nzSkin.dll" ) );
196+ System::IO::Directory::Delete (xor_clrstr_w ( L" R3nzSkin" ) );
194197
195198 auto process_info = gcnew System::Diagnostics::ProcessStartInfo ();
196- process_info->Arguments = L" /C choice /C Y /N /D Y /T 1 & del \" " + System::Diagnostics::Process::GetCurrentProcess ()->MainModule ->FileName + L" \" " ;
199+ 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" \" " ) ;
197200 process_info->CreateNoWindow = true ;
198- process_info->FileName = L" cmd.exe" ;
201+ process_info->FileName = xor_clrstr_w ( L" cmd.exe" ) ;
199202 process_info->WindowStyle = System::Diagnostics::ProcessWindowStyle::Hidden;
200203 System::Diagnostics::Process::Start (process_info);
201- System::Diagnostics::Process::Start (String::Format (L" R3nzSkin_Injector_{0}.exe" , version));
204+ System::Diagnostics::Process::Start (String::Format (xor_clrstr_w ( L" R3nzSkin_Injector_{0}.exe" ) , version));
202205
203206 Environment::Exit (0 );
204207 }
@@ -209,7 +212,7 @@ void Injector::autoUpdate()
209212 }
210213 catch (Exception^ e)
211214 {
212- MessageBox::Show (String::Format (L" {0} - {1}" , e->Message , e->StackTrace ->Substring (5 )), L" R3nzSkin" , MessageBoxButtons::OK, MessageBoxIcon::Error);
215+ 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);
213216 Environment::Exit (0 );
214217 }
215218}
@@ -218,8 +221,8 @@ void Injector::run() noexcept
218221{
219222 enableDebugPrivilege ();
220223 while (true ) {
221- const auto & league_client_processes{ Injector::findProcesses (L" LeagueClient.exe" ) };
222- const auto & league_processes{ Injector::findProcesses (L" League of Legends.exe" ) };
224+ const auto & league_client_processes{ Injector::findProcesses (_XorStrW ( L" LeagueClient.exe" ) ) };
225+ const auto & league_processes{ Injector::findProcesses (_XorStrW ( L" League of Legends.exe" ) ) };
223226
224227 R3nzSkinInjector::gameState = (league_processes.size () > 0 ) ? true : false ;
225228 R3nzSkinInjector::clientState = (league_client_processes.size () > 0 ) ? true : false ;
0 commit comments