Sys_LoadModule
0x00b6c6c0 · 574 bytes · __cdecl
_Z14Sys_LoadModulePKc9Sys_Flags
Decompiled
undefined (2 params)
/* Sys_LoadModule(char const*, Sys_Flags) */
int Sys_LoadModule(char *param_1,undefined4 param_2)
{
char cVar1;
int iVar2;
int iVar3;
uint uVar4;
uint uVar5;
char *pcVar6;
int *piVar7;
uint uVar8;
uint *puVar9;
char *pcVar10;
uint *puVar11;
int in_GS_OFFSET;
char acStack_824 [4];
uint local_820 [256];
char local_420 [1024];
int local_20;
local_20 = *(int *)(in_GS_OFFSET + 0x14);
cVar1 = V_IsAbsolutePath(param_1);
if (cVar1 == '\0') {
getcwd((char *)local_820,0x400);
puVar9 = local_820;
do {
puVar11 = puVar9;
uVar4 = *puVar11 + 0xfefefeff & ~*puVar11;
uVar5 = uVar4 & 0x80808080;
puVar9 = puVar11 + 1;
} while (uVar5 == 0);
if ((uVar4 & 0x8080) == 0) {
puVar9 = (uint *)((int)puVar11 + 6);
uVar5 = uVar5 >> 0x10;
}
pcVar10 = (char *)((int)puVar9 + ((-3 - (uint)CARRY1((byte)uVar5,(byte)uVar5)) - (int)local_820)
);
if ((acStack_824[(int)(pcVar10 + 3)] == '/') || (acStack_824[(int)(pcVar10 + 3)] == '\\')) {
acStack_824[(int)(pcVar10 + 3)] = '\0';
puVar9 = local_820;
do {
puVar11 = puVar9;
uVar5 = *puVar11 + 0xfefefeff & ~*puVar11;
uVar4 = uVar5 & 0x80808080;
puVar9 = puVar11 + 1;
} while (uVar4 == 0);
puVar9 = (uint *)((int)puVar11 + 6);
uVar8 = uVar4 >> 0x10;
if ((uVar5 & 0x8080) != 0) {
puVar9 = puVar11 + 1;
uVar8 = uVar4;
}
pcVar10 = (char *)((int)puVar9 +
((-3 - (uint)CARRY1((byte)uVar8,(byte)uVar8)) - (int)local_820));
}
pcVar6 = strstr(param_1,"bin/");
if ((param_1 == pcVar6) ||
(((acStack_824[(int)(pcVar10 + 3)] == 'n' && (acStack_824[(int)(pcVar10 + 2)] == 'i')) &&
(acStack_824[(int)(pcVar10 + 1)] == 'b')))) {
V_snprintf(local_420,0x400,"%s/%s",local_820,param_1);
}
else {
V_snprintf(local_420,0x400,"%s/bin/%s",local_820,param_1);
}
iVar2 = Sys_LoadLibrary(local_420,param_2);
if (iVar2 == 0) goto LAB_00b6c6e6;
iVar3 = dlsym(iVar2,"BuiltDebug");
if (iVar3 == 0) goto LAB_00b6c72e;
LAB_00b6c840:
piVar7 = (int *)CommandLine_Tier0();
iVar3 = (**(code **)(*piVar7 + 0x28))(piVar7,"-allowdebug");
if ((iVar3 == 0) && (cVar1 = Plat_IsInDebugSession(0), cVar1 == '\0')) {
Error("Module %s is a debug build\n",param_1);
}
}
else {
LAB_00b6c6e6:
iVar2 = Sys_LoadLibrary(param_1,param_2);
iVar3 = dlsym(iVar2,"BuiltDebug");
if (iVar3 == 0) goto LAB_00b6c72e;
if (iVar2 != 0) goto LAB_00b6c840;
}
DevWarning("Module %s is a debug build\n",param_1);
if (s_bRunningWithDebugModules == '\0') {
s_bRunningWithDebugModules = '\x01';
}
LAB_00b6c72e:
if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
return iVar2;
}
/* WARNING: Subroutine does not return */
__stack_chk_fail();
}
SourceMod gamedata
paste intoaddons/sourcemod/gamedata/<your_plugin>.txt
used as the SourceMod key — change to fit your plugin's convention
SourceMod library name (server / engine / matchmaking)
Just a Signatures{} block, ready to drop into a gamedata
file. Wire it up in your plugin however you like - SDKCall, DHooks,
raw memory ops, or anything else.
Signatures + Functions block. The plugin uses
DHookCreateFromConf - DHooks reads return type, this-type,
calling convention, and argument types straight from the gamedata. Less
boilerplate in the plugin, types travel with the gamedata.
Gamedata KeyValues
DHooks plugin example
Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.