Muy bueno Kar, che hay una duda con esto del callApi que me carcome no pude lograr nunca pasar estas funciones, vos que la tenes mas clara capas que las sacas.
Option Explicit
Private Declare Function RtlGetCompressionWorkSpaceSize Lib "NTDLL" (ByVal flags As Integer, WorkSpaceSize As Long, UNKNOWN_PARAMETER As Long) As Long
Private Declare Function NtAllocateVirtualMemory Lib "ntdll.dll" (ByVal ProcHandle As Long, BaseAddress As Long, ByVal NumBits As Long, regionsize As Long, ByVal flags As Long, ByVal ProtectMode As Long) As Long
Private Declare Function RtlCompressBuffer Lib "NTDLL" (ByVal flags As Integer, ByVal BuffUnCompressed As Long, ByVal UnCompSize As Long, ByVal BuffCompressed As Long, ByVal CompBuffSize As Long, ByVal UNKNOWN_PARAMETER As Long, OutputSize As Long, ByVal WorkSpace As Long) As Long
Private Declare Function RtlDecompressBuffer Lib "NTDLL" (ByVal flags As Integer, ByVal BuffUnCompressed As Long, ByVal UnCompSize As Long, ByVal BuffCompressed As Long, ByVal CompBuffSize As Long, OutputSize As Long) As Long
Private Declare Function NtFreeVirtualMemory Lib "ntdll.dll" (ByVal ProcHandle As Long, BaseAddress As Long, regionsize As Long, ByVal flags As Long) As Long
Public Function Compress(Data() As Byte, Out() As Byte) As Long
Dim WorkSpaceSize As Long
Dim WorkSpace As Long
ReDim Out(UBound(Data) * 1.13 + 4)
RtlGetCompressionWorkSpaceSize 2, WorkSpaceSize, 0
NtAllocateVirtualMemory -1, WorkSpace, 0, WorkSpaceSize, 4096, 64
RtlCompressBuffer 2, VarPtr(Data(0)), UBound(Data) + 1, VarPtr(Out(0)), (UBound(Data) * 1.13 + 4), 0, Compress, WorkSpace
NtFreeVirtualMemory -1, WorkSpace, 0, 16384
ReDim Preserve Out(Compress)
End Function
Public Function DeCompress(Data() As Byte, dest() As Byte) As Long
If UBound(Data) Then
Dim lBufferSize As Long
ReDim dest(UBound(Data) * 12.5)
RtlDecompressBuffer 2, VarPtr(dest(0)), (UBound(Data) * 12.5), VarPtr(Data(0)), UBound(Data), lBufferSize
If lBufferSize Then
ReDim Preserve dest(lBufferSize - 1)
DeCompress = lBufferSize - 1
End If
End If
End Function
Saludos.