Skip to content

Commit

Permalink
Add symbols for AdvancedLuaErrorReporter
Browse files Browse the repository at this point in the history
  • Loading branch information
danielga committed Nov 27, 2022
1 parent 237b0ca commit ae09196
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
4 changes: 4 additions & 0 deletions helpers_extended/include/GarrysMod/FunctionPointers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class GModDataPack;
struct netsocket_t;
class LuaFile;
class CSteam3Server;
struct lua_State;

namespace FunctionPointers
{
Expand Down Expand Up @@ -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( );

}
1 change: 1 addition & 0 deletions helpers_extended/include/GarrysMod/Symbols.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ extern const Symbol GMOD_GetNetSocket;
extern const std::vector<Symbol> GModDataPack_AddOrUpdateFile;
extern const Symbol Steam3Server;
extern const std::vector<Symbol> GlobalVars;
extern const std::vector<Symbol> AdvancedLuaErrorReporter;

}
14 changes: 14 additions & 0 deletions helpers_extended/source/FunctionPointers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<AdvancedLuaErrorReporter_t>(
lua_shared_loader, Symbols::AdvancedLuaErrorReporter
);
}

return func_pointer;
}
}
21 changes: 21 additions & 0 deletions helpers_extended/source/Symbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Symbol> AdvancedLuaErrorReporter = { Symbol::FromName( "?AdvancedLuaErrorReporter@@YAHPEAUlua_State@@@Z" ) };

#elif defined ARCHITECTURE_X86

const std::vector<Symbol> CBasePlayer_HandleClientLuaError = {
Expand Down Expand Up @@ -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<Symbol> 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
Expand Down Expand Up @@ -327,6 +334,18 @@ namespace Symbols

};

const std::vector<Symbol> 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<Symbol> CBasePlayer_HandleClientLuaError = {
Expand Down Expand Up @@ -409,6 +428,8 @@ namespace Symbols

};

const std::vector<Symbol> AdvancedLuaErrorReporter = { Symbol::FromName( "_Z24AdvancedLuaErrorReporterP9lua_State" ) };

#endif

}
2 changes: 1 addition & 1 deletion source/ABICompatibility.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <Platform.hpp>

// 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).

Expand Down

0 comments on commit ae09196

Please sign in to comment.