innoextract

package module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2026 License: Zlib Imports: 11 Imported by: 0

README

innoextract-go

innoextract-go is a Go library for reading the metadata and embedded data files in modern Inno Setup installers. It is an altered-source Go port of the innoextract extractor core; it does not run an installer, its wizard, Pascal script, DLLs, or registry actions.

The module path is:

github.com/Peiratooo/innoextract-go

Install it with:

go get github.com/Peiratooo/innoextract-go

Basic use

The input is an io.ReaderAt, so the library can seek without taking ownership of a file. *os.File and *bytes.Reader are typical inputs. A separate size argument and context.Context are not required.

package main

import (
	"fmt"
	"log"
	"os"

	innoextract "github.com/Peiratooo/innoextract-go"
)

func main() {
	setup, err := os.Open("setup.exe")
	if err != nil {
		log.Fatal(err)
	}
	defer setup.Close()

	archive, err := innoextract.Open(setup)
	if err != nil {
		log.Fatal(err)
	}

	info := archive.Info()
	fmt.Printf("%s %s (%s)\n", info.AppName, info.AppVersion, info.DataVersion)
	for _, entry := range archive.Files() {
		fmt.Printf("%s (%d bytes)\n", entry.Path, entry.Size)
	}

	files, err := archive.Extract()
	if err != nil {
		// `files` may contain entries that were decoded successfully.
		log.Printf("extraction completed with errors: %v", err)
	}
	for _, file := range files {
		fmt.Printf("%s: %d bytes, sha256=%s\n", file.Path, len(file.Data), file.SHA256)
	}
}

For callers that do not need to retain the parsed archive, the one-shot form is equivalent to Open followed by Archive.Extract:

files, err := innoextract.Extract(setup)

File.Data is the decoded content and File.SHA256 is the lowercase SHA-256 digest calculated by the library. Paths are normalized to safe relative slash-separated paths. Duplicate archive entries are kept as separate entries; they are not written to disk or silently merged.

Options

Options are passed to Open or the one-shot Extract function:

  • WithPassword(password) supplies a password where the selected encrypted format is supported.
  • WithCodepage(codepage) selects the code page used by legacy ANSI metadata; the modern 6.x metadata stream is UTF-16LE.
  • WithSliceProvider(provider) supplies an io.ReaderAt for an external data slice when an installer is split across .bin files. The provider is only called for slices referenced by the archive.
  • WithMemoryLimit(bytes) bounds extraction/decompression memory. The default extraction budget is 1 GiB; the setup metadata header is bounded at 64 MiB.

Extraction is memory-oriented: decoded content is returned in File.Data and the package does not create output directories or write files. The caller owns and closes the input reader after it has finished with the archive.

Results and errors

Archive.Info returns installer metadata, including the data version, application fields, languages, encryption flag, and a detected GOG game ID. Archive.Files returns the file manifest. Archive.Verify decodes and checksums the entries without returning file data.

Parsing and archive-wide failures are returned by Open (and by the one-shot Extract) as errors such as ErrInvalidFormat, ErrUnsupportedVersion, ErrUnsupportedCompression, ErrUnsupportedEncryption, or ErrLimitExceeded. Use errors.Is to test these sentinel errors.

An individual file can fail while other files succeed. In that case Archive.Extract returns the successful []File together with an *ExtractError; its Failures field contains an EntryError for each failed entry, and errors.Is/errors.As can still inspect the underlying cause. Callers should inspect both return values rather than discarding successful files whenever err != nil.

Compatibility boundary

The current setup metadata parser accepts Inno Setup data versions from 6.0 through 6.7 (inclusive). Versions outside that range, including future 6.8+ formats and older 1.x–5.x formats, are not promised and normally return ErrUnsupportedVersion. The repository includes a 6.6.1 sample integration test; applications should still validate the exact installer families they need.

Encrypted 6.5+ installers use an outer encryption header. The header is recognized, but encrypted 6.5+ data is currently rejected with ErrUnsupportedEncryption; WithPassword does not bypass this limitation. Unencrypted 6.5+ installers remain within the version boundary. Encrypted installers in general should be treated as unsupported unless a future release explicitly documents their format.

License and source

This repository's LICENSE records that the code is an altered source version of innoextract, whose original copyright is held by Daniel Scharrer (2011–2020), and adds the Go-port contributors' notice. It carries the original permissive three-condition license: preserve attribution, mark altered source versions, and retain the notice. Distributions must include that file. innoextract-go is not affiliated with Inno Setup.

Documentation

Overview

Package innoextract reads files embedded in Inno Setup installers.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidFormat          = fault.ErrInvalidFormat
	ErrUnsupportedVersion     = fault.ErrUnsupportedVersion
	ErrPasswordRequired       = fault.ErrPasswordRequired
	ErrIncorrectPassword      = fault.ErrIncorrectPassword
	ErrUnsupportedEncryption  = fault.ErrUnsupportedEncryption
	ErrUnsupportedCompression = fault.ErrUnsupportedCompression
	ErrMissingSlice           = fault.ErrMissingSlice
	ErrChecksumMismatch       = fault.ErrChecksumMismatch
	ErrCorrupt                = fault.ErrCorrupt
	ErrLimitExceeded          = fault.ErrLimitExceeded
)

Functions

This section is empty.

Types

type Archive

type Archive struct {
	// contains filtered or unexported fields
}

Archive is a parsed Inno Setup installer. Its methods do not write to disk.

func Open

func Open(r io.ReaderAt, opts ...Option) (*Archive, error)

func (*Archive) Extract

func (a *Archive) Extract() ([]File, error)

func (*Archive) Files

func (a *Archive) Files() []Entry

func (*Archive) Info

func (a *Archive) Info() Info

func (*Archive) Verify

func (a *Archive) Verify() error

type ChecksumType

type ChecksumType string

ChecksumType identifies an installer-provided checksum.

const (
	ChecksumNone    ChecksumType = ""
	ChecksumAdler32 ChecksumType = "adler32"
	ChecksumCRC32   ChecksumType = "crc32"
	ChecksumMD5     ChecksumType = "md5"
	ChecksumSHA1    ChecksumType = "sha1"
	ChecksumSHA256  ChecksumType = "sha256"
)

type Entry

type Entry struct {
	Index          int
	Path           string
	Size           uint64
	CompressedSize uint64
	Checksum       string
	ChecksumType   ChecksumType
	Languages      string
	Components     string
	Tasks          string
	Check          string
	Temporary      bool
	Bits32         bool
	Bits64         bool
	Encrypted      bool
}

type EntryError

type EntryError struct {
	Entry Entry
	Err   error
}

func (EntryError) Error

func (e EntryError) Error() string

func (EntryError) Unwrap

func (e EntryError) Unwrap() error

type ExtractError

type ExtractError struct {
	Failures []EntryError
}

func (*ExtractError) Error

func (e *ExtractError) Error() string

func (*ExtractError) Unwrap

func (e *ExtractError) Unwrap() []error

type File

type File struct {
	Entry
	Data   []byte
	SHA256 string
}

func Extract

func Extract(r io.ReaderAt, opts ...Option) ([]File, error)

Extract is the one-shot form of Open followed by Archive.Extract.

type Info

type Info struct {
	DataVersion string
	AppName     string
	AppVersion  string
	AppID       string
	Publisher   string
	Languages   []Language
	GOGGameID   string
	Encrypted   bool
}

type Language

type Language struct {
	Name        string
	DisplayName string
	ID          uint32
	Codepage    uint32
}

type Option

type Option func(*options) error

func WithCodepage

func WithCodepage(codepage uint32) Option

func WithMemoryLimit

func WithMemoryLimit(bytes int64) Option

func WithPassword

func WithPassword(password string) Option

func WithSliceProvider

func WithSliceProvider(provider SliceProvider) Option

type SliceProvider

type SliceProvider func(index uint32) (io.ReaderAt, error)

Directories

Path Synopsis
internal
crypto
Package crypto contains the small set of cryptographic primitives used by the Inno Setup data stream.
Package crypto contains the small set of cryptographic primitives used by the Inno Setup data stream.
gog
Package gog contains the format-only parts of GOG installer handling.
Package gog contains the format-only parts of GOG installer handling.
loader
Package loader locates the Inno Setup payloads embedded in an executable.
Package loader locates the Inno Setup payloads embedded in an executable.
pathutil
Package pathutil contains the path rules used when turning an Inno Setup destination into a path that is safe to hand to a caller.
Package pathutil contains the path rules used when turning an Inno Setup destination into a path that is safe to hand to a caller.
setup
Package setup decodes the metadata streams used by modern Inno Setup files.
Package setup decodes the metadata streams used by modern Inno Setup files.
stream
Package stream decodes the compressed data portions described by the parser's internal format model.
Package stream decodes the compressed data portions described by the parser's internal format model.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL