From c845803be9de2c1e10d25e86009195d4798085df Mon Sep 17 00:00:00 2001 From: hero Date: Sat, 17 Aug 2024 01:00:57 +0200 Subject: [PATCH] just small changes --- src/core/menu/framework.cpp | 4 +-- src/core/menu/framework.h | 4 +-- src/core/shared/common.cpp | 6 +++-- src/sdk/signal.h | 52 ++++++++++++++++++++++++++++++------- 4 files changed, 50 insertions(+), 16 deletions(-) diff --git a/src/core/menu/framework.cpp b/src/core/menu/framework.cpp index 26a5351..9a39e92 100644 --- a/src/core/menu/framework.cpp +++ b/src/core/menu/framework.cpp @@ -229,7 +229,7 @@ void gui::framework::sliderf( float& val, float min, float max, const std::strin cur_menu.cursor.y += size.y + text_size.y + 4; } -void gui::framework::combo( std::size_t& val, std::vector< std::string > items, const std::string& label ) { +void gui::framework::combo( std::size_t& val, const std::vector< std::string >& items, const std::string& label ) { auto cur_pos = cur_menu.pos + cur_menu.cursor; const auto size = vec2_t( 160, 26 ); @@ -271,7 +271,7 @@ void gui::framework::combo( std::size_t& val, std::vector< std::string > items, cur_menu.cursor.y += size.y + text_size.y + 4; } -void gui::framework::multicombo( std::size_t& val, std::vector< std::string > items, const std::string& label ) { +void gui::framework::multicombo( std::size_t& val, const std::vector< std::string >& items, const std::string& label ) { auto cur_pos = cur_menu.pos + cur_menu.cursor; const auto size = vec2_t( 160, 26 ); diff --git a/src/core/menu/framework.h b/src/core/menu/framework.h index 739f815..42b8454 100644 --- a/src/core/menu/framework.h +++ b/src/core/menu/framework.h @@ -56,7 +56,7 @@ namespace gui { bool checkbox( bool& val, const std::string& label ); void slider( int& val, int min, int max, const std::string& label ); void sliderf( float& val, float min, float max, const std::string& label ); - void combo( std::size_t& val, std::vector< std::string > items, const std::string& label ); - void multicombo( std::size_t& val, std::vector< std::string > items, const std::string& label ); + void combo( std::size_t& val, const std::vector< std::string >& items, const std::string& label ); + void multicombo( std::size_t& val, const std::vector< std::string >& items, const std::string& label ); } // namespace framework } // namespace gui diff --git a/src/core/shared/common.cpp b/src/core/shared/common.cpp index f58f21d..9960890 100644 --- a/src/core/shared/common.cpp +++ b/src/core/shared/common.cpp @@ -56,15 +56,17 @@ void* c_common::get_interface( const char* module_name, const char* interface_na result = fn( interface_name, nullptr ); - if ( !result ) + if ( !result ) { + util::console::log( "[!] couldn't find interface %s in %s.\n", interface_name, module_name ); return nullptr; + } util::console::log( "[+] found interface %s in %s at %p.\n", interface_name, module_name, result ); return result; } - util::console::log( "[!] couldn't find interface %s in %s.\n", interface_name, module_name ); + util::console::log( "[!] couldn't find CreateInterface fn in %s.\n", module_name ); return nullptr; } diff --git a/src/sdk/signal.h b/src/sdk/signal.h index d2f252d..dfa9e39 100644 --- a/src/sdk/signal.h +++ b/src/sdk/signal.h @@ -3,7 +3,6 @@ #include // member functions only for now (__thiscall conv etc.) -// return value dismissed for now class signal_t { friend class c_signal; @@ -73,21 +72,54 @@ class c_signal { } #define _SIGNAL3( t, name, a1_t, a1, a2_t, a2, a3_t, a3 ) \ static t __fastcall name##_handler( void* ecx, int edx, a1_t a1, a2_t a2, a3_t a3 ) { \ - t ret = 0; \ - const auto sig = photon->signal->get( #name ); \ + t ret = 0; \ + auto sig = photon->signal->get( #name ); \ for ( const auto& cbk : sig->get_callbacks( ) ) { \ using orig_fn_t = t( __rescall* )( void*, a1_t, a2_t, a3_t ); \ ret = reinterpret_cast< t ( * )( orig_fn_t, void*, a1_t, a2_t, a3_t ) >( cbk )( reinterpret_cast< orig_fn_t >( sig->get_original( ) ), ecx, a1, a2, a3 ); \ } \ return ret; \ } +#define _SIGNAL4( t, name, a1_t, a1, a2_t, a2, a3_t, a3_, a4_t, a4 ) \ + static t __fastcall name##_handler( void* ecx, int edx, a1_t a1, a2_t a2, a3_t a3, a4_t a4 ) { \ + t ret = 0; \ + auto sig = photon->signal->get( #name ); \ + for ( const auto& cbk : sig->get_callbacks( ) ) { \ + using orig_fn_t = t( __rescall* )( void*, a1_t, a2_t, a3_t, a4_t ); \ + ret = reinterpret_cast< t ( * )( orig_fn_t, void*, a1_t, a2_t, a3_t, a4_t ) >( cbk )( reinterpret_cast< orig_fn_t >( sig->get_original( ) ), ecx, a1, a2, a3, a4 ); \ + } \ + return ret; \ + } +#define _SIGNAL5( t, name, a1_t, a1, a2_t, a2, a3_t, a3_, a4_t, a4, a5_t, a5 ) \ + static t __fastcall name##_handler( void* ecx, int edx, a1_t a1, a2_t a2, a3_t a3, a4_t a4, a5_t a5 ) { \ + t ret = 0; \ + auto sig = photon->signal->get( #name ); \ + for ( const auto& cbk : sig->get_callbacks( ) ) { \ + using orig_fn_t = t( __rescall* )( void*, a1_t, a2_t, a3_t, a4_t, a5_t ); \ + ret = reinterpret_cast< t ( * )( orig_fn_t, void*, a1_t, a2_t, a3_t, a4_t, a5_t ) >( cbk )( reinterpret_cast< orig_fn_t >( sig->get_original( ) ), ecx, a1, a2, a3, a4, a5 ); \ + } \ + return ret; \ + } +#define _SIGNAL6( t, name, a1_t, a1, a2_t, a2, a3_t, a3_, a4_t, a4, a5_t, a5, a6_t, a6 ) \ + static t __fastcall name##_handler( void* ecx, int edx, a1_t a1, a2_t a2, a3_t a3, a4_t a4, a5_t a5, a6_t a6 ) { \ + t ret = 0; \ + auto sig = photon->signal->get( #name ); \ + for ( const auto& cbk : sig->get_callbacks( ) ) { \ + using orig_fn_t = t( __rescall* )( void*, a1_t, a2_t, a3_t, a4_t, a5_t, a6_t ); \ + ret = reinterpret_cast< t ( * )( orig_fn_t, void*, a1_t, a2_t, a3_t, a4_t, a5_t, a6_t ) >( cbk )( reinterpret_cast< orig_fn_t >( sig->get_original( ) ), ecx, a1, a2, a3, a4, a5, a6 ); \ + } \ + return ret; \ + } -#define _SIGNAL_CALLBACK0( t, name ) t name##_cbk( t( __rescall* original )( void* ), void* ecx ) -#define _SIGNAL_CALLBACK1( t, name, a1_t, a1 ) t name##_cbk( t( __rescall* original )( void*, a1_t ), void* ecx, a1_t a1 ) -#define _SIGNAL_CALLBACK2( t, name, a1_t, a1, a2_t, a2 ) t name##_cbk( t( __rescall* original )( void*, a1_t, a2_t ), void* ecx, a1_t a1, a2_t a2 ) -#define _SIGNAL_CALLBACK3( t, name, a1_t, a1, a2_t, a2, a3_t, a3 ) t name##_cbk( t( __rescall* original )( void*, a1_t, a2_t, a3_t ), void* ecx, a1_t a1, a2_t a2, a3_t a3 ) +#define _SIGNAL_CALLBACK0( t, name ) t name##_cbk( t( __rescall* original )( void* ), void* ecx ) +#define _SIGNAL_CALLBACK1( t, name, a1_t, a1 ) t name##_cbk( t( __rescall* original )( void*, a1_t ), void* ecx, a1_t a1 ) +#define _SIGNAL_CALLBACK2( t, name, a1_t, a1, a2_t, a2 ) t name##_cbk( t( __rescall* original )( void*, a1_t, a2_t ), void* ecx, a1_t a1, a2_t a2 ) +#define _SIGNAL_CALLBACK3( t, name, a1_t, a1, a2_t, a2, a3_t, a3 ) t name##_cbk( t( __rescall* original )( void*, a1_t, a2_t, a3_t ), void* ecx, a1_t a1, a2_t a2, a3_t a3 ) +#define _SIGNAL_CALLBACK4( t, name, a1_t, a1, a2_t, a2, a3_t, a3, a4_t, a4 ) t name##_cbk( t( __rescall* original )( void*, a1_t, a2_t, a3_t, a4_t ), void* ecx, a1_t a1, a2_t a2, a3_t a3, a4_t a4 ) +#define _SIGNAL_CALLBACK5( t, name, a1_t, a1, a2_t, a2, a3_t, a3, a4_t, a4, a5_t, a5 ) t name##_cbk( t( __rescall* original )( void*, a1_t, a2_t, a3_t, a4_t, a5_t ), void* ecx, a1_t a1, a2_t a2, a3_t a3, a4_t a4, a5_t a5 ) +#define _SIGNAL_CALLBACK6( t, name, a1_t, a1, a2_t, a2, a3_t, a3, a4_t, a4, a5_t, a5, a6_t, a6 ) t name##_cbk( t( __rescall* original )( void*, a1_t, a2_t, a3_t, a4_t, a5_t, a6_t ), void* ecx, a1_t a1, a2_t a2, a3_t a3, a4_t a4, a5_t a5, a6_t a6 ) -#define _SIGNAL_NAME( _0, _1, _2, _3, _4, _5, _6, NAME, ... ) NAME +#define _SIGNAL_NAME( _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, NAME, ... ) NAME -#define SIGNAL( t, name, ... ) _SIGNAL_NAME( _0 __VA_OPT__(, ) __VA_ARGS__, _SIGNAL3, _3, _SIGNAL2, _2, _SIGNAL1, _1, _SIGNAL0 )( t, name __VA_OPT__(, ) __VA_ARGS__ ) -#define SIGNAL_CALLBACK( t, name, ... ) _SIGNAL_NAME( _0 __VA_OPT__(, ) __VA_ARGS__, _SIGNAL_CALLBACK3, _3, _SIGNAL_CALLBACK2, _2, _SIGNAL_CALLBACK1, _1, _SIGNAL_CALLBACK0 )( t, name __VA_OPT__(, ) __VA_ARGS__ ) +#define SIGNAL( t, name, ... ) _SIGNAL_NAME( _0 __VA_OPT__(, ) __VA_ARGS__, _SIGNAL6, _6, _SIGNAL5, _5, _SIGNAL4, _4, _SIGNAL3, _3, _SIGNAL2, _2, _SIGNAL1, _1, _SIGNAL0 )( t, name __VA_OPT__(, ) __VA_ARGS__ ) +#define SIGNAL_CALLBACK( t, name, ... ) _SIGNAL_NAME( _0 __VA_OPT__(, ) __VA_ARGS__, _SIGNAL_CALLBACK6, _6, _SIGNAL_CALLBACK5, _5, _SIGNAL_CALLBACK4, _4, _SIGNAL_CALLBACK3, _3, _SIGNAL_CALLBACK2, _2, _SIGNAL_CALLBACK1, _1, _SIGNAL_CALLBACK0 )( t, name __VA_OPT__(, ) __VA_ARGS__ )