# dvs-code/fh6-offline-patcher architecture

> Architecture diagram of the GitHub repository dvs-code/fh6-offline-patcher, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dvs-code/fh6-offline-patcher
- Repository: https://github.com/dvs-code/fh6-offline-patcher

## Overview

FH6 Offline Patcher is an offline Windows tool that turns an original game EXE and matching support files into a patched EXE, leaving the inputs untouched. The main workflow runs through `patcher.py` into `engine.py`: discover and validate inputs, recognize patch sites, plan and apply patches, reconstruct and validate the result, then publish it with a report. The graph also preserves documented patch-feature modules and the static-analysis/container layer. Some subsystem links rely on the SOURCE INDEX or README; unsampled implementation details are not inferred.

Main entry points: [`engine.py`](https://github.com/dvs-code/fh6-offline-patcher/blob/main/engine.py) (Patch orchestrator), [`planning.py`](https://github.com/dvs-code/fh6-offline-patcher/blob/main/planning.py) (Patch planning), [`static_container.py`](https://github.com/dvs-code/fh6-offline-patcher/blob/main/static_container.py) (Support container), [`debugger_detach.py`](https://github.com/dvs-code/fh6-offline-patcher/blob/main/debugger_detach.py) (Debugger detach)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Patching workflow"]
  node_patcher["CLI and interface<br/>[patcher.py]"]
  node_engine["Patch orchestrator<br/>[engine.py]"]
  node_input_inspection["Input inspection"]
  node_planning["Patch planning<br/>[planning.py]"]
  node_reconstruction["Reconstruction<br/>[reconstruction.py]"]
end

subgraph group_features["Patch capabilities"]
  node_patch_actions["Patch actions<br/>[patch_actions.py]"]
  node_allocation["Allocation analysis<br/>[allocation.py]"]
  node_debugger["Debugger detach<br/>[debugger_detach.py]"]
  node_imports["Import context<br/>[import_context.py]"]
  node_hashed_exports["Hashed exports<br/>[hashed_exports.py]"]
  node_mac_collection["MAC collection<br/>[mac_collection.py]"]
  node_formatter["Formatter variant"]
  node_responses["Response creators"]
  node_rtti["RTTI handling<br/>[rtti.py]"]
end

subgraph group_analysis["Static analysis"]
  node_recognition["Site recognition<br/>[recognition.py]"]
  node_roles["Role validation<br/>[role_validation.py]"]
  node_dependencies["Dependency validation<br/>[dependencies.py]"]
  node_control_flow["Control-flow analysis<br/>[control_flow.py]"]
  node_semantics["Instruction semantics"]
  node_tls["TLS layout<br/>[tls_layout.py]"]
end

subgraph group_containers["Image and containers"]
  node_static_image["PE image model<br/>[static_image.py]"]
  node_static_container["Support container"]
  node_embedded_container["Embedded container"]
end

node_user(("User"))
node_inputs["Original game files"]
node_output["Patched EXE and report"]

node_user -->|"selects inputs"| node_patcher
node_inputs -->|"provides files"| node_patcher
node_patcher -->|"invokes patching"| node_engine
node_engine -->|"inspects inputs"| node_input_inspection
node_engine -->|"requests plan"| node_planning
node_engine -->|"loads profiles"| node_recognition
node_engine -->|"discovers allocation"| node_allocation
node_engine -->|"processes container"| node_embedded_container
node_engine -->|"applies actions"| node_patch_actions
node_engine -->|"reconstructs image"| node_reconstruction
node_engine -->|"reads container"| node_static_container
node_engine -->|"parses image"| node_static_image
node_engine -->|"publishes result"| node_output
node_patcher -->|"offers output folder"| node_output
node_planning -->|"plans feature"| node_debugger
node_planning -->|"plans feature"| node_imports
node_planning -->|"plans feature"| node_mac_collection
node_planning -->|"selects actions"| node_patch_actions
node_planning -->|"uses profiles"| node_recognition
node_planning -->|"validates roles"| node_roles
node_planning -->|"plans feature"| node_formatter
node_planning -->|"plans feature"| node_responses
node_planning -->|"plans feature"| node_rtti
node_recognition -->|"scans image"| node_static_image
node_recognition -->|"uses errors"| node_static_container
node_roles -->|"checks profiles"| node_recognition
node_roles -->|"checks dependencies"| node_dependencies
node_roles -->|"checks layout"| node_tls
node_roles -->|"uses semantics"| node_semantics
node_dependencies -->|"reads imports"| node_imports
node_dependencies -->|"checks operands"| node_tls
node_dependencies -->|"analyzes code"| node_semantics
node_dependencies -->|"uses errors"| node_static_container
node_static_image -->|"uses errors"| node_static_container
node_embedded_container -->|"opens container"| node_static_container
node_embedded_container -->|"uses image"| node_static_image
node_allocation -->|"resolves imports"| node_imports
node_allocation -->|"uses errors"| node_static_container
node_allocation -->|"uses semantics"| node_semantics
node_debugger -->|"finds callers"| node_control_flow
node_debugger -->|"creates actions"| node_patch_actions
node_debugger -->|"uses errors"| node_static_container
node_debugger -->|"uses semantics"| node_semantics
node_control_flow -->|"finds function extent"| node_semantics
node_reconstruction -->|"uses container"| node_static_container
node_reconstruction -->|"uses image"| node_static_image
node_reconstruction -->|"produces executable"| node_output

click node_patcher "https://github.com/dvs-code/fh6-offline-patcher/blob/main/patcher.py"
click node_engine "https://github.com/dvs-code/fh6-offline-patcher/blob/main/engine.py"
click node_input_inspection "https://github.com/dvs-code/fh6-offline-patcher/blob/main/inspect_static_inputs.py"
click node_planning "https://github.com/dvs-code/fh6-offline-patcher/blob/main/planning.py"
click node_reconstruction "https://github.com/dvs-code/fh6-offline-patcher/blob/main/reconstruction.py"
click node_recognition "https://github.com/dvs-code/fh6-offline-patcher/blob/main/recognition.py"
click node_roles "https://github.com/dvs-code/fh6-offline-patcher/blob/main/role_validation.py"
click node_dependencies "https://github.com/dvs-code/fh6-offline-patcher/blob/main/dependencies.py"
click node_static_image "https://github.com/dvs-code/fh6-offline-patcher/blob/main/static_image.py"
click node_static_container "https://github.com/dvs-code/fh6-offline-patcher/blob/main/static_container.py"
click node_embedded_container "https://github.com/dvs-code/fh6-offline-patcher/blob/main/embedded_container.py"
click node_patch_actions "https://github.com/dvs-code/fh6-offline-patcher/blob/main/patch_actions.py"
click node_allocation "https://github.com/dvs-code/fh6-offline-patcher/blob/main/allocation.py"
click node_debugger "https://github.com/dvs-code/fh6-offline-patcher/blob/main/debugger_detach.py"
click node_imports "https://github.com/dvs-code/fh6-offline-patcher/blob/main/import_context.py"
click node_control_flow "https://github.com/dvs-code/fh6-offline-patcher/blob/main/control_flow.py"
click node_hashed_exports "https://github.com/dvs-code/fh6-offline-patcher/blob/main/hashed_exports.py"
click node_mac_collection "https://github.com/dvs-code/fh6-offline-patcher/blob/main/mac_collection.py"
click node_formatter "https://github.com/dvs-code/fh6-offline-patcher/blob/main/formatter_variant.py"
click node_responses "https://github.com/dvs-code/fh6-offline-patcher/blob/main/response_creators.py"
click node_rtti "https://github.com/dvs-code/fh6-offline-patcher/blob/main/rtti.py"
click node_semantics "https://github.com/dvs-code/fh6-offline-patcher/blob/main/static_semantics.py"
click node_tls "https://github.com/dvs-code/fh6-offline-patcher/blob/main/tls_layout.py"

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_patcher,node_engine,node_input_inspection,node_planning,node_reconstruction,node_user toneBlue
class node_patch_actions,node_allocation,node_debugger,node_imports,node_hashed_exports,node_mac_collection,node_formatter,node_responses,node_rtti toneAmber
class node_recognition,node_roles,node_dependencies,node_control_flow,node_semantics,node_tls toneMint
class node_static_image,node_static_container,node_embedded_container toneRose
class node_inputs,node_output toneIndigo
```

## Components

### Patching workflow

- [CLI and interface](https://github.com/dvs-code/fh6-offline-patcher/blob/main/patcher.py): `patcher.py`
- [Patch orchestrator](https://github.com/dvs-code/fh6-offline-patcher/blob/main/engine.py): `engine.py`
- [Input inspection](https://github.com/dvs-code/fh6-offline-patcher/blob/main/inspect_static_inputs.py): `inspect_static_inputs.py`
- [Patch planning](https://github.com/dvs-code/fh6-offline-patcher/blob/main/planning.py): `planning.py`
- [Reconstruction](https://github.com/dvs-code/fh6-offline-patcher/blob/main/reconstruction.py): `reconstruction.py`

### Patch capabilities

- [Patch actions](https://github.com/dvs-code/fh6-offline-patcher/blob/main/patch_actions.py): `patch_actions.py`
- [Allocation analysis](https://github.com/dvs-code/fh6-offline-patcher/blob/main/allocation.py): `allocation.py`
- [Debugger detach](https://github.com/dvs-code/fh6-offline-patcher/blob/main/debugger_detach.py): `debugger_detach.py`
- [Import context](https://github.com/dvs-code/fh6-offline-patcher/blob/main/import_context.py): `import_context.py`
- [Hashed exports](https://github.com/dvs-code/fh6-offline-patcher/blob/main/hashed_exports.py): `hashed_exports.py`
- [MAC collection](https://github.com/dvs-code/fh6-offline-patcher/blob/main/mac_collection.py): `mac_collection.py`
- [Formatter variant](https://github.com/dvs-code/fh6-offline-patcher/blob/main/formatter_variant.py): `formatter_variant.py`
- [Response creators](https://github.com/dvs-code/fh6-offline-patcher/blob/main/response_creators.py): `response_creators.py`
- [RTTI handling](https://github.com/dvs-code/fh6-offline-patcher/blob/main/rtti.py): `rtti.py`

### Static analysis

- [Site recognition](https://github.com/dvs-code/fh6-offline-patcher/blob/main/recognition.py): `recognition.py`
- [Role validation](https://github.com/dvs-code/fh6-offline-patcher/blob/main/role_validation.py): `role_validation.py`
- [Dependency validation](https://github.com/dvs-code/fh6-offline-patcher/blob/main/dependencies.py): `dependencies.py`
- [Control-flow analysis](https://github.com/dvs-code/fh6-offline-patcher/blob/main/control_flow.py): `control_flow.py`
- [Instruction semantics](https://github.com/dvs-code/fh6-offline-patcher/blob/main/static_semantics.py): `static_semantics.py`
- [TLS layout](https://github.com/dvs-code/fh6-offline-patcher/blob/main/tls_layout.py): `tls_layout.py`

### Image and containers

- [PE image model](https://github.com/dvs-code/fh6-offline-patcher/blob/main/static_image.py): `static_image.py`
- [Support container](https://github.com/dvs-code/fh6-offline-patcher/blob/main/static_container.py): `static_container.py`
- [Embedded container](https://github.com/dvs-code/fh6-offline-patcher/blob/main/embedded_container.py): `embedded_container.py`

### Other components

- **User**
- **Original game files**
- **Patched EXE and report**

## Connections

- User → CLI and interface: selects inputs (evidence: `README.md`)
- Original game files → CLI and interface: provides files (evidence: `README.md`)
- CLI and interface → Patch orchestrator: invokes patching (evidence: `patcher.py`)
- Patch orchestrator → Input inspection: inspects inputs (evidence: `engine.py`)
- Patch orchestrator → Patch planning: requests plan (evidence: `engine.py`)
- Patch orchestrator → Site recognition: loads profiles (evidence: `engine.py`)
- Patch orchestrator → Allocation analysis: discovers allocation (evidence: `engine.py`)
- Patch orchestrator → Embedded container: processes container (evidence: `engine.py`)
- Patch orchestrator → Patch actions: applies actions (evidence: `engine.py`)
- Patch orchestrator → Reconstruction: reconstructs image (evidence: `engine.py`)
- Patch orchestrator → Support container: reads container (evidence: `engine.py`)
- Patch orchestrator → PE image model: parses image (evidence: `engine.py`)
- Patch orchestrator → Patched EXE and report: publishes result (evidence: `engine.py`)
- CLI and interface → Patched EXE and report: offers output folder (evidence: `README.md`)
- Patch planning → Debugger detach: plans feature (evidence: `planning.py`)
- Patch planning → Import context: plans feature (evidence: `planning.py`)
- Patch planning → MAC collection: plans feature (evidence: `planning.py`)
- Patch planning → Patch actions: selects actions (evidence: `planning.py`)
- Patch planning → Site recognition: uses profiles (evidence: `planning.py`)
- Patch planning → Role validation: validates roles (evidence: `planning.py`)
- Patch planning → Formatter variant: plans feature (evidence: `planning.py`)
- Patch planning → Response creators: plans feature (evidence: `planning.py`)
- Patch planning → RTTI handling: plans feature (evidence: `planning.py`)
- Site recognition → PE image model: scans image (evidence: `recognition.py`)
- Site recognition → Support container: uses errors (evidence: `recognition.py`)
- Role validation → Site recognition: checks profiles (evidence: `role_validation.py`)
- Role validation → Dependency validation: checks dependencies (evidence: `role_validation.py`)
- Role validation → TLS layout: checks layout (evidence: `role_validation.py`)
- Role validation → Instruction semantics: uses semantics (evidence: `role_validation.py`)
- Dependency validation → Import context: reads imports (evidence: `dependencies.py`)
- Dependency validation → TLS layout: checks operands (evidence: `dependencies.py`)
- Dependency validation → Instruction semantics: analyzes code (evidence: `dependencies.py`)
- Dependency validation → Support container: uses errors (evidence: `dependencies.py`)
- PE image model → Support container: uses errors (evidence: `static_image.py`)
- Embedded container → Support container: opens container (evidence: `embedded_container.py`)
- Embedded container → PE image model: uses image (evidence: `embedded_container.py`)
- Allocation analysis → Import context: resolves imports (evidence: `allocation.py`)
- Allocation analysis → Support container: uses errors (evidence: `allocation.py`)
- Allocation analysis → Instruction semantics: uses semantics (evidence: `allocation.py`)
- Debugger detach → Control-flow analysis: finds callers (evidence: `debugger_detach.py`)
- Debugger detach → Patch actions: creates actions (evidence: `debugger_detach.py`)
- Debugger detach → Support container: uses errors (evidence: `debugger_detach.py`)
- Debugger detach → Instruction semantics: uses semantics (evidence: `debugger_detach.py`)
- Control-flow analysis → Instruction semantics: finds function extent (evidence: `control_flow.py`)
- Reconstruction → Support container: uses container (evidence: `reconstruction.py`)
- Reconstruction → PE image model: uses image (evidence: `reconstruction.py`)
- Reconstruction → Patched EXE and report: produces executable (evidence: `README.md`)
