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. |
在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