Pkg.InnoSetup — API for parsing Inno Setup installers

Overview

The Pkg.InnoSetup module contains the API for parsing Inno Setup installers. An Inno Setup installer is a Windows PE executable that embeds two compressed payloads at the end of the binary: a Setup0 blob carrying the manifest (header, languages, messages, file/registry/icon/run tables, etc.) and a Setup1 blob carrying the concatenated compressed file data, organized as data entries that group one or more files into shared chunks. Both payloads can optionally be encrypted. This module locates the payloads by scanning for the well-known Inno Setup loader signature, parses the manifest tables, verifies the embedded checksums and decompresses individual files on demand.

Use InnoSetupObject.Parse() once before calling any of the accessor methods. When the installer is encrypted, the password must be supplied to InnoSetupObject.Parse() to unlock the manifest and the file data.

Parsing an Inno Setup Installer

The following code example demonstrates how to parse an installer, identify its version, list the embedded payloads, verify their checksums and dump basic header fields:

from Pro.Core import *
from Pkg.InnoSetup import *

def parseInno(fname):
    c = createContainerFromFile(fname)
    if c.isNull():
        return
    obj = InnoSetupObject()
    if not obj.Load(c) or not obj.Initialize():
        return
    print("setup id          :", obj.GetSetupId())
    print("version           :", obj.GetVersion())
    print("known version     :", obj.IsKnownVersion())
    print("encrypted         :", obj.IsEncrypted())
    s0_off, s0_size = obj.GetSetup0Range()
    s1_off, s1_size = obj.GetSetup1Range()
    print("setup0            : offset=0x%x size=%d ok=%s" %
          (s0_off, s0_size, obj.VerifySetup0Checksum()))
    print("setup1            : offset=0x%x size=%d ok=%s" %
          (s1_off, s1_size, obj.VerifySetup1Checksum()))
    h = obj.GetHeader()
    print("application       :", h.get("ApplicationName"))
    print("version           :", h.get("ApplicationVersion"))
    print("publisher         :", h.get("ApplicationPublisher"))
    print("default directory :", h.get("DefaultDirectoryName"))

Listing Files and Decompressing One

The [Files] table is exposed by InnoSetupObject.GetFiles(). Each entry references a data entry (returned by InnoSetupObject.GetDataEntries()) through its Location field. A Location of 0xFFFFFFFF indicates that the entry has no embedded payload (e.g. a file pulled at install time from an external source). The following snippet lists the [Files] entries that carry a payload and decompresses the first one:

from Pro.Core import *
from Pkg.InnoSetup import *

def extractFirstFile(fname, out_fname):
    c = createContainerFromFile(fname)
    if c.isNull():
        return
    obj = InnoSetupObject()
    if not obj.Load(c) or not obj.Initialize():
        return
    files = obj.GetFiles()
    for i, f in enumerate(files):
        if f.get("Location", 0xFFFFFFFF) == 0xFFFFFFFF:
            continue
        print("[%d] %s -> %s" % (i, f.get("Source"), f.get("Destination")))
    # decompress the first entry that has a payload
    for i, f in enumerate(files):
        if f.get("Location", 0xFFFFFFFF) == 0xFFFFFFFF:
            continue
        data = obj.DecompressFile(i)
        if data is not None and not data.isNull():
            fh = NT_CreateFile(out_fname)
            NT_WriteFile(fh, data.read(0, data.size()))
            NT_CloseFile(fh)
        return

Iterating the Manifest Tables

The manifest exposes the standard Inno Setup tables: languages, messages, types, components, tasks, directories, files, icons, INI entries, registry entries, install/uninstall delete entries, install/uninstall run entries, permissions and signature keys. The following snippet prints a summary:

from Pro.Core import *
from Pkg.InnoSetup import *

def summarizeInno(fname):
    c = createContainerFromFile(fname)
    if c.isNull():
        return
    obj = InnoSetupObject()
    if not obj.Load(c) or not obj.Initialize():
        return
    print("languages    :", len(obj.GetLanguages()))
    print("messages     :", len(obj.GetMessages()))
    print("types        :", len(obj.GetTypes()))
    print("components   :", len(obj.GetComponents()))
    print("tasks        :", len(obj.GetTasks()))
    print("directories  :", len(obj.GetDirectories()))
    print("files        :", len(obj.GetFiles()))
    print("data entries :", len(obj.GetDataEntries()))
    print("icons        :", len(obj.GetIcons()))
    print("ini          :", len(obj.GetINIEntries()))
    print("registry     :", len(obj.GetRegistryEntries()))
    print("delete       :", len(obj.GetDeleteEntries()))
    print("uninst del   :", len(obj.GetUninstallDeleteEntries()))
    print("run          :", len(obj.GetRunEntries()))
    print("uninst run   :", len(obj.GetUninstallRunEntries()))
    print("sig keys     :", len(obj.GetSigKeys()))
    for lang in obj.GetLanguages():
        print(" lang:", lang.get("Name"), "-", lang.get("LanguageName"))

Handling Encrypted Installers

Encrypted installers require the password to be supplied to InnoSetupObject.Parse(). After parsing, InnoSetupObject.IsEncrypted(), InnoSetupObject.IsFullEncrypted() and InnoSetupObject.CanDecrypt() describe the encryption state, and InnoSetupObject.GetEncryptionHeader() exposes the cipher parameters (KDF salt, iteration count, base nonce, password verification material, etc.):

from Pro.Core import *
from Pkg.InnoSetup import *

def openEncrypted(fname, password):
    c = createContainerFromFile(fname)
    if c.isNull():
        return
    obj = InnoSetupObject()
    if not obj.Load(c):
        return
    if not obj.Parse(password=password):
        return
    if not obj.CanDecrypt():
        print("wrong password")
        return
    print("encryption header:", obj.GetEncryptionHeader())
    # files can now be decompressed
    files = obj.GetFiles()
    if files:
        data = obj.DecompressFile(0)
        if data is not None and not data.isNull():
            print("decompressed", data.size(), "bytes")

Module API

Pkg.InnoSetup module API.

Classes:

InnoSetupObject()

This class represents an Inno Setup installer.

class InnoSetupObject

Bases: Pro.PE.PEObject

This class represents an Inno Setup installer.

Inno Setup installers are Windows PE executables that embed two compressed payloads at the end of the binary: a Setup0 blob (the installer manifest, holding the header, languages, messages, file/registry/icon/run tables, etc.) and a Setup1 blob (the concatenated compressed file data, organized as data entries that group one or more files into shared chunks). Both payloads can optionally be encrypted. This class locates the payloads by scanning for the well-known Inno Setup loader signature, parses the manifest tables and exposes helpers to verify checksums, decrypt headers and decompress individual files.

Use Parse() once before calling any of the accessor methods. When the installer is encrypted, the password must be supplied to Parse() to unlock the manifest; without it only the structural offsets are available.

Methods:

CanDecrypt()

Returns True if encrypted content can be decrypted; otherwise returns False.

DecompressChunk(data_entry, wo)

Decompresses a single Setup1 chunk described by a data entry.

DecompressFile(file[, wo])

Decompresses a single file from the [Files] table.

GetComponents()

Retrieves the list of component entries declared in the [Components] section.

GetDataEntries()

Retrieves the list of data entries that describe the compressed chunks composing the Setup1 payload.

GetDecompressionModuleRange()

Retrieves the file range of the embedded decompression module (the LZMA/zlib decoder DLL extracted by the loader at install time).

GetDecryptionModuleRange()

Retrieves the file range of the embedded decryption module (used by encrypted installers).

GetDeleteEntries()

Retrieves the list of pre-install delete entries declared in the [InstallDelete] section (files and directories to remove before installation).

GetDirectories()

Retrieves the list of directory entries declared in the [Dirs] section.

GetEncryptionHeader()

Retrieves the encryption header describing the cipher, salt, KDF parameters and verification material used to encrypt the manifest and/or file data.

GetFiles()

Retrieves the list of file entries declared in the [Files] section.

GetHeader()

Retrieves the parsed Inno Setup header.

GetHeaderField(name)

Retrieves a single field from the parsed header by name.

GetINIEntries()

Retrieves the list of INI entries declared in the [INI] section.

GetIcons()

Retrieves the list of icon entries declared in the [Icons] section (Start Menu and Desktop shortcuts created at install time).

GetLanguages()

Retrieves the list of language entries declared by the installer.

GetMessages()

Retrieves the list of localized message entries (UI strings used by the wizard, custom messages, etc.).

GetOffsets()

Retrieves the file offsets and sizes of the various Inno Setup regions (loader signature, Setup0 header, Setup1 data, decompression module, decryption module, etc.).

GetPermissions()

Retrieves the list of permission entries used by the [Files] and [Dirs] tables to apply ACLs at install time.

GetRegistryEntries()

Retrieves the list of registry entries declared in the [Registry] section.

GetRunEntries()

Retrieves the list of post-install run entries declared in the [Run] section (commands executed after the files are installed).

GetSetup0Data()

Retrieves the decompressed Setup0 manifest data.

GetSetup0Range()

Retrieves the file range of the Setup0 payload (the compressed manifest blob containing the header and tables).

GetSetup1Data()

Retrieves the raw Setup1 payload as a container.

GetSetup1Range()

Retrieves the file range of the Setup1 payload (the concatenated compressed file data).

GetSetupId()

Retrieves the Setup ID string embedded in the loader signature.

GetSigKeys()

Retrieves the list of ISSigKey entries (public keys used by Inno Setup to verify externally-signed files at install time).

GetTasks()

Retrieves the list of task entries declared in the [Tasks] section (optional user-selectable actions such as desktop icon creation).

GetTypes()

Retrieves the list of setup type entries declared in the [Types] section (e.g., “Full installation”, “Compact installation”, “Custom installation”).

GetUninstallDeleteEntries()

Retrieves the list of uninstall delete entries declared in the [UninstallDelete] section (files and directories to remove during uninstallation).

GetUninstallRunEntries()

Retrieves the list of uninstall run entries declared in the [UninstallRun] section (commands executed during uninstallation).

GetVersion([short])

Retrieves the detected Inno Setup version.

GetWizardImages()

Retrieves the list of large wizard background images embedded in the installer (the bitmaps shown on the welcome and finish pages of the setup wizard).

GetWizardImagesSmall()

Retrieves the list of small wizard header images embedded in the installer (the bitmaps shown in the header strip of the setup wizard pages).

IsEncrypted()

Returns True if the installer is at least partially encrypted; otherwise returns False.

IsFullEncrypted()

Returns True if the installer is fully encrypted; otherwise returns False.

IsKnownVersion()

Reports whether the detected Inno Setup version is one of the variants supported by the parser.

OutputHeader(out)

Writes a human-readable dump of the parsed header to the supplied text stream.

Parse([wo, password])

Parses the installer: locates the Setup0/Setup1 payloads, identifies the Inno Setup version, and decodes the manifest tables.

VerifySetup0Checksum()

Verifies the integrity checksum stored in the Setup0 payload.

VerifySetup1Checksum()

Verifies the integrity checksum stored in the Setup1 payload.

CanDecrypt()bool
Returns

Returns True if encrypted content can be decrypted; otherwise returns False.

Return type

bool

See also Parse() and IsEncrypted().

DecompressChunk(data_entry: Dict[str, Any], wo: Pro.Core.NTIWait)Optional[Pro.Core.NTContainer]

Decompresses a single Setup1 chunk described by a data entry.

When the chunk is encrypted, the installer must have been opened with the correct password (see Parse()).

Parameters
  • data_entry (Dict[str, Any]) – A data entry dictionary as returned by GetDataEntries().

  • wo (NTIWait) – Wait object for the long-running decompression. Aborts the operation when triggered.

Returns

Returns the container holding the decompressed chunk, or None on failure.

Return type

Optional[NTContainer]

See also GetDataEntries() and DecompressFile().

DecompressFile(file: Union[int, Dict[str, Any]], wo: Optional[Pro.Core.NTIWait] = None)Optional[Pro.Core.NTContainer]

Decompresses a single file from the [Files] table.

When the file shares a solid chunk with other files, the chunk is decompressed transparently and the requested file slice is returned. When the file is encrypted, the installer must have been opened with the correct password (see Parse()).

Parameters
  • file (Union[int, Dict[str, Any]]) – Either the zero-based index into the list returned by GetFiles(), or the file entry dictionary itself.

  • wo (NTIWait) – Optional wait object for the long-running decompression. Aborts the operation when triggered.

Returns

Returns the container holding the decompressed file content, or None on failure.

Return type

Optional[NTContainer]

See also GetFiles() and DecompressChunk().

GetComponents()List[Dict[str, Any]]

Retrieves the list of component entries declared in the [Components] section.

Returns

Returns a list of component dictionaries.

Return type

List[Dict[str, Any]]

See also GetTypes().

GetDataEntries()List[Dict[str, Any]]

Retrieves the list of data entries that describe the compressed chunks composing the Setup1 payload.

Each [Files] entry references one of these data entries; multiple files can share the same chunk when solid compression is enabled. Each entry carries the chunk offset and size inside Setup1, the original and compressed sizes, the compression method, the chunk checksum and the encryption flags.

Returns

Returns a list of data entry dictionaries.

Return type

List[Dict[str, Any]]

See also GetFiles(), DecompressChunk() and DecompressFile().

GetDecompressionModuleRange()Optional[Tuple[int, int]]

Retrieves the file range of the embedded decompression module (the LZMA/zlib decoder DLL extracted by the loader at install time).

Returns

Returns a (offset, size) tuple, or None if the installer does not embed a separate decompression module.

Return type

Optional[Tuple[int, int]]

GetDecryptionModuleRange()Optional[Tuple[int, int]]

Retrieves the file range of the embedded decryption module (used by encrypted installers).

Returns

Returns a (offset, size) tuple, or None if the installer does not embed a separate decryption module.

Return type

Optional[Tuple[int, int]]

See also IsEncrypted().

GetDeleteEntries()List[Dict[str, Any]]

Retrieves the list of pre-install delete entries declared in the [InstallDelete] section (files and directories to remove before installation).

Returns

Returns a list of delete entry dictionaries.

Return type

List[Dict[str, Any]]

See also GetUninstallDeleteEntries().

GetDirectories()List[Dict[str, Any]]

Retrieves the list of directory entries declared in the [Dirs] section.

Returns

Returns a list of directory dictionaries.

Return type

List[Dict[str, Any]]

GetEncryptionHeader()Dict[str, Any]

Retrieves the encryption header describing the cipher, salt, KDF parameters and verification material used to encrypt the manifest and/or file data.

Returns

Returns a dictionary with the encryption header fields. Returns an empty dictionary when the installer is not encrypted.

Return type

Dict[str, Any]

See also IsEncrypted(), IsFullEncrypted() and CanDecrypt().

GetFiles()List[Dict[str, Any]]

Retrieves the list of file entries declared in the [Files] section.

Each entry describes a single logical file: source, destination, attributes, flags, the index of the data entry that holds the compressed payload, and so on. Use DecompressFile() to obtain the decompressed bytes of a file.

Returns

Returns a list of file dictionaries.

Return type

List[Dict[str, Any]]

See also GetDataEntries() and DecompressFile().

GetHeader()Dict[str, Any]

Retrieves the parsed Inno Setup header.

The header carries top-level installer metadata such as application name, application version, default directory, default group, license/info text references, wizard style flags, supported architectures, compression settings, counts of the various tables, and so on.

Returns

Returns a dictionary keyed by header field name.

Return type

Dict[str, Any]

See also GetHeaderField() and OutputHeader().

GetHeaderField(name: str)Any

Retrieves a single field from the parsed header by name.

Parameters

name (str) – The header field name.

Returns

Returns the field value, or None if the field does not exist.

Return type

Any

See also GetHeader().

GetINIEntries()List[Dict[str, Any]]

Retrieves the list of INI entries declared in the [INI] section.

Returns

Returns a list of INI entry dictionaries.

Return type

List[Dict[str, Any]]

GetIcons()List[Dict[str, Any]]

Retrieves the list of icon entries declared in the [Icons] section (Start Menu and Desktop shortcuts created at install time).

Returns

Returns a list of icon dictionaries.

Return type

List[Dict[str, Any]]

GetLanguages()List[Dict[str, Any]]

Retrieves the list of language entries declared by the installer. Each entry carries the language internal name, display name, LCID, codepage, dialog font and message overrides.

Returns

Returns a list of language dictionaries.

Return type

List[Dict[str, Any]]

GetMessages()List[Dict[str, Any]]

Retrieves the list of localized message entries (UI strings used by the wizard, custom messages, etc.). Each entry references the language it belongs to.

Returns

Returns a list of message dictionaries.

Return type

List[Dict[str, Any]]

See also GetLanguages().

GetOffsets()Dict[str, int]

Retrieves the file offsets and sizes of the various Inno Setup regions (loader signature, Setup0 header, Setup1 data, decompression module, decryption module, etc.).

Returns

Returns a dictionary keyed by region name. Values are absolute file offsets or sizes in bytes.

Return type

Dict[str, int]

GetPermissions()List[Dict[str, Any]]

Retrieves the list of permission entries used by the [Files] and [Dirs] tables to apply ACLs at install time.

Returns

Returns a list of permission dictionaries.

Return type

List[Dict[str, Any]]

GetRegistryEntries()List[Dict[str, Any]]

Retrieves the list of registry entries declared in the [Registry] section.

Returns

Returns a list of registry entry dictionaries.

Return type

List[Dict[str, Any]]

GetRunEntries()List[Dict[str, Any]]

Retrieves the list of post-install run entries declared in the [Run] section (commands executed after the files are installed).

Returns

Returns a list of run entry dictionaries.

Return type

List[Dict[str, Any]]

See also GetUninstallRunEntries().

GetSetup0Data()Pro.Core.NTContainer

Retrieves the decompressed Setup0 manifest data.

Returns

Returns the container holding the decompressed manifest, or an invalid container on failure.

Return type

NTContainer

See also GetSetup0Range().

GetSetup0Range()Tuple[int, int]

Retrieves the file range of the Setup0 payload (the compressed manifest blob containing the header and tables).

Returns

Returns a (offset, size) tuple in bytes.

Return type

Tuple[int, int]

See also GetSetup0Data() and VerifySetup0Checksum().

GetSetup1Data()Pro.Core.NTContainer

Retrieves the raw Setup1 payload as a container. Individual files are not decompressed by this method; use DecompressFile() to extract a specific file.

Returns

Returns the container holding the Setup1 payload, or an invalid container on failure.

Return type

NTContainer

See also GetSetup1Range() and DecompressFile().

GetSetup1Range()Tuple[int, int]

Retrieves the file range of the Setup1 payload (the concatenated compressed file data).

Returns

Returns a (offset, size) tuple in bytes.

Return type

Tuple[int, int]

See also GetSetup1Data() and VerifySetup1Checksum().

GetSetupId()str

Retrieves the Setup ID string embedded in the loader signature. The Setup ID identifies the Inno Setup format variant and is used to discriminate between supported releases.

Returns

Returns the Setup ID string.

Return type

str

GetSigKeys()List[Dict[str, Any]]

Retrieves the list of ISSigKey entries (public keys used by Inno Setup to verify externally-signed files at install time).

Returns

Returns a list of signature key dictionaries.

Return type

List[Dict[str, Any]]

GetTasks()List[Dict[str, Any]]

Retrieves the list of task entries declared in the [Tasks] section (optional user-selectable actions such as desktop icon creation).

Returns

Returns a list of task dictionaries.

Return type

List[Dict[str, Any]]

GetTypes()List[Dict[str, Any]]

Retrieves the list of setup type entries declared in the [Types] section (e.g., “Full installation”, “Compact installation”, “Custom installation”).

Returns

Returns a list of type dictionaries.

Return type

List[Dict[str, Any]]

See also GetComponents().

GetUninstallDeleteEntries()List[Dict[str, Any]]

Retrieves the list of uninstall delete entries declared in the [UninstallDelete] section (files and directories to remove during uninstallation).

Returns

Returns a list of uninstall delete entry dictionaries.

Return type

List[Dict[str, Any]]

See also GetDeleteEntries().

GetUninstallRunEntries()List[Dict[str, Any]]

Retrieves the list of uninstall run entries declared in the [UninstallRun] section (commands executed during uninstallation).

Returns

Returns a list of uninstall run entry dictionaries.

Return type

List[Dict[str, Any]]

See also GetRunEntries().

GetVersion(short: bool = True)Union[Tuple[int, int, int], Tuple[int, int, int, int]]

Retrieves the detected Inno Setup version.

Parameters

short (bool) – When True (default), returns a (major, minor, patch) tuple. When False, returns a (major, minor, patch, revision) tuple including the internal revision.

Returns

Returns the version tuple.

Return type

Union[Tuple[int, int, int], Tuple[int, int, int, int]]

See also IsKnownVersion().

GetWizardImages()List[Dict[str, Any]]

Retrieves the list of large wizard background images embedded in the installer (the bitmaps shown on the welcome and finish pages of the setup wizard).

Returns

Returns a list of wizard image dictionaries. Each entry exposes the image data and basic metadata.

Return type

List[Dict[str, Any]]

See also GetWizardImagesSmall().

GetWizardImagesSmall()List[Dict[str, Any]]

Retrieves the list of small wizard header images embedded in the installer (the bitmaps shown in the header strip of the setup wizard pages).

Returns

Returns a list of small wizard image dictionaries.

Return type

List[Dict[str, Any]]

See also GetWizardImages().

IsEncrypted()bool
Returns

Returns True if the installer is at least partially encrypted; otherwise returns False.

Return type

bool

See also IsFullEncrypted(), CanDecrypt() and GetEncryptionHeader().

IsFullEncrypted()bool
Returns

Returns True if the installer is fully encrypted; otherwise returns False.

Return type

bool

See also IsEncrypted().

IsKnownVersion()bool

Reports whether the detected Inno Setup version is one of the variants supported by the parser.

Returns

Returns True if the version is known; otherwise returns False.

Return type

bool

See also GetVersion().

OutputHeader(out: Pro.Core.NTTextStream)

Writes a human-readable dump of the parsed header to the supplied text stream.

Parameters

out (NTTextStream) – The destination text stream.

See also GetHeader().

Parse(wo: Optional[Pro.Core.NTIWait] = None, password: Optional[Union[bytes, str]] = None)bool

Parses the installer: locates the Setup0/Setup1 payloads, identifies the Inno Setup version, and decodes the manifest tables.

Parameters
  • wo (NTIWait) – Optional wait object for long-running operations. Parsing aborts early if the wait object is aborted.

  • password (Union[bytes, str]) – Optional password used to decrypt the manifest of encrypted installers. Accepts either a str or bytes value.

Returns

Returns True if successful; otherwise returns False.

Return type

bool

VerifySetup0Checksum()bool

Verifies the integrity checksum stored in the Setup0 payload.

Returns

Returns True if the checksum matches; otherwise returns False.

Return type

bool

See also GetSetup0Range().

VerifySetup1Checksum()bool

Verifies the integrity checksum stored in the Setup1 payload.

Returns

Returns True if the checksum matches; otherwise returns False.

Return type

bool

See also GetSetup1Range().