From eb69484bd6436992fd745e4c9dc5bc940cc6f91b Mon Sep 17 00:00:00 2001 From: Yang Liu Date: Sun, 1 Jun 2025 17:35:16 +0800 Subject: [WOW64] Override DOS stub to Wine builtin DLL (#2698) --- wow64/CMakeLists.txt | 21 +++++++++++++++++++++ wow64/override_wine_builtin.py | 14 ++++++++++++++ 2 files changed, 35 insertions(+) create mode 100755 wow64/override_wine_builtin.py diff --git a/wow64/CMakeLists.txt b/wow64/CMakeLists.txt index 6221e75d..13d7947c 100644 --- a/wow64/CMakeLists.txt +++ b/wow64/CMakeLists.txt @@ -1,6 +1,22 @@ cmake_minimum_required(VERSION 3.13) project(wowbox64 C ASM) +if(${CMAKE_VERSION} VERSION_LESS "3.12.2") + find_package(PythonInterp 3) + if(NOT PYTHONINTERP_FOUND) + message( FATAL_ERROR "You need a Python interpreter, CMake will exit." ) + endif() + if(${PYTHON_VERSION_MAJOR} LESS 3) + message( FATAL_ERROR "You need a Python 3 interpreter, CMake will exit." ) + endif() +else() + find_package(Python3) + if(NOT Python3_Interpreter_FOUND) + message( FATAL_ERROR "You need a Python interpreter, CMake will exit." ) + endif() + set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE} CACHE INTERNAL "The Python3 executable" FORCE) +endif() + set(BOX64_ROOT "${CMAKE_SOURCE_DIR}/..") string(REPLACE "," ";" DYNAREC_ASM "${DYNAREC_ASM_STR}") @@ -122,4 +138,9 @@ add_compile_definitions(DYNAREC ARM64) target_link_options(wowbox64 PRIVATE -nostdlib -nodefaultlibs -lclang_rt.builtins-aarch64 -Wl,--image-base,0x004c0000) +add_custom_command( + TARGET wowbox64 POST_BUILD + COMMAND "${PYTHON_EXECUTABLE}" ${CMAKE_SOURCE_DIR}/override_wine_builtin.py $ +) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) diff --git a/wow64/override_wine_builtin.py b/wow64/override_wine_builtin.py new file mode 100755 index 00000000..ee95e958 --- /dev/null +++ b/wow64/override_wine_builtin.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 + +import subprocess +import sys + +data = 'Wine builtin DLL\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + +def main(output_file): + + with open(output_file, 'r+b') as f: + f.seek(64) # Move cursor to DOS stub + f.write(data.encode('utf-8')) + +main(sys.argv[1]) \ No newline at end of file -- cgit 1.4.1