# longwayhomie/polyengine architecture

> Architecture diagram of the GitHub repository longwayhomie/polyengine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/longwayhomie/polyengine
- Repository: https://github.com/longwayhomie/polyengine

## Overview

PolyEngine is a Windows PE packer with a command-line Builder and a GUI front end. Its main workflow accepts a PE, DLL, or raw shellcode; prepares a packed loader and payload; optionally applies identity metadata and signing; and emits an executable whose embedded stub handles runtime loading. The README documents additional loader, evasion, and OPSEC options. The map reflects those documented capabilities and the sampled files; several internal call relationships are not visible in the excerpts, so uncertain links are omitted.

Main entry points: [`Builder/Builder.cpp`](https://github.com/longwayhomie/polyengine/blob/master/Builder/Builder.cpp) (Builder CLI), [`Stub/Stub.cpp`](https://github.com/longwayhomie/polyengine/blob/master/Stub/Stub.cpp) (Embedded loader), [`GUI/src/app.cpp`](https://github.com/longwayhomie/polyengine/blob/master/GUI/src/app.cpp) (App state), [`GUI/src/main.cpp`](https://github.com/longwayhomie/polyengine/blob/master/GUI/src/main.cpp) (GUI application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gui["GUI"]
  node_gui_app["GUI application<br/>[main.cpp]"]
  node_gui_screens["Build screens<br/>[screens.cpp]"]
  node_app_state["App state<br/>[app.cpp]"]
  node_gui_services["GUI services<br/>[services.cpp]"]
  node_profile_history[("Profiles and history<br/>[services.cpp]")]
end

subgraph group_build["Build pipeline"]
  node_builder["Builder CLI<br/>[Builder.cpp]"]
  node_identity["Metadata cloning<br/>[CloneMeta.cpp]"]
  node_signing["PE signing<br/>[PeSigning.cpp]"]
  node_manifest["UAC manifest<br/>[UacManifest.cpp]"]
end

subgraph group_engine["Packing engine"]
  node_pe_builder["PE construction<br/>[PeBuilder.c]"]
  node_runpe["PE loader<br/>[RunPE.c]"]
  node_compression["Compression<br/>[Compression.c]"]
  node_crypto["Payload crypto<br/>[Crypto.c]"]
  node_mutation["Stub mutation<br/>[MutationEngine.c]"]
end

subgraph group_runtime["Loader runtime"]
  node_stub["Embedded loader<br/>[Stub.cpp]"]
  node_payload["Payload execution<br/>[Payload.c]"]
  node_evasion["Sandbox checks<br/>[Evasion.cpp]"]
  node_opsec["OPSEC controls<br/>[Opsec.c]"]
  node_syscalls["Syscall support<br/>[Syscalls.c]"]
  node_stomping["Module stomping<br/>[ModuleStomping.c]"]
  node_unhooker["API unhooking<br/>[Unhooker.c]"]
end

node_operator(("Operator"))
node_tsa(("Timestamp service"))
node_artifact["Packed executable"]

node_operator -->|"uses"| node_gui_app
node_gui_app -->|"renders"| node_gui_screens
node_gui_screens -->|"edits configuration"| node_app_state
node_app_state -->|"starts build"| node_gui_services
node_app_state -->|"loads and saves"| node_profile_history
node_gui_services -->|"launches CLI"| node_builder
node_operator -->|"runs CLI"| node_builder
node_builder -->|"constructs loader"| node_pe_builder
node_builder -->|"prepares payload"| node_compression
node_builder -->|"encrypts payload"| node_crypto
node_builder -->|"mutates decryptor"| node_mutation
node_builder -.->|"clones metadata"| node_identity
node_builder -.->|"embeds manifest"| node_manifest
node_builder -.->|"signs output"| node_signing
node_builder -->|"writes"| node_artifact
node_tsa -.->|"timestamps"| node_signing
node_artifact -->|"contains"| node_stub
node_stub -->|"checks environment"| node_evasion
node_stub -->|"applies controls"| node_opsec
node_stub -.->|"restores code"| node_unhooker
node_stub -->|"selects loading mode"| node_stomping
node_stub -->|"dispatches payload"| node_payload
node_payload -->|"loads PE payload"| node_runpe
node_syscalls -->|"supports native calls"| node_stub

click node_gui_app "https://github.com/longwayhomie/polyengine/blob/master/GUI/src/main.cpp"
click node_gui_screens "https://github.com/longwayhomie/polyengine/blob/master/GUI/src/screens.cpp"
click node_app_state "https://github.com/longwayhomie/polyengine/blob/master/GUI/src/app.cpp"
click node_gui_services "https://github.com/longwayhomie/polyengine/blob/master/GUI/src/services.cpp"
click node_profile_history "https://github.com/longwayhomie/polyengine/blob/master/GUI/src/services.cpp"
click node_builder "https://github.com/longwayhomie/polyengine/blob/master/Builder/Builder.cpp"
click node_pe_builder "https://github.com/longwayhomie/polyengine/blob/master/Engine/PeBuilder.c"
click node_runpe "https://github.com/longwayhomie/polyengine/blob/master/Engine/RunPE.c"
click node_compression "https://github.com/longwayhomie/polyengine/blob/master/Engine/Compression.c"
click node_crypto "https://github.com/longwayhomie/polyengine/blob/master/Engine/Crypto.c"
click node_mutation "https://github.com/longwayhomie/polyengine/blob/master/Engine/MutationEngine.c"
click node_identity "https://github.com/longwayhomie/polyengine/blob/master/Builder/CloneMeta.cpp"
click node_signing "https://github.com/longwayhomie/polyengine/blob/master/Builder/PeSigning.cpp"
click node_manifest "https://github.com/longwayhomie/polyengine/blob/master/Builder/UacManifest.cpp"
click node_stub "https://github.com/longwayhomie/polyengine/blob/master/Stub/Stub.cpp"
click node_payload "https://github.com/longwayhomie/polyengine/blob/master/Stub/Payload.c"
click node_evasion "https://github.com/longwayhomie/polyengine/blob/master/Stub/Evasion.cpp"
click node_opsec "https://github.com/longwayhomie/polyengine/blob/master/Stub/Opsec.c"
click node_syscalls "https://github.com/longwayhomie/polyengine/blob/master/Stub/Syscalls.c"
click node_stomping "https://github.com/longwayhomie/polyengine/blob/master/Stub/ModuleStomping.c"
click node_unhooker "https://github.com/longwayhomie/polyengine/blob/master/Stub/Unhooker.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_gui_app,node_gui_screens,node_app_state,node_gui_services,node_profile_history toneBlue
class node_builder,node_identity,node_signing,node_manifest toneAmber
class node_pe_builder,node_runpe,node_compression,node_crypto,node_mutation toneMint
class node_stub,node_payload,node_evasion,node_opsec,node_syscalls,node_stomping,node_unhooker toneRose
class node_operator,node_tsa,node_artifact toneIndigo
```

## Components

### GUI

- [GUI application](https://github.com/longwayhomie/polyengine/blob/master/GUI/src/main.cpp): `GUI/src/main.cpp`
- [Build screens](https://github.com/longwayhomie/polyengine/blob/master/GUI/src/screens.cpp): `GUI/src/screens.cpp`
- [App state](https://github.com/longwayhomie/polyengine/blob/master/GUI/src/app.cpp): `GUI/src/app.cpp`
- [GUI services](https://github.com/longwayhomie/polyengine/blob/master/GUI/src/services.cpp): `GUI/src/services.cpp`
- [Profiles and history](https://github.com/longwayhomie/polyengine/blob/master/GUI/src/services.cpp): `GUI/src/services.cpp`

### Build pipeline

- [Builder CLI](https://github.com/longwayhomie/polyengine/blob/master/Builder/Builder.cpp): `Builder/Builder.cpp`
- [Metadata cloning](https://github.com/longwayhomie/polyengine/blob/master/Builder/CloneMeta.cpp): `Builder/CloneMeta.cpp`
- [PE signing](https://github.com/longwayhomie/polyengine/blob/master/Builder/PeSigning.cpp): `Builder/PeSigning.cpp`
- [UAC manifest](https://github.com/longwayhomie/polyengine/blob/master/Builder/UacManifest.cpp): `Builder/UacManifest.cpp`

### Packing engine

- [PE construction](https://github.com/longwayhomie/polyengine/blob/master/Engine/PeBuilder.c): `Engine/PeBuilder.c`
- [PE loader](https://github.com/longwayhomie/polyengine/blob/master/Engine/RunPE.c): `Engine/RunPE.c`
- [Compression](https://github.com/longwayhomie/polyengine/blob/master/Engine/Compression.c): `Engine/Compression.c`
- [Payload crypto](https://github.com/longwayhomie/polyengine/blob/master/Engine/Crypto.c): `Engine/Crypto.c`
- [Stub mutation](https://github.com/longwayhomie/polyengine/blob/master/Engine/MutationEngine.c): `Engine/MutationEngine.c`

### Loader runtime

- [Embedded loader](https://github.com/longwayhomie/polyengine/blob/master/Stub/Stub.cpp): `Stub/Stub.cpp`
- [Payload execution](https://github.com/longwayhomie/polyengine/blob/master/Stub/Payload.c): `Stub/Payload.c`
- [Sandbox checks](https://github.com/longwayhomie/polyengine/blob/master/Stub/Evasion.cpp): `Stub/Evasion.cpp`
- [OPSEC controls](https://github.com/longwayhomie/polyengine/blob/master/Stub/Opsec.c): `Stub/Opsec.c`
- [Syscall support](https://github.com/longwayhomie/polyengine/blob/master/Stub/Syscalls.c): `Stub/Syscalls.c`
- [Module stomping](https://github.com/longwayhomie/polyengine/blob/master/Stub/ModuleStomping.c): `Stub/ModuleStomping.c`
- [API unhooking](https://github.com/longwayhomie/polyengine/blob/master/Stub/Unhooker.c): `Stub/Unhooker.c`

### Other components

- **Operator**
- **Timestamp service**
- **Packed executable**

## Connections

- Operator → GUI application: uses
- GUI application → Build screens: renders
- Build screens → App state: edits configuration
- App state → GUI services: starts build
- App state → Profiles and history: loads and saves
- GUI services → Builder CLI: launches CLI
- Operator → Builder CLI: runs CLI
- Builder CLI → PE construction: constructs loader
- Builder CLI → Compression: prepares payload
- Builder CLI → Payload crypto: encrypts payload
- Builder CLI → Stub mutation: mutates decryptor
- Builder CLI → Metadata cloning: clones metadata
- Builder CLI → UAC manifest: embeds manifest
- Builder CLI → PE signing: signs output
- Builder CLI → Packed executable: writes
- Timestamp service → PE signing: timestamps
- Packed executable → Embedded loader: contains
- Embedded loader → Sandbox checks: checks environment
- Embedded loader → OPSEC controls: applies controls
- Embedded loader → API unhooking: restores code
- Embedded loader → Module stomping: selects loading mode
- Embedded loader → Payload execution: dispatches payload
- Payload execution → PE loader: loads PE payload
- Syscall support → Embedded loader: supports native calls
