AllocateCircularBuffer
0x00b69330 · 1268 bytes · __cdecl
_Z22AllocateCircularBufferi
Decompiled
undefined (1 param)
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* AllocateCircularBuffer(int) */
undefined4 * AllocateCircularBuffer(int param_1)
{
undefined4 *puVar1;
uint uVar2;
char cVar3;
undefined4 *puVar4;
uint uVar5;
int iVar6;
undefined4 *puVar7;
int iVar8;
bool bVar9;
if (0x2274 < param_1) {
if (0x44e8 < param_1) {
if (0x89d0 < param_1) {
puVar4 = malloc(param_1 + 0x13);
goto LAB_00b69369;
}
if (DAT_010453f0 == (undefined4 *)0x0) {
if ((CFixedBudgetMemoryPool<35304u,16>::Alloc()::autoMutex__ == '\0') &&
(iVar6 = __cxa_guard_acquire(&CFixedBudgetMemoryPool<35304u,16>::Alloc()::autoMutex__),
iVar6 != 0)) {
CFixedBudgetMemoryPool<35304u,16>::Alloc()::autoMutex__ = 0;
DAT_01045430 = 0;
__cxa_guard_release(&CFixedBudgetMemoryPool<35304u,16>::Alloc()::autoMutex__);
}
uVar5 = ThreadGetCurrentId();
if (uVar5 == CFixedBudgetMemoryPool<35304u,16>::Alloc()::autoMutex__) {
LAB_00b69528:
DAT_01045430 = DAT_01045430 + 1;
}
else {
LOCK();
bVar9 = CFixedBudgetMemoryPool<35304u,16>::Alloc()::autoMutex__ == 0;
uVar2 = uVar5;
if (!bVar9) {
uVar2 = CFixedBudgetMemoryPool<35304u,16>::Alloc()::autoMutex__;
}
CFixedBudgetMemoryPool<35304u,16>::Alloc()::autoMutex__ = uVar2;
UNLOCK();
if (bVar9) goto LAB_00b69528;
CThreadFastMutex::Lock(0x104542c,uVar5);
}
if (DAT_010453f0 == (undefined4 *)0x0) {
puVar7 = malloc(0x89e80);
puVar4 = puVar7 + 0x227a0;
DAT_010453f0 = puVar7;
_DAT_010453f4 = puVar4;
do {
do {
iVar6 = DAT_010453ec;
puVar1 = g_LargeBuffers;
iVar8 = DAT_010453ec + 0x10001;
*puVar7 = g_LargeBuffers;
/* try { // try from 00b69776 to 00b6977a has its CatchHandler @ 00b698ae */
cVar3 = ThreadInterlockedAssignIf64(&g_LargeBuffers,puVar7,iVar8,puVar1,iVar6);
} while (cVar3 == '\0');
puVar7 = puVar7 + 0x227a;
} while (puVar4 != puVar7);
}
DAT_01045430 = DAT_01045430 + -1;
if (DAT_01045430 == 0) {
LOCK();
UNLOCK();
CFixedBudgetMemoryPool<35304u,16>::Alloc()::autoMutex__ = 0;
}
}
do {
puVar4 = g_LargeBuffers;
if (g_LargeBuffers == (undefined4 *)0x0) {
puVar4 = malloc(0x89e8);
break;
}
cVar3 = ThreadInterlockedAssignIf64
(&g_LargeBuffers,*g_LargeBuffers,DAT_010453ec + -1,g_LargeBuffers,
DAT_010453ec);
} while (cVar3 == '\0');
goto LAB_00b69369;
}
if (DAT_01045400 == (undefined4 *)0x0) {
if ((CFixedBudgetMemoryPool<17664u,44>::Alloc()::autoMutex__ == '\0') &&
(iVar6 = __cxa_guard_acquire(&CFixedBudgetMemoryPool<17664u,44>::Alloc()::autoMutex__),
iVar6 != 0)) {
CFixedBudgetMemoryPool<17664u,44>::Alloc()::autoMutex__ = 0;
DAT_01045438 = 0;
__cxa_guard_release(&CFixedBudgetMemoryPool<17664u,44>::Alloc()::autoMutex__);
}
uVar5 = ThreadGetCurrentId();
if (uVar5 == CFixedBudgetMemoryPool<17664u,44>::Alloc()::autoMutex__) {
LAB_00b696a0:
DAT_01045438 = DAT_01045438 + 1;
}
else {
LOCK();
bVar9 = CFixedBudgetMemoryPool<17664u,44>::Alloc()::autoMutex__ == 0;
uVar2 = uVar5;
if (!bVar9) {
uVar2 = CFixedBudgetMemoryPool<17664u,44>::Alloc()::autoMutex__;
}
CFixedBudgetMemoryPool<17664u,44>::Alloc()::autoMutex__ = uVar2;
UNLOCK();
if (bVar9) goto LAB_00b696a0;
CThreadFastMutex::Lock(0x1045434,uVar5);
}
if (DAT_01045400 == (undefined4 *)0x0) {
puVar7 = malloc(0xbdc00);
puVar4 = puVar7 + 0x2f700;
DAT_01045400 = puVar7;
_DAT_01045404 = puVar4;
do {
do {
iVar6 = DAT_010453fc;
puVar1 = g_MediumBuffers;
iVar8 = DAT_010453fc + 0x10001;
*puVar7 = g_MediumBuffers;
/* try { // try from 00b6984e to 00b69852 has its CatchHandler @ 00b69866 */
cVar3 = ThreadInterlockedAssignIf64(&g_MediumBuffers,puVar7,iVar8,puVar1,iVar6);
} while (cVar3 == '\0');
puVar7 = puVar7 + 0x1140;
} while (puVar4 != puVar7);
}
DAT_01045438 = DAT_01045438 + -1;
if (DAT_01045438 == 0) {
LOCK();
UNLOCK();
CFixedBudgetMemoryPool<17664u,44>::Alloc()::autoMutex__ = 0;
}
}
do {
puVar4 = g_MediumBuffers;
if (g_MediumBuffers == (undefined4 *)0x0) {
puVar4 = malloc(0x4500);
break;
}
cVar3 = ThreadInterlockedAssignIf64
(&g_MediumBuffers,*g_MediumBuffers,DAT_010453fc + -1,g_MediumBuffers,
DAT_010453fc);
} while (cVar3 == '\0');
goto LAB_00b69369;
}
if (DAT_01045410 == (undefined4 *)0x0) {
if ((CFixedBudgetMemoryPool<8840u,24>::Alloc()::autoMutex__ == '\0') &&
(iVar6 = __cxa_guard_acquire(&CFixedBudgetMemoryPool<8840u,24>::Alloc()::autoMutex__),
iVar6 != 0)) {
CFixedBudgetMemoryPool<8840u,24>::Alloc()::autoMutex__ = 0;
DAT_01045440 = 0;
__cxa_guard_release(&CFixedBudgetMemoryPool<8840u,24>::Alloc()::autoMutex__);
}
uVar5 = ThreadGetCurrentId();
if (uVar5 == CFixedBudgetMemoryPool<8840u,24>::Alloc()::autoMutex__) {
LAB_00b695d8:
DAT_01045440 = DAT_01045440 + 1;
}
else {
LOCK();
bVar9 = CFixedBudgetMemoryPool<8840u,24>::Alloc()::autoMutex__ == 0;
uVar2 = uVar5;
if (!bVar9) {
uVar2 = CFixedBudgetMemoryPool<8840u,24>::Alloc()::autoMutex__;
}
CFixedBudgetMemoryPool<8840u,24>::Alloc()::autoMutex__ = uVar2;
UNLOCK();
if (bVar9) goto LAB_00b695d8;
CThreadFastMutex::Lock(0x104543c,uVar5);
}
if (DAT_01045410 == (undefined4 *)0x0) {
puVar7 = malloc(0x33cc0);
puVar4 = puVar7 + 0xcf30;
DAT_01045410 = puVar7;
_DAT_01045414 = puVar4;
do {
do {
iVar6 = DAT_0104540c;
puVar1 = g_SmallBuffers;
iVar8 = DAT_0104540c + 0x10001;
*puVar7 = g_SmallBuffers;
/* try { // try from 00b697de to 00b697e2 has its CatchHandler @ 00b6988d */
cVar3 = ThreadInterlockedAssignIf64(&g_SmallBuffers,puVar7,iVar8,puVar1,iVar6);
} while (cVar3 == '\0');
puVar7 = puVar7 + 0x8a2;
} while (puVar4 != puVar7);
}
DAT_01045440 = DAT_01045440 + -1;
if (DAT_01045440 == 0) {
LOCK();
UNLOCK();
CFixedBudgetMemoryPool<8840u,24>::Alloc()::autoMutex__ = 0;
}
}
do {
puVar4 = g_SmallBuffers;
if (g_SmallBuffers == (undefined4 *)0x0) {
puVar4 = malloc(0x2288);
break;
}
cVar3 = ThreadInterlockedAssignIf64
(&g_SmallBuffers,*g_SmallBuffers,DAT_0104540c + -1,g_SmallBuffers,DAT_0104540c
);
} while (cVar3 == '\0');
LAB_00b69369:
puVar4[3] = param_1;
puVar4[1] = 0;
puVar4[2] = 0;
*puVar4 = 0;
return puVar4;
}
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.