Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Library:StormLib

From ReverseEngineering.wiki
Library
Developer Ladislav Zezula
Platforms Windows, Linux, macOS
Versions 9.40 at commit 116135c (STORMLIB_VERSION 0x0928)
License MIT
Website https://github.com/ladislav-zezula/StormLib
On this wiki Facts · Code · Notes · Topics

Open-source C/C++ library (MIT) for reading, creating, modifying and verifying MPQ archives, with an API named after the SFile* functions of Blizzard's storm.dll. It is the de-facto reference implementation of the MPQ format, including its many edge cases.

Identification

  • DLL builds export named functions such as SFileOpenArchive, SFileOpenFileEx, SFileReadFile, SFileExtractFile, SFileFindFirstFile, SFileGetFileInfo, SFileVerifyArchive.
  • Unverified: Blizzard's own storm.dll implements the same calls but exports them by ordinal only, so a binary importing SFile* by name links StormLib rather than storm.dll. Test by listing the export table of a storm.dll shipped with Diablo or StarCraft.
  • Static builds contain the strings (listfile), (attributes), (signature), (patch_metadata) and the MPQ hash constants listed in Format:MPQ (MoPaQ)#Identification; they also carry bundled zlib, bzip2 and LibTomCrypt code. The bundled copy in src/zlib is Library:Zlib 1.2.5 at commit 116135c (inftrees.c lext tail 73, 195 and the banner " inflate 1.2.5 Copyright 1995-2010 Mark Adler "), so a StormLib-based tool built from this source shows zlib 1.2.5 even when the rest of the binary is new; builds that link a system zlib show that version instead.

API overview

Open an archive (SFileOpenArchive), open a file by name (SFileOpenFileEx), read it (SFileReadFile) or extract it in one call (SFileExtractFile). Writing: SFileCreateArchive, SFileAddFileEx, SFileRemoveFile, SFileRenameFile, SFileCompactArchive. Enumeration uses the listfile (SFileFindFirstFile), with external listfiles accepted for archives that lack one. SFileOpenPatchArchive chains World of Warcraft patch archives over a base archive.

Source map

Where to look in the repository when a format detail is unclear:

  • src/StormLib.h: on-disk structures (header, hash and block entries, user data, patch info) and every flag and compression constant.
  • src/SBaseCommon.cpp: crypt table, string hashes, block cipher, file key derivation and known-plaintext key recovery, hash table probing.
  • src/SFileOpenArchive.cpp: header search in 512-byte steps, user-data handling, map-type detection (Warcraft III / StarCraft II quirks).
  • src/SBaseFileTable.cpp: loading, validating and repairing the classic tables and the HET/BET tables.
  • src/SFileReadFile.cpp and src/SCompression.cpp: sector reading and the compression dispatch, including the StarCraft beta variant.
  • src/SFileAttributes.cpp, src/SFileVerify.cpp: (attributes) and signatures.

Code & repositories

  • https://github.com/ladislav-zezula/StormLib @ 116135c27e8c0dcf8ea0a0c549a6d737ce10fc73 · license: MIT
    The StormLib source itself: C/C++ library for reading, creating, modifying and verifying MPQ archives (all four header versions, HET/BET tables, WoW patch chains, Warcraft III / StarCraft II map quirks).
    Tested on: Source read at this commit (StormLib 9.40); not built. See Format:MPQ (MoPaQ) for the algorithms reimplemented from it and checked against mpyq on public samples. · checked 2026-10-17; last activity 2026-10-12; Note: the latest release ships binaries; the wiki links only the source, never the binaries

Pitfalls

  • The structures in StormLib.h are internal and change between releases; the in-memory header is always converted to the format-3 layout, so a dumped TMPQHeader is not the bytes on disk.
  • StormLib is deliberately more tolerant than the games (it repairs malformed tables), so "StormLib opens it" does not prove the game will.

Evidence & references

  • Repository pinned at commit 116135c27e8c0dcf8ea0a0c549a6d737ce10fc73 (license MIT, detected by GitHub).