43 unsigned int type,
unsigned int numsyms,
101 if (!
self)
return NULL;
135 if (!
self || !self->system)
return;
138 self->system->close(hdr_p->
fh);
141 self->system->free(hdr);
155 unsigned char buf[16];
203 char *
fn = (
char *) sys->
alloc(sys, (
size_t) 13);
239 hdr->
extra = (
char *) sys->
alloc(sys, (
size_t)
i+1);
343 return self->error =
error;
364 #define BITS_TYPE struct kwajd_stream
366 #define BITS_ORDER_MSB
367 #define BITS_NO_READ_INPUT
368 #define READ_BYTES do { \
369 if (i_ptr >= i_end) { \
370 if ((err = lzh_read_input(lzh))) return err; \
371 i_ptr = lzh->i_ptr; \
372 i_end = lzh->i_end; \
374 INJECT_BITS(*i_ptr++, 8); \
379 #define TABLEBITS(tbl) KWAJ_TABLEBITS
380 #define MAXSYMBOLS(tbl) KWAJ_##tbl##_SYMS
381 #define HUFF_TABLE(tbl,idx) lzh->tbl##_table[idx]
382 #define HUFF_LEN(tbl,idx) lzh->tbl##_len[idx]
383 #define HUFF_ERROR return MSPACK_ERR_DATAFORMAT
396 #define READ_BITS_SAFE(val, n) do { \
398 if (lzh->input_end && bits_left < lzh->input_end) \
399 return MSPACK_ERR_OK; \
402 #define READ_HUFFSYM_SAFE(tbl, val) do { \
403 READ_HUFFSYM(tbl, val); \
404 if (lzh->input_end && bits_left < lzh->input_end) \
405 return MSPACK_ERR_OK; \
408 #define BUILD_TREE(tbl, type) \
410 err = lzh_read_lens(lzh, type, MAXSYMBOLS(tbl), &HUFF_LEN(tbl,0)); \
411 if (err) return err; \
413 if (make_decode_table(MAXSYMBOLS(tbl), TABLEBITS(tbl), \
414 &HUFF_LEN(tbl,0), &HUFF_TABLE(tbl,0))) \
415 return MSPACK_ERR_DATAFORMAT;
417 #define WRITE_BYTE do { \
418 if (lzh->sys->write(lzh->output, &lzh->window[pos], 1) != 1) \
419 return MSPACK_ERR_WRITE; \
440 register unsigned short sym;
443 unsigned int types[6];
479 lit_run = (
len == 32) ? 0 : 1;
495 if (!lzh || !lzh->
sys)
return;
501 unsigned int type,
unsigned int numsyms,
504 register unsigned int bit_buffer;
505 register int bits_left;
506 unsigned char *i_ptr, *i_end;
507 unsigned int i,
c,
sel;
513 i = numsyms;
c = (
i==16)?4: (
i==32)?5: (
i==64)?6: (
i==256)?8 :0;
514 for (
i = 0;
i < numsyms;
i++) lens[
i] =
c;
519 for (
i = 1;
i < numsyms;
i++) {
528 for (
i = 1;
i < numsyms;
i++) {
536 for (
i = 0;
i < numsyms;
i++) {
static RzILOpEffect * sel(cs_insn *insn, bool is_thumb)
const lzma_allocator const uint8_t * in
const lzma_allocator const uint8_t size_t uint8_t * out
static struct mskwajd_header * kwajd_open(struct mskwaj_decompressor *base, const char *filename)
static int kwajd_decompress(struct mskwaj_decompressor *base, const char *input, const char *output)
static void lzh_free(struct kwajd_stream *kwaj)
static int kwajd_read_headers(struct mspack_system *sys, struct mspack_file *fh, struct mskwajd_header *hdr)
void mspack_destroy_kwaj_decompressor(struct mskwaj_decompressor *base)
#define READ_BITS_SAFE(val, n)
static int lzh_decompress(struct kwajd_stream *kwaj)
#define READ_HUFFSYM_SAFE(tbl, val)
static int kwajd_extract(struct mskwaj_decompressor *base, struct mskwajd_header *hdr, const char *filename)
struct mskwaj_decompressor * mspack_create_kwaj_decompressor(struct mspack_system *sys)
#define BUILD_TREE(tbl, type)
static void kwajd_close(struct mskwaj_decompressor *base, struct mskwajd_header *hdr)
static struct kwajd_stream * lzh_init(struct mspack_system *sys, struct mspack_file *in, struct mspack_file *out)
static int lzh_read_input(struct kwajd_stream *kwaj)
static int lzh_read_lens(struct kwajd_stream *kwaj, unsigned int type, unsigned int numsyms, unsigned char *lens)
static int kwajd_error(struct mskwaj_decompressor *base)
return memset(p, 0, total)
static const char struct stat static buf struct stat static buf static idle const char static path static fd const char static len const void static prot const char struct module static image struct kernel_sym static table unsigned char static buf static fsuid unsigned struct dirent unsigned static count const struct iovec static count static pid const void static len static flags const struct sched_param static p static pid static policy struct timespec static tp static suid unsigned fn
int lzss_decompress(struct mspack_system *system, struct mspack_file *input, struct mspack_file *output, int input_buffer_size, int mode)
insn_type_descr_t types[]
struct mspack_file * output
struct mspack_file * input
unsigned char window[LZSS_WINDOW_SIZE]
struct mspack_system * sys
unsigned char inbuf[KWAJ_INPUT_SIZE]
struct mskwaj_decompressor base
void(* close)(struct mspack_file *file)
struct mspack_file *(* open)(struct mspack_system *self, const char *filename, int mode)
int(* seek)(struct mspack_file *file, off_t offset, int mode)
int(* read)(struct mspack_file *file, void *buffer, int bytes)
int(* write)(struct mspack_file *file, void *buffer, int bytes)
void *(* alloc)(struct mspack_system *self, size_t bytes)
struct mspack_system * sys
void error(const char *msg)
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)
int read(izstream &zs, T *x, Items items)