diff --git a/UE4SS/CMakeLists.txt b/UE4SS/CMakeLists.txt index b00f0f73..b831163e 100644 --- a/UE4SS/CMakeLists.txt +++ b/UE4SS/CMakeLists.txt @@ -3,11 +3,6 @@ project(UE4SS) message("Configuring UE4SS") -# Add proxy generator subproject (generates Windows proxy DLLs; PE-format specific) -if(WIN32) - add_subdirectory("proxy_generator") -endif() - # Release settings option(UE4SS_LIB_BETA_IS_STARTED "Have beta releases started for the current major version" ON) option(UE4SS_LIB_IS_BETA "Is this a beta release" ON) diff --git a/UE4SS/proxy_generator/CMakeLists.txt b/UE4SS/proxy_generator/CMakeLists.txt deleted file mode 100644 index 71d041f5..00000000 --- a/UE4SS/proxy_generator/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.22) - -set(TARGET proxy_generator) -project(${TARGET}) - -add_executable(${TARGET} "main.cpp") -target_link_libraries(${TARGET} PRIVATE Constructs File imagehlp) -target_compile_definitions(${TARGET} PRIVATE RC_FILE_BUILD_STATIC) - -# Directly set folder for proxy_generator to Programs/proxy -set_target_properties(${TARGET} PROPERTIES FOLDER "Programs/proxy") - -add_subdirectory("proxy") diff --git a/UE4SS/proxy_generator/exports/dwmapi.exports b/UE4SS/proxy_generator/exports/dwmapi.exports deleted file mode 100644 index 092da8c9..00000000 --- a/UE4SS/proxy_generator/exports/dwmapi.exports +++ /dev/null @@ -1,145 +0,0 @@ -Path: C:\Windows\System32\dwmapi.dll - -12 DllCanUnloadNow -16 DllGetClassObject -17 DwmAttachMilContent -18 DwmDefWindowProc -19 DwmDetachMilContent -20 DwmEnableBlurBehindWindow -3 DwmEnableComposition -21 DwmEnableMMCSS -22 DwmExtendFrameIntoClientArea -23 DwmFlush -24 DwmGetColorizationColor -26 DwmGetCompositionTimingInfo -27 DwmGetGraphicsStreamClient -30 DwmGetGraphicsStreamTransformHint -31 DwmGetTransportAttributes -34 DwmGetUnmetTabRequirements -35 DwmGetWindowAttribute -50 DwmInvalidateIconicBitmaps -85 DwmIsCompositionEnabled -86 DwmModifyPreviousDxFrameDuration -87 DwmQueryThumbnailSourceSize -88 DwmRegisterThumbnail -89 DwmRenderGesture -90 DwmSetDxFrameDuration -91 DwmSetIconicLivePreviewBitmap -92 DwmSetIconicThumbnail -93 DwmSetPresentParameters -94 DwmSetWindowAttribute -95 DwmShowContact -96 DwmTetherContact -57 DwmTetherTextContact -97 DwmTransitionOwnedWindow -98 DwmUnregisterThumbnail -99 DwmUpdateThumbnailProperties -37 DwmpAllocateSecurityDescriptor -1 DwmpDxGetWindowSharedSurface -2 DwmpDxUpdateWindowSharedSurface -29 DwmpDxgiIsThreadDesktopComposited -44 DwmpEnableDDASupport -38 DwmpFreeSecurityDescriptor -28 DwmpGetColorizationParameters -36 DwmpRenderFlick -32 DwmpSetColorizationParameters -84 DwmpUpdateProxyWindowForCapture -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 diff --git a/UE4SS/proxy_generator/exports/xinput1_3.exports b/UE4SS/proxy_generator/exports/xinput1_3.exports deleted file mode 100644 index 878d1b84..00000000 --- a/UE4SS/proxy_generator/exports/xinput1_3.exports +++ /dev/null @@ -1,14 +0,0 @@ -Path: C:\Windows\System32\xinput1_3.dll - -1 DllMain -5 XInputEnable -7 XInputGetBatteryInformation -4 XInputGetCapabilities -6 XInputGetDSoundAudioDeviceGuids -8 XInputGetKeystroke -2 XInputGetState -3 XInputSetState -100 -101 -102 -103 diff --git a/UE4SS/proxy_generator/main.cpp b/UE4SS/proxy_generator/main.cpp deleted file mode 100644 index 07a4e796..00000000 --- a/UE4SS/proxy_generator/main.cpp +++ /dev/null @@ -1,410 +0,0 @@ -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#define WIN32_LEAN_AND_MEAN -#define NOMINMAX -#include -#include -#include -#include -#include - -using namespace RC; -namespace fs = std::filesystem; - -using std::cerr; -using std::cout; -using std::endl; -using std::ifstream; -using std::ofstream; - -using std::string; - -struct ExportFunction -{ - uint16_t ordinal; - bool is_named; - string name; - - ExportFunction(uint16_t ordinal, bool is_named, string name) : ordinal(ordinal), is_named(is_named), name(name) - { - } -}; - -std::vector DumpExports(const fs::path& dll_path) -{ - auto dll_file = File::open(dll_path); - const auto dll_file_map = dll_file.memory_map(); - - ULONG export_directory_size = 0; - IMAGE_EXPORT_DIRECTORY* export_directory = - (IMAGE_EXPORT_DIRECTORY*)ImageDirectoryEntryToData(dll_file_map.data(), FALSE, IMAGE_DIRECTORY_ENTRY_EXPORT, &export_directory_size); - - if (export_directory == nullptr) - { - auto err_msg = to_string(SysError(GetLastError())); - cerr << std::format("Failed to get export directory, reason: {}", err_msg) << '\n'; - return {}; - } - - IMAGE_DOS_HEADER* dos_header = (IMAGE_DOS_HEADER*)dll_file_map.data(); - IMAGE_NT_HEADERS* nt_header = (IMAGE_NT_HEADERS*)(dll_file_map.data() + dos_header->e_lfanew); - - DWORD* name_rvas = (DWORD*)ImageRvaToVa(nt_header, dll_file_map.data(), export_directory->AddressOfNames, NULL); - DWORD* function_rvas = (DWORD*)ImageRvaToVa(nt_header, dll_file_map.data(), export_directory->AddressOfFunctions, NULL); - uint16_t* ordinals = (uint16_t*)ImageRvaToVa(nt_header, dll_file_map.data(), export_directory->AddressOfNameOrdinals, NULL); - - std::vector exports; - std::set exported_ordinals; - - for (size_t i = 0; i < export_directory->NumberOfNames; i++) - { - std::string export_name = (char*)ImageRvaToVa(nt_header, dll_file_map.data(), name_rvas[i], NULL); - uint16_t ordinal = ordinals[i] + 1; - - ExportFunction named_export(ordinal, true, export_name); - exports.push_back(named_export); - - exported_ordinals.insert(ordinal); - } - - for (size_t i = 0; i < export_directory->NumberOfFunctions; i++) - { - uint16_t ordinal = (uint16_t)(export_directory->Base + i); - uint32_t function_rva = function_rvas[i]; - - if (function_rva == 0) continue; - if (exported_ordinals.contains(ordinal)) continue; // a named function for this ordinal was already exported - - ExportFunction ordinal_export(ordinal, false, std::format("ordinal{}", ordinal)); - exports.push_back(ordinal_export); - } - - return exports; -} - -std::vector ReadExportsFile(const fs::path& exp_path, fs::path& dll_path_out) -{ - dll_path_out.clear(); - ifstream exp_file(exp_path); - string line; - - std::getline(exp_file, line); - if (line.find("Path: ") != string::npos) - { - dll_path_out = line.substr(6); - } - - if (dll_path_out.empty()) - { - cerr << std::format("Failed to read export file (missing file path info)") << endl; - return {}; - } - - std::vector exports; - while (std::getline(exp_file, line)) - { - std::istringstream s(line); - - uint16_t ordinal{}; - string export_name; - s >> ordinal >> export_name; - - // invalid line - let's just hope functions with ordinal 0 don't exist - if (ordinal == 0) continue; - auto is_named = !export_name.empty(); - - ExportFunction exp(ordinal, is_named, is_named ? export_name : std::format("ordinal{}", ordinal)); - exports.push_back(exp); - } - - return exports; -} - -int _tmain(int argc, TCHAR* argv[]) -{ - if (argc != 3) - { - cerr << "Invalid arguments! Expected: proxy_generator.exe " << endl; - return -1; - } - - const fs::path input_file = argv[1]; - const fs::path output_path = argv[2]; - - if (!fs::exists(input_file)) - { - cerr << "Input file doesn't exist!\n" << endl; - return -1; - } - - fs::path input_dll = input_file; - fs::path input_dll_name = input_file.filename(); - std::vector exports; - - if (input_file.extension() == ".exports") - { - cout << std::format("Generating a proxy using {}, output path: {}", input_dll_name.string(), output_path.string()) << endl; - exports = ReadExportsFile(input_file, input_dll); - input_dll_name = input_dll.filename(); - } - else - { - cout << std::format("Generating a proxy for {}, output path: {}", input_dll.string(), output_path.string()) << endl; - exports = DumpExports(input_dll); - - const auto exports_path = (output_path / input_dll_name).replace_extension("exports"); - ofstream exports_file(exports_path); - exports_file << "Path: " << input_dll.string() << endl << endl; - for (const auto [e, index] : exports | views::enumerate) - { - exports_file << std::format("{} {}", e.ordinal, e.is_named ? e.name : "") << endl; - } - exports_file.close(); - - cout << std::format("Exports file generated at {}", exports_path.string()) << endl; - } - - cout << std::format("Export count: {}", exports.size()) << endl; - - ofstream def_file((output_path / input_dll_name).replace_extension("def")); - def_file << std::format("LIBRARY {}", fs::path(input_dll_name).replace_extension().string()) << endl; - def_file << "EXPORTS" << endl; - - for (const auto [e, index] : exports | views::enumerate) - { - def_file << std::format(" {}=f{} @{}", e.name, index, e.ordinal) << endl; - } - def_file.close(); - - ofstream asm_file((output_path / input_dll_name).replace_extension("asm")); - asm_file << ".code" << endl; - asm_file << "extern mProcs:QWORD" << endl; - - for (const auto [e, index] : exports | views::enumerate) - { - asm_file << std::format("f{} proc", index) << endl; - asm_file << std::format(" jmp mProcs[8*{}]", index) << endl; - asm_file << std::format("f{} endp", index) << endl; - } - - asm_file << "end" << endl; - asm_file.close(); - - ofstream cpp_file(output_path / "dllmain.cpp"); - cpp_file << "#include " << endl; - cpp_file << endl; - cpp_file << "#include " << endl; - cpp_file << "#include " << endl; - cpp_file << "#include " << endl; - cpp_file << endl; - cpp_file << "#define WIN32_LEAN_AND_MEAN" << endl; - cpp_file << "#include " << endl; - cpp_file << "#include " << endl; - cpp_file << "#include " << endl; - cpp_file << endl; - cpp_file << "#pragma comment(lib, \"user32.lib\")" << endl; - cpp_file << "#pragma comment(lib, \"shell32.lib\")" << endl; - cpp_file << endl; - - cpp_file << "using namespace RC;" << endl; - cpp_file << "namespace fs = std::filesystem;" << endl; - cpp_file << endl; - - cpp_file << "HMODULE SOriginalDll = nullptr;" << endl; - cpp_file << std::format("extern \"C\" uintptr_t mProcs[{}] = {{0}};", exports.size()) << endl; - cpp_file << endl; - - cpp_file << "void setup_functions()" << endl; - cpp_file << "{" << endl; - - for (const auto [e, index] : exports | views::enumerate) - { - string getter = e.is_named ? std::format("\"{}\"", e.name) : std::format("MAKEINTRESOURCEA({})", e.ordinal); - cpp_file << std::format(" mProcs[{}] = (uintptr_t)GetProcAddress(SOriginalDll, {});", index, getter) << endl; - } - - cpp_file << "}" << endl; - cpp_file << endl; - - cpp_file << "void load_original_dll()" << endl; - cpp_file << "{" << endl; - cpp_file << " wchar_t path[MAX_PATH];" << endl; - cpp_file << " GetSystemDirectory(path, MAX_PATH);" << endl; - cpp_file << endl; - cpp_file << std::format(" std::wstring dll_path = std::wstring(path) + L\"\\\\{}\";", input_dll_name.string()) << endl; - cpp_file << endl; - cpp_file << " SOriginalDll = LoadLibrary(dll_path.c_str());" << endl; - cpp_file << " if (!SOriginalDll)" << endl; - cpp_file << " {" << endl; - cpp_file << " MessageBox(nullptr, L\"Failed to load proxy DLL\", L\"UE4SS Error\", MB_OK | MB_ICONERROR);" << endl; - cpp_file << " ExitProcess(0);" << endl; - cpp_file << " }" << endl; - cpp_file << "}" << endl; - cpp_file << endl; - - cpp_file << "bool is_absolute_path(const std::string& path)" << endl; - cpp_file << "{" << endl; - cpp_file << " return fs::path(path).is_absolute();" << endl; - cpp_file << "}" << endl; - cpp_file << endl; - - cpp_file << "bool should_disable_ue4ss()" << endl; - cpp_file << "{" << endl; - cpp_file << " int argc = 0;" << endl; - cpp_file << " LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc);" << endl; - cpp_file << " if (!argv)" << endl; - cpp_file << " {" << endl; - cpp_file << " return false;" << endl; - cpp_file << " }" << endl; - cpp_file << endl; - cpp_file << " bool disable = false;" << endl; - cpp_file << " for (int i = 0; i < argc; i++)" << endl; - cpp_file << " {" << endl; - cpp_file << " if (wcscmp(argv[i], L\"--disable-ue4ss\") == 0)" << endl; - cpp_file << " {" << endl; - cpp_file << " disable = true;" << endl; - cpp_file << " break;" << endl; - cpp_file << " }" << endl; - cpp_file << " }" << endl; - cpp_file << endl; - cpp_file << " LocalFree(argv);" << endl; - cpp_file << " return disable;" << endl; - cpp_file << "}" << endl; - cpp_file << endl; - - cpp_file << "std::wstring get_ue4ss_path_from_args()" << endl; - cpp_file << "{" << endl; - cpp_file << " int argc = 0;" << endl; - cpp_file << " LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc);" << endl; - cpp_file << " if (!argv)" << endl; - cpp_file << " {" << endl; - cpp_file << " return L\"\";" << endl; - cpp_file << " }" << endl; - cpp_file << endl; - cpp_file << " std::wstring ue4ss_path;" << endl; - cpp_file << " for (int i = 0; i < argc - 1; i++)" << endl; - cpp_file << " {" << endl; - cpp_file << " if (wcscmp(argv[i], L\"--ue4ss-path\") == 0)" << endl; - cpp_file << " {" << endl; - cpp_file << " ue4ss_path = argv[i + 1];" << endl; - cpp_file << " break;" << endl; - cpp_file << " }" << endl; - cpp_file << " }" << endl; - cpp_file << endl; - cpp_file << " LocalFree(argv);" << endl; - cpp_file << " return ue4ss_path;" << endl; - cpp_file << "}" << endl; - cpp_file << endl; - - cpp_file << "HMODULE load_ue4ss_dll(HMODULE moduleHandle)" << endl; - cpp_file << "{" << endl; - cpp_file << " HMODULE hModule = nullptr;" << endl; - cpp_file << " wchar_t moduleFilenameBuffer[1024]{'\\0'};" << endl; - cpp_file << " GetModuleFileNameW(moduleHandle, moduleFilenameBuffer, sizeof(moduleFilenameBuffer) / sizeof(wchar_t));" << endl; - cpp_file << " const auto currentPath = std::filesystem::path(moduleFilenameBuffer).parent_path();" << endl; - cpp_file << " const fs::path ue4ssPath = currentPath / \"ue4ss\" / \"UE4SS.dll\";" << endl; - cpp_file << endl; - - cpp_file << " // Check for --ue4ss-path command line argument" << endl; - cpp_file << " std::wstring cmdLineUe4ssPath = get_ue4ss_path_from_args();" << endl; - cpp_file << " if (!cmdLineUe4ssPath.empty())" << endl; - cpp_file << " {" << endl; - cpp_file << " fs::path ue4ssArgPath = cmdLineUe4ssPath;" << endl; - cpp_file << " if (!ue4ssArgPath.is_absolute())" << endl; - cpp_file << " {" << endl; - cpp_file << " ue4ssArgPath = currentPath / ue4ssArgPath;" << endl; - cpp_file << " }" << endl; - cpp_file << endl; - cpp_file << " // Attempt to load UE4SS.dll from the command line path" << endl; - cpp_file << " hModule = LoadLibrary(ue4ssArgPath.c_str());" << endl; - cpp_file << " if (hModule)" << endl; - cpp_file << " {" << endl; - cpp_file << " return hModule;" << endl; - cpp_file << " }" << endl; - cpp_file << " }" << endl; - cpp_file << endl; - - cpp_file << " // Check for override.txt" << endl; - cpp_file << " const fs::path overrideFilePath = currentPath / \"override.txt\";" << endl; - cpp_file << " if (fs::exists(overrideFilePath))" << endl; - cpp_file << " {" << endl; - cpp_file << " std::ifstream overrideFile(overrideFilePath);" << endl; - cpp_file << " std::string overridePath;" << endl; - cpp_file << " if (std::getline(overrideFile, overridePath))" << endl; - cpp_file << " {" << endl; - cpp_file << " fs::path ue4ssOverridePath = overridePath;" << endl; - cpp_file << " if (!is_absolute_path(overridePath))" << endl; - cpp_file << " {" << endl; - cpp_file << " ue4ssOverridePath = currentPath / overridePath;" << endl; - cpp_file << " }" << endl; - cpp_file << endl; - cpp_file << " ue4ssOverridePath = ue4ssOverridePath / \"UE4SS.dll\";" << endl; - cpp_file << endl; - cpp_file << " // Attempt to load UE4SS.dll from the override path" << endl; - cpp_file << " hModule = LoadLibrary(ue4ssOverridePath.c_str());" << endl; - cpp_file << " if (hModule)" << endl; - cpp_file << " {" << endl; - cpp_file << " return hModule;" << endl; - cpp_file << " }" << endl; - cpp_file << " }" << endl; - cpp_file << " }" << endl; - cpp_file << endl; - - cpp_file << " // Attempt to load UE4SS.dll from ue4ss directory" << endl; - cpp_file << " hModule = LoadLibrary(ue4ssPath.c_str());" << endl; - cpp_file << " if (!hModule)" << endl; - cpp_file << " {" << endl; - cpp_file << " // If loading from ue4ss directory fails, load from the current directory" << endl; - cpp_file << " hModule = LoadLibrary(L\"UE4SS.dll\");" << endl; - cpp_file << " }" << endl; - cpp_file << endl; - cpp_file << " return hModule;" << endl; - cpp_file << "}" << endl; - cpp_file << endl; - - cpp_file << "BOOL WINAPI DllMain(HMODULE hInstDll, DWORD fdwReason, LPVOID lpvReserved)" << endl; - cpp_file << "{" << endl; - cpp_file << " if (fdwReason == DLL_PROCESS_ATTACH)" << endl; - cpp_file << " {" << endl; - cpp_file << " load_original_dll();" << endl; - cpp_file << " setup_functions();" << endl; - cpp_file << endl; - cpp_file << " // Check if UE4SS should be disabled via command line argument" << endl; - cpp_file << " if (should_disable_ue4ss())" << endl; - cpp_file << " {" << endl; - cpp_file << " // UE4SS is disabled, proxy will still forward calls to original DLL" << endl; - cpp_file << " return TRUE;" << endl; - cpp_file << " }" << endl; - cpp_file << endl; - cpp_file << " HMODULE hUE4SSDll = load_ue4ss_dll(hInstDll);" << endl; - cpp_file << " if (!hUE4SSDll)" << endl; - cpp_file << " {" << endl; - cpp_file << " MessageBox(nullptr, L\"Failed to load UE4SS.dll. Please see the docs on correct installation: " - "https://docs.ue4ss.com/installation-guide\", L\"UE4SS Error\", MB_OK | MB_ICONERROR);" - << endl; - cpp_file << " ExitProcess(0);" << endl; - cpp_file << " }" << endl; - cpp_file << " }" << endl; - cpp_file << " else if (fdwReason == DLL_PROCESS_DETACH)" << endl; - cpp_file << " {" << endl; - cpp_file << " FreeLibrary(SOriginalDll);" << endl; - cpp_file << " }" << endl; - cpp_file << " return TRUE;" << endl; - cpp_file << "}" << endl; - - cpp_file.close(); - - cout << "Finished generating!" << endl; - - return 0; -} diff --git a/UE4SS/proxy_generator/proxy/CMakeLists.txt b/UE4SS/proxy_generator/proxy/CMakeLists.txt deleted file mode 100644 index 4046aac6..00000000 --- a/UE4SS/proxy_generator/proxy/CMakeLists.txt +++ /dev/null @@ -1,118 +0,0 @@ -cmake_minimum_required(VERSION 3.22) - -set(TARGET proxy) -project(${TARGET}) -enable_language(ASM_MASM) - -# Determine proxy name and path with priority: -# 1. User-specified path (if provided) -# 2. Check exports directory (if no user path) -# 3. Default system DLL path (fallback) - -if(UE4SS_PROXY_PATH) - # User explicitly specified a path - message(STATUS "Using user-specified proxy path: ${UE4SS_PROXY_PATH}") - if(CMAKE_CROSSCOMPILING AND UE4SS_PROXY_PATH MATCHES "^[A-Za-z]:") - # Windows absolute path on non-Windows host - extract just the filename - get_filename_component(PROXY_NAME ${UE4SS_PROXY_PATH} NAME_WE) - else() - cmake_path(GET UE4SS_PROXY_PATH STEM PROXY_NAME) - endif() -else() - # No user path specified, check exports directory first - set(DEFAULT_PROXY_NAME "dwmapi") - set(EXPORT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../exports/${DEFAULT_PROXY_NAME}.exports") - - if(EXISTS ${EXPORT_FILE}) - # Found export file, use it - message(STATUS "Found export file: ${EXPORT_FILE}") - set(UE4SS_PROXY_PATH ${EXPORT_FILE}) - set(PROXY_NAME ${DEFAULT_PROXY_NAME}) - set(USE_EXPORT_FILE TRUE) - else() - # No export file, use platform default - if(WIN32 AND NOT CMAKE_CROSSCOMPILING) - set(UE4SS_PROXY_PATH "C:\\Windows\\System32\\${DEFAULT_PROXY_NAME}.dll") - message(STATUS "Using default Windows DLL path: ${UE4SS_PROXY_PATH}") - else() - # Cross-compiling without export file - message(WARNING "No export file found for ${DEFAULT_PROXY_NAME}, build may fail") - set(UE4SS_PROXY_PATH "${DEFAULT_PROXY_NAME}.dll") - endif() - set(PROXY_NAME ${DEFAULT_PROXY_NAME}) - endif() -endif() -add_library(${TARGET} SHARED - "proxy.rc" - "${CMAKE_CURRENT_BINARY_DIR}/dllmain.cpp" - "${CMAKE_CURRENT_BINARY_DIR}/${PROXY_NAME}.asm" - "${CMAKE_CURRENT_BINARY_DIR}/${PROXY_NAME}.def") - -set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME ${PROXY_NAME}) -target_link_libraries(${TARGET} PRIVATE File) - -# Determine if we're using an export file or a DLL -if(UE4SS_PROXY_PATH MATCHES "\\.exports$") - set(USING_EXPORT_FILE TRUE) -elseif(USE_EXPORT_FILE) - set(USING_EXPORT_FILE TRUE) -else() - set(USING_EXPORT_FILE FALSE) -endif() - -# Generate proxy files -if(USING_EXPORT_FILE) - # Using pre-generated export file - add_custom_command( - OUTPUT - "${CMAKE_CURRENT_BINARY_DIR}/dllmain.cpp" - "${CMAKE_CURRENT_BINARY_DIR}/${PROXY_NAME}.asm" - "${CMAKE_CURRENT_BINARY_DIR}/${PROXY_NAME}.def" - COMMAND "$" ${UE4SS_PROXY_PATH} ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS - proxy_generator - ${UE4SS_PROXY_PATH} - COMMENT "Generating proxy files from export file: ${UE4SS_PROXY_PATH}" - ) -elseif(CMAKE_CROSSCOMPILING) - # Cross-compiling without export file - try to find one - set(FALLBACK_EXPORT "${CMAKE_CURRENT_SOURCE_DIR}/../exports/${PROXY_NAME}.exports") - if(EXISTS ${FALLBACK_EXPORT}) - add_custom_command( - OUTPUT - "${CMAKE_CURRENT_BINARY_DIR}/dllmain.cpp" - "${CMAKE_CURRENT_BINARY_DIR}/${PROXY_NAME}.asm" - "${CMAKE_CURRENT_BINARY_DIR}/${PROXY_NAME}.def" - COMMAND "$" ${FALLBACK_EXPORT} ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS - proxy_generator - ${FALLBACK_EXPORT} - COMMENT "Generating proxy files from fallback export: ${FALLBACK_EXPORT}" - ) - else() - message(FATAL_ERROR "Cross-compilation requires export file for ${PROXY_NAME}, but none found") - endif() -else() - # Native Windows build - analyze DLL directly - add_custom_command( - OUTPUT - "${CMAKE_CURRENT_BINARY_DIR}/dllmain.cpp" - "${CMAKE_CURRENT_BINARY_DIR}/${PROXY_NAME}.asm" - "${CMAKE_CURRENT_BINARY_DIR}/${PROXY_NAME}.def" - COMMAND "$" ${UE4SS_PROXY_PATH} ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS - proxy_generator - ${UE4SS_PROXY_PATH} - COMMENT "Generating proxy files from DLL: ${UE4SS_PROXY_PATH}" - ) -endif() - -add_custom_target(proxy_files DEPENDS - "${CMAKE_CURRENT_BINARY_DIR}/dllmain.cpp" - "${CMAKE_CURRENT_BINARY_DIR}/${PROXY_NAME}.asm" - "${CMAKE_CURRENT_BINARY_DIR}/${PROXY_NAME}.def") -add_dependencies(${TARGET} proxy_files) - -# Directly set folders for proxy and proxy_files in Programs/proxy -set_target_properties(${TARGET} PROPERTIES FOLDER "Programs/proxy") -set_target_properties(proxy_files PROPERTIES FOLDER "Programs/proxy") \ No newline at end of file diff --git a/UE4SS/proxy_generator/proxy/proxy.rc b/UE4SS/proxy_generator/proxy/proxy.rc deleted file mode 100644 index e14588fd..00000000 --- a/UE4SS/proxy_generator/proxy/proxy.rc +++ /dev/null @@ -1,31 +0,0 @@ -1 VERSIONINFO - FILEVERSION 0,0,0,0 - PRODUCTVERSION 0,0,0,0 - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "FileDescription", "UE4SS Injection Proxy" - VALUE "FileVersion", "0.0.0.0" - VALUE "InternalName", "proxy.rc" - VALUE "LegalCopyright", "Copyright (C) 2023" - VALUE "OriginalFilename", "proxy.rc" - VALUE "ProductName", "UE4SS Injection Proxy" - VALUE "ProductVersion", "0.0.0.0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END \ No newline at end of file diff --git a/UE4SS/proxy_generator/proxy/xmake.lua b/UE4SS/proxy_generator/proxy/xmake.lua deleted file mode 100644 index edeae08e..00000000 --- a/UE4SS/proxy_generator/proxy/xmake.lua +++ /dev/null @@ -1,32 +0,0 @@ -option("ue4ssProxyPath") - set_default("C:\\Windows\\System32\\dwmapi.dll") - set_description("Set path for a dll to generate the proxy for") - -target("proxy") - set_kind("shared") - add_options("ue4ssProxyPath") - set_languages("cxx23") - set_exceptions("cxx") - add_rules("c++", "asm") - - set_policy("build.across_targets_in_parallel", false) - - add_deps("File", "proxy_generator") - - add_files("proxy.rc") - - -- Set the name of the target file to be the base file name of the proxy dll ("dwmapi"). - set_basename(path.basename(get_config("ue4ssProxyPath"))) - - after_load(function (target) - local output_path = path.join(target:dep("proxy_generator"):autogendir()) - local proxy_name = path.basename(target:targetfile()) - target:add("files", path.join(output_path, "dllmain.cpp"), { always_added = true }) - target:add("files", path.join(output_path, proxy_name .. ".asm"), { rule = "asm", always_added = true }) - target:add("files", path.join(output_path, proxy_name .. ".def"), { always_added = true }) - end) - - on_install(function(target) - os.mkdir(target:installdir()) - os.cp(target:targetfile(), target:installdir()) - end) diff --git a/UE4SS/proxy_generator/xmake.lua b/UE4SS/proxy_generator/xmake.lua deleted file mode 100644 index 8f1842cf..00000000 --- a/UE4SS/proxy_generator/xmake.lua +++ /dev/null @@ -1,50 +0,0 @@ -local projectName = "proxy_generator" - -rule("dllexports") - set_extensions(".exports") - -target(projectName) - set_kind("binary") - set_languages("cxx23") - set_exceptions("cxx") - - add_files("main.cpp") - - add_deps("File", "Constructs") - add_links("imagehlp") - - add_files("exports/*.exports", { rule = "dllexports" }) - - after_build(function(target) - local proxy_exe = target:targetfile() - local output_path = target:autogendir() - import("core.base.task") - - local input = get_config("ue4ssProxyPath") - - local dll_name = path.basename(input):lower() - for k, sourcebatch in pairs(target:sourcebatches()) do - if k == "dllexports" then - for _, expfile in ipairs(sourcebatch.sourcefiles) do - if path.basename(expfile):lower() == dll_name then - input = path.absolute(expfile) - goto found - end - end - end - end - ::found:: - - -- The second arg of task.run is used if we plan on calling `xmake proxy_files`. - -- The proxy_files task is not exposed to the CLI, so we pass an empty second arg. - task.run("proxy_files", {}, proxy_exe, input, output_path) - end) - --- Define a task that executes the proxy_generator exe with the provided arguments -task("proxy_files") - on_run(function (proxy_gen_exe, input, output_path) - os.mkdir(output_path) - os.execv(proxy_gen_exe, {input, output_path}) - end) - -includes("proxy") diff --git a/UE4SS/xmake.lua b/UE4SS/xmake.lua index 54dccae4..b9547f5e 100644 --- a/UE4SS/xmake.lua +++ b/UE4SS/xmake.lua @@ -1,7 +1,3 @@ -if is_plat("windows") and get_config("ue4ssCross") ~= "msvc-wine" then - includes("proxy_generator") -end - if is_plat("windows") then add_requires("imgui v1.92.1", { debug = is_mode_debug(), configs = { win32 = true, dx11 = true, opengl3 = true, glfw_opengl3 = true , runtimes = get_mode_runtimes()} } ) add_requires("ImGuiTextEdit v1.2.0", { debug = is_mode_debug(), configs = {runtimes = get_mode_runtimes()} })