# crypto2011/idr architecture

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

- Interactive diagram: https://gitdiagram.com/crypto2011/idr
- Repository: https://github.com/crypto2011/idr

## Overview

##### Project Type and Purpose
- IDR is a decompiler tool targeted at analyzing and recovering Delphi executables and DLLs. The README explains that it performs static analysis on compiled files (from Delphi2 up to Delphi XE4) to extract as much of the original source code information as possible. It is also used safely for malware analysis.
- Since the application features a rich interactive UI (many files ending in .dfm and matching dialog-based C++ units indicate this) along with a strong back-end decompilation/disassembly engine, it is effectively a desktop application organized around a core analysis engine with several supporting modules.

##### Analyzing the File Structure
- At the top-level, you see source files (CPP and header files) such as Main.cpp/main.h, and many dialog files (e.g., AboutDlg, ActiveProcesses, EditFunctionDlg, Explorer, etc.). This indicates a substantial graphical UI built with dialogs.
- Core engine components are evident from files like Decompiler.cpp/decompiler.h, Disasm.cpp/disasm.h, Analyze1.cpp, Analyze2.cpp, and other analysis-related files. These form the heart of the static analysis and decompilation process.
- There is also a plugins folder (with its own files and resources) that suggests extensibility and modularity.
- The existence of a KnowledgeBase module (KnowledgeBase.cpp, KBViewer, kb*.7z files, and syskb*.bin files) points to integration of preconfigured decompilation rules/data for various Delphi versions.
- Build scripts and configuration files (e.g., .gitignore, idr.ini) round out the ecosystem.

##### Components
a. User Interface (UI) Layer:
- Dialog windows (AboutDlg, ActiveProcesses, EditFieldsDlg, Explorer, FindDlg, InputDlg, etc.). These form the interactive layer between the user and the core decompilation engine.
b. Core Analysis Engine:
- Decompiler Component: Illustrate modules such as Decompiler.cpp/Decompiler.h and its supporting analysis units (e.g., Analyze1.cpp, Analyze2.cpp, etc.) which process binary executables.
- Disassembly Engine: Represent files like Disasm.cpp/Disasm.h that provide low-level binary disassembly prior to decompilation.
- Helper/Utility Components: Indicate analysis helpers (e.g., Hex2Double, EditFunctionDlg, and Misc) that support parsing and data transformation.
c. Plugin/Extensibility Layer:
d. Knowledge Base Integration:
- KnowledgeBase component (including KnowledgeBase.cpp, KBViewer, and supporting binary knowledge files such as kb*.7z and syskb*.bin files) that facilitates version-specific decompilation rules and heuristics.
e. External Configuration/Resource Files:
- Also denote build configuration elements (e.g., idr.ini) for runtime settings.

##### Relationships and Data Flows
- The Core Analysis Engine should be subdivided to show the interaction between the Disassembly Engine (for low-level code translation) and the Decompiler Component (for higher-level reconstruction).
- Knowledge Base as feeding into the decompilation engine, providing rules, metadata, and other critical data used during analysis.
- Outputs sent back to the UI – results, performance reports, or recovered source code – alongside any logging or debugging components.

##### Architectural Patterns and Design Principles
- The design implies a separation of concerns between presentation (UI dialogs) and business logic (decompilation and disassembly processing).
- An extensibility mechanism is present (plugins) which can be highlighted as an inversion of control or interface-based integration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Input Layer
    subgraph "Input Layer"
        INPUT("Executable Selection"):::external
    end

    %% User Interface Layer
    subgraph "User Interface Layer"
        UI_Manager("UI Dialog Manager"):::ui
        AboutDlg("AboutDlg"):::ui
        ActiveProcesses("ActiveProcesses"):::ui
        EditFieldsDlg("EditFieldsDlg"):::ui
        EditFunctionDlg("EditFunctionDlg"):::ui
        Explorer("Explorer"):::ui
        FindDlg("FindDlg"):::ui
        InputDlg("InputDlg"):::ui
        OtherDialogs("Other Dialogs"):::ui
    end

    %% Core Analysis Engine
    subgraph "Core Analysis Engine"
        Decomp("Decompiler Component"):::core
        Disasm("Disassembly Engine"):::core
        Utility("Helper/Utility Components"):::core
    end

    %% Plugin/Extensibility Layer
    subgraph "Plugin/Extensibility Layer"
        PluginMgr("Plugin Manager"):::plugin
    end

    %% Knowledge Base Integration Layer
    subgraph "Knowledge Base Integration"
        KB("Knowledge Base"):::kb
        KBViewer("KBViewer"):::kb
    end

    %% External Resources
    subgraph "External Resources"
        Config("Resource & Configuration Manager"):::external
    end

    %% Relationships and Data Flows
    INPUT -->|"selectsFile"| UI_Manager
    UI_Manager -->|"sendsFileInfo"| Decomp
    Decomp -->|"requestsDisassembly"| Disasm
    Disasm -->|"returnsDisassembly"| Decomp
    Utility -->|"supportsAnalysis"| Decomp
    PluginMgr -->|"extends"| Decomp
    KB -->|"suppliesRules"| Decomp
    KBViewer -->|"viewsKBData"| Decomp
    Decomp -->|"returnsResults"| UI_Manager
    Config ---|"providesConfig"| UI_Manager
    Config ---|"providesConfig"| Decomp

    %% Styles
    classDef ui fill:#A9D0F5,stroke:#333,stroke-width:2px;
    classDef core fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef plugin fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef kb fill:#F5DEB3,stroke:#333,stroke-width:2px;
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:2px;

    %% Click Events for User Interface Layer
    click AboutDlg "https://github.com/crypto2011/idr/blob/master/AboutDlg.cpp"
    click ActiveProcesses "https://github.com/crypto2011/idr/blob/master/ActiveProcesses.cpp"
    click EditFieldsDlg "https://github.com/crypto2011/idr/blob/master/EditFieldsDlg.cpp"
    click EditFunctionDlg "https://github.com/crypto2011/idr/blob/master/EditFunctionDlg.cpp"
    click Explorer "https://github.com/crypto2011/idr/blob/master/Explorer.cpp"
    click FindDlg "https://github.com/crypto2011/idr/blob/master/FindDlg.cpp"
    click InputDlg "https://github.com/crypto2011/idr/blob/master/InputDlg.cpp"

    %% Click Events for Core Analysis Engine
    click Decomp "https://github.com/crypto2011/idr/blob/master/Decompiler.cpp"
    click Disasm "https://github.com/crypto2011/idr/blob/master/Disasm.cpp"
    click Utility "https://github.com/crypto2011/idr/blob/master/Hex2Double.cpp"

    %% Click Events for Plugin/Extensibility Layer
    click PluginMgr "https://github.com/crypto2011/idr/blob/master/Plugins.cpp"
    click PluginMgr "https://github.com/crypto2011/idr/tree/master/Plugins/"

    %% Click Events for Knowledge Base Integration
    click KB "https://github.com/crypto2011/idr/blob/master/KnowledgeBase.cpp"
    click KBViewer "https://github.com/crypto2011/idr/blob/master/KBViewer.cpp"

    %% Click Events for External Resources
    click Config "https://github.com/crypto2011/idr/blob/master/bin/idr.manifest"
    click Config "https://github.com/crypto2011/idr/blob/master/idr.ini"
```
