该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
*op++ = (BYTE)(16 | ((m_off & 0x4000) >> 11));
m3_m4_len:
while (m_len > 255)
{
m_len -= 255;
*op++ = 0;
}
*op++ = (BYTE)m_len;
}
}
m3_m4_offset:
*op++ = (BYTE)((m_off & 63) <
*op++ = (BYTE)(m_off >> 6);
}
ii = ip;
if (ip >= ip_end)
break;
}
*out_len = op - out;
return (unsigned long) (in_end - ii);
}
int _stdcall compress(void *in, unsigned long in_len,
void *out)
{
BYTE *op = out;
unsigned long t,out_len;
if (in_len <= 13)
t = in_len;
else
{
t = _do_compress (in,in_len,op,&out_len);
op += out_len;
}
if (t > 0)
{
BYTE *ii = (BYTE*)in + in_len - t;
if (op == (BYTE*)out && t <= 238)
*op++ = (BYTE) ( 17 + t );
else
if (t <= 3)
op[-2] |= (BYTE)t ;
else
if (t <= 18)
*op++ = (BYTE)(t-3);
else
{
unsigned long tt = t - 18;
*op++ = 0;
while (tt > 255)
{
tt -= 255;
*op++ = 0;
}
*op++ = (BYTE)tt;
}
do *op++ = *ii++; while (--t > 0);
}
*op++ = 17;
*op++ = 0;
*op++ = 0;
return (op - (BYTE*)out);
}
int _stdcall decompress (void *in, unsigned long in_len,
void *out)
{
register BYTE *op;
register BYTE *ip;
register unsigned long t;
register BYTE *m_pos;
unsigned short dwBuf;
BYTE *ip_end = (BYTE*)in + in_len;
op = out;
ip = in;
if(*ip > 17)
{
t = *ip++ - 17;
if (t
goto match_next;
do *op++ = *ip++; while (--t > 0);
goto first_literal_run;
}
for(;;)
{
t = *ip++;
if (t >= 16) goto match;
if (t == 0)
{
while (*ip == 0)
{
t += 255;
ip++;
}
t += 15 + *ip++;
}
//*(unsigned long*) op = *(unsigned long*) ip;
//memcpy(op, ip, 4);
op[0] = ip[0];
op[1] = ip[1];
op[2] = ip[2];
op[3] = ip[3];
op += 4; ip += 4;
if (--t > 0)
{
if (t >= 4)
{
do
{
//*(unsigned long*) op = *(unsigned long*) ip;
//memcpy(op, ip, 4);
op[0] = ip[0];
op[1] = ip[1];
op[2] = ip[2];
op[3] = ip[3];
op += 4; ip += 4; t -= 4;
} while (t >= 4);
if (t > 0) do *op++ = *ip++; while (--t > 0);
}
else
do *op++ = *ip++; while (--t > 0);
}
first_literal_run:
t = *ip++;
if (t >= 16)
goto match;
m_pos = op - 0x0801;
m_pos -= t >> 2;
m_pos -= *ip++ <
*op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos;
goto match_done;
for(;;)
{
match:
if (t >= 64)
{
m_pos = op - 1;
m_pos -= (t >> 2) & 7;
m_pos -= *ip++ <
t = (t >> 5) - 1;
goto copy_match;
}
else
if (t >= 32)
{
t &= 31;
if (t == 0)
{
while (*ip == 0)
{
t += 255;
ip++;
}
t += 31 + *ip++;
}
m_pos = op - 1;
//memcpy(&dwBuf, ip, 2);
//dwBuf = 0;
dwBuf = (ip[0]);
dwBuf |= (ip[1] <
m_pos -= (dwBuf >> 2);
ip += 2;
}
else
if (t >= 16)
{
m_pos = op;
m_pos -= (t & 8) <
t &= 7;
if (t == 0)
{
while (*ip == 0)
{
t += 255;
ip++;
}
t += 7 + *ip++;
}
//memcpy(&dwBuf, ip, 2);
//dwBuf = 0;
dwBuf = (ip[0]);
dwBuf |= (ip[1] <
m_pos -= (dwBuf >> 2);
ip += 2;
if (m_pos == op)
goto eof_found;
m_pos -= 0x4000;
}
else
{
m_pos = op - 1;
m_pos -= t >> 2;
m_pos -= *ip++ <
*op++ = *m_pos++; *op++ = *m_pos;
goto match_done;
}
if (t >= 6 && (op - m_pos) >= 4)
{
//* (unsigned long*) op = * (unsigned long*) m_pos;
// memcpy(op, m_pos, 4);
op[0] = m_pos[0];
op[1] = m_pos[1];
op[2] = m_pos[2];
op[3] = m_pos[3];
op += 4; m_pos += 4; t -= 2;
do
{
//* (unsigned long*) op = * (unsigned long*)m_pos;
// memcpy(op, m_pos, 4);
op[0] = m_pos[0];
op[1] = m_pos[1];
op[2] = m_pos[2];
op[3] = m_pos[3];
op += 4; m_pos += 4; t -= 4;
}while (t >= 4);
if (t > 0)
do *op++ = *m_pos++; while (--t > 0);
}
else
{
copy_match:
*op++ = *m_pos++; *op++ = *m_pos++;
do *op++ = *m_pos++; while (--t > 0);
}
match_done:
t = ip[-2] & 3;
if (t == 0)break;
match_next:
do *op++ = *ip++; while (--t > 0);
t = *ip++;
}
}
eof_found:
if (ip != ip_end) return -1;
return (op - (BYTE*)out);
}