4.1.10.6.19 DecompressMessage

 procedure DecompressMessage(
   pInBuffer: sequence of BYTE,
   cbInBufferCompress: DWORD,
   cbInBufferDecompress: DWORD,
   DRS_COMP_ALG_TYPE: compressionAlg
   ref pOutputBuffer: sequence of BYTE)

Informative summary of behavior: Compression subdivides a data stream into sequences of bytes called compression chunks. The DecompressMessage procedure decompresses the data stream.

The following table identifies the size of the compression chunk for each algorithm type.

Algorithm

Chunk size

COMP_ALG_NONE

Not applicable

COMP_ALG_MSZIP

32768

COMP_ALG_W2K3

65536

Each compression chunk in the compressed byte sequence is represented by means of a COMPRESSED_DATA structure.

 pInBlock: ADDRESS OF COMPRESSED_DATA
 cbInputProcessed: DWORD
 cbDecompressedData: DWORD
  
 if (cbInBufferCompress = cbInBufferDecompress) then
   /* No decompression required here. */
   pOutBuffer := pInBuffer
   cbOutBuffer := cbInBufferDeCompress
 else
   cbInputProcessed := 0
   while (cbInputProcessed ≤ cbInBufferCompress)
       pInBlock :=  ADR(pInputBuffer[cbInputProcessed])
       if (pInBlock^.cbDecompressedSize = 
             pInBlock^.cbCompressedSize) then
         pDecompressedData := pInBlock^.data
         cbDecompressedData := pInBlock^.cbDecompressedSize
       else
         if (compressionAlg = DRS_COMP_ALG_MSZIP) then
           pDecompressedData := 
             Decompress pInBlock^.data in accordance
             with [RFC1951]. 
         else
           pDecompressedData := new sequence of BYTE of length 
                                pInBlock^.cbDecompressedSize 
           CompressOrDecompressWin2k3(pInBlock^.data,
               pInBlock^.cbDecompressedSize,
               pDecompressedData, FALSE)
         endif
         cbDecompressedData := pInBlock^.cbDecompressedSize
       endif
       pOutputBuffer := Append sequence of BYTE pDeCompressedData of
                        size cbDecompressedData to sequence of BYTE 
                        pOutputBuffer
       cbOutputBuffer := 
           cbOutputBuffer + pInBlock^.cbDecompressedSize 
       cbInputProcessed := cbInputProcessed + 
                           pInBlock^.cbCompressedSize
       Round up value in cbInputProcessed such that 
         ADR(pInBlock[cbInputProcessed]) align on double word 
         boundary.
   endwhile
 endif