### Process Inno Setup Installer with Options Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/cli-extract.md Shows how to call the `process_file` function with a set of `extract_options`. This example configures options for extraction, specifies an output directory, and enables file listing. ```cpp extract_options opts; opts.extract = true; opts.output_dir = "/extract/here"; opts.list = true; try { process_file("/path/to/installer.exe", opts); } catch (const format_error& e) { std::cerr << "Error: " << e.what() << std::endl; return 1; } ``` -------------------------------- ### Step 2: Loading Setup Version Information Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/loader-module.md Loads the setup version from the installer file using the `header_offset` obtained previously. It then prints the version details. ```cpp file.seekg(offsets.header_offset); setup::version version; version.load(file); std::cout << "Inno Setup version: " << version.a() << "." << version.b() << "." << version.c() << std::endl; ``` -------------------------------- ### Detect Inno Setup Version from Installer File Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-version.md Illustrates how to load installer offsets, parse the version information, and determine the Inno Setup version, including its variant (Unicode/ANSI) and bitness. ```cpp std::ifstream installer("setup.exe", std::ios::binary); loader::offsets offsets; offsets.load(installer); if (offsets.header_offset == 0) { std::cerr << "No setup headers found" << std::endl; return false; } installer.seekg(offsets.header_offset); setup::version version; try { version.load(installer); std::cout << "Inno Setup version: " << version << std::endl; if (!version.known) { std::cout << "WARNING: Version is not officially supported" << std::endl; } if (version.is_unicode()) { std::cout << "Unicode variant" << std::endl; } else { std::cout << "ANSI variant" << std::endl; } if (version.bits() == 16) { std::cout << "16-bit variant (very old)" << std::endl; } // Decide on extraction approach if (version >= INNO_VERSION(5, 0, 0)) { // Use modern extraction } else if (version >= INNO_VERSION(3, 0, 0)) { // Use legacy extraction } else { // Use minimal extraction } } catch (const setup::version_error&) { std::cerr << "Invalid version identifier" << std::endl; return false; } ``` -------------------------------- ### Load Installer Data Offsets and Headers with C++ Library Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/README.md This C++ code snippet demonstrates how to use the innoextract library to find data offsets and load setup headers from an Inno Setup installer executable. ```cpp #include "setup/info.hpp" #include "loader/offsets.hpp" #include "stream/block.hpp" #include "cli/extract.hpp" // Find data offsets std::ifstream file("installer.exe", std::ios::binary); loader::offsets offsets; offsets.load(file); // Load setup headers file.seekg(offsets.header_offset); setup::version version; version.load(file); auto header_stream = stream::block_reader::get(file, version); setup::info info; info.load(*header_stream, setup::info::Files | setup::info::DataEntries); // Process files for (const auto& file_entry : info.files) { std::cout << "File: " << file_entry.destination << std::endl; } ``` -------------------------------- ### Main Setup Configuration and Metadata Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/README.md Details the main setup configuration and metadata, including application information, installation behavior, and platform support. ```APIDOC ## Main Setup Configuration (`setup::header`) ### Description Contains the primary setup configuration and metadata for the installer. ### Fields - Application information. - Installation behavior options. - Architecture and platform support. - UI settings (color). - Privilege and Windows version requirements. ``` -------------------------------- ### C++ Installer Data Extraction Usage Example Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/stream-module.md Demonstrates loading installer offsets and headers, then iterating through files to extract them using stream::chunk_reader and stream::file_reader. ```cpp // Load installer offsets std::ifstream installer("setup.exe", std::ios::binary); loader::offsets offsets; offsets.load(installer); // Load setup headers installer.seekg(offsets.header_offset); auto header_stream = stream::block_reader::get(installer, version); setup::info info; info.load(*header_stream, setup::info::Files | setup::info::DataEntries); // Extract a file stream::slice_reader slices(installer, offsets.data_offset); for (const auto& file : info.files) { const auto& data = info.data_entries[file.location]; auto chunk = stream::chunk_reader::get(slices, data.chunk, key); auto file_stream = stream::file_reader::get(*chunk, data.file, nullptr); std::ofstream output(file.destination, std::ios::binary); output << file_stream->rdbuf(); } ``` -------------------------------- ### Iterate Through Setup Entry Collections Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-entries.md Provides examples for iterating through and accessing data within various collections of setup entries, such as files, components, languages, tasks, registry entries, and run entries. ```cpp // Access all file entries for (const auto& file : info.files) { std::cout << "File: " << file.destination << std::endl; // Access associated data if (file.location < info.data_entries.size()) { const auto& data = info.data_entries[file.location]; std::cout << " Size: " << data.uncompressed_size << std::endl; } // Check options if (file.options.test(setup::file_entry::flags::DontCopy)) { std::cout << " (not copied)" << std::endl; } } // Access components for (const auto& component : info.components) { std::cout << "Component: " << component.name << std::endl; std::cout << " Size: " << component.size << std::endl; std::cout << " Selected: " << (component.used ? "yes" : "no") << std::endl; } // Access languages for (const auto& lang : info.languages) { std::cout << "Language: " << lang.language_name << std::endl; std::cout << " Codepage: " << lang.codepage << std::endl; } // Access tasks for (const auto& task : info.tasks) { std::cout << "Task: " << task.name << std::endl; std::cout << " Components: " << task.components << std::endl; } // Access registry entries for (const auto& reg : info.registry_entries) { std::cout << "Registry: " << reg.subkey << std::endl; std::cout << " Value: " << reg.value_name << " = " << reg.value_data << std::endl; } // Access run entries for (const auto& run : info.run_entries) { std::cout << "Run: " << run.program << std::endl; std::cout << " Parameters: " << run.parameters << std::endl; } ``` -------------------------------- ### Version Comparison Example Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-version.md Demonstrates implicit conversion of a `setup::version` object to a 32-bit constant for comparison with version macros. ```cpp setup::version v; v.load(stream); if (v >= INNO_VERSION(5, 0, 0)) { std::cout << "Version 5.0 or later" << std::endl; } ``` -------------------------------- ### Check Installation Options Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-header.md Verifies various installation options set for the Inno Setup package. Use these checks to determine if the installer is password-protected, will create an application directory, or may close running applications. ```cpp if (header.options.test(setup::header::flags::EncryptionUsed)) { std::cout << "Installer is password-protected" << std::endl; } if (header.options.test(setup::header::flags::CreateAppDir)) { std::cout << "Will create: " << header.default_dir_name << std::endl; } if (header.options.test(setup::header::flags::CloseApplications)) { std::cout << "May close running applications" << std::endl; } ``` -------------------------------- ### Get Full Installer Information Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/errors.md Retrieve comprehensive details about the installer, including its structure and metadata. ```bash # Get full details innoextract --info installer.exe ``` -------------------------------- ### Streaming Output of Version Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-version.md Example showing how to print a `setup::version` object to an output stream in a human-readable format, including variant information. ```cpp setup::version v(INNO_VERSION(5, 6, 2), setup::version::Unicode, true); std::cout << v << std::endl; // Output: 5.6.2 Unicode (Unicode flag) ``` -------------------------------- ### Extracting Version Components Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-version.md Example demonstrating how to extract and print the major, minor, release, and build components of a `setup::version` object. ```cpp setup::version v(INNO_VERSION(5, 6, 2)); std::cout << v.a() << "." << v.b() << "." << v.c() << std::endl; // Output: 5.6.2 ``` -------------------------------- ### List Files in an Installer with innoextract CLI Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/README.md Use the --list option with the innoextract command-line tool to view the contents of an Inno Setup installer without extracting. ```bash innoextract --list installer.exe ``` -------------------------------- ### Step 3: Loading Setup Headers Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/loader-module.md Loads the setup information, including file and data entry details, using a `block_reader` and the `setup::info::load` method. This step requires the setup version to be loaded first. ```cpp auto header_stream = stream::block_reader::get(file, version); setup::info info; info.load(*header_stream, setup::info::Files | setup::info::DataEntries); ``` -------------------------------- ### Check Installer Data Version Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/errors.md Query the specific data version of the Inno Setup installer. ```bash # Check version innoextract --data-version installer.exe ``` -------------------------------- ### setup::directory_entry Definition Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-entries.md Defines a directory to be created during installation, including its name, attributes, permissions, and Windows version requirements. ```cpp struct directory_entry : public item { std::string name; // Directory name std::string attributes; // Directory attributes boost::int16_t permission; // Index into permission list windows_version_range winver; // Windows version requirement FLAGS(flags, DeleteAfterInstall, // Obsolete Permanent ); flags options; }; ``` -------------------------------- ### Compare Inno Setup Versions Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-version.md Demonstrates direct, component, range, and variant comparisons for Inno Setup versions using the INNO_VERSION macro. ```cpp // Direct comparison if (version.value >= INNO_VERSION(5, 0, 0)) { // Modern Inno Setup 5.0+ } // Component comparison if (version.a() == 6 && version.b() >= 2) { // Inno Setup 6.2 or later } // Range checking if (version >= INNO_VERSION(5, 1, 5) && version < INNO_VERSION(6, 0, 0)) { // Version 5.1.5 through 5.x } // Variant checking if (version.is_unicode() && version.bits() == 32) { // Unicode 32-bit variant } ``` -------------------------------- ### setup::task_entry Definition Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-entries.md Defines an additional installation task, presented as a checkbox on the tasks page. It includes details like name, description, required components, and conditions. ```cpp struct task_entry : public item { std::string name; // Task identifier std::string description; // Display text std::string group_description; // Group display text std::string components; // Required components std::string languages; // Associated languages std::string check; // Task condition bool used; // Task is selected windows_version_range winver; // Windows version requirement FLAGS(flags, Exclusive, Unchecked, // Obsolete OnlyOnDebug ); flags options; }; ``` -------------------------------- ### setup::run_entry Definition Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-entries.md Specifies a program or command to be executed during or after the installation. It includes program path, parameters, working directory, display mode, and wait behavior. ```cpp struct run_entry : public item { std::string program; // Program path/command std::string parameters; // Command parameters std::string working_dir; // Working directory enum run_type { DoNotShow, ShowMinimized, ShowMaximized, ShowNormal }; run_type show; // Window display mode enum wait_mode { DoNotWait, WaitUntilTerminated, WaitUntilWindowClosed }; wait_mode wait; // Wait behavior enum error_handling { IgnoreErrors, StopOnError }; error_handling on_error; // Error handling std::string languages; // Associated languages std::string check; // Run condition windows_version_range winver; // Windows version requirement FLAGS(flags, NeverShowWindow, RunMinimized, RunMaximized, // Obsolete Shellexecute, Wait, PostInstall, RunOnce ); flags options; }; ``` -------------------------------- ### setup::info Structure Definition Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-info.md Defines the central data structure for storing Inno Setup installer metadata. It includes version, header, and various entry collections like components, files, and registry entries. ```cpp struct info { // Version information setup::version version; // Text encoding util::codepage_id codepage; // Main header setup::header header; // Entry collections std::vector components; std::vector data_entries; std::vector delete_entries; std::vector uninstall_delete_entries; std::vector directories; std::vector files; std::vector icons; std::vector ini_entries; std::vector languages; std::vector messages; std::vector permissions; std::vector registry_entries; std::vector run_entries; std::vector uninstall_run_entries; std::vector tasks; std::vector types; // Additional resources std::vector wizard_images; std::vector wizard_images_small; std::string decompressor_dll; std::string decrypt_dll; }; ``` -------------------------------- ### Step 1: Finding Setup Data Offsets Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/loader-module.md Initializes the `loader::offsets` structure and calls its `load` method to find the header offset within an installer file. It checks if `header_offset` is zero, indicating no setup headers were found. ```cpp std::ifstream file("installer.exe", std::ios::binary); loader::offsets offsets; offsets.load(file); if (offsets.header_offset == 0) { std::cerr << "No setup headers found" return false; } ``` -------------------------------- ### next() Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-version.md Get the version constant for the next known supported Inno Setup version. ```APIDOC ### next() → version_constant Get next known version. **Returns:** Version constant for next supported version **Usage:** Iterating through version range ``` -------------------------------- ### Test Installer Integrity with innoextract CLI Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/README.md Use the --test option with the innoextract command-line tool to verify the integrity of an Inno Setup installer. ```bash innoextract --test installer.exe ``` -------------------------------- ### setup::type_entry Definition Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-entries.md Represents an installation type such as Typical, Full, or Custom. It includes properties for name, description, associated languages, and Windows version requirements. ```cpp struct type_entry : public item { std::string name; // Type name std::string description; // Human-readable description std::string languages; // Associated languages std::string check; // Install condition int level; // Nesting level windows_version_range winver; // Windows version requirement FLAGS(flags, IsCustom, // User-defined type // Obsolete FullInstall, Compact ); flags options; }; ``` -------------------------------- ### Setup Header Configuration Fields Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-header.md Defines the structure for application and installation configuration. Used to specify details like application name, version, copyright, installation directories, user information, security settings, and display preferences. ```cpp struct header { // Application information std::string app_name; std::string app_versioned_name; std::string app_id; std::string app_copyright; std::string app_publisher; std::string app_publisher_url; std::string app_support_phone; std::string app_support_url; std::string app_updates_url; std::string app_version; // Installation directories and names std::string default_dir_name; std::string default_group_name; std::string uninstall_icon_name; std::string base_filename; std::string uninstall_files_dir; std::string uninstall_name; std::string uninstall_icon; // User information std::string default_user_name; std::string default_user_organisation; std::string default_serial; std::string app_mutex; // Help and documentation std::string app_readme_file; std::string app_contact; std::string app_comments; std::string app_modify_path; // Registry and file management std::string create_uninstall_registry_key; std::string uninstallable; // Filter expressions std::string close_applications_filter; std::string setup_mutex; std::string changes_environment; std::string changes_associations; // Architecture and platform std::string architectures_allowed_expr; std::string architectures_installed_in_64bit_mode_expr; // Documentation text std::string license_text; std::string info_before; std::string info_after; // Security std::string uninstaller_signature; std::string compiled_code; // Display settings Color back_color; Color back_color2; Color image_back_color; Color small_image_back_color; enum style { ClassicStyle, ModernStyle }; style wizard_style; style uninstall_style; boost::uint32_t wizard_resize_percent_x; boost::uint32_t wizard_resize_percent_y; enum alpha_format { AlphaIgnored, AlphaDefined, AlphaPremultiplied }; alpha_format image_alpha_format; // Security crypto::checksum password; std::string password_salt; // Installation requirements boost::int64_t extra_disk_space_required; size_t slices_per_disk; enum install_verbosity { NormalInstallMode, SilentInstallMode, VerySilentInstallMode }; install_verbosity install_mode; enum log_mode { AppendLog, NewLog, OverwriteLog }; } ``` -------------------------------- ### Print Comprehensive Installer Information Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/configuration.md Prints detailed installer information, automatically enabling --list-languages, --gog-game-id, and --show-password. ```bash innoextract --info installer.exe ``` -------------------------------- ### bits() Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-version.md Get the bit width variant of the Inno Setup version. ```APIDOC ### bits() → boost::uint16_t Get bit width variant. **Returns:** 16 or 32 **Example:** ```cpp if (version.bits() == 16) { std::cout << "16-bit variant" << std::endl; } else { std::cout << "32-bit variant" << std::endl; } ``` ``` -------------------------------- ### Extract All Files with innoextract CLI Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/README.md Use the innoextract command-line tool to extract all files from an Inno Setup installer. ```bash innoextract installer.exe ``` -------------------------------- ### process_file Function Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/cli-extract.md Processes an Inno Setup installer file based on provided options. This function handles reading, parsing, and extracting or listing files from the installer, with support for password protection and various configuration settings. ```APIDOC ## process_file Function ### Description Processes an Inno Setup installer file based on provided options. This function handles reading, parsing, and extracting or listing files from the installer, with support for password protection and various configuration settings. ### Method ```cpp void process_file(const boost::filesystem::path & installer, const extract_options & o); ``` ### Parameters #### Path Parameters - **installer** (const boost::filesystem::path&): Path to the Inno Setup installer file - **o** (const extract_options&): Configuration options for processing ### Behavior - Reads and parses the installer executable - Extracts setup headers and data entries - Performs the requested action (list, test, extract) based on options - Handles password-protected installers - Manages file extraction with collision handling ### Throws - `format_error`: If the installer format is invalid - `std::exception`: Various stream or filesystem errors ### Example ```cpp extract_options opts; opts.extract = true; opts.output_dir = "/extract/here"; opts.list = true; try { process_file("/path/to/installer.exe", opts); } catch (const format_error& e) { std::cerr << "Error: " << e.what() << std::endl; return 1; } ``` ``` -------------------------------- ### Safe Extraction Procedure in C++ Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/errors.md This C++ code demonstrates a robust method for extracting Inno Setup installers, including detailed error handling for various stages like loading offsets, headers, and file chunks. ```cpp #include #include int extract_safely(const std::string& installer_path) { try { // Step 1: Load offsets std::ifstream file(installer_path, std::ios::binary); if (!file.is_open()) { std::cerr << "Cannot open: " << installer_path << std::endl; return 1; } loader::offsets offsets; try { offsets.load(file); } catch (const std::exception& e) { std::cerr << "Cannot read offsets: " << e.what() << std::endl; return 2; } if (offsets.header_offset == 0) { std::cerr << "No setup data found" << std::endl; return 2; } // Step 2: Load headers file.seekg(offsets.header_offset); setup::version version; try { version.load(file); } catch (const setup::version_error&) { std::cerr << "Invalid version identifier" << std::endl; return 2; } // Step 3: Load info auto header_stream = stream::block_reader::get(file, version); setup::info info; try { info.load(*header_stream, setup::info::Files | setup::info::DataEntries); } catch (const format_error& e) { std::cerr << "Invalid format: " << e.what() << std::endl; return 2; } catch (const stream::block_error& e) { std::cerr << "Corrupted headers: " << e.what() << std::endl; return 2; } // Step 4: Extract files stream::slice_reader slices(file, offsets.data_offset); for (const auto& file_entry : info.files) { try { const auto& data = info.data_entries[file_entry.location]; auto chunk = stream::chunk_reader::get(slices, data.chunk, key); auto file_stream = stream::file_reader::get(*chunk, data.file, nullptr); // Write file... } catch (const stream::chunk_error& e) { std::cerr << "Cannot read file: " << e.what() << std::endl; return 2; } } return 0; } catch (const std::exception& e) { std::cerr << "Unexpected error: " << e.what() << std::endl; return 2; } } ``` -------------------------------- ### List Installer Details Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/errors.md Lists detailed information about the installer, including sizes and checksums. This command helps in understanding the structure and integrity of the installer. ```bash innoextract --list --list-sizes --list-checksums installer.exe ``` -------------------------------- ### Loading Version from Stream Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-version.md Example of loading version information from a binary input stream, typically after seeking to the correct offset in an installer file. ```cpp std::ifstream file("installer.exe", std::ios::binary); setup::version version; file.seekg(header_offset); // From loader::offsets version.load(file); std::cout << "Version: " << version << std::endl; ``` -------------------------------- ### Print Setup Data Version Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/configuration.md Prints only the setup data version number. This option runs as a single action and suppresses all other output. ```bash innoextract --data-version installer.exe ``` -------------------------------- ### Extract Password-Protected Installer with innoextract CLI Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/README.md Use the --password option with the innoextract command-line tool to extract files from an Inno Setup installer that is protected by a password. ```bash innoextract --password secret installer.exe ``` -------------------------------- ### setup::version Structure Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-version.md Defines the structure for representing Inno Setup version identifiers and variant information. ```APIDOC ## setup::version Structure Version identifier for Inno Setup installers. ### Definition ```cpp struct version { typedef boost::uint32_t version_constant; version_constant value; // 32-bit version value FLAGS(flags, Bits16, // 16-bit variant Unicode, // Unicode (wide char) variant ISX // ISX script variant ); flags variant; // Version variant flags bool known; // True if version is recognized }; ``` ### Member Fields | Field | Type | Description | |-------|------|-------------| | `value` | `version_constant` | Encoded version (32 bits: a.b.c[.d]) | | `variant` | `flags` | Version variant flags | | `known` | `bool` | True if this version is officially supported | ``` -------------------------------- ### Load Installer Information Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-info.md Loads all entry types from an input stream. Ensure the stream is positioned at the setup::version identifier before calling. This method decompresses header blocks and applies codepage decoding. ```cpp void load(std::istream & is, entry_types entries, util::codepage_id force_codepage = 0); ``` ```cpp std::ifstream file("installer.exe"); setup::info installer; file.seekg(header_offset); // From loader::offsets setup::info::entry_types entries = setup::info::Files | setup::info::Languages | setup::info::DataEntries; installer.load(file, entries); ``` ```cpp std::ifstream installer("setup.exe", std::ios::binary); setup::info info; try { installer.seekg(offsets.header_offset); info.load(installer, ~0); // Load all entry types std::cout << "Found " << info.files.size() << " files" << std::endl; std::cout << "Languages: " << info.languages.size() << std::endl; } catch (const std::exception& e) { std::cerr << "Failed to load installer: " << e.what() << std::endl; } ``` -------------------------------- ### Loading Inno Setup Offsets from an Executable Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/loader-module.md Demonstrates how to use the `loader::offsets::load` method to parse an Inno Setup executable and retrieve offset information. Includes error handling for stream read errors and checks if the magic number was found. ```cpp std::ifstream installer("game.exe", std::ios::binary); loader::offsets offsets; try { offsets.load(installer); if (!offsets.found_magic) { std::cout << "No Inno Setup magic found, checking for external data..." << std::endl; } std::cout << "Header offset: 0x" << std::hex << offsets.header_offset << std::endl; std::cout << "Data offset: 0x" << std::hex << offsets.data_offset << std::endl; } catch (const std::exception& e) { std::cerr << "Failed to read executable: " << e.what() << std::endl; } ``` -------------------------------- ### Step 4: Accessing Setup Data Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/loader-module.md Demonstrates how to access setup data, differentiating between embedded data (when `data_offset` is non-zero) and external slices (when `data_offset` is zero). ```cpp if (offsets.data_offset != 0) { // Embedded data stream::slice_reader slices(file, offsets.data_offset); } else { // External slices stream::slice_reader slices(dirname, basename, basename2, slices_per_disk); } ``` -------------------------------- ### Install innoextract Source: https://github.com/dscharrer/innoextract/blob/master/README.md Installs the compiled innoextract binaries system-wide. Requires root privileges. ```bash # make install ``` -------------------------------- ### Base Class: setup::item Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-entries.md The base structure for all setup entry types, providing common properties inherited by derived entries. ```cpp struct item { // Base properties inherited by all entries }; ``` -------------------------------- ### Check Architecture Support Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-header.md Determines the supported CPU architectures for the Inno Setup package. Checks if the installer is designed for 32-bit (x86) or 64-bit (Amd64) systems. ```cpp if (header.architectures_allowed.test(setup::header::architecture_types::X86)) { std::cout << "Supports 32-bit" << std::endl; } if (header.architectures_allowed.test(setup::header::architecture_types::Amd64)) { std::cout << "Supports 64-bit" << std::endl; } ``` -------------------------------- ### Extract installer without known version data Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/errors.md Use the `innoextract --no-extract-unknown` option to process an installer even if its version data is not recognized. This can be useful for custom or unsupported Inno Setup variants. ```bash # Try with unknown version flag innoextract --no-extract-unknown installer.exe ``` -------------------------------- ### List Files and Sizes Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/configuration.md Lists the files contained within an installer, optionally including their sizes. ```bash innoextract --list --list-sizes installer.exe ``` -------------------------------- ### Verify installer file integrity Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/errors.md Use the `file` command to check the basic type and format of an installer file. This is a preliminary step before using InnoExtract. ```bash # Verify file file installer.exe ``` -------------------------------- ### extract_options Structure Definition Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/cli-extract.md Defines the configuration structure for processing and extracting Inno Setup installers. It includes options for output control, actions, file handling, GOG-specific settings, version handling, filtering, encoding, file management, and paths. ```cpp struct extract_options { // Output control bool quiet; // Suppress informational output bool silent; // Output only errors and warnings // Actions bool list; // List files bool list_sizes; // Show size information for files bool list_checksums; // Show checksum information for files bool test; // Test files (verify checksums, no extraction) bool extract; // Extract files (default action) bool data_version; // Print the data version only bool list_languages; // List available languages bool gog_game_id; // Show the GOG.com game ID bool show_password; // Show password check information bool check_password; // Abort if provided password is incorrect // Debug #ifdef DEBUG bool dump_headers; // Dump decompressed setup headers #endif // File handling bool warn_unused; // Warn if there are unused files bool preserve_file_times; // Set timestamps of extracted files bool local_timestamps; // Use local timezone for setting timestamps bool extract_temp; // Extract temporary files // GOG-specific bool gog; // Try to extract additional GOG.com archives bool gog_galaxy; // Re-assemble GOG Galaxy file parts // Version handling bool extract_unknown; // Try to extract unknown Inno Setup versions // Filtering bool language_only; // Extract files not associated with any language std::string language; // Extract only files for this language std::vector include; // Extract only files matching these patterns // Encoding boost::uint32_t codepage; // Windows codepage for ANSI strings (0 = auto-detect) // File management setup::filename_map filenames; // Filename mapping and conversion CollisionAction collisions; // How to handle duplicate files std::string default_language; // Default language for renaming std::string password; // Password for encrypted files // Paths boost::filesystem::path output_dir; // Directory for extracted files }; ``` -------------------------------- ### Setup Version Error Type Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/types.md Indicates an error associated with an invalid setup version identifier. This exception is derived from std::exception. ```cpp struct version_error : public std::exception ``` -------------------------------- ### Install InnoExtract on Gentoo Linux Source: https://github.com/dscharrer/innoextract/wiki/Install Installs the app-arch/innoextract package from the main Portage tree on Gentoo Linux. ```bash # emerge app-arch/innoextract ``` -------------------------------- ### Handle setup::version_error during version loading Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/errors.md Catch `setup::version_error` when an invalid or unrecognized setup version identifier is encountered in the stream. This exception inherits directly from `std::exception`. ```cpp try { setup::version version; version.load(stream); } catch (const setup::version_error& e) { std::cerr << "Invalid version identifier" << std::endl; return ExitDataError; } ``` -------------------------------- ### List Required Files for Multi-Disk Installers Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/errors.md When dealing with multi-disk installers, use this command to list all necessary slice files. ```bash # List required files innoextract --list installer.exe ``` -------------------------------- ### Loading External Data for Lightweight Installers Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/loader-module.md This code demonstrates how to load data from external files when the installer executable contains only headers and no embedded data. It assumes data files are in the same directory as the executable. ```cpp if (offsets.data_offset == 0) { // Load from external files in same directory boost::filesystem::path installer_dir = boost::filesystem::path(exe_path).parent_path(); stream::slice_reader slices(installer_dir, "setup", "setup", 1); } ``` -------------------------------- ### Loading Headers from Multi-part Installer Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/loader-module.md Use this snippet to load header offsets from the main .exe file of a multi-part installer. Data may reside in separate .bin files. ```cpp // Load headers from installer.exe std::ifstream main("installer.exe"); loader::offsets offsets; offsets.load(main); // Data may be in installer-1.bin, installer-2.bin, etc. stream::slice_reader slices(directory, "installer", "", slices_per_disk); ``` -------------------------------- ### setup::version Structure Definition Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-version.md Defines the `version` structure used to store Inno Setup version information, including a 32-bit value, variant flags, and a flag indicating if the version is recognized. ```cpp struct version { typedef boost::uint32_t version_constant; version_constant value; // 32-bit version value FLAGS(flags, Bits16, // 16-bit variant Unicode, // Unicode (wide char) variant ISX // ISX script variant ); flags variant; // Version variant flags bool known; // True if version is recognized }; ``` -------------------------------- ### Individual Entry Type Structures Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/README.md Defines the structures for various individual entry types within an Inno Setup installer, such as directories, files, types, components, tasks, and registry modifications. ```APIDOC ## Individual Entry Type Structures (`setup`) ### Description Defines the structures for various types of entries found in an Inno Setup installer. ### Entry Types - `setup::directory_entry`: Directories to be created. - `setup::file_entry`: Files to be extracted. - `setup::type_entry`: Installation types. - `setup::component_entry`: Optional components. - `setup::task_entry`: Additional tasks. - `setup::run_entry`: Programs to execute. - `setup::registry_entry`: Registry modifications. - `setup::ini_entry`: INI file modifications. - `setup::delete_entry`: Files to be deleted. - `setup::icon_entry`: Program shortcuts. - `setup::permission_entry`: File permissions. - `setup::language_entry`: Language information. - `setup::message_entry`: Custom messages. ``` -------------------------------- ### Define Inno Setup Version Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/types.md Represents an Inno Setup version identifier. Use its methods to extract version components and check variant properties. ```cpp struct version { version_constant value; // 32-bit version value FLAGS(flags, Bits16, // 16-bit variant Unicode, // Unicode variant ISX // ISX variant ); flags variant; // Version flags bool known; // True if version is recognized }; ``` -------------------------------- ### Install Build Dependencies on apt-based Systems Source: https://github.com/dscharrer/innoextract/wiki/Install Installs essential packages for compiling InnoExtract from source on systems like Ubuntu using apt. ```bash $ sudo apt-get install build-essential cmake libboost-all-dev liblzma-dev ``` -------------------------------- ### Conditional Logic Based on Inno Setup Version Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-version.md Shows how to apply different extraction logic based on the detected Inno Setup version, enabling support for features like LZMA compression or Unicode. ```cpp setup::info info; if (info.version >= INNO_VERSION(5, 0, 0)) { // Version 5.0+ features available // - LZMA compression // - Enhanced encryption // - Additional options } else if (info.version >= INNO_VERSION(2, 0, 0)) { // Version 2.0+ features // - Unicode support // - Component selection } else { // Version 1.x features // - Limited functionality // - No Unicode } ``` -------------------------------- ### Update Package List and Install InnoExtract on Ubuntu from PPA Source: https://github.com/dscharrer/innoextract/wiki/Install Updates the apt package list after adding a PPA and then installs the innoextract package. ```bash $ sudo apt-get update $ sudo apt-get install innoextract ``` -------------------------------- ### Install InnoExtract on Debian Unstable (sid) Source: https://github.com/dscharrer/innoextract/wiki/Install Installs the innoextract package directly from the Debian unstable repositories. ```bash # apt-get install innoextract ``` -------------------------------- ### Extract Password-Protected Installer Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/cli-extract.md Demonstrates how to extract files from a password-protected installer. It sets the `extract` and `password` options and enables `check_password` to verify the provided password. ```cpp extract_options opts; opts.extract = true; opts.password = "secret123"; opts.check_password = true; process_file(installer_path, opts); ``` -------------------------------- ### List Files with Size Information Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/cli-extract.md Configures `extract_options` to list files from an installer, including their sizes, and disables quiet mode to show informational output. This is useful for inspecting installer contents before extraction. ```cpp extract_options opts; opts.list = true; opts.list_sizes = true; opts.quiet = false; process_file(installer_path, opts); ``` -------------------------------- ### Load Inno Setup Header Data Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-header.md Loads header fields from an input stream based on the Inno Setup version. Decodes string fields and populates configuration fields. Requires an input stream positioned at the header data and a version identifier. ```cpp void load(std::istream & is, const version & version); ``` ```cpp std::ifstream file("installer.exe"); setup::header header; setup::version version; file.seekg(version_offset); version.load(file); header.load(file, version); std::cout << "Application: " << header.app_name << " v" << header.app_version << std::endl; std::cout << "Install to: " << header.default_dir_name << std::endl; ``` -------------------------------- ### Selective Loading of Installer Entries Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-info.md Loads specific entry types from an installer stream. Use bitwise OR to combine desired entry types. ```cpp setup::info::entry_types needed = setup::info::Files | setup::info::DataEntries | setup::info::Languages; info.load(installer_stream, needed); ``` -------------------------------- ### Install InnoExtract on Fedora using yum Source: https://github.com/dscharrer/innoextract/wiki/Install Installs the innoextract package on Fedora systems after adding the appropriate openSUSE build service repository. ```bash # yum install innoextract ``` -------------------------------- ### Version Constants Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/setup-version.md Predefined version constants for common Inno Setup versions, defined using macros. ```APIDOC ## Version Constants Predefined version constants for common Inno Setup versions. ```cpp #define INNO_VERSION_EXT(a, b, c, d) ( \ (a << 24) | (b << 16) | (c << 8) | d) #define INNO_VERSION(a, b, c) INNO_VERSION_EXT(a, b, c, 0) // Examples INNO_VERSION(1, 2, 10) // 1.2.10 INNO_VERSION(2, 0, 19) // 2.0.19 INNO_VERSION(5, 5, 9) // 5.5.9 INNO_VERSION(6, 3, 3) // 6.3.3 ``` ``` -------------------------------- ### Install InnoExtract on Arch Linux using AUR Helper Source: https://github.com/dscharrer/innoextract/wiki/Install Installs the innoextract package on Arch Linux via an AUR helper, such as packer. ```bash # packer -S innoextract ``` -------------------------------- ### Provide Password for Encrypted Installers Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/configuration.md Enter the password directly on the command line to decrypt protected installers. Be aware of security implications as the password may be visible in the process list. ```bash innoextract --password secretpassword installer.exe ``` -------------------------------- ### stream::block_reader::get Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/stream-module.md Reads and decompresses header blocks containing setup metadata. It verifies checksums and applies decompression based on the Inno Setup version. ```APIDOC ## stream::block_reader::get ### Description Reads and decompresses header blocks containing setup metadata. It verifies checksums and applies decompression based on the Inno Setup version. ### Method static pointer get(std::istream & base, const setup::version & version) ### Parameters - `base` (std::istream&): Input stream positioned at block stream start - `version` (const setup::version&): Inno Setup version identifier ### Returns Smart pointer to decompressed stream ### Throws `stream::block_error` if checksum invalid or compression unsupported ### Behavior - Reads compressed header blocks - Verifies block checksums - Decompresses data based on version and compression method - Returns stream suitable for reading setup::info ### Example ```cpp std::ifstream file("installer.exe", std::ios::binary); file.seekg(offsets.header_offset + version.encoded_size()); auto header_stream = stream::block_reader::get(file, version); setup::info info; info.load(*header_stream, setup::info::Files); ``` ``` -------------------------------- ### Extract Files Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/configuration.md Extracts files from an installer. This is the default action if no other action is specified. ```bash innoextract --extract installer.exe ``` -------------------------------- ### Check File Permissions Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/errors.md Inspect the read/write permissions of the installer file to diagnose access errors. ```bash # Check permissions ls -la installer.exe ``` -------------------------------- ### Update Package List and Install InnoExtract on Debian from openSUSE Repo Source: https://github.com/dscharrer/innoextract/wiki/Install Updates the apt package list after adding a new repository and then installs the innoextract package. ```bash # apt-get update # apt-get install innoextract ``` -------------------------------- ### Extract installer data version Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/errors.md Use the `innoextract --data-version` option to attempt extraction of version information from an installer. This can help diagnose issues with unrecognized versions. ```bash # Try with version extraction innoextract --data-version installer.exe ``` -------------------------------- ### Provide Encryption Password Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/errors.md Supply the correct password when extracting an encrypted installer. ```bash # Provide password innoextract --password "correct_password" installer.exe ``` -------------------------------- ### Skip Extraction of Unknown Inno Setup Versions Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/configuration.md Configure Innoextract to not attempt extraction if the Inno Setup version is unrecognized. This can prevent errors with potentially incompatible installers. ```bash innoextract --no-extract-unknown installer.exe ``` -------------------------------- ### Get Decompressed Header Stream Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/stream-module.md Factory method to obtain a decompressed stream for reading setup metadata. It handles reading compressed blocks, verifying checksums, and decompressing data based on the Inno Setup version. Use this to read header information before loading setup details. ```cpp class block_reader { public: typedef std::istream type; typedef util::unique_ptr::type pointer; static pointer get(std::istream & base, const setup::version & version); }; ``` ```cpp std::ifstream file("installer.exe", std::ios::binary); file.seekg(offsets.header_offset + version.encoded_size()); auto header_stream = stream::block_reader::get(file, version); setup::info info; info.load(*header_stream, setup::info::Files); ``` -------------------------------- ### Get Finalized Checksum Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/api-reference/crypto-module.md Example of finalizing a checksum computation and accessing its properties. Ensure the hasher has been updated with data before calling finalize. ```cpp crypto::hasher hash(SHA1_CHECKSUM); hash.update(data.data(), data.size()); checksum result = hash.finalize(); std::cout << "Bytes in hash: " << result.data.size() << std::endl; ``` -------------------------------- ### Load and Print Version Components Source: https://github.com/dscharrer/innoextract/blob/master/_autodocs/types.md Demonstrates loading a version from a stream and printing its major.minor.release.build components. ```cpp setup::version v; v.load(stream); std::cout << v.a() << "." << v.b() << "." << v.c() << std::endl; // Output: 5.6.2 ```