# detached64/hijackgen architecture

> Architecture diagram of the GitHub repository detached64/hijackgen, 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/detached64/hijackgen
- Repository: https://github.com/detached64/hijackgen

## Overview

##### Project Type & Purpose
- HijackGen is a desktop utility built on .NET (C#) that generates DLL source code tailored for DLL hijacking. It is composed of a GUI application (HijackGen.GUI) and a core engine (the HijackGen project) that handles the generation logic.
- The README and references indicate that it leverages techniques and inspirations from projects like PeNet, dll-hijack-by-proxying, and AheadLib-x86-x64.

##### Main Components to Identify
a. GUI Layer (HijackGen.GUI):
- Contains Windows Forms (e.g., MainForm, AboutBox, Options forms) that allow user interaction.
- Acts as the presentation layer, gathering user input and displaying the generated results or options.
- Responsible for interfacing with the core engine through API calls or direct method invocations.

b. Core Engine (HijackGen):
- Holds the business logic, including key modules such as:
- DllParser – likely responsible for analyzing DLL structures.
- Generator – the module that processes information along with templates to produce the hijackable DLL code.
- DataItem and Message classes – manage data structures and user messages or resource handling.
- It is independent of the UI and encapsulates the actual DLL hijacking code generation logic.

c. Template System:
- The Templates directory contains various text files (ExternX64.txt, Free.txt, etc.) and a Templates.cs file, which are used to define and manage the source code templates for DLL generation.
- This is a configurable piece that can be extended or modified without impacting core logic.

d. Supporting Elements:
- Configurations and resources (e.g., App.config, resource files such as *.resx) that support localization (e.g., zh-Hans resources) and application settings.

##### Relationships & Interactions
- The core engine interacts with the Template System by reading the appropriate template files to produce DLL source code.
- Dependencies between the core engine and potential external references (as per the README, external libraries like PeNet may be used for parsing).

##### Architectural Patterns or Design Principles
- Separation of Concerns: Clear decoupling between the UI (HijackGen.GUI) and the business logic (HijackGen core).
- Modularity: The Template System is modular (templates stored as text files) allowing for flexibility and easy extension.
- Reusability and Maintainability: Encapsulate all DLL parsing and generation logic within dedicated modules, facilitating testing and future enhancements.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer Subgraph
    subgraph "Presentation Layer (HijackGen.GUI)"
        GUI_MainForm["MainForm"]:::guiLayer
        GUI_AboutBox["AboutBox"]:::guiLayer
        GUI_DefOptions["DefOptions"]:::guiLayer
        GUI_HOptions["HOptions"]:::guiLayer
        GUI_OptionsTemplate["OptionsTemplate"]:::guiLayer
    end

    %% Core Engine Subgraph
    subgraph "Core Engine (HijackGen)"
        BE_Generator["Generator"]:::coreEngine
        BE_DllParser["DllParser"]:::coreEngine
        BE_DataItem["DataItem"]:::coreEngine
        BE_Message["Message"]:::coreEngine
    end

    %% Template System Subgraph
    subgraph "Template System (HijackGen/Templates)"
        TS_TemplatesFile["Templates.cs"]:::templates
        TS_Txt["Template Files (.txt)"]:::templates
    end

    %% Configurations & Resources Subgraph
    subgraph "Configurations & Resources"
        Config["App.config & Resource Files"]:::config
    end

    %% Documentation & Help Subgraph
    subgraph "Documentation & Help"
        Docs["Documentation (docs)"]:::docs
    end

    %% External Dependency
    External["External Library (PeNet)"]:::external

    %% Relationships
    GUI_MainForm -->|"sendsInput"| BE_Generator
    BE_Generator -->|"invokesDLLGen"| BE_DllParser
    BE_Generator -->|"loadsTemplates"| TS_Txt
    BE_Generator -->|"loadsTemplatesCode"| TS_TemplatesFile
    BE_Generator -->|"usesConfig"| Config
    GUI_MainForm -->|"readsConfig"| Config
    BE_Generator -->|"returnsResult"| GUI_MainForm
    BE_DllParser -->|"parsesDLL"| External

    %% Styling Classes
    classDef guiLayer fill:#FFCCFF,stroke:#990099,stroke-width:2px;
    classDef coreEngine fill:#CCFFCC,stroke:#339933,stroke-width:2px;
    classDef templates fill:#FFFFCC,stroke:#999900,stroke-width:2px;
    classDef config fill:#CCFFFF,stroke:#339999,stroke-width:2px;
    classDef docs fill:#FFDD99,stroke:#CC6600,stroke-width:2px;
    classDef external fill:#CCCCFF,stroke:#6666CC,stroke-width:2px;

    %% Click Events for GUI Layer
    click GUI_MainForm "https://github.com/detached64/hijackgen/blob/master/HijackGen.GUI/MainForm.cs"
    click GUI_AboutBox "https://github.com/detached64/hijackgen/blob/master/HijackGen.GUI/AboutBox.cs"
    click GUI_DefOptions "https://github.com/detached64/hijackgen/blob/master/HijackGen.GUI/DefOptions.cs"
    click GUI_HOptions "https://github.com/detached64/hijackgen/blob/master/HijackGen.GUI/HOptions.cs"
    click GUI_OptionsTemplate "https://github.com/detached64/hijackgen/blob/master/HijackGen.GUI/OptionsTemplate.cs"

    %% Click Events for Core Engine
    click BE_Generator "https://github.com/detached64/hijackgen/blob/master/HijackGen/Generator.cs"
    click BE_DllParser "https://github.com/detached64/hijackgen/blob/master/HijackGen/DllParser.cs"
    click BE_DataItem "https://github.com/detached64/hijackgen/blob/master/HijackGen/DataItem.cs"
    click BE_Message "https://github.com/detached64/hijackgen/blob/master/HijackGen/Message.Designer.cs"

    %% Click Events for Template System
    click TS_TemplatesFile "https://github.com/detached64/hijackgen/blob/master/HijackGen/Templates/Templates.cs"
    click TS_Txt "https://github.com/detached64/hijackgen/tree/master/HijackGen/Templates"

    %% Click Event for Configurations
    click Config "https://github.com/detached64/hijackgen/blob/master/HijackGen.GUI/App.config"

    %% Click Event for Documentation
    click Docs "https://github.com/detached64/hijackgen/tree/master/docs"
```
