# hasherezade/exe_to_dll architecture

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

- Interactive diagram: https://gitdiagram.com/hasherezade/exe_to_dll
- Repository: https://github.com/hasherezade/exe_to_dll

## Overview

##### Project type and purpose
- This is a native C++ command-line utility (“exe_to_dll”) whose sole purpose is to take a Windows PE executable (EXE) and transform it into a loadable DLL by rewriting its headers and export table. It supports both 32-bit and 64-bit binaries.

##### File structure
- Top-level:
- CMakeLists.txt – build orchestration
- .gitmodules – brings in submodule “libpeconv”
- README.md, .gitignore, CI config
- exe_to_dll/
- main.cpp – CLI argument parsing and orchestrator
- pe_handler.cpp/.h – core logic for in-memory PE rewriting
- exports_block.h – helper for building the export directory
- libpeconv/ – third-party (submodule) library for PE parsing/manipulation
- tests/ – test harness invoking the built tool against sample EXEs
- tests/test_case1 – CMake + test binary

##### README for additional insights
- Describes the workflow:
Command-line → input.exe → exe_to_dll → output.dll “Start” export → optional rundll32 test
- Mentions supported architectures and the expected “Start” export

##### Detail
- If desired, include a side note about CMakeLists.txt driving the build of both the tool and its tests

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entities
    User["User (CLI Invoker)"]:::external
    CLI["CLI Interface\n(main.cpp)"]:::firstParty
    Handler["Conversion Engine / PE Handler\n(pe_handler.cpp/.h)"]:::firstParty
    Libpe["PE Processing Library\n(libpeconv)"]:::thirdParty
    ExportBuilder["Export Table Builder\n(exports_block.h)\nExports: Start"]:::firstParty
    FileIO["File System I/O"]:::external
    DLL["Output DLL"]:::external
    TestSuite["Test Harness\ntests/"]:::external
    Rundll["rundll32\n(External)"]:::external
    Build["Build Orchestration\nCMakeLists.txt"]:::external

    %% Flow
    User -->|"invoke"| CLI
    CLI -->|"parse args\ncall handler"| Handler
    Handler -->|"load & parse PE"| Libpe
    Handler -->|"rewrite headers"| ExportBuilder
    ExportBuilder -->|"construct export table"| Handler
    Handler -->|"write DLL"| FileIO
    FileIO -->|"produces"| DLL
    DLL -->|"verify via tool"| TestSuite
    TestSuite -->|"shells out"| Rundll

    %% Build orchestration
    Build --> CLI
    Build --> Handler
    Build --> ExportBuilder
    Build --> Libpe
    Build --> TestSuite

    %% Click Events
    click CLI "https://github.com/hasherezade/exe_to_dll/blob/master/exe_to_dll/main.cpp"
    click Handler "https://github.com/hasherezade/exe_to_dll/blob/master/exe_to_dll/pe_handler.cpp"
    click Handler "https://github.com/hasherezade/exe_to_dll/blob/master/exe_to_dll/pe_handler.h"
    click ExportBuilder "https://github.com/hasherezade/exe_to_dll/blob/master/exe_to_dll/exports_block.h"
    click Libpe "https://github.com/hasherezade/exe_to_dll/tree/master/libpeconv/"
    click Build "https://github.com/hasherezade/exe_to_dll/blob/master/CMakeLists.txt"
    click Build "https://github.com/hasherezade/exe_to_dll/blob/master/exe_to_dll/CMakeLists.txt"
    click Build "https://github.com/hasherezade/exe_to_dll/blob/master/tests/CMakeLists.txt"
    click Build "https://github.com/hasherezade/exe_to_dll/blob/master/tests/test_case1/CMakeLists.txt"
    click TestSuite "https://github.com/hasherezade/exe_to_dll/tree/master/tests/"
    click TestSuite "https://github.com/hasherezade/exe_to_dll/blob/master/tests/test_case1/main.cpp"

    %% Styles
    classDef firstParty fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef thirdParty fill:#90EE90,stroke:#000,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:1px
```
