Latest available version: IDA and decompilers v8.4.240320sp1 see all releases
Hex-Rays logo State-of-the-art binary code analysis tools
email icon
compress.hpp File Reference

Data compression functions. More...

Macros

#define PKZ_OK   0
 
#define PKZ_ERRNO   1
 
#define PKZ_STREAM_ERROR   2
 
#define PKZ_DATA_ERROR   3
 
#define PKZ_MEM_ERROR   4
 
#define PKZ_BUF_ERROR   5
 
#define PKZ_VERSION_ERROR   6
 
#define PKZ_RERR   777
 
#define PKZ_WERR   778
 
#define STORED   0
 
#define SHRUNK   1
 
#define REDUCED1   2
 
#define REDUCED2   3
 
#define REDUCED3   4
 
#define REDUCED4   5
 
#define IMPLODED   6
 
#define TOKENIZED   7
 
#define DEFLATED   8
 
#define NUM_METHODS   9 /* index of last method + 1 */
 

Enumerations

enum  linput_close_code_t { LOC_CLOSE , LOC_UNMAKE , LOC_KEEP }
 Upon closing outer linput, perform one of these actions. More...
 

Functions

idaman THREAD_SAFE int ida_export zip_deflate (void *ud, ssize_t(idaapi *file_reader)(void *ud, void *buf, size_t size), ssize_t(idaapi *file_writer)(void *ud, const void *buf, size_t size))
 Compress data. More...
 
idaman THREAD_SAFE int ida_export zip_inflate (void *ud, ssize_t(idaapi *file_reader)(void *ud, void *buf, size_t size), ssize_t(idaapi *file_writer)(void *ud, const void *buf, size_t size))
 Uncompress data. More...
 
idaman THREAD_SAFE int ida_export process_zipfile (const char *zipfile, int(idaapi *callback)(void *ud, qoff64_t offset, int method, uint64 csize, uint64 ucsize, uint32 attributes, const char *filename), void *ud=nullptr)
 Process zip file and enumerate all files stored in it. More...
 
idaman THREAD_SAFE int ida_export process_zip_linput (linput_t *li, int(idaapi *callback)(void *ud, qoff64_t offset, int method, uint64 csize, uint64 ucsize, uint32 attributes, const char *filename), void *ud=nullptr)
 Process zip file and enumerate all files stored in it. More...
 
idaman THREAD_SAFE int ida_export process_zipfile_entry (const char *zipfile, const char *entry, int(idaapi *callback)(void *ud, qoff64_t offset, int method, uint64 csize, uint64 ucsize, uint32 attributes, const char *filename), void *ud=nullptr, bool case_sensitive=true)
 Search for specified entry in zip file, and calls the callback with it, if found. More...
 
idaman THREAD_SAFE linput_t *ida_export create_zip_linput (linput_t *in, ssize_t insize=-1, linput_close_code_t loc=LOC_CLOSE)
 Create a linput to read a compressed input stream. More...
 

Variables

bool legacy_idb
 for old idb files
 

Detailed Description

Data compression functions.

Enumeration Type Documentation

◆ linput_close_code_t

Upon closing outer linput, perform one of these actions.

Enumerator
LOC_CLOSE 

close the inner linput

LOC_UNMAKE 

unmake the inner linput

LOC_KEEP 

do nothing

Function Documentation

◆ zip_deflate()

idaman THREAD_SAFE int ida_export zip_deflate ( void *  ud,
ssize_t(idaapi *)(void *ud, void *buf, size_t size)  file_reader,
ssize_t(idaapi *)(void *ud, const void *buf, size_t size)  file_writer 
)

Compress data.

This function depends on the value of legacy_idb, so it is not completely thread safe. However, legacy_idb does not change its value.

Returns
Compression error codes

◆ zip_inflate()

idaman THREAD_SAFE int ida_export zip_inflate ( void *  ud,
ssize_t(idaapi *)(void *ud, void *buf, size_t size)  file_reader,
ssize_t(idaapi *)(void *ud, const void *buf, size_t size)  file_writer 
)

Uncompress data.

This function depends on the value of legacy_idb, so it is not completely thread safe. However, legacy_idb does not change its value.

Returns
Compression error codes

◆ process_zipfile()

idaman THREAD_SAFE int ida_export process_zipfile ( const char *  zipfile,
int(idaapi *)(void *ud, qoff64_t offset, int method, uint64 csize, uint64 ucsize, uint32 attributes, const char *filename)  callback,
void *  ud = nullptr 
)

Process zip file and enumerate all files stored in it.

Parameters
zipfilename of zip file
callbackcallback for each file. params:
  • ud: user data
  • offset: offset in the zip file
  • method: compression method (Compression methods)
  • csize: compressed size
  • ucsize: uncompressed size
  • attributes: file attributes
uduser data
Returns
Compression error codes

◆ process_zip_linput()

idaman THREAD_SAFE int ida_export process_zip_linput ( linput_t *  li,
int(idaapi *)(void *ud, qoff64_t offset, int method, uint64 csize, uint64 ucsize, uint32 attributes, const char *filename)  callback,
void *  ud = nullptr 
)

Process zip file and enumerate all files stored in it.

Parameters
liinput file
callbackcallback for each file. params:
  • ud: user data
  • offset: offset in the zip file
  • method: compression method (Compression methods)
  • csize: compressed size
  • ucsize: uncompressed size
  • attributes: file attributes
uduser data
Returns
Compression error codes

◆ process_zipfile_entry()

idaman THREAD_SAFE int ida_export process_zipfile_entry ( const char *  zipfile,
const char *  entry,
int(idaapi *)(void *ud, qoff64_t offset, int method, uint64 csize, uint64 ucsize, uint32 attributes, const char *filename)  callback,
void *  ud = nullptr,
bool  case_sensitive = true 
)

Search for specified entry in zip file, and calls the callback with it, if found.

Parameters
zipfilename of zip file
entryentry in zip file. E.g., "path/to/entry.dat"
callbackcallback for each file. params:
  • ud: user data
  • offset: offset in the zip file
  • method: compression method (Compression methods)
  • csize: compressed size
  • ucsize: uncompressed size
  • attributes: file attributes
uduser data
case_sensitiveshould the search be case sensitive?
Returns
Compression error codes

◆ create_zip_linput()

idaman THREAD_SAFE linput_t *ida_export create_zip_linput ( linput_t *  in,
ssize_t  insize = -1,
linput_close_code_t  loc = LOC_CLOSE 
)

Create a linput to read a compressed input stream.

Parameters
inlinput with compressed data, seeked to the stream beginning
insizesize of compressed data. -1 - unknown
locwhat to do upon closing the resulting linput
Returns
linput that can be used to read uncompressed data. nullptr if any error (no more linput descriptors).