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

Format:Windows Installer MSI

From ReverseEngineering.wiki
Format
On this wiki Facts · Code · Notes · Topics

Windows Installer (.msi) database: a Compound File Binary whose stream names are packed into private Unicode, with _StringPool/_StringData, _Tables, _Columns and relational tables (File, Component, Media, CustomAction, ...) plus the payload in cabinet streams.

An .msi (also .msp patches, .mst transforms, .msm merge modules) is a relational database stored in a Format:Compound File Binary. The install logic is in tables; the files usually sit in cabinets (Format:Microsoft Cabinet) embedded as streams or shipped beside the .msi. Tool:WiX Toolset, Tool:Advanced Installer and Tool:InstallShield (Basic MSI) produce it. Source: GNOME msitools (libmsi, LGPL): libmsi/table.c, string.c, msipriv.h.

Stream names

Every table is a stream, but its name is not plain UTF-16: libmsi encodes it (encode_streamname / decode_streamname).

  • The 64 characters 0-9 A-Z a-z . _ map to 6-bit values (digits 0-9, A-Z 10-35, a-z 36-61, . 62, _ 63).
  • Two such characters in a row are packed into one code point in U+3800..U+47FF (UTF-8 E3 A0 80 .. E4 9F BF): first character in the low 6 bits, second above it. A single remaining character becomes U+4800 + value. Any other character is stored unchanged.
  • A stream holding a table gets the prefix U+4840 (UTF-8 E4 A1 80). Streams of embedded binaries have no prefix.
  • libmsi limits a stream name to 62 bytes (MAX_STREAM_NAME_LEN).

To read an MSI by hand decode the names first, or use msitools: msiinfo, msidump, msiextract, msibuild; wixl builds packages.

Fixed streams

  • _StringPool and _StringData: all strings. The pool is an array of 4-byte entries (u16 length, u16 reference count). Entry 0 holds the code page: low word = low 16 bits, and bit 15 (0x8000) of the second word is set when string references in tables are 3 bytes instead of 2 (large pools); the other 15 bits are the code page's high bits. An entry with length 0 and a nonzero count is a string over 64 KiB: the next entry's two words give the low and high 16 bits of the length. An entry with 0 length and 0 count is empty but still has a string id. _StringData is the concatenated bytes in the database code page.
  • _Tables and _Columns: the catalog (table names; per column table, number, name, type).
  • _Streams and _Storages: tables listing embedded streams and substorages; table streams themselves are not in _Streams.
  • \x05SummaryInformation: property set with title, author, template (platform;languages), revision code, installer version, source flags. The stream name is \x05SummaryInformation (Wine suminfo.c opens L"\5SummaryInformation", which is a character 0x05 prefix, not a table-encoded name). The property ids (Wine include/msidefs.h, commit 7298a818b7): 1 code page, 2 title, 3 subject, 4 author, 5 keywords, 6 comments, 7 template, 8 last author, 9 revision number, 10 edit time, 11 last printed, 12 create time, 13 last save time, 14 page count (the MSI installer version), 15 word count (the source flags), 16 character count (the restriction flags), 18 application name, 19 security. Strings are VT_LPSTR, times VT_FILETIME, counts VT_I4; Wine reads the revision number as the package's product string (msi_get_suminfo_product). Unverified: that the revision number holds the package code GUID, the template the platform;languages string, and the MSI installer version is the number x100 (general MSI knowledge).

Column types

Type word bits in _Columns (msipriv.h): 0x00FF size mask, 0x0100 valid, 0x0200 localizable, 0x0800 string, 0x1000 nullable, 0x2000 primary key, 0x4000 temporary, 0x8000 unknown. A string column stores a string-pool index (2 or 3 bytes). A string+valid column is a binary column pointing to a stream.

Tables an analyst reads first

The Media '#' rule, the CustomAction type bits and the File attribute bits were read in Wine's dlls/msi (media.c, include/msidefs.h, commit 7298a818b7); the other roles below are Unverified general MSI knowledge.

  • File (File, Component_, FileName as short|long, FileSize, Version, Language, Attributes, Sequence): the payload list; Sequence is the file's position across cabinets. File Attributes bits (Wine): 0x1 read-only, 0x2 hidden, 0x4 system, 0x200 vital, 0x400 checksum, 0x1000 patch added, 0x2000 non-compressed, 0x4000 compressed.
  • Media (DiskId, LastSequence, Cabinet, VolumeLabel, Source): a Cabinet name starting with # is a stream inside the MSI, otherwise an external file (Wine msi_cabextract in media.c line 645 tests cabinet[0] == '#'). Wine looks the disk up with SELECT * FROM Media WHERE DiskId = %d and finds the cabinet of a file with WHERE LastSequence >= <File.Sequence> ORDER BY DiskId, so a file belongs to the first Media row whose LastSequence is not smaller than its Sequence.
  • Component, Directory, Feature, FeatureComponents: layout and selection.
  • CustomAction (Action, Type, Source, Target): the code that runs. Type bits (Wine msidbCustomActionType): the low 3 bits are the kind 1 DLL, 2 EXE, 3 text data, 5 JScript, 6 VBScript, 7 nested install; bits 4-5 are the source of Source/Target (0x00 Binary table, 0x10 a file, 0x20 a directory, 0x30 a property); 0x40 continue on failure, 0x80 asynchronous, 0x100 first sequence (or rollback in a script), 0x200 once per process (or commit in a script), 0x400 in-script (deferred), 0x800 no impersonate, 0x1000 64-bit script, 0x2000 hide target, 0x4000 Terminal Services aware. InstallExecuteSequence and InstallUISequence order the actions. Custom action DLLs and scripts sit in the Binary table: this is where an installer's real logic hides.
  • Registry, Shortcut, ServiceInstall, Property, LaunchCondition, Upgrade: what the package changes.

Extracting the payload

  1. Dump Media; take the cabinet streams (or the external .cab) and extract with cabextract, 7-Zip or libmspack.
  2. Cabinet file names are File-table keys; map them to real names through File, Component and Directory.
  3. Read CustomAction and Binary for code that runs with elevated rights.

Code & repositories

  • https://github.com/GNOME/msitools @ 452f9b6a9d734a370429cf406bd92108dce9422b · license: LGPL-2.1-or-later (declared by the contributor; GitHub's detector did not recognize a license file)
    GNOME msitools (libmsi, msiinfo, msidump, msiextract, msibuild, wixl): reads and writes MSI databases; table.c has the stream-name encoding, string.c the string pool.
    Tested on: source read, not run: source reading only · checked 2026-10-18; last activity 2026-09-11
  • https://github.com/wine-mirror/wine @ 7298a818b79446bae153b8d5aa27235ab3703bf9 · license: LGPL-2.1-or-later (declared by the contributor; GitHub's detector did not recognize COPYING.LIB)
    Wine's msi.dll (dlls/msi): table.c has the MSI stream name encoding, string.c the string pool, suminfo.c the summary information, media.c the '#' cabinet streams; include/msidefs.h the property ids and attribute bits.
    Tested on: source read, not run: source read, not run (single files fetched at the pinned commit) · checked 2026-10-19; last activity 2026-10-16

See also

Format:Compound File Binary, Format:Microsoft Cabinet, Tool:WiX Toolset, Tool:Advanced Installer, Tool:InstallShield, Technique:Identifying the toolchain of a binary.