Rizin
unix-like reverse engineering framework and cli tools
lzma_block Struct Reference

Options for the Block and Block Header encoders and decoders. More...

#include <block.h>

Public Attributes

uint32_t version
 Block format version. More...
 
uint32_t header_size
 Size of the Block Header field. More...
 
lzma_check check
 Type of integrity Check. More...
 
lzma_vli compressed_size
 Size of the Compressed Data in bytes. More...
 
lzma_vli uncompressed_size
 Uncompressed Size in bytes. More...
 
lzma_filterfilters
 Array of filters. More...
 
uint8_t raw_check [LZMA_CHECK_SIZE_MAX]
 Raw value stored in the Check field. More...
 
void * reserved_ptr1
 
void * reserved_ptr2
 
void * reserved_ptr3
 
uint32_t reserved_int1
 
uint32_t reserved_int2
 
lzma_vli reserved_int3
 
lzma_vli reserved_int4
 
lzma_vli reserved_int5
 
lzma_vli reserved_int6
 
lzma_vli reserved_int7
 
lzma_vli reserved_int8
 
lzma_reserved_enum reserved_enum1
 
lzma_reserved_enum reserved_enum2
 
lzma_reserved_enum reserved_enum3
 
lzma_reserved_enum reserved_enum4
 
lzma_bool ignore_check
 A flag to Block decoder to not verify the Check field. More...
 
lzma_bool reserved_bool2
 
lzma_bool reserved_bool3
 
lzma_bool reserved_bool4
 
lzma_bool reserved_bool5
 
lzma_bool reserved_bool6
 
lzma_bool reserved_bool7
 
lzma_bool reserved_bool8
 

Detailed Description

Options for the Block and Block Header encoders and decoders.

Different Block handling functions use different parts of this structure. Some read some members, other functions write, and some do both. Only the members listed for reading need to be initialized when the specified functions are called. The members marked for writing will be assigned new values at some point either by calling the given function or by later calls to lzma_code().

Definition at line 30 of file block.h.

Member Data Documentation

◆ check

lzma_check lzma_block::check

Type of integrity Check.

The Check ID is not stored into the Block Header, thus its value must be provided also when decoding.

Read by:

  • lzma_block_header_encode()
  • lzma_block_header_decode()
  • lzma_block_compressed_size()
  • lzma_block_unpadded_size()
  • lzma_block_total_size()
  • lzma_block_encoder()
  • lzma_block_decoder()
  • lzma_block_buffer_encode()
  • lzma_block_buffer_decode()

Definition at line 93 of file block.h.

Referenced by block_buffer_encode(), block_decode(), block_encode(), code(), LZMA_API(), lzma_block_decoder_init(), lzma_block_encoder_init(), main(), parse_block_header(), stream_decode(), stream_encode(), stream_encoder_init(), test1(), test2(), and test3().

◆ compressed_size

lzma_vli lzma_block::compressed_size

Size of the Compressed Data in bytes.

Encoding: If this is not LZMA_VLI_UNKNOWN, Block Header encoder will store this value to the Block Header. Block encoder doesn't care about this value, but will set it once the encoding has been finished.

Decoding: If this is not LZMA_VLI_UNKNOWN, Block decoder will verify that the size of the Compressed Data field matches compressed_size.

Usually you don't know this value when encoding in streamed mode, and thus cannot write this field into the Block Header.

In non-streamed mode you can reserve space for this field before encoding the actual Block. After encoding the data, finish the Block by encoding the Block Header. Steps in detail:

  • Set compressed_size to some big enough value. If you don't know better, use LZMA_VLI_MAX, but remember that bigger values take more space in Block Header.
  • Call lzma_block_header_size() to see how much space you need to reserve for the Block Header.
  • Encode the Block using lzma_block_encoder() and lzma_code(). It sets compressed_size to the correct value.
  • Use lzma_block_header_encode() to encode the Block Header. Because space was reserved in the first step, you don't need to call lzma_block_header_size() anymore, because due to reserving, header_size has to be big enough. If it is "too big", lzma_block_header_encode() will add enough Header Padding to make Block Header to match the size specified by header_size.

Read by:

  • lzma_block_header_size()
  • lzma_block_header_encode()
  • lzma_block_compressed_size()
  • lzma_block_unpadded_size()
  • lzma_block_total_size()
  • lzma_block_decoder()
  • lzma_block_buffer_decode()

Written by:

  • lzma_block_header_decode()
  • lzma_block_compressed_size()
  • lzma_block_encoder()
  • lzma_block_decoder()
  • lzma_block_buffer_encode()
  • lzma_block_buffer_decode()

Definition at line 148 of file block.h.

Referenced by block_buffer_encode(), block_decode(), block_encode(), block_encode_normal(), block_encode_uncompressed(), block_encoder_init(), code(), LZMA_API(), lzma_block_decoder_init(), parse_block_header(), test1(), and test2().

◆ filters

lzma_filter* lzma_block::filters

Array of filters.

There can be 1-4 filters. The end of the array is marked with .id = LZMA_VLI_UNKNOWN.

Read by:

  • lzma_block_header_size()
  • lzma_block_header_encode()
  • lzma_block_encoder()
  • lzma_block_decoder()
  • lzma_block_buffer_encode()
  • lzma_block_buffer_decode()

Written by:

  • lzma_block_header_decode(): Note that this does NOT free() the old filter options structures. All unused filters[] will have .id == LZMA_VLI_UNKNOWN and .options == NULL. If decoding fails, all filters[] are guaranteed to be LZMA_VLI_UNKNOWN and NULL.
Note
Because of the array is terminated with .id = LZMA_VLI_UNKNOWN, the actual array must have LZMA_FILTERS_MAX + 1 members or the Block Header decoder will overflow the buffer.

Definition at line 200 of file block.h.

Referenced by block_buffer_encode(), block_encode_normal(), block_encode_uncompressed(), code(), free_properties(), LZMA_API(), lzma_block_decoder_init(), lzma_block_encoder_init(), parse_block_header(), stream_decode(), stream_encoder_update(), test1(), and test3().

◆ header_size

uint32_t lzma_block::header_size

Size of the Block Header field.

This is always a multiple of four.

Read by:

  • lzma_block_header_encode()
  • lzma_block_header_decode()
  • lzma_block_compressed_size()
  • lzma_block_unpadded_size()
  • lzma_block_total_size()
  • lzma_block_decoder()
  • lzma_block_buffer_decode()

Written by:

  • lzma_block_header_size()
  • lzma_block_buffer_encode()

Definition at line 72 of file block.h.

Referenced by block_encode_normal(), block_encode_uncompressed(), code(), LZMA_API(), lzma_block_decoder_init(), main(), parse_block_header(), stream_decode(), stream_encode(), test3(), and worker_encode().

◆ ignore_check

lzma_bool lzma_block::ignore_check

A flag to Block decoder to not verify the Check field.

This field is supported by liblzma >= 5.1.4beta if .version >= 1.

If this is set to true, the integrity check won't be calculated and verified. Unless you know what you are doing, you should leave this to false. (A reason to set this to true is when the file integrity is verified externally anyway and you want to speed up the decompression, which matters mostly when using SHA-256 as the integrity check.)

If .version >= 1, read by:

  • lzma_block_decoder()
  • lzma_block_buffer_decode()

Written by (.version is ignored):

  • lzma_block_header_decode() always sets this to false

Definition at line 261 of file block.h.

Referenced by LZMA_API(), lzma_block_decoder_init(), and stream_decode().

◆ raw_check

uint8_t lzma_block::raw_check[LZMA_CHECK_SIZE_MAX]

Raw value stored in the Check field.

After successful coding, the first lzma_check_size(check) bytes of this array contain the raw value stored in the Check field.

Note that CRC32 and CRC64 are stored in little endian byte order. Take it into account if you display the Check values to the user.

Written by:

  • lzma_block_encoder()
  • lzma_block_decoder()
  • lzma_block_buffer_encode()
  • lzma_block_buffer_decode()

Definition at line 217 of file block.h.

Referenced by block_buffer_encode(), block_decode(), and block_encode().

◆ reserved_bool2

lzma_bool lzma_block::reserved_bool2

Definition at line 263 of file block.h.

◆ reserved_bool3

lzma_bool lzma_block::reserved_bool3

Definition at line 264 of file block.h.

◆ reserved_bool4

lzma_bool lzma_block::reserved_bool4

Definition at line 265 of file block.h.

◆ reserved_bool5

lzma_bool lzma_block::reserved_bool5

Definition at line 266 of file block.h.

◆ reserved_bool6

lzma_bool lzma_block::reserved_bool6

Definition at line 267 of file block.h.

◆ reserved_bool7

lzma_bool lzma_block::reserved_bool7

Definition at line 268 of file block.h.

◆ reserved_bool8

lzma_bool lzma_block::reserved_bool8

Definition at line 269 of file block.h.

◆ reserved_enum1

lzma_reserved_enum lzma_block::reserved_enum1

Definition at line 237 of file block.h.

◆ reserved_enum2

lzma_reserved_enum lzma_block::reserved_enum2

Definition at line 238 of file block.h.

◆ reserved_enum3

lzma_reserved_enum lzma_block::reserved_enum3

Definition at line 239 of file block.h.

◆ reserved_enum4

lzma_reserved_enum lzma_block::reserved_enum4

Definition at line 240 of file block.h.

◆ reserved_int1

uint32_t lzma_block::reserved_int1

Definition at line 229 of file block.h.

◆ reserved_int2

uint32_t lzma_block::reserved_int2

Definition at line 230 of file block.h.

◆ reserved_int3

lzma_vli lzma_block::reserved_int3

Definition at line 231 of file block.h.

◆ reserved_int4

lzma_vli lzma_block::reserved_int4

Definition at line 232 of file block.h.

◆ reserved_int5

lzma_vli lzma_block::reserved_int5

Definition at line 233 of file block.h.

◆ reserved_int6

lzma_vli lzma_block::reserved_int6

Definition at line 234 of file block.h.

◆ reserved_int7

lzma_vli lzma_block::reserved_int7

Definition at line 235 of file block.h.

◆ reserved_int8

lzma_vli lzma_block::reserved_int8

Definition at line 236 of file block.h.

◆ reserved_ptr1

void* lzma_block::reserved_ptr1

Definition at line 226 of file block.h.

◆ reserved_ptr2

void* lzma_block::reserved_ptr2

Definition at line 227 of file block.h.

◆ reserved_ptr3

void* lzma_block::reserved_ptr3

Definition at line 228 of file block.h.

◆ uncompressed_size

lzma_vli lzma_block::uncompressed_size

Uncompressed Size in bytes.

This is handled very similarly to compressed_size above.

uncompressed_size is needed by fewer functions than compressed_size. This is because uncompressed_size isn't needed to validate that Block stays within proper limits.

Read by:

  • lzma_block_header_size()
  • lzma_block_header_encode()
  • lzma_block_decoder()
  • lzma_block_buffer_decode()

Written by:

  • lzma_block_header_decode()
  • lzma_block_encoder()
  • lzma_block_decoder()
  • lzma_block_buffer_encode()
  • lzma_block_buffer_decode()

Definition at line 172 of file block.h.

Referenced by block_buffer_encode(), block_decode(), block_encode(), block_encoder_init(), code(), LZMA_API(), lzma_block_decoder_init(), parse_block_header(), stream_decode(), stream_encode(), test1(), test2(), and worker_encode().

◆ version

uint32_t lzma_block::version

Block format version.

To prevent API and ABI breakages when new features are needed, a version number is used to indicate which fields in this structure are in use:

  • liblzma >= 5.0.0: version = 0 is supported.
  • liblzma >= 5.1.4beta: Support for version = 1 was added, which adds the ignore_check field.

If version is greater than one, most Block related functions will return LZMA_OPTIONS_ERROR (lzma_block_header_decode() works with any version value).

Read by:

  • All functions that take pointer to lzma_block as argument, including lzma_block_header_decode().

Written by:

  • lzma_block_header_decode()

Definition at line 52 of file block.h.

Referenced by block_buffer_encode(), LZMA_API(), lzma_block_decoder_init(), lzma_block_encoder_init(), parse_block_header(), stream_decode(), stream_encoder_init(), and worker_encode().


The documentation for this struct was generated from the following file: