Rizin
unix-like reverse engineering framework and cli tools
DotZLib.Inflater Class Reference

Implements a data decompressor, using the inflate algorithm in the ZLib dll More...

Inheritance diagram for DotZLib.Inflater:
DotZLib.CodecBase DotZLib.Codec

Public Member Functions

 Inflater ()
 Constructs an new instance of the Inflater More...
 
override void Add (byte[] data, int offset, int count)
 Adds more data to the codec to be processed. More...
 
override void Finish ()
 Finishes up any pending data that needs to be processed and handled. More...
 
- Public Member Functions inherited from DotZLib.CodecBase
 CodecBase ()
 Initializes a new instance of the CodeBase class. More...
 
void Add (byte[] data)
 Adds more data to the codec to be processed. More...
 
void Dispose ()
 Releases any unmanaged resources and calls the CleanUp() method of the derived class More...
 

Protected Member Functions

override void CleanUp ()
 Closes the internal zlib inflate stream More...
 
- Protected Member Functions inherited from DotZLib.CodecBase
void OnDataAvailable ()
 Fires the DataAvailable event More...
 
void copyInput (byte[] data, int startIndex, int count)
 Copies a number of bytes to the internal codec buffer - ready for proccesing More...
 
void resetOutput ()
 Resets the internal output buffers to a known state - ready for processing More...
 
void setChecksum (uint newSum)
 Updates the running checksum property More...
 

Private Member Functions

static int inflateInit_ (ref ZStream sz, string vs, int size)
 
static int inflate (ref ZStream sz, int flush)
 
static int inflateReset (ref ZStream sz)
 
static int inflateEnd (ref ZStream sz)
 

Additional Inherited Members

- Protected Attributes inherited from DotZLib.CodecBase
bool _isDisposed = false
 True if the object instance has been disposed, false otherwise More...
 
- Static Protected Attributes inherited from DotZLib.CodecBase
const int kBufferSize = 16384
 The size of the internal buffers More...
 
- Package Attributes inherited from DotZLib.CodecBase
ZStream _ztream = new ZStream()
 Instance of the internal zlib buffer structure that is passed to all functions in the zlib dll More...
 
- Properties inherited from DotZLib.CodecBase
uint Checksum [get]
 Gets the checksum of the data that has been added so far More...
 
- Properties inherited from DotZLib.Codec
uint Checksum [get]
 Gets the checksum of the data that has been added so far More...
 
- Events inherited from DotZLib.CodecBase
DataAvailableHandler DataAvailable
 Occurs when more processed data are available. More...
 
- Events inherited from DotZLib.Codec
DataAvailableHandler DataAvailable
 Occurs when more processed data are available. More...
 

Detailed Description

Implements a data decompressor, using the inflate algorithm in the ZLib dll

Definition at line 18 of file Inflater.cs.

Constructor & Destructor Documentation

◆ Inflater()

DotZLib.Inflater.Inflater ( )
inline

Constructs an new instance of the Inflater

Definition at line 37 of file Inflater.cs.

37  : base()
38  {
39  int retval = inflateInit_(ref _ztream, Info.Version, Marshal.SizeOf(_ztream));
40  if (retval != 0)
41  throw new ZLibException(retval, "Could not initialize inflater");
42 
43  resetOutput();
44  }
ZStream _ztream
Instance of the internal zlib buffer structure that is passed to all functions in the zlib dll
Definition: CodecBase.cs:25
void resetOutput()
Resets the internal output buffers to a known state - ready for processing
Definition: CodecBase.cs:180
static int inflateInit_(ref ZStream sz, string vs, int size)

References DotZLib.CodecBase._ztream, DotZLib.Inflater.inflateInit_(), DotZLib.CodecBase.resetOutput(), and DotZLib.Info.Version.

Member Function Documentation

◆ Add()

override void DotZLib.Inflater.Add ( byte[]  data,
int  offset,
int  count 
)
inlinevirtual

Adds more data to the codec to be processed.

Parameters
dataByte array containing the data to be added to the codec
offsetThe index of the first byte to add from data
countThe number of bytes to add

Adding data may, or may not, raise the DataAvailable event

Implements DotZLib.CodecBase.

Definition at line 54 of file Inflater.cs.

55  {
56  if (data == null) throw new ArgumentNullException();
57  if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
58  if ((offset+count) > data.Length) throw new ArgumentException();
59 
60  int total = count;
61  int inputIndex = offset;
62  int err = 0;
63 
64  while (err >= 0 && inputIndex < total)
65  {
66  copyInput(data, inputIndex, Math.Min(total - inputIndex, kBufferSize));
67  err = inflate(ref _ztream, (int)FlushTypes.None);
68  if (err == 0)
69  while (_ztream.avail_out == 0)
70  {
72  err = inflate(ref _ztream, (int)FlushTypes.None);
73  }
74 
75  inputIndex += (int)_ztream.total_in;
76  }
78  }
static bool err
Definition: armass.c:435
void OnDataAvailable()
Fires the DataAvailable event
Definition: CodecBase.cs:75
void setChecksum(uint newSum)
Updates the running checksum property
Definition: CodecBase.cs:191
const int kBufferSize
The size of the internal buffers
Definition: CodecBase.cs:35
void copyInput(byte[] data, int startIndex, int count)
Copies a number of bytes to the internal codec buffer - ready for proccesing
Definition: CodecBase.cs:168
static int inflate(ref ZStream sz, int flush)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
Definition: sflib.h:98
voidpf uLong offset
Definition: ioapi.h:144
FlushTypes
Defines constants for the various flush types used with zlib
Definition: DotZLib.cs:23
static int
Definition: sfsocketcall.h:114
uint avail_out
Definition: DotZLib.cs:37
uint total_in
Definition: DotZLib.cs:34

References DotZLib.CodecBase._ztream, DotZLib.ZStream.adler, DotZLib.ZStream.avail_out, DotZLib.CodecBase.copyInput(), count, err, DotZLib.Inflater.inflate(), int, DotZLib.CodecBase.kBufferSize, DotZLib.CodecBase.OnDataAvailable(), DotZLib.CodecBase.setChecksum(), and DotZLib.ZStream.total_in.

◆ CleanUp()

override void DotZLib.Inflater.CleanUp ( )
inlineprotectedvirtual

Closes the internal zlib inflate stream

Implements DotZLib.CodecBase.

Definition at line 101 of file Inflater.cs.

101 { inflateEnd(ref _ztream); }
static int inflateEnd(ref ZStream sz)

References DotZLib.CodecBase._ztream, and DotZLib.Inflater.inflateEnd().

◆ Finish()

override void DotZLib.Inflater.Finish ( )
inlinevirtual

Finishes up any pending data that needs to be processed and handled.

Implements DotZLib.CodecBase.

Definition at line 84 of file Inflater.cs.

85  {
86  int err;
87  do
88  {
89  err = inflate(ref _ztream, (int)FlushTypes.Finish);
91  }
92  while (err == 0);
94  inflateReset(ref _ztream);
95  resetOutput();
96  }
static int inflateReset(ref ZStream sz)

References DotZLib.CodecBase._ztream, DotZLib.ZStream.adler, err, DotZLib.Inflater.inflate(), DotZLib.Inflater.inflateReset(), DotZLib.CodecBase.OnDataAvailable(), DotZLib.CodecBase.resetOutput(), and DotZLib.CodecBase.setChecksum().

◆ inflate()

static int DotZLib.Inflater.inflate ( ref ZStream  sz,
int  flush 
)
private

◆ inflateEnd()

static int DotZLib.Inflater.inflateEnd ( ref ZStream  sz)
private

◆ inflateInit_()

static int DotZLib.Inflater.inflateInit_ ( ref ZStream  sz,
string  vs,
int  size 
)
private

◆ inflateReset()

static int DotZLib.Inflater.inflateReset ( ref ZStream  sz)
private

Referenced by DotZLib.Inflater.Finish().


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