/* vim: set filetype=c ts=8 noexpandtab: */ #include "common.h" #include "bitstream.h" #include "packet.h" #include __declspec(naked) void __stdcall BitStream__ctor( struct CBitStream *this, char *buffer, int lengthInBytes, char copyData) { _asm { pop eax pop ecx push eax mov eax, 0x44D930 jmp eax } } __declspec(naked) void __stdcall BitStream__dtor(struct CBitStream *this) { _asm { pop eax pop ecx push eax mov eax, 0x44D9B0 jmp eax } } __declspec(naked) int __stdcall BitStream__Read(struct CBitStream *this, char *out) { _asm { pop eax pop ecx push eax mov eax, 0x44D840 jmp eax } } int __stdcall Hooked_BitStream__ReadCompressed( char *out, unsigned char a, unsigned char unsignedData) { struct CBitStream *this; unsigned char tmpa, tmpread; int myReadOffset; _asm mov this, ecx tmpa = (a >> 3) - 1; if (unsignedData) { unsignedData = 0; a = 0; } else { unsignedData = 0xFF; a = 0xF0; } while (tmpa > 0) { myReadOffset = this->readOffset + 1; if (myReadOffset > this->numberOfBitsUsed) { return 0; } if ((0x80 >> this->readOffset) == this->ptrData[myReadOffset]) { this->readOffset = myReadOffset; return (int) thiscall3( (void*) 0x44DA70, this, (int) out, tmpa, 1); } this->readOffset = myReadOffset; out[tmpa] = unsignedData; tmpa--; } if (this->readOffset + 1 > this->numberOfBitsUsed) { return 0; } if (!thiscall1((void*) 0x44D840, this, (int) &tmpread)) { /*readBit*/ return 0; } out += 0; /*? esi + ebx but esi should be always 0?*/ if (tmpread) { if (!thiscall3((void*) 0x44DA70, this, (int) out, 4, 1)) { return 0; } *out |= a; } else { if (!thiscall3((void*) 0x44DA70, this, (int) out, 8, 1)) { return 0; } } return 1; }