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

Commit 260ef5e

Browse files
committed
Resolved False Positive Antivirus Alerts
1 parent 85e1608 commit 260ef5e

File tree

6 files changed

+359
-259
lines changed

6 files changed

+359
-259
lines changed

R3nzSkin_Injector/Injector.cpp

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "Injector.hpp"
1212
#include "R3nzUI.hpp"
13+
#include "xorstr.hpp"
1314
#include "lazy_importer.hpp"
1415

1516
using namespace System;
@@ -18,6 +19,8 @@ using namespace System::Threading;
1819
using namespace System::Globalization;
1920
using namespace System::Net;
2021

22+
#define xor_clrstr_w(x) msclr::interop::marshal_as<String^>(static_cast<std::wstring>(_XorStrW(x)))
23+
2124
proclist_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.\nTry reinstalling the cheat.", L"R3nzSkin", MB_ICONERROR | MB_OK);
98+
LI_FN(MessageBoxW)(nullptr, _XorStrW(L"R3nzSkin.dll file could not be found.\nTry 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\nWould 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\nWould 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;

R3nzSkin_Injector/R3nzSkin_Injector.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@
207207
<FileType>CppForm</FileType>
208208
</ClInclude>
209209
<ClInclude Include="resource.h" />
210+
<ClInclude Include="xorstr.hpp" />
210211
</ItemGroup>
211212
<ItemGroup>
212213
<ResourceCompile Include="R3nzSkin_Injector.rc" />

R3nzSkin_Injector/R3nzSkin_Injector.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
<ClInclude Include="lazy_importer.hpp">
3636
<Filter>Source Files</Filter>
3737
</ClInclude>
38+
<ClInclude Include="xorstr.hpp">
39+
<Filter>Source Files</Filter>
40+
</ClInclude>
3841
</ItemGroup>
3942
<ItemGroup>
4043
<Image Include="icon.ico">

0 commit comments

Comments
 (0)