How 7-Zip Opens and Extracts Windows CAB Files

This article explains the technical and practical mechanics behind how 7-Zip reads, decompresses, and extracts Microsoft Cabinet (CAB) archives. It covers the internal structure of CAB files, how 7-Zip parses headers, the proprietary compression algorithms supported, and the exact process used to unpack these files through both the graphical interface and the command line.

Understanding the CAB Archive Format

Microsoft Cabinet (.cab) is a proprietary archive format developed for Windows software packaging and operating system updates. A CAB file is organized into three primary structural layers:

  1. CFHEADER: The main archive header, which begins with the signature bytes MSCF (Microsoft Cabinet) and stores metadata such as archive size, folder count, and file count.
  2. CFFOLDER: Logical groupings of compressed data. Unlike standard ZIP archives that compress files individually, a CAB file compresses groups of files together into continuous data streams across blocks.
  3. CFFILE: Metadata entries for each archived file, including filename, timestamps, attributes, and byte offsets within the uncompressed folder stream.
  4. CFDATA: The raw data blocks containing the compressed payload, check values, and block sizes.

How 7-Zip Parses and Inspects CAB Files

When you open a .cab file in 7-Zip, the software does not rely on Windows system APIs like setupapi.dll. Instead, 7-Zip uses its own native, cross-platform Cabinet parser located within its archive handling modules.

  1. Signature Verification: 7-Zip reads the first few bytes of the file to verify the MSCF magic number. If the signature is present, it assigns the CAB handler to the archive.
  2. Header Parsing: 7-Zip parses the CFHEADER to determine if the archive is a single file or part of a multi-volume spanning set.
  3. Table Construction: 7-Zip traverses the CFFILE and CFFOLDER records to construct a virtual directory tree. This allows you to browse the contents in the 7-Zip File Manager before decompressing any actual data.

Decompressing CAB Data Streams

CAB files can employ different compression methods. 7-Zip contains built-in decompression engines for all standard CAB algorithms:

  • None (Store): Data is uncompressed and copied directly.
  • MSZIP: A Deflate-based algorithm where each block is wrapped in an MSZIP-specific framing structure. 7-Zip applies a modified zlib/deflate routine to expand the stream.
  • LZX: A sliding-dictionary compression method developed by Jonathan Forbes and Tom Stamp, later adapted by Microsoft. LZX uses variable-size sliding windows (typically 32 KB to 2 MB) and Huffman coding. 7-Zip features a native LZX decoder designed to handle these continuous streams.
  • Quantum: An older, arithmetic-coding-based compression method rarely used in modern Windows packages, but still supported by 7-Zip's legacy decoders.

Because CAB files use solid compression across each CFFOLDER, 7-Zip decompresses data sequentially. To extract a specific file located at the end of a folder block, 7-Zip decompresses the preceding data blocks in memory until it reaches the requested file's offset.

Handling Multi-Part and Spanned CAB Files

Installers often split large installations across multiple CAB files (e.g., data1.cab, data2.cab).

  • The CFHEADER flags indicate whether an archive is preceded by an earlier cabinet or followed by a continuation cabinet.
  • When extracting spanning CAB files, 7-Zip reads the pointer metadata pointing to the neighboring archive names.
  • If all segments are kept in the same directory, 7-Zip links the split streams automatically and extracts the complete files across boundaries without requiring manual reassembly.

How to Extract CAB Files Using 7-Zip

Using the Graphical Interface

  1. Right-click the .cab file in Windows Explorer.
  2. Select 7-Zip from the context menu.
  3. Choose Extract Here or Extract to "[Folder Name]".
  4. Alternatively, double-click the file to open it in 7-Zip File Manager, highlight the required files, and click the Extract button on the toolbar.

Using the Command Line

To extract a CAB file silently and maintain the internal directory hierarchy, use the 7z executable:

7z x archive.cab -o"C:\TargetDirectory"
  • x: Extracts files with full paths preserved.
  • -o: Specifies the output directory (do not add a space between -o and the directory path).