From 2756183a56b2934d32585f263551569c80138fc2 Mon Sep 17 00:00:00 2001 From: Whindmar Saksit Date: Sat, 18 May 2024 15:03:58 +0200 Subject: [PATCH] Don't copy version.dll (#49) There is no need to copy the original version.dll, just load it with the full path to system32. --- src/loader/main.cpp | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/src/loader/main.cpp b/src/loader/main.cpp index d1bc6f7..81b93cd 100644 --- a/src/loader/main.cpp +++ b/src/loader/main.cpp @@ -5,8 +5,6 @@ extern "C" extern void FuckOffEAAppSetup(); } -HINSTANCE hL = 0; - const std::wstring GetExePathWide() { WCHAR result[MAX_PATH]; @@ -39,37 +37,14 @@ void LibraryLoadError(DWORD dwMessageId, const wchar_t* libName, const wchar_t* void LoadProxiedLibrary() { - auto exePath = GetExePathWide(); - wchar_t org_dll[MAX_PATH]; GetSystemDirectoryW(org_dll, MAX_PATH); - swprintf_s(org_dll, L"%s\\version.dll", org_dll); - - auto temp_path = std::filesystem::temp_directory_path() / L"version.org.dll"; - - try - { - std::filesystem::copy_file(org_dll, temp_path); - } - catch (const std::exception& e) - { - if (!std::filesystem::exists(temp_path)) - { - wchar_t buffer[4096]; - swprintf_s( - buffer, - L"Failed copying version.dll from system32 to \"%s\"\n\n%S\n\n", - temp_path.c_str(), - e.what()); - MessageBoxW(GetForegroundWindow(), buffer, ERROR_MSGBOX_CAPTION_L, MB_ICONERROR); - return; - } - } + lstrcatW(org_dll, L"\\version.dll"); - hL = LoadLibraryExW(temp_path.c_str(), 0, LOAD_WITH_ALTERED_SEARCH_PATH); + HINSTANCE hL = LoadLibraryExW(org_dll, 0, LOAD_WITH_ALTERED_SEARCH_PATH); if (!hL) { - LibraryLoadError(GetLastError(), L"version.org.dll", temp_path.c_str()); + LibraryLoadError(GetLastError(), L"version.dll", org_dll); return; }