# hfiref0x/vboxhardenedloader architecture

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

- Interactive diagram: https://gitdiagram.com/hfiref0x/vboxhardenedloader
- Repository: https://github.com/hfiref0x/vboxhardenedloader

## Overview

##### Project type and purpose
- This is a native, Windows-based “hardened loader” tool.
- It consists of a user-mode loader application (Zekamashi) and a kernel-mode monitoring/patching driver (Tsugumi).
- Its goal is to inject/patch VirtualBox binaries at runtime to defeat VM-detection checks.

##### File structure
Top-level components:
- Binary/ – prebuilt executables, ACPI/EFI tables, hide-VM scripts, documentation.
- Source/
– Tsugumi_shell/ – the x64 kernel driver project (patches VirtualBox modules).
– Zekamashi_v2/loader/ – the x64 user-mode loader application, driver-loader framework, helper libs.
- Build scripts, VS solution files, driver resources and driver-loading utilities (minirtl, hde, idrv).

##### Pull architectural hints from the README
- “Tsugumi – monitoring driver”
- “Zekamashi – application, x64 – load Tsugumi… stop monitoring”
- Dependencies: Intel NAL driver (iQVM64.sys), Windows WDK, Visual Studio.
- Binary assets: ACPI/EFI tables, hidevm commands used by loader at runtime.

##### Main components
a. Zekamashi (User-Mode Loader App)
– Parses CLI, selects payloads, invokes NAL to install Tsugumi.
– Contains “minirtl” library, pattern-matching engine, resource loader.
b. Intel NAL Driver (iQVM64.sys)
– Third-party signed driver temporarily used to load Tsugumi.
c. Tsugumi (Kernel-Mode Monitoring/Patching Driver)
– Hooks VirtualBox process loading, patches in-memory DLLs.
– Uses hde (disassembler), pattern tables, victim.c engine.
d. VirtualBox/KVM Process
– Target of runtime patches (VBoxHardening.dll, ACPI tables, EFI VGA modules).
e. Binary Assets
– ACPI-DSDT/SSDT tables, EFI firmware blobs, hidevm scripts. Loaded by Zekamashi at setup.
f. Host Windows OS Kernel
– Enforces driver signing, manages driver load sequence, provides WDK kernel APIs.

##### Relationships and data flow
1) Operator runs Zekamashi.exe (admin+) →
2) Zekamashi deploys Intel NAL driver →
3) NAL driver loads Tsugumi driver →
4) Tsugumi registers callbacks/hooks on image load and module resolve →
5) When VirtualBox binaries are loaded, Tsugumi scans their memory, applies byte-patches using patterns/hde →
6) Patched VM process runs without hardening checks.
7) Zekamashi may unload Tsugumi or revert patches on demand.

##### Architectural patterns and design principles
- User-Mode↔Kernel-Mode boundary – clear separation of concerns.
- Plugin/Pattern Engine – hde and pattern modules form an extensible patching pipeline.
- Resource/Data-Driven design – Binary/ folder assets selected at runtime.
- Command-line interface for extensibility, scripting via hidevm scripts.

##### Key callouts
- “Admin privileges required” annotation on Zekamashi load path.
- “Pattern matching & patch engine (hde + patterns.c)” inside Tsugumi.
- “Driver-loader shim (minirtl + idrv)” inside Zekamashi.
- “ACPI/EFI patch modules” as optional data inputs.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User-Mode Layer
    subgraph "User-Mode Layer"
        direction TB
        CLI["CLI (admin+)"]:::user
        Zeka["Zekamashi.exe"]:::user
        minirtl["Driver-loader shim (minirtl)"]:::user
        idrv["NAL interface (nal.c/h)"]:::user
        hde["Lightweight disassembler (hde)"]:::user
        patterns["Patch patterns (patterns.c/h)"]:::user
        victim["Victim selection engine (victim.c/h)"]:::user
        resloader["Resource loader (Resource.rc/h)"]:::user
    end

    %% Host OS Kernel Boundary
    HostOS["Host OS Kernel"]:::kernelBoundary

    %% Kernel-Mode Layer
    subgraph "Kernel-Mode Layer"
        direction TB
        NAL["Intel NAL Driver (iQVM64.sys)"]:::kernel
        subgraph "Tsugumi Driver"
            direction TB
            Tsugumi["Tsugumi.sys"]:::kernel
            ImgCallback["Image load callback"]:::kernel
            PMatcher["Pattern matcher (hde+patterns)"]:::kernel
            PApplier["Patch applier"]:::kernel
        end
    end

    %% VirtualBox Process Layer
    subgraph "VirtualBox/VM Layer"
        direction TB
        VBProc["VBoxHardening.dll process"]:::vm
    end

    %% Data Assets
    BinAssets["Binary Assets (ACPI/EFI tables, hide-VM)"]:::data

    %% Prebuilt Loader Executable
    LoaderExe["Prebuilt loader.exe"]:::data

    %% Connections
    CLI -->|parses CLI & invokes| Zeka
    Zeka -->|uses| minirtl
    Zeka -->|uses| idrv
    Zeka -->|uses| hde
    Zeka -->|uses| patterns
    Zeka -->|uses| victim
    Zeka -->|loads resources from| resloader
    resloader -->|reads| BinAssets
    Zeka -->|deploys| NAL
    NAL -->|loads| Tsugumi
    HostOS -->|enforces signing & provides APIs| Zeka
    HostOS -->|enforces signing & provides APIs| Tsugumi
    Tsugumi -->|hooks image load| ImgCallback
    ImgCallback -->|invokes| PMatcher
    PMatcher -->|executes| PApplier
    PApplier -->|patches| VBProc
    BinAssets -->|assets used by| Zeka
    LoaderExe -->|example output| Zeka

    %% Click Events
    click Zeka "https://github.com/hfiref0x/vboxhardenedloader/tree/master/Source/Zekamashi_v2/loader"
    click CLI "https://github.com/hfiref0x/vboxhardenedloader/blob/master/Source/Zekamashi_v2/loader/main.c"
    click minirtl "https://github.com/hfiref0x/vboxhardenedloader/tree/master/Source/Zekamashi_v2/loader/minirtl"
    click idrv "https://github.com/hfiref0x/vboxhardenedloader/blob/master/Source/Zekamashi_v2/loader/idrv/nal.c"
    click hde "https://github.com/hfiref0x/vboxhardenedloader/tree/master/Source/Zekamashi_v2/loader/hde"
    click patterns "https://github.com/hfiref0x/vboxhardenedloader/blob/master/Source/Zekamashi_v2/loader/patterns.c"
    click victim "https://github.com/hfiref0x/vboxhardenedloader/blob/master/Source/Zekamashi_v2/loader/victim.c"
    click resloader "https://github.com/hfiref0x/vboxhardenedloader/blob/master/Source/Zekamashi_v2/loader/Resource.rc"
    click NAL "https://github.com/hfiref0x/vboxhardenedloader/blob/master/Source/Zekamashi_v2/loader/drv/iQVM64.sys"
    click Tsugumi "https://github.com/hfiref0x/vboxhardenedloader/tree/master/Source/Tsugumi_shell/Tsugumi_shell"
    click ImgCallback "https://github.com/hfiref0x/vboxhardenedloader/blob/master/Source/Tsugumi_shell/Tsugumi_shell/main.c"
    click BinAssets "https://github.com/hfiref0x/vboxhardenedloader/tree/master/Binary/data/"
    click LoaderExe "https://github.com/hfiref0x/vboxhardenedloader/blob/master/Binary/loader.exe"

    %% Styles
    classDef user fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef kernel fill:#F08080,stroke:#000,stroke-width:1px
    classDef vm fill:#90EE90,stroke:#000,stroke-width:1px
    classDef data fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef kernelBoundary fill:none,stroke:#000,stroke-dasharray: 5 5,stroke-width:2px
    class HostOS kernelBoundary
```
