CBitWrite::WriteBits
0x0009c290 · 481 bytes · __thiscall
_ZN9CBitWrite9WriteBitsEPKvi
Decompiled
undefined (3 params)
/* CBitWrite::WriteBits(void const*, int) */
byte __thiscall CBitWrite::WriteBits(CBitWrite *this,void *param_1,int param_2)
{
uint *puVar1;
byte bVar2;
byte bVar3;
byte bVar4;
int iVar5;
uint uVar6;
uint uVar7;
byte *local_18;
iVar5 = *(int *)(this + 0x14);
if (*(int *)(this + 8) <
(0x20 - iVar5) + (*(int *)(this + 0x18) - *(int *)(this + 0x20)) * 8 + param_2) {
this[4] = (CBitWrite)0x1;
return 0;
}
if (param_2 < 8) {
local_18 = param_1;
}
else {
uVar6 = param_2 - 8U >> 3;
local_18 = (byte *)((int)param_1 + uVar6 + 1);
while( true ) {
bVar3 = *(byte *)param_1;
bVar2 = (byte)iVar5;
if (iVar5 < 8) {
puVar1 = *(uint **)(this + 0x18);
uVar7 = ((&CBitBuffer::s_nMaskTable)[iVar5] & (uint)bVar3) << (0x20 - bVar2 & 0x1f) |
*(uint *)(this + 0x10);
*(uint *)(this + 0x10) = uVar7;
if (puVar1 == *(uint **)(this + 0x1c)) {
this[4] = (CBitWrite)0x1;
}
else {
*(uint **)(this + 0x18) = puVar1 + 1;
*puVar1 = uVar7;
}
*(int *)(this + 0x14) = iVar5 + 0x18;
*(uint *)(this + 0x10) = (uint)(bVar3 >> (bVar2 & 0x1f));
}
else {
*(int *)(this + 0x14) = iVar5 + -8;
uVar7 = (uint)bVar3 << (0x20 - bVar2 & 0x1f) | *(uint *)(this + 0x10);
*(uint *)(this + 0x10) = uVar7;
if (iVar5 + -8 == 0) {
puVar1 = *(uint **)(this + 0x18);
if (puVar1 == *(uint **)(this + 0x1c)) {
this[4] = (CBitWrite)0x1;
}
else {
*(uint **)(this + 0x18) = puVar1 + 1;
*puVar1 = uVar7;
}
*(undefined4 *)(this + 0x10) = 0;
*(undefined4 *)(this + 0x14) = 0x20;
}
}
if ((byte *)((int)param_1 + 1) == local_18) break;
param_1 = (void *)((int)param_1 + 1);
iVar5 = *(int *)(this + 0x14);
}
param_2 = (param_2 - 8U) + uVar6 * -8;
}
if (param_2 != 0) {
iVar5 = *(int *)(this + 0x14);
bVar3 = *local_18;
bVar2 = (byte)iVar5;
if (iVar5 < param_2) {
puVar1 = *(uint **)(this + 0x18);
uVar6 = ((&CBitBuffer::s_nMaskTable)[iVar5] & (uint)bVar3) << (0x20 - bVar2 & 0x1f) |
*(uint *)(this + 0x10);
*(uint *)(this + 0x10) = uVar6;
if (puVar1 == *(uint **)(this + 0x1c)) {
this[4] = (CBitWrite)0x1;
bVar4 = 0;
}
else {
*(uint **)(this + 0x18) = puVar1 + 1;
*puVar1 = uVar6;
bVar4 = (byte)this[4] ^ 1;
}
*(uint *)(this + 0x10) = (uint)(bVar3 >> (bVar2 & 0x1f));
*(int *)(this + 0x14) = 0x20 - (param_2 - iVar5);
return bVar4;
}
uVar6 = (&CBitBuffer::s_nMaskTable)[param_2];
*(int *)(this + 0x14) = iVar5 - param_2;
uVar6 = (bVar3 & uVar6) << (0x20 - bVar2 & 0x1f) | *(uint *)(this + 0x10);
*(uint *)(this + 0x10) = uVar6;
if (iVar5 - param_2 == 0) {
puVar1 = *(uint **)(this + 0x18);
if (puVar1 == *(uint **)(this + 0x1c)) {
this[4] = (CBitWrite)0x1;
bVar3 = 0;
}
else {
*(uint **)(this + 0x18) = puVar1 + 1;
*puVar1 = uVar6;
bVar3 = (byte)this[4] ^ 1;
}
*(undefined4 *)(this + 0x10) = 0;
*(undefined4 *)(this + 0x14) = 0x20;
return bVar3;
}
}
return (byte)this[4] ^ 1;
}
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.