old_bf_read::ReadBits
0x00242e60 · 677 bytes · __thiscall
_ZN11old_bf_read8ReadBitsEPvi
Decompiled
undefined (3 params)
/* old_bf_read::ReadBits(void*, int) */
void __thiscall old_bf_read::ReadBits(old_bf_read *this,void *param_1,int param_2)
{
uint uVar1;
uint uVar2;
int iVar3;
uint uVar4;
uint *puVar5;
int iVar6;
byte bVar7;
uint *puVar8;
uint *local_1c;
uint *local_18;
for (local_1c = param_1; ((uint)local_1c & 3) != 0; local_1c = (uint *)((int)local_1c + 1)) {
if (param_2 < 8) goto LAB_00242fc9;
iVar3 = *(int *)(this + 0xc);
uVar2 = iVar3 + 8;
if (*(int *)(this + 8) < (int)uVar2) {
*(int *)(this + 0xc) = *(int *)(this + 8);
local_18._0_1_ = 0;
this[0x10] = (old_bf_read)0x1;
}
else {
iVar6 = iVar3 >> 5;
uVar1 = *(uint *)(*(int *)this + iVar6 * 4);
*(uint *)(this + 0xc) = uVar2;
local_18._0_1_ = (byte)(uVar1 >> ((byte)iVar3 & 0x1f));
if (iVar6 == iVar3 + 7 >> 5) {
local_18._0_1_ = (byte)local_18 & (byte)DAT_003f2d40;
}
else {
local_18._0_1_ =
(byte)((*(uint *)(*(int *)this + 4 + iVar6 * 4) & (&g_ExtraMasks)[uVar2 & 0x1f]) <<
(8U - (char)(uVar2 & 0x1f) & 0x1f)) | (byte)local_18;
}
}
param_2 = param_2 + -8;
*(byte *)local_1c = (byte)local_18;
}
if (0x1f < param_2) {
uVar2 = param_2 - 0x20U >> 5;
puVar5 = local_1c + uVar2 + 1;
do {
while( true ) {
uVar1 = *(uint *)(this + 0xc);
if ((int)(uVar1 + 0x20) <= *(int *)(this + 8)) break;
*(int *)(this + 0xc) = *(int *)(this + 8);
puVar8 = local_1c + 1;
this[0x10] = (old_bf_read)0x1;
*local_1c = 0;
local_1c = puVar8;
if (puVar8 == puVar5) goto LAB_00242fbb;
}
iVar3 = (int)uVar1 >> 5;
uVar4 = *(uint *)(*(int *)this + iVar3 * 4);
*(uint *)(this + 0xc) = uVar1 + 0x20;
local_18._0_1_ = (byte)(uVar1 & 0x1f);
uVar4 = uVar4 >> (byte)local_18;
if (iVar3 != (int)(uVar1 + 0x1f) >> 5) {
uVar4 = uVar4 | (*(uint *)(*(int *)this + 4 + iVar3 * 4) & (&g_ExtraMasks)[uVar1 & 0x1f]) <<
(0x20 - (byte)local_18 & 0x1f);
}
*local_1c = uVar4;
local_1c = local_1c + 1;
} while (local_1c != puVar5);
LAB_00242fbb:
param_2 = (param_2 - 0x20U) + uVar2 * -0x20;
local_1c = puVar5;
}
LAB_00242fc9:
if (param_2 < 8) {
local_18 = local_1c;
}
else {
uVar2 = param_2 - 8U >> 3;
local_18 = (uint *)((int)local_1c + uVar2 + 1);
do {
while( true ) {
iVar3 = *(int *)(this + 0xc);
uVar1 = iVar3 + 8;
if ((int)uVar1 <= *(int *)(this + 8)) break;
*(int *)(this + 0xc) = *(int *)(this + 8);
puVar5 = (uint *)((int)local_1c + 1);
this[0x10] = (old_bf_read)0x1;
*(undefined1 *)local_1c = 0;
local_1c = puVar5;
if (puVar5 == local_18) goto LAB_00243069;
}
iVar6 = iVar3 >> 5;
uVar4 = *(uint *)(*(int *)this + iVar6 * 4);
*(uint *)(this + 0xc) = uVar1;
bVar7 = (byte)(uVar4 >> ((byte)iVar3 & 0x1f));
if (iVar6 == iVar3 + 7 >> 5) {
bVar7 = bVar7 & (byte)DAT_003f2d40;
}
else {
bVar7 = (byte)((*(uint *)(*(int *)this + 4 + iVar6 * 4) & (&g_ExtraMasks)[uVar1 & 0x1f]) <<
(8U - (char)(uVar1 & 0x1f) & 0x1f)) | bVar7;
}
*(byte *)local_1c = bVar7;
local_1c = (uint *)((int)local_1c + 1);
} while (local_1c != local_18);
LAB_00243069:
param_2 = (param_2 - 8U) + uVar2 * -8;
}
if (param_2 == 0) {
return;
}
iVar3 = *(int *)(this + 0xc);
uVar2 = param_2 + iVar3;
if (*(int *)(this + 8) < (int)uVar2) {
*(int *)(this + 0xc) = *(int *)(this + 8);
bVar7 = 0;
this[0x10] = (old_bf_read)0x1;
}
else {
iVar6 = iVar3 >> 5;
uVar1 = *(uint *)(*(int *)this + iVar6 * 4);
*(uint *)(this + 0xc) = uVar2;
bVar7 = (byte)(uVar1 >> ((byte)iVar3 & 0x1f));
if (iVar6 == (int)(uVar2 - 1) >> 5) {
bVar7 = bVar7 & *(byte *)(&g_ExtraMasks + param_2);
}
else {
bVar7 = bVar7 | (byte)(((&g_ExtraMasks)[uVar2 & 0x1f] &
*(uint *)(*(int *)this + 4 + iVar6 * 4)) <<
((char)param_2 - (char)(uVar2 & 0x1f) & 0x1fU));
}
}
*(byte *)local_18 = bVar7;
return;
}
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.