... | ... |
@@ -125,32 +125,14 @@ int cli_LzmaDecode(struct CLI_LZMA *L) { |
125 | 125 |
return LZMA_RESULT_OK; |
126 | 126 |
} |
127 | 127 |
|
128 |
-/* int cli_LzmaInitUPX(CLI_LZMA **Lp, uint32_t dictsz) { */ |
|
129 |
-/* CLI_LZMA *L = *Lp; */ |
|
130 | 128 |
|
131 |
-/* if(!L) { */ |
|
132 |
-/* *Lp = L = cli_calloc(sizeof(*L), 1); */ |
|
133 |
-/* if(!L) { */ |
|
134 |
-/* return LZMA_RESULT_DATA_ERROR; */ |
|
135 |
-/* } */ |
|
136 |
-/* } */ |
|
137 |
- |
|
138 |
-/* L->state.Properties.pb = 2; /\* FIXME: these *\/ */ |
|
139 |
-/* L->state.Properties.lp = 0; /\* values may *\/ */ |
|
140 |
-/* L->state.Properties.lc = 3; /\* not be static *\/ */ |
|
141 |
- |
|
142 |
-/* L->state.Properties.DictionarySize = dictsz; */ |
|
143 |
- |
|
144 |
-/* if (!(L->state.Probs = (CProb *)cli_malloc(LzmaGetNumProbs(&L->state.Properties) * sizeof(CProb)))) */ |
|
145 |
-/* return LZMA_RESULT_DATA_ERROR; */ |
|
146 |
- |
|
147 |
-/* if (!(L->state.Dictionary = (unsigned char *)cli_malloc(L->state.Properties.DictionarySize))) { */ |
|
148 |
-/* free(L->state.Probs); */ |
|
149 |
-/* return LZMA_RESULT_DATA_ERROR; */ |
|
150 |
-/* } */ |
|
151 |
- |
|
152 |
-/* L->initted = 1; */ |
|
153 |
- |
|
154 |
-/* LzmaDecoderInit(&L->state); */ |
|
155 |
-/* return LZMA_RESULT_OK; */ |
|
156 |
-/* } */ |
|
129 |
+int cli_LzmaInitUPX(struct CLI_LZMA *L, uint32_t dsz) { |
|
130 |
+ unsigned char fake_hdr[5]; |
|
131 |
+ unsigned char *next_in = L->next_in; |
|
132 |
+ SizeT avail_in = L->avail_in; |
|
133 |
+ cli_writeint32(fake_hdr + 1, dsz); |
|
134 |
+ *fake_hdr = 9 /* lc */ + 9* ( 5* 2 /* pb */ + 0 /* lp */); |
|
135 |
+ L->next_in = fake_hdr; |
|
136 |
+ L->avail_in = 5; |
|
137 |
+ return cli_LzmaInit(L, dsz); |
|
138 |
+} |
... | ... |
@@ -52,7 +52,7 @@ struct stream_state { |
52 | 52 |
int cli_LzmaInit(struct CLI_LZMA *, uint64_t); |
53 | 53 |
void cli_LzmaShutdown(struct CLI_LZMA *); |
54 | 54 |
int cli_LzmaDecode(struct CLI_LZMA *); |
55 |
-/* int cli_LzmaInitUPX(struct CLI_LZMA **, uint32_t); FIXMELZMA */ |
|
55 |
+int cli_LzmaInitUPX(struct CLI_LZMA *, uint32_t); |
|
56 | 56 |
|
57 | 57 |
#define LZMA_STREAM_END 2 |
58 | 58 |
#define LZMA_RESULT_OK 0 |
... | ... |
@@ -528,7 +528,7 @@ int upx_inflatelzma(char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint3 |
528 | 528 |
uint32_t magic[]={0xb16,0xb1e,0}; |
529 | 529 |
|
530 | 530 |
memset(&l, 0, sizeof(l)); |
531 |
- //cli_LzmaInitUPX(&lz, *dsize); /* FIXMELZMA: make func and check return value */ |
|
531 |
+ cli_LzmaInitUPX(&l, *dsize); /* FIXMELZMA: check return value */ |
|
532 | 532 |
s.avail_in = ssize; |
533 | 533 |
s.avail_out = *dsize; |
534 | 534 |
s.next_in = (unsigned char*)src+2; |