Add safetyhook to load logic

This commit is contained in:
Kenzzer 2025-04-03 13:30:30 +00:00
parent ccaf7f2f44
commit 2a1bb88e90
No known key found for this signature in database
GPG Key ID: BD2A655EB5DC87A9
3 changed files with 21 additions and 1 deletions

View File

@ -676,6 +676,19 @@ void CoreProviderImpl::InitializeBridge()
bool CoreProviderImpl::LoadBridge(char *error, size_t maxlength)
{
char file[PLATFORM_MAX_PATH];
char myerror[255];
/* Load safetyhook first. The core & extensions might depend on it */
g_SMAPI->PathFormat(file,
sizeof(file),
"%s/bin/" PLATFORM_ARCH_FOLDER "safetyhook." PLATFORM_LIB_EXT,
g_SourceMod.GetSourceModPath());
safetyhook_ = ke::SharedLib::Open(file, myerror, sizeof(myerror));
if (!safetyhook_) {
ke::SafeSprintf(error, maxlength, "failed to load %s: %s", file, myerror);
return false;
}
/* Now it's time to load the logic binary */
g_SMAPI->PathFormat(file,
@ -683,7 +696,6 @@ bool CoreProviderImpl::LoadBridge(char *error, size_t maxlength)
"%s/bin/" PLATFORM_ARCH_FOLDER "sourcemod.logic." PLATFORM_LIB_EXT,
g_SourceMod.GetSourceModPath());
char myerror[255];
logic_ = ke::SharedLib::Open(file, myerror, sizeof(myerror));
if (!logic_) {
ke::SafeSprintf(error, maxlength, "failed to load %s: %s", file, myerror);

View File

@ -76,6 +76,7 @@ public:
}
private:
ke::RefPtr<ke::SharedLib> safetyhook_;
ke::RefPtr<ke::SharedLib> logic_;
LogicInitFunction logic_init_;
GameHooks hooks_;

View File

@ -50,6 +50,13 @@ helpers = SM.package_helpers
helpers.builder = builder
folder_map = helpers.CreateFolders(folder_list)
# Copy safetyhook
for cxx_task in SM.libsafetyhook:
if cxx_task.target.arch == 'x86_64' in cxx_task.binary.path:
builder.AddCopy(cxx_task.binary, folder_map['addons/sourcemod/bin/x64'])
else:
builder.AddCopy(cxx_task.binary, folder_map['addons/sourcemod/bin'])
# Copy binaries.
for cxx_task in SM.binaries:
# mms expects our loader (sourcemod_mm) to exist in /bin/