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

Commit

Permalink
Injector optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
hotline1337 committed Apr 26, 2023
1 parent 6b5c4ed commit d993df8
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 29 deletions.
6 changes: 3 additions & 3 deletions R3nzSkin/R3nzSkin.rc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// T�rk�e (T�rkiye) resources
// Turkish (Turkey) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_TRK)
LANGUAGE LANG_TURKISH, SUBLANG_DEFAULT
Expand Down Expand Up @@ -71,7 +71,7 @@ BEGIN
VALUE "FileDescription", "R3nzSkin DLL"
VALUE "FileVersion", "1.0.0.0"
VALUE "InternalName", "R3nzSkin.dll"
VALUE "LegalCopyright", "Copyright (c) 2021-2022 Erdem Y�lmaz"
VALUE "LegalCopyright", "Copyright (c) 2021-2023 Erdem Y�lmaz"
VALUE "OriginalFilename", "R3nzSkin.dll"
VALUE "ProductName", "R3nzSkin DLL"
VALUE "ProductVersion", "1.0.0.0"
Expand All @@ -83,7 +83,7 @@ BEGIN
END
END

#endif // T�rk�e (T�rkiye) resources
#endif // Turkish (Turkey) resources
/////////////////////////////////////////////////////////////////////////////


Expand Down
2 changes: 1 addition & 1 deletion R3nzSkin/R3nzSkin.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RiotGamesServers|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
Expand Down
26 changes: 11 additions & 15 deletions R3nzSkin_Injector/Injector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ proclist_t WINAPI Injector::findProcesses(const std::wstring name) noexcept
if (process_snap == INVALID_HANDLE_VALUE)
return list;

PROCESSENTRY32W pe32;
PROCESSENTRY32W pe32{};
pe32.dwSize = sizeof(PROCESSENTRY32W);

if (LI_FN(Process32FirstW).get()(process_snap, &pe32)) {
Expand All @@ -43,7 +43,7 @@ bool WINAPI Injector::isInjected(const std::uint32_t pid) noexcept
return false;

HMODULE hMods[1024];
DWORD cbNeeded;
DWORD cbNeeded{};

if (LI_FN(K32EnumProcessModules)(hProcess, hMods, sizeof(hMods), &cbNeeded)) {
for (auto i{ 0u }; i < (cbNeeded / sizeof(HMODULE)); ++i) {
Expand All @@ -69,11 +69,11 @@ bool WINAPI Injector::inject(const std::uint32_t pid) noexcept
if (!handle || handle == INVALID_HANDLE_VALUE)
return false;

FILETIME ft;
SYSTEMTIME st;
FILETIME ft{};
SYSTEMTIME st{};
LI_FN(GetSystemTime)(&st);
LI_FN(SystemTimeToFileTime)(&st, &ft);
FILETIME create, exit, kernel, user;
FILETIME create{}, exit{}, kernel{}, user{};
LI_FN(GetProcessTimes)(handle, &create, &exit, &kernel, &user);

const auto delta{ 10 - static_cast<std::int32_t>((*reinterpret_cast<std::uint64_t*>(&ft) - *reinterpret_cast<std::uint64_t*>(&create.dwLowDateTime)) / 10000000U) };
Expand Down Expand Up @@ -102,8 +102,8 @@ bool WINAPI Injector::inject(const std::uint32_t pid) noexcept
return false;
}

HANDLE thread;
LI_FN(NtCreateThreadEx).nt_cached()(&thread, GENERIC_ALL, NULL, handle, reinterpret_cast<LPTHREAD_START_ROUTINE>(::GetProcAddress(::GetModuleHandle(L"kernel32.dll"), "LoadLibraryW")), dll_path_remote, FALSE, NULL, NULL, NULL, NULL);
HANDLE thread{};
LI_FN(NtCreateThreadEx).nt_cached()(&thread, GENERIC_ALL, NULL, 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);

if (!thread || thread == INVALID_HANDLE_VALUE) {
LI_FN(VirtualFreeEx).get()(handle, dll_path_remote, 0u, MEM_RELEASE);
Expand All @@ -120,9 +120,8 @@ bool WINAPI Injector::inject(const std::uint32_t pid) noexcept

void WINAPI Injector::enableDebugPrivilege() noexcept
{
HANDLE token;

if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token)) {
HANDLE token{};
if (OpenProcessToken(LI_FN(GetCurrentProcess).get()(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token)) {
LUID value;
if (LookupPrivilegeValueW(NULL, SE_DEBUG_NAME, &value)) {
TOKEN_PRIVILEGES tp{};
Expand Down Expand Up @@ -162,18 +161,15 @@ void Injector::renameExe() noexcept
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 leagueProcessesSize{ league_processes.size() };
R3nzSkinInjector::gameState = (leagueProcessesSize > 0) ? true : false;
R3nzSkinInjector::gameState = (league_processes.size() > 0) ? true : false;
R3nzSkinInjector::clientState = (league_client_processes.size() > 0) ? true : false;

// antiviruses don't like endless loops, show them that this loop is a breaking point. (technically still an infinite loop :D)
if (leagueProcessesSize > 0xff)
if (league_processes.size() > 0xff)
break;

for (auto& pid : league_processes) {
Expand Down
6 changes: 3 additions & 3 deletions R3nzSkin_Injector/R3nzSkin_Injector.rc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// T�rk�e (T�rkiye) resources
// Turkish (Turkey) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_TRK)
LANGUAGE LANG_TURKISH, SUBLANG_DEFAULT
Expand Down Expand Up @@ -71,7 +71,7 @@ BEGIN
VALUE "FileDescription", "R3nSkin DLL Injector"
VALUE "FileVersion", "1.0.0.0"
VALUE "InternalName", "R3nzSkin.exe"
VALUE "LegalCopyright", "Copyright (c) 2021-2022 Erdem Y�lmaz"
VALUE "LegalCopyright", "Copyright (c) 2021-2023 Erdem Y�lmaz"
VALUE "OriginalFilename", "R3nzSkin.exe"
VALUE "ProductName", "R3nSkin DLL Injector"
VALUE "ProductVersion", "1.0.0.0"
Expand All @@ -93,7 +93,7 @@ END
// remains consistent on all systems.
IDI_ICON1 ICON "icon.ico"

#endif // T�rk�e (T�rkiye) resources
#endif // Turkish (Turkey) resources
/////////////////////////////////////////////////////////////////////////////


Expand Down
11 changes: 7 additions & 4 deletions R3nzSkin_Injector/R3nzSkin_Injector.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<RootNamespace>R3nzSkinInjector</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>R3nzSkin_Injector</ProjectName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RiotGamesServers|Win32'" Label="Configuration">
Expand All @@ -41,7 +41,7 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>true</CLRSupport>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
Expand Down Expand Up @@ -120,9 +120,9 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RiotGamesServers|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<WarningLevel>Level2</WarningLevel>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<SDLCheck>false</SDLCheck>
<PreprocessorDefinitions>WIN32;_RIOT;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<LanguageStandard>stdcpp17</LanguageStandard>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
Expand All @@ -138,6 +138,7 @@
<CreateHotpatchableImage>false</CreateHotpatchableImage>
<StringPooling>true</StringPooling>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -147,6 +148,8 @@
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
<EntryPointSymbol>main</EntryPointSymbol>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<SetChecksum>true</SetChecksum>
<CLRThreadAttribute>STAThreadingAttribute</CLRThreadAttribute>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ChinaServer|Win32'">
Expand Down
2 changes: 1 addition & 1 deletion R3nzSkin_Injector/R3nzUI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace R3nzSkinInjector {
#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(R3nzUI::typeid));
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());
Expand Down
3 changes: 1 addition & 2 deletions R3nzSkin_Injector/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ using namespace System;
using namespace System::Windows::Forms;
using namespace System::Threading;

[STAThread]
int main([[maybe_unused]] array<String^>^ args)
{
std::srand(static_cast<unsigned int>(std::time(nullptr)));
Expand All @@ -21,7 +20,7 @@ int main([[maybe_unused]] array<String^>^ args)
R3nzSkinInjector::R3nzUI form;

auto thread{ std::thread(Injector::run) };
Thread^ 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 d993df8

Please sign in to comment.