Microsoft Cabinet (.cab)

Windows cabinet files.

Overview

A cabinet begins with a header (MSCF, size, offset of the first file entry, counts) followed by folder entries, file entries and CFDATA blocks. Folders are compressed with MSZIP, Quantum or LZX and can span cabinets.

Where it is used

  • Windows installers and updates, driver packages.
  • Setup programs and MSI media.

History

  • Introduced by Microsoft in the mid 1990s.

Status today

  • Still used throughout Windows.

Structures read by the implementation

Offsets are in bytes from the start of the buffer named in each heading. Field names are taken from the implementation and are not an official specification. Fixed-width integers are shown as u/i (unsigned/signed) followed by bit width and byte order.

CabCarver.FindCabinet buffer data · CabCarver.cs

OffsetSizeTypeFieldNotes
i + 11u8–
i + 21u8–
i + 31u8–
i + 44u32 LE–

FolderResult.Carve buffer tables · CabCarver.cs

OffsetSizeTypeFieldNotes
position2u16 LE–
position2u16 LEHeader Reserve
position4u32 LE–
position4u32 LESize
position + 21u8Folder Reserve
position + 31u8Data Reserve
position + 44u32 LE–
position + 42u16 LE–
position + 44u32 LEOffset
position + 62u16 LE–
position + 84u32 LESignature At
position + 82u16 LEFolder
position + 102u16 LEDate
position + 124u32 LESignature Length
position + 122u16 LETime
position + 142u16 LEAttributes

FolderResult.WalkFolder buffer head · CabCarver.cs

OffsetSizeTypeFieldNotes
0x04u32 LEStored
0x42u16 LEPacked
0x44bytesSum
0x44bytesOk
0x62u16 LESize

struct.ParseHeader buffer h · CabCarver.cs

OffsetSizeTypeFieldNotes
0x44u32 LE–
0x84u32 LESize
0x104u32 LEFiles Offset
0x181u8–
0x191u8–
0x1A2u16 LEFolders
0x1C2u16 LEFiles
0x1E2u16 LEFlags
0x202u16 LE–
0x222u16 LE–

CabFolders.Decode buffer head · CabExtractor.cs

OffsetSizeTypeFieldNotes
0x42u16 LEPacked
0x62u16 LEUncomp

Other fields read

Read inOffsetSizeTypeFieldNotes
struct.Checksum(i * 4)4u32 LE–
LzxDecoder.UndoE8(i + 1)4i32 LEAbsolute

Constants

General CabCarver

NameValueTypeNotes
HeaderSize36int
BlockHeaderSize8int
InitialRead64 * 1024int
SignatureMarker0x00100000int

General CabExtractor

NameValueTypeNotes
HeaderSize36int
BlockHeaderSize8int

General Lzx

NameValueTypeNotes
NumChars256int
PretreeElements20int
AlignedElements8int
NumPrimaryLengths7int
NumSecondaryLengths249int
FrameSize32768int
BlockVerbatim1int
BlockAligned2int
BlockUncompressed3int
ExtraBitsBuildExtraBits()int[]
PositionBaseBuildPositionBase()int[]

General LzxDecoder

NameValueTypeNotes
NumChars256int
LengthHeaders8int
PrimaryLengths7int
LengthSymbols249int
PretreeSymbols20int
AlignedSymbols8int
E8FileSize12_000_000int

General CabArchiveModule

NameValueTypeNotes
Magic[0x4D, 0x53, 0x43, 0x46, 0x00, 0x00, 0x00, 0x00]byte[]

Implementation limits reader

ClassNameValueNotes
CabCarverMaxBlockOutput32768
CabCarverMaxTables64 * 1024 * 1024
CabCarverMaxInflated512L * 1024 * 1024
CabCarverMaxSignature1024 * 1024
CabExtractorMaxBlockOutput32768
CabExtractorMaxFolderOutputint.MaxValue
LzxMinMatch2
LzxDecoderMinMatch2
LzxDecoderMinAlignedSlot8
LzxDecoderMaxOffsetSlots50
LzxDecoderDefaultBlockSize32768

Signatures and magic strings referenced

TextWhereContext
MSCFstruct.ParseHeaderif (!h.StartsWith(“MSCF”u8) || BinaryPrimitives.ReadUInt32LittleEndian(h[4..]) != 0)
MSCFCabExtractor.Readif (h.Length < HeaderSize || !h.AsSpan(0, 4).SequenceEqual(“MSCF”u8) || BinaryPrimitives.ReadUInt32LittleEndian(h.AsSpan(4)) != 0)
Structures and constants were extracted from: Carving/Plugins/Cab/CabCarver.cs, Carving/Plugins/Cab/CabExtractor.cs, Carving/Plugins/Cab/Lzx.cs, IO/Compression/LzxDecoder.cs, Modules/FileSystems/CabArchiveModule.cs. Prose sections are a summary from public sources; verify details before relying on them.