Last active
July 8, 2016 01:02
-
-
Save Andoryuuta/593d935cc9f5809f90a34d7c742db94e to your computer and use it in GitHub Desktop.
Ren compress repeated data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int __cdecl PacketManagerClass::DecodeRawPacket_Extention(cPacketManagePacketListEntry *PacketBuf1, cPacketManagePacketListEntry *PacketBuf2, char *RawPacketSrc, int PacketLength, int *PacketThingy) | |
{ | |
int BitIndex; // edx@1 | |
int result; // eax@2 | |
cPacketManagePacketListEntry *PacketBuf2_1; // esi@3 | |
char *NextExtraDataPtr; // ebp@9 | |
signed int dist; // edi@11 | |
unsigned int Uint64Count; // ebx@11 | |
char BitSet_0; // al@12 | |
char BitSet_1; // al@18 | |
int i2; // esi@22 | |
char BitSet_3; // al@24 | |
char *DataPtr; // edi@28 | |
char BitSet_2; // al@30 | |
char *DataPtr_1; // eax@38 | |
int DecompressedBuffer_Index_LoopDecCount; // esi@41 | |
char *DecompressedBuffer_LoopPtr; // ecx@41 | |
int tmpIndex; // edx@42 | |
char tmpValue; // bl@42 | |
int DecompressedBuffer_Index; // [sp+10h] [bp-1014h]@9 | |
int BytesRead; // [sp+14h] [bp-1010h]@9 | |
int BitIndex_2; // [sp+18h] [bp-100Ch]@9 | |
int i; // [sp+1Ch] [bp-1008h]@22 | |
char *NextExtraDataPtr_1; // [sp+20h] [bp-1004h]@9 | |
char DecompressedBuffer[4096]; // [sp+24h] [bp-1000h]@28 | |
BitIndex = 0; | |
PacketBuf2_1 = PacketBuf2; | |
NextExtraDataPtr = RawPacketSrc + 1; | |
DecompressedBuffer_Index = 0; | |
BitIndex_2 = 0; | |
BytesRead = 0; | |
NextExtraDataPtr_1 = RawPacketSrc + 1; | |
if (!PacketBuf1 || !PacketBuf2 || !RawPacketSrc) | |
{ | |
return 0; | |
} | |
if !(PacketLength <= 500) | |
{ | |
return 0; | |
} | |
if (*RawPacketSrc % 2) | |
{ | |
if (PacketLength - 7 > 0) | |
{ | |
Uint64Count = PacketLength / 8; | |
do | |
{ | |
BitSet_0 = (*NextExtraDataPtr >> BitIndex++) & 1; | |
if (BitIndex == 8) | |
{ | |
++NextExtraDataPtr; | |
BitIndex = 0; | |
} | |
if (BitSet_0) | |
{ | |
*&PacketBuf2_1->Packet[0] = *&PacketBuf1->Packet[0]; | |
*&PacketBuf2_1->Packet[4] = *&PacketBuf1->Packet[4]; | |
BytesRead += 8; | |
} | |
PacketBuf2_1 = (PacketBuf2_1 + 8); | |
--Uint64Count; | |
} while (Uint64Count); | |
} // End QWORD section | |
if (PacketLength % 8) | |
{ | |
BitSet_1 = (*NextExtraDataPtr >> BitIndex++) & 1; | |
if (BitIndex == 8) | |
{ | |
++NextExtraDataPtr; | |
BitIndex = 0; | |
} | |
if (BitSet_1) | |
{ | |
return 0; | |
} | |
} | |
} | |
i2 = 0; | |
for (i = 0; i2 < PacketLength; i = i2) | |
{ | |
if (*RawPacketSrc % 2) { // If lowest bit is NOT set // or !(*RawPacketSrc % 2) | |
BitSet_3 = (*NextExtraDataPtr_1 >> BitIndex_2++) & 1; | |
if (BitIndex_2 == 8) | |
{ | |
BitIndex_2 = 0; | |
++NextExtraDataPtr_1; | |
} | |
if (BitSet_3) | |
{ | |
i2 += 8; | |
continue | |
} | |
} | |
if (__OFSUB__(i2, i2 + 8) ^ 1)// Maybe: if i >= 8 | |
{ | |
DataPtr = &DecompressedBuffer[4 * DecompressedBuffer_Index]; | |
do | |
{ | |
if (i2 >= PacketLength) | |
break; | |
BitSet_2 = (*NextExtraDataPtr >> BitIndex++) & 1; | |
if (BitIndex == 8) | |
{ | |
++NextExtraDataPtr; | |
BitIndex = 0; | |
} | |
if (BitSet_2) | |
{ | |
PacketBuf2->Packet[i2] = *(&PacketBuf1->Packet[i2]); | |
++BytesRead; | |
} | |
else | |
{ | |
*DataPtr = i2; | |
DataPtr += 4; | |
++DecompressedBuffer_Index; | |
} | |
++i2; | |
} while (i2 < i + 8); | |
i2 = i; | |
} | |
i2 += 8; | |
} | |
DataPtr_1 = NextExtraDataPtr; | |
if (BitIndex) | |
DataPtr_1 = NextExtraDataPtr + 1; | |
*PacketThingy = DecompressedBuffer_Index + DataPtr_1 - RawPacketSrc; | |
if (DecompressedBuffer_Index > 0) | |
{ | |
DecompressedBuffer_Index_LoopDecCount = DecompressedBuffer_Index; | |
DecompressedBuffer_LoopPtr = DecompressedBuffer; | |
do | |
{ | |
tmpIndex = *DecompressedBuffer_LoopPtr; | |
tmpValue = *DataPtr_1++; | |
DecompressedBuffer_LoopPtr += 4; | |
--DecompressedBuffer_Index_LoopDecCount; | |
PacketBuf2->Packet[tmpIndex] = tmpValue; | |
} while (DecompressedBuffer_Index_LoopDecCount); | |
} | |
result = DecompressedBuffer_Index + BytesRead; | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original: