diff options
| author | Ladislav Zezula <ladislav.zezula@avg.com> | 2013-11-13 07:56:31 +0100 | 
|---|---|---|
| committer | Ladislav Zezula <ladislav.zezula@avg.com> | 2013-11-13 07:56:31 +0100 | 
| commit | a70863499e5e9e6560477b8f4a0a594d6e62650e (patch) | |
| tree | 21118705bf1d412ed9aea0b51daf25f98b4fabad /src/SCompression.cpp | |
| parent | 66b71713c2a60e6f6ccc55245b067dad34fd6154 (diff) | |
+ Support for SQP and MPK archives
+ Makefiles fixed
Diffstat (limited to 'src/SCompression.cpp')
| -rw-r--r-- | src/SCompression.cpp | 53 | 
1 files changed, 53 insertions, 0 deletions
| diff --git a/src/SCompression.cpp b/src/SCompression.cpp index 8e4fcac..933dc61 100644 --- a/src/SCompression.cpp +++ b/src/SCompression.cpp @@ -532,6 +532,47 @@ static int Decompress_LZMA(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBu      return 1;  } +static int Decompress_LZMA_MPK(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) +{ +    ELzmaStatus LzmaStatus; +    ISzAlloc SzAlloc; +    Byte * destBuffer = (Byte *)pvOutBuffer; +    Byte * srcBuffer = (Byte *)pvInBuffer; +    SizeT destLen = *pcbOutBuffer; +    SizeT srcLen = cbInBuffer; +    SRes nResult; +    BYTE LZMA_Props[] = {0x5D, 0x00, 0x00, 0x00, 0x01}; + +    // There must be at least 0x0E bytes in the buffer +    if(srcLen <= sizeof(LZMA_Props)) +        return 0; + +    // Verify the props header +    if(memcmp(pvInBuffer, LZMA_Props, sizeof(LZMA_Props))) +        return 0; + +    // Fill the callbacks in structures +    SzAlloc.Alloc = LZMA_Callback_Alloc; +    SzAlloc.Free = LZMA_Callback_Free; + +    // Perform compression +    srcLen = cbInBuffer - sizeof(LZMA_Props); +    nResult = LzmaDecode(destBuffer, +                        &destLen, +                         srcBuffer + sizeof(LZMA_Props), +                        &srcLen, +                         srcBuffer,  +                         sizeof(LZMA_Props), +                         LZMA_FINISH_END, +                        &LzmaStatus, +                        &SzAlloc); +    if(nResult != SZ_OK) +        return 0; + +    *pcbOutBuffer = (unsigned int)destLen; +    return 1; +} +  /******************************************************************************/  /*                                                                            */  /*  Support functions for SPARSE compression (0x20)                           */ @@ -1073,3 +1114,15 @@ int WINAPI SCompDecompress2(void * pvOutBuffer, int * pcbOutBuffer, void * pvInB          SetLastError(ERROR_FILE_CORRUPT);      return nResult;  } + +/*****************************************************************************/ +/*                                                                           */ +/*   File decompression for MPK archives                                     */ +/*                                                                           */ +/*****************************************************************************/ + +int SCompDecompressMpk(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer) +{ +    return Decompress_LZMA_MPK(pvOutBuffer, pcbOutBuffer, pvInBuffer, cbInBuffer);     +} + | 
