# longsoft/uefitool architecture

> Architecture diagram of the GitHub repository longsoft/uefitool, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/longsoft/uefitool
- Repository: https://github.com/longsoft/uefitool

## Overview

##### And Define the Main Components
- UEFITool – the primary GUI application built using C++/Qt. It is responsible for presenting the firmware image as a tree structure. It includes further subdivision into submodules such as QHexView (a fully featured hex editor component) and various dialogs for user interactions (goto dialogs, search dialogs, etc.).
- UEFIExtract – a command-line utility that leverages the shared firmware-parsing engine (ffsParser) from the common libraries to recursively extract the parsed image into the filesystem.
- UEFIFind – another command-line utility designed to search for particular patterns in the firmware image using similar parsing logic.
- Common Library/Modules – this directory is a core shared component; it contains:
- UEFI parsing logic (ffs.cpp, ffsparser.cpp, tree handling, image reconstruction routines still in progress).
- Compression and decompression routines (LZMA, Tiano, zlib) as well as digest/hash functionality.
- Data structures, utility functions, and custom parsers including NVRAM, PE image handling, and other firmware-specific formats.
- Code generation components (the “generated” subdirectory) and integration for external specifications (Kaitai Struct, ksy files).
- Build & Testing Infrastructure – including configuration/build scripts (CMakeLists.txt, meson.build files) and continuous integration workflows (.github/workflows).

##### Relationships and Data Flow
- The GUI (UEFITool) and CLI tools (UEFIExtract/UEFIFind) are built on top of the common parsing and utility libraries.
- They employ the same underlying firmware image-parsing engine (ffsParser, file system analysis, decompression modules).
- In UEFITool, the QHexView module connects the UI elements with low-level data buffers (reading memory via models).
- Command-line tools call into the same libraries and may share some manifest and configuration files from the repository.
- The build scripts (CMake, Meson) act as the external orchestration layer, enabling compilation and dependency configuration for different target environments.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Each tool (UEFITool, UEFIExtract, UEFIFind) has its own dedicated application logic while sharing a central common library.
- Modular Design: The repository is divided into discrete modules (QHexView for UI, common for parsing, and dedicated directories for each executable) that make it easier to maintain and extend.
- Cross-Platform and Extensibility: The use of Qt for the GUI and the availability of alternative build systems (CMake and Meson) support portability and flexible integration of future features.
- Use of External Compression/Decompression and Parsing Libraries: Integration with third-party standards like Kaitai and compression toolkits reinforces the robustness of the parsing engine.

##### Relevant Technologies and Frameworks
- C++ as the primary programming language.
- Qt (Qt5/Qt6) for the GUI and cross-platform UI components.
- Build systems: CMake and Meson.
- Compression libraries: LZMA, Tiano, and zlib.
- Testing and CI/CD: GitHub workflows and static analysis tools (Coverity, SonarCloud).
- External tools and libraries like bstrlib and Kaitai for parsing binary formats.

##### Final Element Checklist
- Clearly labeled nodes:
- UEFITool (with submodules like QHexView)
- UEFIExtract
- UEFIFind
- Common Parsing Library (including compression, digest, and file system modules)
- Testing/Fuzzing tools and Build Infrastructure
- Dependency of tools on the common library.
- Internal relationships (e.g., QHexView feeds into the UEFITool UI).
- Notations for technologies/frameworks:
- C++/Qt usage in UEFITool.
- CMake and Meson for build processes.
- Compression libraries and digest code in common.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Dependencies
    subgraph "External Dependencies"
        Qt["Qt (GUI Framework)"]:::external
        LZMA["LZMA (Compression)"]:::external
        Tiano["Tiano (Compression)"]:::external
        zlib["zlib (Compression)"]:::external
        Kaitai["Kaitai Struct"]:::external
    end

    %% Build & Testing Infrastructure
    subgraph "Build & Testing Infrastructure"
        BuildInfra["Build Scripts & CI/CD"]:::build
        Fuzzing["Fuzzing / Testing"]:::build
    end

    %% Common Parsing Library
    subgraph "Common Library"
        Common["Common Parsing & Utility Library"]:::common
    end

    %% GUI Components
    subgraph "GUI Components"
        UEFITool["UEFITool (GUI Application)"]:::gui
        QHexView["QHexView (Hex Editor & Dialogs)"]:::gui
    end

    %% CLI Tools
    subgraph "CLI Tools"
        UEFIExtract["UEFIExtract (CLI Extraction Utility)"]:::cli
        UEFIFind["UEFIFind (CLI Search Utility)"]:::cli
    end

    %% Relationships
    QHexView -->|"integrates_into_UI"| UEFITool

    UEFITool -->|"uses_parsing"| Common
    UEFIExtract -->|"extracts_from_fw"| Common
    UEFIFind -->|"searches_fw"| Common

    BuildInfra -->|"builds"| UEFITool
    BuildInfra -->|"builds"| UEFIExtract
    BuildInfra -->|"builds"| UEFIFind
    BuildInfra -->|"builds"| Common

    Fuzzing -->|"tests"| Common

    Qt -->|"framework"| UEFITool
    LZMA -->|"compression"| Common
    Tiano -->|"compression"| Common
    zlib -->|"compression"| Common
    Kaitai -->|"parsing"| Common

    %% Click Events
    click UEFITool "https://github.com/longsoft/uefitool/tree/new_engine/UEFITool/"
    click QHexView "https://github.com/longsoft/uefitool/tree/new_engine/UEFITool/QHexView"
    click UEFIExtract "https://github.com/longsoft/uefitool/tree/new_engine/UEFIExtract/"
    click UEFIFind "https://github.com/longsoft/uefitool/tree/new_engine/UEFIFind/"
    click Common "https://github.com/longsoft/uefitool/tree/new_engine/common/"
    click BuildInfra "https://github.com/longsoft/uefitool/blob/new_engine/CMakeLists.txt"
    click Fuzzing "https://github.com/longsoft/uefitool/tree/new_engine/fuzzing/"

    %% Styles
    classDef gui fill:#a3d8f4,stroke:#1f77b4,stroke-width:2px;
    classDef cli fill:#f4d8a3,stroke:#d17b1d,stroke-width:2px;
    classDef common fill:#d8a3f4,stroke:#8e44ad,stroke-width:2px;
    classDef build fill:#a3f4a3,stroke:#27ae60,stroke-width:2px;
    classDef external fill:#f4a3a3,stroke:#c0392b,stroke-width:2px;
```
