# massgravel/tsforge architecture

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

- Interactive diagram: https://gitdiagram.com/massgravel/tsforge
- Repository: https://github.com/massgravel/tsforge

## Overview

TSforge is a Windows activation and evaluation-data manipulation tool, exposed as a command-line program and library. Users choose an operation and optional activation ID/version; the CLI dispatches to an activator or modifier, which consults Windows Software Protection Platform (SPP) licensing state and may update the physical or token store. The README also documents trusted-store dump/load, timer and key-state changes, generated-key installation, and IID configuration. Source excerpts are partial, so edges show documented operations and visible calls without inferring internal wiring for unsampled implementations.

Main entry points: [`TSforgeCLI/Program.cs`](https://github.com/massgravel/tsforge/blob/master/TSforgeCLI/Program.cs) (CLI dispatcher), [`LibTSforge/PhysicalStore/IPhysicalStore.cs`](https://github.com/massgravel/tsforge/blob/master/LibTSforge/PhysicalStore/IPhysicalStore.cs) (Physical store API), [`LibTSforge/Modifiers/GenPKeyInstall.cs`](https://github.com/massgravel/tsforge/blob/master/LibTSforge/Modifiers/GenPKeyInstall.cs) (Generated key install), [`LibTSforge/Activators/KMS4K.cs`](https://github.com/massgravel/tsforge/blob/master/LibTSforge/Activators/KMS4K.cs) (KMS4K)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Command line"]
  node_cli["CLI dispatcher<br/>[Program.cs]"]
end

subgraph group_operations["Activation and changes"]
  node_zero["ZeroCID<br/>[ZeroCID.cs]"]
  node_kms4k["KMS4K<br/>[KMS4K.cs]"]
  node_avma4k["AVMA4K<br/>[AVMA4K.cs]"]
  node_rearm["Rearm reset<br/>[RearmReset.cs]"]
  node_grace["Grace reset"]
  node_genkey["Generated key install<br/>[GenPKeyInstall.cs]"]
  node_duid["Unique ID delete<br/>[UniqueIdDelete.cs]"]
  node_kmscharge["KMS host charge<br/>[KMSHostCharge.cs]"]
  node_tamper["Tamper flag delete"]
  node_keylock["Key lock delete"]
  node_iid["IID parameters<br/>[SetIIDParams.cs]"]
end

subgraph group_licensing["SPP licensing"]
  node_spp["Windows SPP API<br/>[SLAPI.cs]"]
  node_spputils["SPP utilities<br/>[SPPUtils.cs]"]
  node_pkeyconfig["Product key config<br/>[PKeyConfig.cs]"]
  node_productkey["Product key data<br/>[ProductKey.cs]"]
end

subgraph group_stores["Local activation stores"]
  node_physical["Physical store API<br/>[IPhysicalStore.cs]"]
  node_modernstore[("Modern store")]
  node_vista[("Vista store")]
  node_win7[("Windows 7 store")]
  node_token[("Token store")]
end

subgraph group_internals["Encoding and crypto"]
  node_physcrypto["Store encryption<br/>[PhysStoreCrypto.cs]"]
  node_crypto["Crypto utilities<br/>[CryptoUtils.cs]"]
  node_variablebag["Variable bag<br/>[VariableBag.cs]"]
end

node_user(("Operator"))
node_system["Windows SPP"]
node_dumpfile["Dump or load file"]

node_user -->|"chooses operation"| node_cli
node_cli -->|"dispatches"| node_zero
node_cli -->|"dispatches"| node_kms4k
node_cli -->|"dispatches"| node_avma4k
node_cli -->|"dispatches"| node_rearm
node_cli -->|"dispatches"| node_grace
node_cli -->|"dispatches"| node_genkey
node_cli -->|"dispatches"| node_duid
node_cli -->|"dispatches"| node_kmscharge
node_cli -->|"dispatches"| node_tamper
node_cli -->|"dispatches"| node_keylock
node_cli -->|"dispatches"| node_iid
node_zero -->|"queries licensing"| node_spp
node_zero -->|"updates store"| node_physical
node_zero -->|"restarts SPP"| node_spputils
node_kms4k -->|"checks key"| node_spp
node_kms4k -->|"stops service"| node_spputils
node_kms4k -->|"updates store"| node_physical
node_kms4k -->|"serializes data"| node_variablebag
node_kmscharge -->|"checks key"| node_spp
node_kmscharge -->|"updates store"| node_physical
node_kmscharge -->|"serializes data"| node_variablebag
node_kmscharge -->|"restarts SPP"| node_spputils
node_genkey -->|"loads configuration"| node_pkeyconfig
node_genkey -->|"builds key data"| node_productkey
node_genkey -->|"updates store"| node_physical
node_genkey -->|"updates tokens"| node_token
node_genkey -->|"refreshes licensing"| node_spp
node_iid -->|"updates store"| node_physical
node_rearm -->|"updates store"| node_physical
node_grace -->|"updates store"| node_physical
node_duid -->|"updates store"| node_physical
node_tamper -->|"updates store"| node_physical
node_keylock -->|"updates store"| node_physical
node_physical -->|"selects format"| node_modernstore
node_physical -->|"selects format"| node_vista
node_physical -->|"selects format"| node_win7
node_modernstore -->|"decrypts or encrypts"| node_physcrypto
node_win7 -->|"decrypts or encrypts"| node_physcrypto
node_token -->|"hashes content"| node_crypto
node_variablebag -->|"hashes data"| node_crypto
node_spp -->|"calls licensing API"| node_system
node_spputils -->|"controls service"| node_system
node_cli -->|"reads or writes"| node_dumpfile
node_cli -->|"dump or load"| node_physical

click node_cli "https://github.com/massgravel/tsforge/blob/master/TSforgeCLI/Program.cs"
click node_zero "https://github.com/massgravel/tsforge/blob/master/LibTSforge/Activators/ZeroCID.cs"
click node_kms4k "https://github.com/massgravel/tsforge/blob/master/LibTSforge/Activators/KMS4K.cs"
click node_avma4k "https://github.com/massgravel/tsforge/blob/master/LibTSforge/Activators/AVMA4K.cs"
click node_rearm "https://github.com/massgravel/tsforge/blob/master/LibTSforge/Modifiers/RearmReset.cs"
click node_grace "https://github.com/massgravel/tsforge/blob/master/LibTSforge/Modifiers/GracePeriodReset.cs"
click node_genkey "https://github.com/massgravel/tsforge/blob/master/LibTSforge/Modifiers/GenPKeyInstall.cs"
click node_duid "https://github.com/massgravel/tsforge/blob/master/LibTSforge/Modifiers/UniqueIdDelete.cs"
click node_kmscharge "https://github.com/massgravel/tsforge/blob/master/LibTSforge/Modifiers/KMSHostCharge.cs"
click node_tamper "https://github.com/massgravel/tsforge/blob/master/LibTSforge/Modifiers/TamperedFlagsDelete.cs"
click node_keylock "https://github.com/massgravel/tsforge/blob/master/LibTSforge/Modifiers/KeyChangeLockDelete.cs"
click node_iid "https://github.com/massgravel/tsforge/blob/master/LibTSforge/Modifiers/SetIIDParams.cs"
click node_spp "https://github.com/massgravel/tsforge/blob/master/LibTSforge/SPP/SLAPI.cs"
click node_spputils "https://github.com/massgravel/tsforge/blob/master/LibTSforge/SPP/SPPUtils.cs"
click node_pkeyconfig "https://github.com/massgravel/tsforge/blob/master/LibTSforge/SPP/PKeyConfig.cs"
click node_productkey "https://github.com/massgravel/tsforge/blob/master/LibTSforge/SPP/ProductKey.cs"
click node_physical "https://github.com/massgravel/tsforge/blob/master/LibTSforge/PhysicalStore/IPhysicalStore.cs"
click node_modernstore "https://github.com/massgravel/tsforge/blob/master/LibTSforge/PhysicalStore/PhysicalStoreModern.cs"
click node_vista "https://github.com/massgravel/tsforge/blob/master/LibTSforge/PhysicalStore/PhysicalStoreVista.cs"
click node_win7 "https://github.com/massgravel/tsforge/blob/master/LibTSforge/PhysicalStore/PhysicalStoreWin7.cs"
click node_token "https://github.com/massgravel/tsforge/blob/master/LibTSforge/TokenStore/TokenStoreModern.cs"
click node_physcrypto "https://github.com/massgravel/tsforge/blob/master/LibTSforge/Crypto/PhysStoreCrypto.cs"
click node_crypto "https://github.com/massgravel/tsforge/blob/master/LibTSforge/Crypto/CryptoUtils.cs"
click node_variablebag "https://github.com/massgravel/tsforge/blob/master/LibTSforge/PhysicalStore/VariableBag.cs"

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_cli toneBlue
class node_zero,node_kms4k,node_avma4k,node_rearm,node_grace,node_genkey,node_duid,node_kmscharge,node_tamper,node_keylock,node_iid toneAmber
class node_spp,node_spputils,node_pkeyconfig,node_productkey toneMint
class node_physical,node_modernstore,node_vista,node_win7,node_token toneRose
class node_physcrypto,node_crypto,node_variablebag,node_user,node_system,node_dumpfile toneIndigo
```

## Components

### Command line

- [CLI dispatcher](https://github.com/massgravel/tsforge/blob/master/TSforgeCLI/Program.cs): `TSforgeCLI/Program.cs`

### Activation and changes

- [ZeroCID](https://github.com/massgravel/tsforge/blob/master/LibTSforge/Activators/ZeroCID.cs): `LibTSforge/Activators/ZeroCID.cs`
- [KMS4K](https://github.com/massgravel/tsforge/blob/master/LibTSforge/Activators/KMS4K.cs): `LibTSforge/Activators/KMS4K.cs`
- [AVMA4K](https://github.com/massgravel/tsforge/blob/master/LibTSforge/Activators/AVMA4K.cs): `LibTSforge/Activators/AVMA4K.cs`
- [Rearm reset](https://github.com/massgravel/tsforge/blob/master/LibTSforge/Modifiers/RearmReset.cs): `LibTSforge/Modifiers/RearmReset.cs`
- [Grace reset](https://github.com/massgravel/tsforge/blob/master/LibTSforge/Modifiers/GracePeriodReset.cs): `LibTSforge/Modifiers/GracePeriodReset.cs`
- [Generated key install](https://github.com/massgravel/tsforge/blob/master/LibTSforge/Modifiers/GenPKeyInstall.cs): `LibTSforge/Modifiers/GenPKeyInstall.cs`
- [Unique ID delete](https://github.com/massgravel/tsforge/blob/master/LibTSforge/Modifiers/UniqueIdDelete.cs): `LibTSforge/Modifiers/UniqueIdDelete.cs`
- [KMS host charge](https://github.com/massgravel/tsforge/blob/master/LibTSforge/Modifiers/KMSHostCharge.cs): `LibTSforge/Modifiers/KMSHostCharge.cs`
- [Tamper flag delete](https://github.com/massgravel/tsforge/blob/master/LibTSforge/Modifiers/TamperedFlagsDelete.cs): `LibTSforge/Modifiers/TamperedFlagsDelete.cs`
- [Key lock delete](https://github.com/massgravel/tsforge/blob/master/LibTSforge/Modifiers/KeyChangeLockDelete.cs): `LibTSforge/Modifiers/KeyChangeLockDelete.cs`
- [IID parameters](https://github.com/massgravel/tsforge/blob/master/LibTSforge/Modifiers/SetIIDParams.cs): `LibTSforge/Modifiers/SetIIDParams.cs`

### SPP licensing

- [Windows SPP API](https://github.com/massgravel/tsforge/blob/master/LibTSforge/SPP/SLAPI.cs): `LibTSforge/SPP/SLAPI.cs`
- [SPP utilities](https://github.com/massgravel/tsforge/blob/master/LibTSforge/SPP/SPPUtils.cs): `LibTSforge/SPP/SPPUtils.cs`
- [Product key config](https://github.com/massgravel/tsforge/blob/master/LibTSforge/SPP/PKeyConfig.cs): `LibTSforge/SPP/PKeyConfig.cs`
- [Product key data](https://github.com/massgravel/tsforge/blob/master/LibTSforge/SPP/ProductKey.cs): `LibTSforge/SPP/ProductKey.cs`

### Local activation stores

- [Physical store API](https://github.com/massgravel/tsforge/blob/master/LibTSforge/PhysicalStore/IPhysicalStore.cs): `LibTSforge/PhysicalStore/IPhysicalStore.cs`
- [Modern store](https://github.com/massgravel/tsforge/blob/master/LibTSforge/PhysicalStore/PhysicalStoreModern.cs): `LibTSforge/PhysicalStore/PhysicalStoreModern.cs`
- [Vista store](https://github.com/massgravel/tsforge/blob/master/LibTSforge/PhysicalStore/PhysicalStoreVista.cs): `LibTSforge/PhysicalStore/PhysicalStoreVista.cs`
- [Windows 7 store](https://github.com/massgravel/tsforge/blob/master/LibTSforge/PhysicalStore/PhysicalStoreWin7.cs): `LibTSforge/PhysicalStore/PhysicalStoreWin7.cs`
- [Token store](https://github.com/massgravel/tsforge/blob/master/LibTSforge/TokenStore/TokenStoreModern.cs): `LibTSforge/TokenStore/TokenStoreModern.cs`

### Encoding and crypto

- [Store encryption](https://github.com/massgravel/tsforge/blob/master/LibTSforge/Crypto/PhysStoreCrypto.cs): `LibTSforge/Crypto/PhysStoreCrypto.cs`
- [Crypto utilities](https://github.com/massgravel/tsforge/blob/master/LibTSforge/Crypto/CryptoUtils.cs): `LibTSforge/Crypto/CryptoUtils.cs`
- [Variable bag](https://github.com/massgravel/tsforge/blob/master/LibTSforge/PhysicalStore/VariableBag.cs): `LibTSforge/PhysicalStore/VariableBag.cs`

### Other components

- **Operator**
- **Windows SPP**
- **Dump or load file**

## Connections

- Operator → CLI dispatcher: chooses operation
- CLI dispatcher → ZeroCID: dispatches
- CLI dispatcher → KMS4K: dispatches
- CLI dispatcher → AVMA4K: dispatches
- CLI dispatcher → Rearm reset: dispatches
- CLI dispatcher → Grace reset: dispatches
- CLI dispatcher → Generated key install: dispatches
- CLI dispatcher → Unique ID delete: dispatches
- CLI dispatcher → KMS host charge: dispatches
- CLI dispatcher → Tamper flag delete: dispatches
- CLI dispatcher → Key lock delete: dispatches
- CLI dispatcher → IID parameters: dispatches
- ZeroCID → Windows SPP API: queries licensing
- ZeroCID → Physical store API: updates store
- ZeroCID → SPP utilities: restarts SPP
- KMS4K → Windows SPP API: checks key
- KMS4K → SPP utilities: stops service
- KMS4K → Physical store API: updates store
- KMS4K → Variable bag: serializes data
- KMS host charge → Windows SPP API: checks key
- KMS host charge → Physical store API: updates store
- KMS host charge → Variable bag: serializes data
- KMS host charge → SPP utilities: restarts SPP
- Generated key install → Product key config: loads configuration
- Generated key install → Product key data: builds key data
- Generated key install → Physical store API: updates store
- Generated key install → Token store: updates tokens
- Generated key install → Windows SPP API: refreshes licensing
- IID parameters → Physical store API: updates store
- Rearm reset → Physical store API: updates store
- Grace reset → Physical store API: updates store
- Unique ID delete → Physical store API: updates store
- Tamper flag delete → Physical store API: updates store
- Key lock delete → Physical store API: updates store
- Physical store API → Modern store: selects format
- Physical store API → Vista store: selects format
- Physical store API → Windows 7 store: selects format
- Modern store → Store encryption: decrypts or encrypts
- Windows 7 store → Store encryption: decrypts or encrypts
- Token store → Crypto utilities: hashes content
- Variable bag → Crypto utilities: hashes data
- Windows SPP API → Windows SPP: calls licensing API
- SPP utilities → Windows SPP: controls service
- CLI dispatcher → Dump or load file: reads or writes
- CLI dispatcher → Physical store API: dump or load
