COM_LoadFile
0x00126a60 · 430 bytes · __cdecl
_Z12COM_LoadFilePKciPij
Decompiled
undefined (4 params)
/* COM_LoadFile(char const*, int, int*, unsigned int) */
void * COM_LoadFile(char *param_1,int param_2,int *param_3,uint param_4)
{
size_t __size;
int iVar1;
void *pvVar2;
int in_GS_OFFSET;
void *local_a4;
char local_a0 [128];
int local_20;
local_20 = *(int *)(in_GS_OFFSET + 0x14);
if (param_3 != (int *)0x0) {
*param_3 = 0;
}
iVar1 = COM_FindFile(param_1,&local_a4,param_4);
if (local_a4 == (void *)0x0) {
pvVar2 = (void *)0x0;
goto LAB_00126b7e;
}
V_FileBase(param_1,local_a0,0x80);
__size = iVar1 + 1;
switch(param_2) {
default:
Sys_Error("COM_LoadFile: bad usehunk");
goto switchD_00126ae6_caseD_2;
case 1:
pvVar2 = (void *)Hunk_AllocName(__size,local_a0,true);
break;
case 2:
case 3:
goto switchD_00126ae6_caseD_2;
case 4:
pvVar2 = loadbuf;
if (loadsize <= iVar1) goto switchD_00126ae6_caseD_5;
break;
case 5:
switchD_00126ae6_caseD_5:
pvVar2 = malloc(__size);
}
if (pvVar2 == (void *)0x0) {
switchD_00126ae6_caseD_2:
Sys_Error("COM_LoadFile: not enough space for %s",param_1);
(**(code **)(g_pFileSystem[1] + 0xc))(g_pFileSystem + 1,local_a4);
pvVar2 = (void *)0x0;
}
else {
(**(code **)(*g_pFileSystem + 0x118))(g_pFileSystem,pvVar2,__size,iVar1,local_a4);
(**(code **)(g_pFileSystem[1] + 0xc))(g_pFileSystem + 1,local_a4);
*(undefined1 *)((int)pvVar2 + iVar1) = 0;
if (param_3 != (int *)0x0) {
*param_3 = iVar1;
}
}
LAB_00126b7e:
if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
return pvVar2;
}
/* 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.