Func _WinAPI_CompressBuffer($pUncompressedBuffer, $iUncompressedSize, $pCompressedBuffer, $iCompressedSize, $iFormatAndEngine = 0x0002)
Local $Ret, $pWorkSpace = 0, $Error = 1
Do
$Ret = DllCall('ntdll.dll', 'uint', 'RtlGetCompressionWorkSpaceSize', 'ushort', $iFormatAndEngine, 'ulong*', 0, 'ulong*', 0)
If (@error) Or ($Ret[0]) Then
ExitLoop
EndIf
$pWorkSpace = __HeapAlloc($Ret[2])
If @error Then
ExitLoop
EndIf
$Ret = DllCall('ntdll.dll', 'uint', 'RtlCompressBuffer', 'ushort', $iFormatAndEngine, 'ptr', $pUncompressedBuffer, 'ulong', $iUncompressedSize, 'ptr', $pCompressedBuffer, 'ulong', $iCompressedSize, 'ulong', 4096, 'ulong*', 0, 'ptr', $pWorkSpace)
If (@error) Or ($Ret[0]) Or (Not $Ret[7]) Then
ExitLoop
EndIf
$Error = 0
Until 1
__HeapFree($pWorkSpace)
If $Error Then
If IsArray($Ret) Then
Return SetError(1, $Ret[0], 0)
Else
Return SetError(9, 0, 0)
EndIf
EndIf
Return $Ret[7]
EndFunc ;==>_WinAPI_CompressBuffer
|