函数参考


_WinAPI_DecompressBuffer

Decompresses an entire compressed buffer.

#Include <WinAPIEx.au3>
_WinAPI_DecompressBuffer ( $pUncompressedBuffer, $iUncompressedSize, $pCompressedBuffer, $iCompressedSize [, $iFormat] )

参数

$pUncompressedBuffer A pointer to a caller-allocated buffer that receives the decompressed data from compressed buffer.
$iUncompressedSize The size of the uncompressed buffer, in bytes.
$pCompressedBuffer A pointer to the buffer that contains the data to decompress.
$iCompressedSize The size of the compressed buffer, in bytes.
$iFormat [可选参数] The compression format of the data in compressed buffer. This parameter must be one of the
following values.

$COMPRESSION_FORMAT_LZNT1
$COMPRESSION_FORMAT_XPRESS
$COMPRESSION_FORMAT_XPRESS_HUFF

返回值

Success The size of the decompressed data stored in uncompressed buffer, in bytes.
Failure 0 and sets the @error flag to non-zero, @extended flag may contain the NTSTATUS code.

注意/说明

The _WinAPI_DecompressBuffer() function takes as input an entire compressed buffer and produces its decompressed
equivalent provided that the uncompressed data fits within the specified destination buffer.

To compress an uncompressed buffer, use the _WinAPI_CompressBuffer function.

相关

详情参考

在MSDN中搜索


示例/演示


#Include <APIConstants.au3>
#Include <WinAPIEx.au3>

Opt('MustDeclareVars', 1)

Global $pBuffer[2], $Data, $Size

; Create compressed and uncompressed buffers
For $i = 0 To 1
    $pBuffer[$i] = _WinAPI_CreateBuffer(1024)
Next

; Compress binary data
$Data = Binary('0x00112233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF')
$Size = BinaryLen($Data)
DllStructSetData(DllStructCreate('byte[' & $Size & ']', $pBuffer[0]), 1, $Data)
$Size = _WinAPI_CompressBuffer($pBuffer[0], $Size, $pBuffer[1], 1024, BitOR($COMPRESSION_FORMAT_LZNT1, $COMPRESSION_ENGINE_MAXIMUM))
If Not @error Then
    ConsoleWrite('Compressed:   ' & DllStructGetData(DllStructCreate('byte[' & $Size & ']', $pBuffer[1]), 1) & @CR)
EndIf

; Decompress data
$Size = _WinAPI_DecompressBuffer($pBuffer[0], 1024, $pBuffer[1], $Size)
If Not @error Then
    ConsoleWrite('Uncompressed: ' & DllStructGetData(DllStructCreate('byte[' & $Size & ']', $pBuffer[0]), 1) & @CR)
EndIf

; Free memory
For $i = 0 To 1
    _WinAPI_FreeMemory($pBuffer[$i])
Next