Rizin
unix-like reverse engineering framework and cli tools
lzma2_decoder.h File Reference

LZMA2 decoder. More...

#include "common.h"

Go to the source code of this file.

Functions

lzma_ret lzma_lzma2_decoder_init (lzma_next_coder *next, const lzma_allocator *allocator, const lzma_filter_info *filters)
 
uint64_t lzma_lzma2_decoder_memusage (const void *options)
 
lzma_ret lzma_lzma2_props_decode (void **options, const lzma_allocator *allocator, const uint8_t *props, size_t props_size)
 

Detailed Description

LZMA2 decoder.

Definition in file lzma2_decoder.h.

Function Documentation

◆ lzma_lzma2_decoder_init()

lzma_ret lzma_lzma2_decoder_init ( lzma_next_coder next,
const lzma_allocator allocator,
const lzma_filter_info filters 
)

Definition at line 257 of file lzma2_decoder.c.

259 {
260  // LZMA2 can only be the last filter in the chain. This is enforced
261  // by the raw_decoder initialization.
262  assert(filters[1].init == NULL);
263 
264  return lzma_lz_decoder_init(next, allocator, filters,
266 }
const lzma_allocator * allocator
Definition: block.h:377
const lzma_filter * filters
Definition: container.h:315
#define NULL
Definition: cris-opc.c:27
lzma_ret lzma_lz_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator, const lzma_filter_info *filters, lzma_ret(*lz_init)(lzma_lz_decoder *lz, const lzma_allocator *allocator, const void *options, lzma_lz_options *lz_options))
Definition: lz_decoder.c:212
static lzma_ret lzma2_decoder_init(lzma_lz_decoder *lz, const lzma_allocator *allocator, const void *opt, lzma_lz_options *lz_options)
assert(limit<=UINT32_MAX/2)
bool init
Definition: core.c:77

References allocator, assert(), filters, init, lzma2_decoder_init(), lzma_lz_decoder_init(), and NULL.

◆ lzma_lzma2_decoder_memusage()

uint64_t lzma_lzma2_decoder_memusage ( const void *  options)

Definition at line 270 of file lzma2_decoder.c.

271 {
272  return sizeof(lzma_lzma2_coder)
274 }
static const char struct stat static buf struct stat static buf static vhangup int options
Definition: sflib.h:145
uint64_t lzma_lzma_decoder_memusage_nocheck(const void *options)

References lzma_lzma_decoder_memusage_nocheck(), and options.

◆ lzma_lzma2_props_decode()

lzma_ret lzma_lzma2_props_decode ( void **  options,
const lzma_allocator allocator,
const uint8_t props,
size_t  props_size 
)

Definition at line 278 of file lzma2_decoder.c.

280 {
281  if (props_size != 1)
282  return LZMA_OPTIONS_ERROR;
283 
284  // Check that reserved bits are unset.
285  if (props[0] & 0xC0)
286  return LZMA_OPTIONS_ERROR;
287 
288  // Decode the dictionary size.
289  if (props[0] > 40)
290  return LZMA_OPTIONS_ERROR;
291 
293  sizeof(lzma_options_lzma), allocator);
294  if (opt == NULL)
295  return LZMA_MEM_ERROR;
296 
297  if (props[0] == 40) {
298  opt->dict_size = UINT32_MAX;
299  } else {
300  opt->dict_size = 2 | (props[0] & 1U);
301  opt->dict_size <<= props[0] / 2U + 11;
302  }
303 
304  opt->preset_dict = NULL;
305  opt->preset_dict_size = 0;
306 
307  *options = opt;
308 
309  return LZMA_OK;
310 }
const lzma_allocator const uint8_t * props
Definition: filter.h:362
#define UINT32_MAX
Options specific to the LZMA1 and LZMA2 filters.
Definition: lzma12.h:185
const uint8_t * preset_dict
Pointer to an initial dictionary.
Definition: lzma12.h:240
uint32_t preset_dict_size
Size of the preset dictionary.
Definition: lzma12.h:254
uint32_t dict_size
Dictionary size in bytes.
Definition: lzma12.h:217
void * lzma_alloc(size_t size, const lzma_allocator *allocator) lzma_attribute((__malloc__)) lzma_attr_alloc_size(1)
Allocates memory.
@ LZMA_MEM_ERROR
Cannot allocate memory.
Definition: base.h:128
@ LZMA_OPTIONS_ERROR
Invalid or unsupported options.
Definition: base.h:160
@ LZMA_OK
Operation completed successfully.
Definition: base.h:58