From e74b841909446017a8409f3f3757e29fd82e3686 Mon Sep 17 00:00:00 2001 From: Will Toohey Date: Mon, 23 Feb 2026 09:14:42 +1000 Subject: [PATCH] Make things build on clang-21 --- ensure_xp_compatible.py | 16 +++++-- meson.build | 60 +++++++++++++------------- src/3rd_party/minhook/src/hde/hde32.c | 4 ++ src/3rd_party/minhook/src/trampoline.c | 4 ++ src/hook.cpp | 1 + src/utils.hpp | 2 + src_injector/d3d9.def | 12 +++--- 7 files changed, 60 insertions(+), 39 deletions(-) diff --git a/ensure_xp_compatible.py b/ensure_xp_compatible.py index e540cc1..af0b9bf 100644 --- a/ensure_xp_compatible.py +++ b/ensure_xp_compatible.py @@ -64,12 +64,15 @@ ignore_functions = [ b"RtlLookupFunctionEntry", b"RtlUnwindEx", b"RtlVirtualUnwind", + b"RtlRestoreContext", b"__C_specific_handler", ] +exceptions = [] for dll_name, imports in needed_functions.items(): if (dll := available_functions.get(dll_name)) is None: - raise MissingDLL(f"Need {dll_name} but it's not in the XP DLLs folder") + exceptions.append(MissingDLL(f"Need {dll_name} but it's not in the XP DLLs folder")) + continue for name, ordinal in imports: if name is not None: @@ -77,13 +80,18 @@ for dll_name, imports in needed_functions.items(): continue if next((fn for fn in dll if fn[0] == name), None) is None: - raise MissingFunction(f'Function "{name}" not present in XP {dll_name}') + exceptions.append(MissingFunction(f'Function "{name}" not present in XP {dll_name}')) + continue elif ordinal is not None: if next((fn for fn in dll if fn[1] == ordinal), None) is None: - raise MissingFunction( + exceptions.append(MissingFunction( f"Function with ordinal {ordinal} not present in XP {dll_name}" - ) + )) + continue else: raise RuntimeError("Import with no name or ordinal???") +if exceptions: + raise ExceptionGroup("Failures", exceptions) + print("All functions present!") diff --git a/meson.build b/meson.build index c0826aa..436ad2f 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ project('layeredfs', 'c', 'cpp', version: '3.10', default_options: [ - 'cpp_std=c++20', + 'cpp_std=c++23', 'buildtype=release', 'strip=true', 'werror=true', @@ -193,33 +193,35 @@ foreach cfg : injector_cfgs ) endforeach -gtest_proj = subproject('gtest', required: false, default_options: {'default_library': 'static'}) -gtest_main_dep = gtest_proj.get_variable('gtest_main_dep') -gmock_dep = gtest_proj.get_variable('gmock_dep') +if host_machine.cpu_family() == 'x86_64' + gtest_proj = subproject('gtest', required: false, default_options: {'default_library': 'static'}) + gtest_main_dep = gtest_proj.get_variable('gtest_main_dep') + gmock_dep = gtest_proj.get_variable('gmock_dep') -test('unit tests', executable('tests_bin', - sources: 'src/tests.cpp', - link_with: [layeredfs_lib, texbin_lib, avs_standalone_lib], - dependencies: [layeredfs_cfg_dep, gtest_main_dep, gmock_dep], - build_by_default: false, - ), - workdir: meson.current_source_dir(), -) + test('unit tests', executable('tests_bin', + sources: 'src/tests.cpp', + link_with: [layeredfs_lib, texbin_lib, avs_standalone_lib], + dependencies: [layeredfs_cfg_dep, gtest_main_dep, gmock_dep], + build_by_default: false, + ), + workdir: meson.current_source_dir(), + ) -test('commandline parsing test', executable('test_commandline', - sources: 'src/test_commandline.cpp', - link_with: [layeredfs_lib, texbin_lib, avs_standalone_lib], - dependencies: [layeredfs_cfg_dep, gtest_main_dep, gmock_dep], - build_by_default: false, - ), - workdir: meson.current_source_dir(), - args: [ - '--layered-disable', - '--layered-verbose', - '--layered-devmode', - '--layered-allowlist=allowed,these folders', - '--layered-blocklist=blocked,these folders', - '--layered-logfile=some logfile.log', - '--layered-data-mods-folder=./some modfolder', - ] -) + test('commandline parsing test', executable('test_commandline', + sources: 'src/test_commandline.cpp', + link_with: [layeredfs_lib, texbin_lib, avs_standalone_lib], + dependencies: [layeredfs_cfg_dep, gtest_main_dep, gmock_dep], + build_by_default: false, + ), + workdir: meson.current_source_dir(), + args: [ + '--layered-disable', + '--layered-verbose', + '--layered-devmode', + '--layered-allowlist=allowed,these folders', + '--layered-blocklist=blocked,these folders', + '--layered-logfile=some logfile.log', + '--layered-data-mods-folder=./some modfolder', + ] + ) +endif diff --git a/src/3rd_party/minhook/src/hde/hde32.c b/src/3rd_party/minhook/src/hde/hde32.c index 08fa25b..3a3556a 100644 --- a/src/3rd_party/minhook/src/hde/hde32.c +++ b/src/3rd_party/minhook/src/hde/hde32.c @@ -10,6 +10,10 @@ #include "hde32.h" #include "table32.h" +#ifdef _MSC_VER +#include +#endif + unsigned int hde32_disasm(const void *code, hde32s *hs) { uint8_t x, c, *p = (uint8_t *)code, cflags, opcode, pref = 0; diff --git a/src/3rd_party/minhook/src/trampoline.c b/src/3rd_party/minhook/src/trampoline.c index ac37f0f..c267088 100644 --- a/src/3rd_party/minhook/src/trampoline.c +++ b/src/3rd_party/minhook/src/trampoline.c @@ -28,6 +28,10 @@ #include +#ifdef _MSC_VER + #include +#endif + #ifndef ARRAYSIZE #define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0])) #endif diff --git a/src/hook.cpp b/src/hook.cpp index d3daf39..b2b6277 100644 --- a/src/hook.cpp +++ b/src/hook.cpp @@ -1,4 +1,5 @@ #include +#include #include #include "hook.h" diff --git a/src/utils.hpp b/src/utils.hpp index 67dded0..368e8e0 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -9,6 +9,8 @@ #include "3rd_party/md5.h" +#define strcasecmp _stricmp + #define lenof(x) (sizeof(x) / sizeof(*x)) char* snprintf_auto(const char* fmt, ...); diff --git a/src_injector/d3d9.def b/src_injector/d3d9.def index d73b599..96a568c 100644 --- a/src_injector/d3d9.def +++ b/src_injector/d3d9.def @@ -2,12 +2,12 @@ EXPORTS ; These are used by windows internals, don't hook them. ; Specifically, @17 is called when "Disable fullscreen optimizations" is checked, ; and this is done with the loader lock held, so the real system DLL loading fails - __ord16 = "C:\Windows\System32\d3d9.#16" @16,NONAME - __ord17 = "C:\Windows\System32\d3d9.#17" @17,NONAME - __ord18 = "C:\Windows\System32\d3d9.#18" @18,NONAME - __ord19 = "C:\Windows\System32\d3d9.#19" @19,NONAME - __ord22 = "C:\Windows\System32\d3d9.#22" @22,NONAME - __ord23 = "C:\Windows\System32\d3d9.#23" @23,NONAME + __ord16 = "C:\Windows\System32\d3d9.#16" @16 NONAME + __ord17 = "C:\Windows\System32\d3d9.#17" @17 NONAME + __ord18 = "C:\Windows\System32\d3d9.#18" @18 NONAME + __ord19 = "C:\Windows\System32\d3d9.#19" @19 NONAME + __ord22 = "C:\Windows\System32\d3d9.#22" @22 NONAME + __ord23 = "C:\Windows\System32\d3d9.#23" @23 NONAME Direct3DCreate9On12 @20 Direct3DCreate9On12Ex @21 Direct3DShaderValidatorCreate9 @24