this is content of packed and unpacked sample file:


i have a part of C code for unpack these files:
Code: Select all
static unsigned xdecompress(const unsigned char *inp, unsigned char *outbuf, unsigned outlen) {
const unsigned counts[16] = { 4, 0, 1, 0,
2, 0, 1, 0,
3, 0, 1, 0,
2, 0, 1, 0 };
unsigned char *outp = outbuf, *p;
unsigned char *outlast = outbuf + outlen - 1;
unsigned mask = 1, bits, len, off;
for (;;) {
assert(mask != 0);
if (mask == 1) { mask = get_u32(inp); //printf("reload mask=%x\n", mask);
inp += 4;}
bits = get_u32(inp);
if (mask & 1) { mask >>= 1; len = 3;++inp;
if (bits & 3) { ++inp;
if (bits & 2) {
if (bits & 1) { ++inp;
if ((bits & 0x7f) == 3) { ++inp; off = bits >> 15; len += (bits >> 7) & 0xff;}
else { off = (bits >> 7) & 0x1ffff; len += ((bits >> 2) & 0x1f) - 1; }
} else { off = (bits >> 6) & 0x3ff; len += (bits >> 2) & 0xf; }
} else { off = (bits >> 2) & 0x3fff; }
} else { off = (bits >> 2) & 0x3f; }
//printf("back ref bits=%u off=%u len=%u\n", bits & 3, off, len);
assert(outp - off >= outbuf);
assert(outp + len <= outlast);
p = outp;
outp += len;
do { put_u32(p, get_u32(p - off)); p += 3; } while (p < outp);
} else
if (outp < outlast - 10) { put_u32(outp, bits); len = counts[mask & 0x0f];
//printf("literal run len=%u\n", len);
outp += len; inp += len; mask >>= len;
} else { //printf("tail len=%u\n", (unsigned)(outlast - outp));
while (outp <= outlast) {
if (mask == 1) { mask = 0x80000000; inp += 4; }
*outp++ = *inp++; mask >>= 1; }
return outlen; }
}
}in attachment sample files.


