COM Interfaces in 7-Zip DLL on Windows

This article provides an overview of the Component Object Model (COM) interfaces used by 7-Zip libraries (such as 7z.dll) on Windows. It details how 7-Zip implements a custom, lightweight COM architecture, lists the core interfaces exposed by the DLL for inspecting, extracting, and creating archives, and outlines the callback and stream interfaces developers must implement to interact with the engine directly.

The 7-Zip COM Architecture

7-Zip relies on an internal COM-like binary interface based on IUnknown. Unlike standard Windows COM components, 7-Zip does not register its interfaces or classes in the Windows Registry, and objects are not created via CoCreateInstance. Instead, 7z.dll exports a dedicated function, CreateObject, to instantiate classes directly:

STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject);

Using this entry point, client applications query for specific interfaces to manipulate archives.


Core Archive Interfaces (Implemented by 7-Zip)

These interfaces are provided by 7z.dll archive handlers to manage archive containers.

  • IInArchive: The primary interface for reading and decompressing archives.

    • Open: Opens an archive stream for reading.
    • Close: Closes the opened archive.
    • GetNumberOfItems: Returns the total number of files and directories.
    • GetProperty: Retrieves file and folder metadata (name, size, timestamp, attributes).
    • Extract: Extracts specified items using a client-provided callback.
    • GetArchiveProperty: Retrieves global archive metadata (format name, comment, headers).
  • IOutArchive: The interface responsible for creating or updating archives.

    • UpdateItems: Writes, appends, or deletes items in an archive based on client input streams.
    • GetFileTimeType: Returns the timestamp precision supported by the target format (e.g., Windows FILETIME or Unix epoch).
  • ISetProperties: Allows callers to configure compression parameters (such as compression level, dictionary size, word size, or encryption algorithms) prior to archive creation.

  • IInArchiveGetStream: Provides access to individual sub-streams within an archive container without unpacking the entire archive.


Stream Interfaces (Implemented by Caller or Library)

7-Zip uses abstract stream interfaces to decouple compression and decompression from direct disk I/O, allowing memory buffers, network streams, or physical files to serve as inputs and outputs.

  • ISequentialInStream: Provides sequential data reading via Read(void *data, UInt32 size, UInt32 *processedSize).
  • ISequentialOutStream: Provides sequential data writing via Write(const void *data, UInt32 size, UInt32 *processedSize).
  • IInStream: Extends ISequentialInStream with random access via Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition).
  • IOutStream: Extends ISequentialOutStream with Seek and SetSize operations for random-access writing.
  • IStreamGetSize: Allows querying the full length of the underlying stream.

Callback Interfaces (Implemented by the Host Application)

To handle user interaction, password prompts, and progress notifications, the host application must implement specific callback interfaces and pass them into 7z.dll.

  • IArchiveOpenCallback: Handles events during archive inspection, such as opening multi-part/split volumes.
  • IArchiveExtractCallback: Directs extraction output.
    • GetStream: Receives the item index and asks the caller for an ISequentialOutStream where unpacked data should be written.
    • PrepareOperation: Notifies the caller of the current operation (Extract, Test, Skip).
    • SetOperationResult: Informs the caller whether the item unpacked successfully or encountered errors (e.g., CRC mismatch, unsupported compression).
  • IArchiveUpdateCallback / IArchiveUpdateCallback2: Supplies incoming file metadata and ISequentialInStream instances during archive creation and update operations.
  • ICryptoGetTextPassword / ICryptoGetTextPassword2: Provides passwords for encrypted headers or payload data during open, extract, or update routines.
  • ICompressProgressInfo: Reports the total bytes processed and remaining during compression and extraction tasks.