From 7c813263d3d57285ba6722f97d6e78129b9b7002 Mon Sep 17 00:00:00 2001 From: Bubbles Date: Wed, 20 Aug 2025 15:53:12 -0500 Subject: [PATCH 1/3] Undefine native linux definition --- source2gen/include/tools/platform.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source2gen/include/tools/platform.h b/source2gen/include/tools/platform.h index 1846a83c..ee742ace 100644 --- a/source2gen/include/tools/platform.h +++ b/source2gen/include/tools/platform.h @@ -2,6 +2,8 @@ // See end of file for extended copyright information. #pragma once +#undef linux + #define WINDOWS 0 #define LINUX 1 From 1ec635fa7904f453bf3c60a410adc0931bbd38f7 Mon Sep 17 00:00:00 2001 From: Hayden <73860227+ImBubbles@users.noreply.github.com> Date: Fri, 22 Aug 2025 18:00:21 -0500 Subject: [PATCH 2/3] Update source2gen/include/tools/platform.h Co-authored-by: Arsenii es3n1n --- source2gen/include/tools/platform.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source2gen/include/tools/platform.h b/source2gen/include/tools/platform.h index ee742ace..4fff9afe 100644 --- a/source2gen/include/tools/platform.h +++ b/source2gen/include/tools/platform.h @@ -2,7 +2,12 @@ // See end of file for extended copyright information. #pragma once -#undef linux +/// Some environments automatically define the bare macro `linux` (in +/// addition to the portable feature-test macro `__linux__`). This pollutes +/// the global namespace and collides with our `platform::linux`. +#if defined(linux) + #undef linux +#endif #define WINDOWS 0 #define LINUX 1 From 9915f4b789f96174eadc2c3c7442b31a1df66883 Mon Sep 17 00:00:00 2001 From: Bubbles Date: Sat, 23 Aug 2025 16:49:24 -0500 Subject: [PATCH 3/3] Fixed libschemasystem.so rendering --- .gitignore | 2 + source2gen/include/sdk/interfaceregs.h | 47 ++++++++++++++----- .../include/tools/loader/loader_linux.h | 2 +- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 1e24a5da..c3852fe3 100644 --- a/.gitignore +++ b/.gitignore @@ -1036,3 +1036,5 @@ bin/ # CLion .idea/** +generate.sh +build.sh diff --git a/source2gen/include/sdk/interfaceregs.h b/source2gen/include/sdk/interfaceregs.h index ddb6f0d7..a7f5e6ee 100644 --- a/source2gen/include/sdk/interfaceregs.h +++ b/source2gen/include/sdk/interfaceregs.h @@ -5,6 +5,7 @@ #include #include #include +#include #include @@ -25,22 +26,42 @@ namespace sdk { const auto maybe_createinterface_symbol = loader::find_module_symbol(library_handle, "CreateInterface"); + if(&maybe_createinterface_symbol == nullptr) { + std::cerr << "Could not find CreateInterface" << std::endl; + return nullptr; + } + return maybe_createinterface_symbol - .transform([](auto createinterface_symbol) { - const auto interface_list = [=] { - if constexpr (current_platform == platform::windows) { - return createinterface_symbol + *reinterpret_cast(createinterface_symbol + 3) + 7; - } else if constexpr (current_platform == platform::linux) { - const auto createinterface_impl = createinterface_symbol + *reinterpret_cast(createinterface_symbol + 1) + 5; - const auto createinterface_mov = createinterface_impl + 0x10; + .transform([](auto createinterface_symbol) -> const InterfaceReg* { + if constexpr (current_platform == platform::windows) { + // Windows logic + auto interface_list = createinterface_symbol + *reinterpret_cast(createinterface_symbol + 3) + 7; + return *reinterpret_cast(interface_list); + } else if constexpr (current_platform == platform::linux) { + // Linux logic + // Fixed by Bubbles -- thank you Ghidra and chatgpt bc this is super dumb + // Offsets from Ghidra, relative to CreateInterface function start + constexpr uintptr_t kInstrOffset = 0x10; // offset of 'mov rbx, [rip+disp32]' in CreateInterface + constexpr int32_t kDisp = 0x000328d9; // displacement in that instruction - return createinterface_mov + *reinterpret_cast(createinterface_mov + 3) + 7; - } - }(); + // Compute RIP-relative address + uintptr_t rip_after = reinterpret_cast(createinterface_symbol) + kInstrOffset + 7; // instruction length = 7 + auto interface_list_ptr = reinterpret_cast(rip_after + kDisp); + if (!interface_list_ptr) { + std::cerr << "interface_list_ptr is null\n"; + return nullptr; + } - return *reinterpret_cast(interface_list); - }) - .value_or(nullptr); + const InterfaceReg* head = *interface_list_ptr; + if (!head) { + std::cerr << "InterfaceReg head is null, check offsets!\n"; + return nullptr; + } + + return head; + } + }) + .value_or(nullptr); } template diff --git a/source2gen/include/tools/loader/loader_linux.h b/source2gen/include/tools/loader/loader_linux.h index 9eab989d..6da37cec 100644 --- a/source2gen/include/tools/loader/loader_linux.h +++ b/source2gen/include/tools/loader/loader_linux.h @@ -27,7 +27,7 @@ namespace loader::linux { } [[nodiscard]] inline auto load_module(std::string_view name) -> std::expected { - if (auto* const handle = dlopen(name.data(), RTLD_LAZY)) { + if (auto* const handle = dlopen(name.data(), RTLD_NOW)) { return handle; } return std::unexpected(ModuleLookupError::from_string(dlerror()));