# focus-creative-games/il2cpp_plus architecture

> Architecture diagram of the GitHub repository focus-creative-games/il2cpp_plus, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/focus-creative-games/il2cpp_plus
- Repository: https://github.com/focus-creative-games/il2cpp_plus

## Overview

##### Project type and purpose
- From the file tree and README, we see this is a small patch-style project (“il2cpp_plus”) that augments the IL2CPP AOT runtime in Unity to support dynamic DLL metadata registration.
- It is not a standalone application but a compiler/runtime extension that must be integrated with HybridCLR.

##### File structure
- Top level contains only metadata files (.gitignore, LICENSE, README.md). The actual C/C++ source must live on another branch or is merged into the upstream IL2CPP codebase.
- There are no “frontend”/“backend” folders—this is a native runtime patch.
- Expect to find in-code hook definitions, modified metadata management modules, and build scripts under IL2CPP’s original source tree when checked out on the correct branch.

##### README for insights
- Purpose: “lightly modify metadata management, insert hook code to support dynamic loading of dll metadata.”
- Dependency: Cannot compile or run alone; must be paired with HybridCLR interpreter.
- Branching: “main” is empty; you need to switch to the appropriate feature branch for source code.

a. Main components to include
- Unity Engine (host)
- IL2CPP AOT Runtime (original)
- il2cpp_plus Patch Module (hook layer)
- HybridCLR Interpreter
- Dynamic Metadata Loader (component or service)
- Managed DLLs (assemblies loaded at runtime)
- Build & Deployment Scripts (optional, for completeness)
b. Relationships and interactions
1. Unity launches → calls IL2CPP AOT Runtime initialization.
2. Patched IL2CPP (“il2cpp_plus”) intercepts metadata requests.
3. If a type or method is missing in static metadata, the hook forwards to the Dynamic Metadata Loader.
4. Dynamic Metadata Loader uses HybridCLR Interpreter APIs to load and parse external DLL metadata.
5. Newly loaded metadata is merged back into the IL2CPP metadata tables.
6. Execution continues in IL2CPP or HybridCLR as appropriate.
c. Architectural patterns & design principles
- Hook/Interceptor pattern: il2cpp_plus inserts minimal hooks into existing metadata APIs.
- Modular runtime extension: decoupling the metadata loader and interpreter from the core IL2CPP.
- Dependency inversion: core runtime calls into abstract hook interfaces rather than concrete implementations.
d. Key technologies & libraries
- C/C++ (IL2CPP source, hook implementations)
- HybridCLR (interpreter that supplies dynamic metadata APIs)
- Unity’s build pipeline & IL2CPP toolchain

##### Capturing essential architectural elements
- Call out optional fallback paths (static AOT vs. dynamic interpreter)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Original IL2CPP"
        direction TB
        Unity["Unity Engine"]:::original
        IL2CPP["IL2CPP AOT Runtime"]:::original
        StaticMeta["Static Metadata Tables"]:::database
    end

    subgraph "il2cpp_plus Patch Layer"
        direction TB
        Patch["il2cpp_plus Patch Module"]:::patch
    end

    subgraph "Dynamic Loading"
        direction TB
        Loader["Dynamic Metadata Loader"]:::patch
        Cache["Dynamic Metadata Cache"]:::database
    end

    subgraph "HybridCLR"
        direction TB
        Interpreter["HybridCLR Interpreter"]:::interpreter
    end

    DLLs["Managed DLLs"]:::external

    BuildScripts["Build & Deployment Scripts"]:::artifact
    LicenseNode["Project Metadata & License"]:::artifact

    Unity -->|"initialize"| IL2CPP
    IL2CPP -->|"metadata request"| Patch
    Patch -->|"hook: MetadataRegistrationHook"| StaticMeta
    Patch -->|"on missing metadata"| Loader
    Loader -->|"use interpreter APIs"| Interpreter
    Interpreter -->|"parse DLL metadata"| DLLs
    DLLs -->|"metadata payload"| Loader
    Loader -->|"merge metadata"| StaticMeta
    Cache -.-> Loader

    %% Click Events
    click Patch "https://github.com/focus-creative-games/il2cpp_plus/blob/main/README.md"
    click BuildScripts "https://github.com/focus-creative-games/il2cpp_plus/blob/main/.gitignore"
    click LicenseNode "https://github.com/focus-creative-games/il2cpp_plus/tree/main/LICENSE"

    %% Styles
    classDef original fill:#cce5ff,stroke:#004085,color:#004085
    classDef patch fill:#d4edda,stroke:#155724,color:#155724
    classDef interpreter fill:#fff3cd,stroke:#856404,color:#856404
    classDef database fill:#cce5ff,stroke:#004085,stroke-dasharray: 5 5
    classDef external fill:#f8d7da,stroke:#721c24,color:#721c24
    classDef artifact fill:#e2e3e5,stroke:#6c757d,color:#6c757d
```
