# can1357/selene architecture

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

- Interactive diagram: https://gitdiagram.com/can1357/selene
- Repository: https://github.com/can1357/selene

## Overview

Selene is a Windows kernel-mode microkernel and virtualization toolkit, alongside several substantial developer tools. Its main runtime workflow initializes kernel facilities and then brings up virtualization, networking, and debugger services; the broader repository also includes execution tracing, a bitcode-to-PE linker, pattern scanning, and PDB-based SDK generation. The source excerpts show Selene’s initialization, VM dependencies, and patching mechanics. Other product branches are represented from README descriptions; their internal call paths were not sampled.

Main entry points: [`selene/main.cpp`](https://github.com/can1357/selene/blob/master/selene/main.cpp) (Kernel initialization), [`selene/su/vm.hpp`](https://github.com/can1357/selene/blob/master/selene/su/vm.hpp) (Virtualization engine), [`selene/hooks/patch_manager.cpp`](https://github.com/can1357/selene/blob/master/selene/hooks/patch_manager.cpp) (Kernel patching), [`apollo-linker/linker.cpp`](https://github.com/can1357/selene/blob/master/apollo-linker/linker.cpp) (LLVM linker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Selene Runtime"]
  node_boot["Kernel initialization<br/>[main.cpp]"]
  node_memory["Memory management<br/>[memory.hpp]"]
  node_pages["Page tables<br/>[page_manager.hpp]"]
  node_patch["Kernel patching<br/>[patch_manager.cpp]"]
  node_scheduler["APIC scheduling"]
  node_network["NDIS networking<br/>[lwip.cpp]"]
  node_gdb["GDB and CE servers"]
  node_crashdump["Crash reporting<br/>[crashdump.cpp]"]
end

subgraph group_virtualization["Virtualization and Tracing"]
  node_vm["Virtualization engine<br/>[vm.hpp]"]
  node_emulation["Instruction emulation<br/>[emulation.cpp]"]
  node_trace["Execution tracing<br/>[xt.hpp]"]
  node_snapshot["Crash snapshots<br/>[trace_snapshot.hpp]"]
end

subgraph group_tools["Developer Tools"]
  node_linker["LLVM linker<br/>[linker.cpp]"]
  node_objects["Link object model<br/>[collection.hpp]"]
  node_transforms["Link transforms"]
  node_apollo_vm["WASM virtualization<br/>[apollo-vm.cpp]"]
  node_flash["Pattern scanner<br/>[main.cpp]"]
  node_flash_engine["Scanning engine<br/>[engine.hpp]"]
  node_pdb["PDB parsing<br/>[pdb.hpp]"]
  node_sdkgen["SDK header generator<br/>[main.cpp]"]
end

subgraph group_interfaces["Kernel Interfaces"]
  node_ntpp["NT API wrappers<br/>[io.cpp]"]
  node_sdk["Windows SDK definitions"]
end

node_operator(("Kernel operator"))

node_operator -->|"loads driver"| node_boot
node_boot -->|"initializes"| node_vm
node_boot -->|"initializes"| node_network
node_boot -->|"initializes"| node_gdb
node_boot -->|"uses"| node_memory
node_boot -->|"initializes"| node_scheduler
node_patch -->|"looks up PTEs"| node_pages
node_patch -->|"accesses PFNs"| node_memory
node_patch -->|"synchronizes via IPI"| node_scheduler
node_vm -->|"uses"| node_memory
node_vm -->|"uses"| node_pages
node_emulation -->|"uses VM context"| node_vm
node_vm -->|"captures snapshots"| node_trace
node_crashdump -->|"submits snapshots"| node_snapshot
node_operator -->|"scans patterns"| node_flash
node_flash -->|"uses engine"| node_flash_engine
node_operator -->|"links bitcode"| node_linker
node_linker -->|"manages objects"| node_objects
node_linker -->|"runs transforms"| node_transforms
node_transforms -->|"supports virtualization"| node_apollo_vm
node_operator -->|"parses symbols"| node_pdb
node_pdb -->|"generates headers"| node_sdkgen
node_sdkgen -->|"emits definitions"| node_sdk
node_boot -->|"uses kernel wrappers"| node_ntpp

click node_boot "https://github.com/can1357/selene/blob/master/selene/main.cpp"
click node_memory "https://github.com/can1357/selene/blob/master/selene/utility/memory.hpp"
click node_pages "https://github.com/can1357/selene/blob/master/selene/utility/page_manager.hpp"
click node_patch "https://github.com/can1357/selene/blob/master/selene/hooks/patch_manager.cpp"
click node_scheduler "https://github.com/can1357/selene/tree/master/selene/sched"
click node_network "https://github.com/can1357/selene/blob/master/selene/net/lwip.cpp"
click node_gdb "https://github.com/can1357/selene/tree/master/selene/gdb"
click node_crashdump "https://github.com/can1357/selene/blob/master/selene/misc/crashdump.cpp"
click node_vm "https://github.com/can1357/selene/blob/master/selene/su/vm.hpp"
click node_emulation "https://github.com/can1357/selene/blob/master/selene/su/emulation.cpp"
click node_trace "https://github.com/can1357/selene/blob/master/selene/su/xt.hpp"
click node_snapshot "https://github.com/can1357/selene/blob/master/shared/trace_snapshot.hpp"
click node_linker "https://github.com/can1357/selene/blob/master/apollo-linker/linker.cpp"
click node_objects "https://github.com/can1357/selene/blob/master/apollo-linker/object/collection.hpp"
click node_transforms "https://github.com/can1357/selene/tree/master/apollo-linker/transform"
click node_apollo_vm "https://github.com/can1357/selene/blob/master/apollo-vm/apollo-vm.cpp"
click node_flash "https://github.com/can1357/selene/blob/master/flash/main.cpp"
click node_flash_engine "https://github.com/can1357/selene/blob/master/flash/includes/flash/engine.hpp"
click node_pdb "https://github.com/can1357/selene/blob/master/pdblib/includes/pdblib/pdb.hpp"
click node_sdkgen "https://github.com/can1357/selene/blob/master/sdkgen/src/main.cpp"
click node_ntpp "https://github.com/can1357/selene/blob/master/shared/ntpp/io.cpp"
click node_sdk "https://github.com/can1357/selene/tree/master/resources/sdk"

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_boot,node_memory,node_pages,node_patch,node_scheduler,node_network,node_gdb,node_crashdump toneBlue
class node_vm,node_emulation,node_trace,node_snapshot toneAmber
class node_linker,node_objects,node_transforms,node_apollo_vm,node_flash,node_flash_engine,node_pdb,node_sdkgen toneMint
class node_ntpp,node_sdk toneRose
class node_operator toneIndigo
```

## Components

### Selene Runtime

- [Kernel initialization](https://github.com/can1357/selene/blob/master/selene/main.cpp): `selene/main.cpp`
- [Memory management](https://github.com/can1357/selene/blob/master/selene/utility/memory.hpp): `selene/utility/memory.hpp`
- [Page tables](https://github.com/can1357/selene/blob/master/selene/utility/page_manager.hpp): `selene/utility/page_manager.hpp`
- [Kernel patching](https://github.com/can1357/selene/blob/master/selene/hooks/patch_manager.cpp): `selene/hooks/patch_manager.cpp`
- [APIC scheduling](https://github.com/can1357/selene/tree/master/selene/sched): `selene/sched`
- [NDIS networking](https://github.com/can1357/selene/blob/master/selene/net/lwip.cpp): `selene/net/lwip.cpp`
- [GDB and CE servers](https://github.com/can1357/selene/tree/master/selene/gdb): `selene/gdb`
- [Crash reporting](https://github.com/can1357/selene/blob/master/selene/misc/crashdump.cpp): `selene/misc/crashdump.cpp`

### Virtualization and Tracing

- [Virtualization engine](https://github.com/can1357/selene/blob/master/selene/su/vm.hpp): `selene/su/vm.hpp`
- [Instruction emulation](https://github.com/can1357/selene/blob/master/selene/su/emulation.cpp): `selene/su/emulation.cpp`
- [Execution tracing](https://github.com/can1357/selene/blob/master/selene/su/xt.hpp): `selene/su/xt.hpp`
- [Crash snapshots](https://github.com/can1357/selene/blob/master/shared/trace_snapshot.hpp): `shared/trace_snapshot.hpp`

### Developer Tools

- [LLVM linker](https://github.com/can1357/selene/blob/master/apollo-linker/linker.cpp): `apollo-linker/linker.cpp`
- [Link object model](https://github.com/can1357/selene/blob/master/apollo-linker/object/collection.hpp): `apollo-linker/object/collection.hpp`
- [Link transforms](https://github.com/can1357/selene/tree/master/apollo-linker/transform): `apollo-linker/transform`
- [WASM virtualization](https://github.com/can1357/selene/blob/master/apollo-vm/apollo-vm.cpp): `apollo-vm/apollo-vm.cpp`
- [Pattern scanner](https://github.com/can1357/selene/blob/master/flash/main.cpp): `flash/main.cpp`
- [Scanning engine](https://github.com/can1357/selene/blob/master/flash/includes/flash/engine.hpp): `flash/includes/flash/engine.hpp`
- [PDB parsing](https://github.com/can1357/selene/blob/master/pdblib/includes/pdblib/pdb.hpp): `pdblib/includes/pdblib/pdb.hpp`
- [SDK header generator](https://github.com/can1357/selene/blob/master/sdkgen/src/main.cpp): `sdkgen/src/main.cpp`

### Kernel Interfaces

- [NT API wrappers](https://github.com/can1357/selene/blob/master/shared/ntpp/io.cpp): `shared/ntpp/io.cpp`
- [Windows SDK definitions](https://github.com/can1357/selene/tree/master/resources/sdk): `resources/sdk`

### Other components

- **Kernel operator**

## Connections

- Kernel operator → Kernel initialization: loads driver
- Kernel initialization → Virtualization engine: initializes (evidence: `selene/main.cpp`)
- Kernel initialization → NDIS networking: initializes (evidence: `selene/main.cpp`)
- Kernel initialization → GDB and CE servers: initializes (evidence: `selene/main.cpp`)
- Kernel initialization → Memory management: uses (evidence: `selene/main.cpp`)
- Kernel initialization → APIC scheduling: initializes (evidence: `selene/main.cpp`)
- Kernel patching → Page tables: looks up PTEs (evidence: `selene/hooks/patch_manager.cpp`)
- Kernel patching → Memory management: accesses PFNs (evidence: `selene/hooks/patch_manager.cpp`)
- Kernel patching → APIC scheduling: synchronizes via IPI (evidence: `selene/hooks/patch_manager.cpp`)
- Virtualization engine → Memory management: uses (evidence: `selene/su/vm.hpp`)
- Virtualization engine → Page tables: uses (evidence: `selene/su/vm.hpp`)
- Instruction emulation → Virtualization engine: uses VM context (evidence: `selene/su/emulation.cpp`)
- Virtualization engine → Execution tracing: captures snapshots (evidence: `selene/su/vm.hpp`)
- Crash reporting → Crash snapshots: submits snapshots
- Kernel operator → Pattern scanner: scans patterns
- Pattern scanner → Scanning engine: uses engine (evidence: `flash/main.cpp`)
- Kernel operator → LLVM linker: links bitcode
- LLVM linker → Link object model: manages objects (evidence: `apollo-linker/linker.cpp`)
- LLVM linker → Link transforms: runs transforms (evidence: `apollo-linker/linker.cpp`)
- Link transforms → WASM virtualization: supports virtualization
- Kernel operator → PDB parsing: parses symbols
- PDB parsing → SDK header generator: generates headers
- SDK header generator → Windows SDK definitions: emits definitions
- Kernel initialization → NT API wrappers: uses kernel wrappers (evidence: `selene/main.cpp`)
