diff --git a/helpers_extended/include/GarrysMod/FunctionPointers.hpp b/helpers_extended/include/GarrysMod/FunctionPointers.hpp index 0ad0ee2..82a763e 100644 --- a/helpers_extended/include/GarrysMod/FunctionPointers.hpp +++ b/helpers_extended/include/GarrysMod/FunctionPointers.hpp @@ -31,6 +31,7 @@ class GModDataPack; struct netsocket_t; class LuaFile; class CSteam3Server; +struct lua_State; namespace FunctionPointers { @@ -68,4 +69,7 @@ GModDataPack_AddOrUpdateFile_t GModDataPack_AddOrUpdateFile( ); typedef CSteam3Server *( *Steam3Server_t )( ); Steam3Server_t Steam3Server( ); +typedef int ( *AdvancedLuaErrorReporter_t )( lua_State *L ); +AdvancedLuaErrorReporter_t AdvancedLuaErrorReporter( ); + } diff --git a/helpers_extended/include/GarrysMod/Symbols.hpp b/helpers_extended/include/GarrysMod/Symbols.hpp index bc7acb7..764c561 100644 --- a/helpers_extended/include/GarrysMod/Symbols.hpp +++ b/helpers_extended/include/GarrysMod/Symbols.hpp @@ -24,5 +24,6 @@ extern const Symbol GMOD_GetNetSocket; extern const std::vector GModDataPack_AddOrUpdateFile; extern const Symbol Steam3Server; extern const std::vector GlobalVars; +extern const std::vector AdvancedLuaErrorReporter; } diff --git a/helpers_extended/source/FunctionPointers.cpp b/helpers_extended/source/FunctionPointers.cpp index f10c03a..8929a1d 100644 --- a/helpers_extended/source/FunctionPointers.cpp +++ b/helpers_extended/source/FunctionPointers.cpp @@ -240,4 +240,18 @@ namespace FunctionPointers return func_pointer; } + + AdvancedLuaErrorReporter_t AdvancedLuaErrorReporter( ) + { + static AdvancedLuaErrorReporter_t func_pointer = nullptr; + if( func_pointer == nullptr ) + { + SourceSDK::FactoryLoader lua_shared_loader( "lua_shared" ); + func_pointer = ResolveSymbols( + lua_shared_loader, Symbols::AdvancedLuaErrorReporter + ); + } + + return func_pointer; + } } diff --git a/helpers_extended/source/Symbols.cpp b/helpers_extended/source/Symbols.cpp index 7cf3d90..47c72ed 100644 --- a/helpers_extended/source/Symbols.cpp +++ b/helpers_extended/source/Symbols.cpp @@ -75,6 +75,8 @@ namespace Symbols Symbol::FromSignature( "\x2A\x2A\x2A\x2A\x41\x8B\xD4\x48\x8D\x4C\x24\x2A\xE8\x2A\x2A\x2A\x2A\x41\x8B\xD4\x48" ) }; + const std::vector AdvancedLuaErrorReporter = { Symbol::FromName( "?AdvancedLuaErrorReporter@@YAHPEAUlua_State@@@Z" ) }; + #elif defined ARCHITECTURE_X86 const std::vector CBasePlayer_HandleClientLuaError = { @@ -156,6 +158,11 @@ namespace Symbols Symbol::FromSignature( "\x2A\x2A\x2A\x2A\x8D\x45\x2A\x6A\x01\x50\xE8\x2A\x2A\x2A\x2A\x8D\x45" ) }; + const std::vector AdvancedLuaErrorReporter = { + Symbol::FromName( "?AdvancedLuaErrorReporter@@YAHPAUlua_State@@@Z" ), + Symbol::FromSignature( "\x55\x8B\xEC\x8B\x0D\x2A\x2A\x2A\x2A\x83\xEC\x4C" ) + }; + #endif #elif defined SYSTEM_LINUX @@ -327,6 +334,18 @@ namespace Symbols }; + const std::vector AdvancedLuaErrorReporter = { + +#if defined ARCHITECTURE_X86 + + Symbol::FromSignature( "\x55\x89\xE5\x57\x56\x53\x83\xEC\x7C\x8B\x15\x2A\x2A\x2A\x2A\x8B\x7D\x2A" ), + +#endif + + Symbol::FromName( "_Z24AdvancedLuaErrorReporterP9lua_State" ) + + }; + #elif defined SYSTEM_MACOSX const std::vector CBasePlayer_HandleClientLuaError = { @@ -409,6 +428,8 @@ namespace Symbols }; + const std::vector AdvancedLuaErrorReporter = { Symbol::FromName( "_Z24AdvancedLuaErrorReporterP9lua_State" ) }; + #endif } diff --git a/source/ABICompatibility.cpp b/source/ABICompatibility.cpp index d2031eb..0f5dc32 100644 --- a/source/ABICompatibility.cpp +++ b/source/ABICompatibility.cpp @@ -1,7 +1,7 @@ #include // Visual Studio 2015 to Visual Studio 2022 -#if defined SYSTEM_WINDOWS && ( _MSC_VER < 1900 || _MSC_VER > 1933 ) +#if defined SYSTEM_WINDOWS && ( _MSC_VER < 1900 || _MSC_VER > 1934 ) #error The only supported compilation platforms for this project on Windows are Visual Studio 2015, 2017, 2019 and 2022 (for ABI compatibility reasons).