10#include "Sdk/C/7zTypes.h"
11#include "Sdk/C/7zVersion.h"
12#include "Sdk/C/LzmaDec.h"
14#define SCRATCH_BUFFER_REQUEST_SIZE SIZE_64KB
41 if (Private->BufferSize >= Size) {
42 Addr = Private->Buffer;
43 Private->Buffer = (VOID *)((UINT8 *)Addr + Size);
44 Private->BufferSize -= Size;
71#define LZMA_HEADER_SIZE (LZMA_PROPS_SIZE + 8)
90 for (Index = LZMA_PROPS_SIZE + 7; Index >= LZMA_PROPS_SIZE; Index--) {
91 DecodedSize =
LShiftU64 (DecodedSize, 8) + EncodedData[Index];
139 IN UINT32 SourceSize,
140 OUT UINT32 *DestinationSize,
141 OUT UINT32 *ScratchSize
146 ASSERT (SourceSize >= LZMA_HEADER_SIZE);
149 if (DecodedSize > MAX_UINT32) {
153 *DestinationSize = (UINT32)DecodedSize;
154 *ScratchSize = SCRATCH_BUFFER_REQUEST_SIZE;
185 IN OUT VOID *Destination,
191 SizeT DecodedBufSize;
192 SizeT EncodedDataSize;
195 AllocFuncs.Functions.Alloc =
SzAlloc;
196 AllocFuncs.Functions.Free =
SzFree;
197 AllocFuncs.Buffer = Scratch;
198 AllocFuncs.BufferSize = SCRATCH_BUFFER_REQUEST_SIZE;
201 EncodedDataSize = (SizeT)(SourceSize - LZMA_HEADER_SIZE);
203 LzmaResult = LzmaDecode (
206 (Byte *)((UINT8 *)Source + LZMA_HEADER_SIZE),
212 &(AllocFuncs.Functions)
215 if (LzmaResult == SZ_OK) {
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
RETURN_STATUS EFIAPI LzmaUefiDecompress(IN CONST VOID *Source, IN UINTN SourceSize, IN OUT VOID *Destination, IN OUT VOID *Scratch)
UINT64 GetDecodedSizeOfBuf(UINT8 *EncodedData)
VOID SzFree(CONST ISzAlloc *P, VOID *Address)
RETURN_STATUS EFIAPI LzmaUefiDecompressGetInfo(IN CONST VOID *Source, IN UINT32 SourceSize, OUT UINT32 *DestinationSize, OUT UINT32 *ScratchSize)
VOID * SzAlloc(CONST ISzAlloc *P, size_t Size)
#define RETURN_UNSUPPORTED
#define RETURN_INVALID_PARAMETER