From 35ea324898281e390d95987fb167bf6870ae126d Mon Sep 17 00:00:00 2001 From: acidicoala <67734819+acidicoala@users.noreply.github.com> Date: Sat, 4 Oct 2025 17:24:36 +0500 Subject: [PATCH] Reworked lib::get_exports --- .idea/dictionaries/project.xml | 1 + KoalaBox | 2 +- static/smoke_api/types.hpp | 17 ++++++++++++----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.idea/dictionaries/project.xml b/.idea/dictionaries/project.xml index fa3df7c..65d6e43 100644 --- a/.idea/dictionaries/project.xml +++ b/.idea/dictionaries/project.xml @@ -8,6 +8,7 @@ dlopen dlsym dynsym + elfio endfor indicies inja diff --git a/KoalaBox b/KoalaBox index 7e7e112..8bc6861 160000 --- a/KoalaBox +++ b/KoalaBox @@ -1 +1 @@ -Subproject commit 7e7e1121acd8591fad3bfa2895fd1b9c1bf57afb +Subproject commit 8bc6861330005c88228f9c626c64ebcc1758d881 diff --git a/static/smoke_api/types.hpp b/static/smoke_api/types.hpp index 8286d5a..56deff2 100644 --- a/static/smoke_api/types.hpp +++ b/static/smoke_api/types.hpp @@ -21,6 +21,7 @@ #define SWAPPED_CALL_CLOSURE(FUNC, ...) \ [&] { SWAPPED_CALL(THIS, FUNC, __VA_ARGS__); } +#if defined(KB_WIN) /** * By default, virtual functions are declared with __thiscall * convention, which is normal since they are class members. @@ -42,7 +43,6 @@ * will store the 1st actual argument to the function, so we * have to omit it from the function signature. */ -#if defined(KB_WIN) #ifdef KB_64 #define PARAMS(...) const void* RCX __VA_OPT__(,) __VA_ARGS__ #define ARGS(...) RCX __VA_OPT__(,) __VA_ARGS__ @@ -55,16 +55,23 @@ #define DECLARE_ARGS() void* ECX = nullptr; const void* EDX = nullptr; #endif #elif defined(KB_LINUX) +/** + * In 64-bit mode, Linux binaries pass first 6 arguments via registers. + * `this` pointer is passed as the first argument via the RDI register. + * + * In 32-bit mode, Linux binaries pass arguments via stack. + * `this` pointer is passed as the first argument via the first stack parameter. + */ #ifdef KB_64 #define PARAMS(...) const void* $RDI __VA_OPT__(,) __VA_ARGS__ #define ARGS(...) $RDI __VA_OPT__(,) __VA_ARGS__ #define THIS $RDI #define DECLARE_ARGS() void* $RDI = nullptr; #else -#define PARAMS(...) const void* $ARG1 __VA_OPT__(,) __VA_ARGS__ -#define ARGS(...) $ARG1 __VA_OPT__(,) __VA_ARGS__ -#define THIS $ARG1 -#define DECLARE_ARGS() void* $ARG1 = nullptr; +#define PARAMS(...) const void* $STACK1 __VA_OPT__(,) __VA_ARGS__ +#define ARGS(...) $STACK1 __VA_OPT__(,) __VA_ARGS__ +#define THIS $STACK1 +#define DECLARE_ARGS() void* $STACK1 = nullptr; #endif #endif