# hotcakex/harden-windows-security architecture

> Architecture diagram of the GitHub repository hotcakex/harden-windows-security, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hotcakex/harden-windows-security
- Repository: https://github.com/hotcakex/harden-windows-security

## Overview

##### Project type and purpose
- This is a single Git repository hosting two related Windows desktop applications:
- “Harden System Security” – a WPF/UWP‐style .NET 9 app that applies OS hardening and displays compliance.
- “AppControl Manager” – another .NET WPF/UWP app for creating and deploying Windows Application Control (WDAC) policies.
- Both are full-stack desktop applications using MVVM, with rich UI, business logic modules, native/interop components, background services, and external integration (Intune via Microsoft Graph).

##### File structure analysis
- Top-level:
- AppControl Manager/
- Harden System Security/
- Intune Files/ (JSON policies)
- .github/workflows (CI/CD, package scans, store builds)
- Cargo projects under eXclude (Rust utilities)
- Each app directory follows the pattern:
- App.xaml, manifest, .csproj – entry points, packaging.
- Pages, ViewModels – MVVM layers.
- CppInterop – native COM EXEs for privileged OS operations.
- RustInterop – FFI libraries (policy serializers, validators).
- IntelGathering, Main, XMLOps, SiPolicy, Signing, SimulationMethods, Others – core business logic modules.
- Background services: QuantumRelayHSS, DISMService (exposed via named pipes or COM) for running privileged tasks.
- Resources (XML/JSON policy templates), Assets (images, audio).

##### README insights
- The README describes two main products, their use cases (personal/enterprise hardening and App Control policy management), and how they leverage only built-in Windows APIs (no third-party).
- Mentions Intune integration via Graph API, deep OS interactions (Group Policy, BitLocker, Event Logs, MDE logs), and defense-in-depth.

##### Main components
a. Presentation layer (UI):
– Two WPF/UWP apps (“Harden” & “AppControl Manager”)
b. Business logic modules:
– Policy creation & editing (XMLOps, SiPolicy, Signing)
– System intelligence gathering (IntelGathering, SimulationMethods)
– Hardening operations (Main, Helpers, Protection categories)
c. Interop/native layer:
– CppInterop/ComManager.exe – privileged COM server for BitLocker, Firewall, DISM, Group Policy
– DISMService.exe – C#/.NET service for provisioned feature management
– RustInterop – FFI library for policy serialization, cryptographic tasks
– QuantumRelayHSS – named-pipe based relay between UI and high-privilege service
d. Data/config layer:
– Local file storage: policy XML/JSON files, logs, resources
– Local OS stores: Registry, Event Logs, Certificates store
e. External services:
– Microsoft Graph API (Intune)
– Microsoft Store (app installs, updates)

##### Relationships and interactions
- UI → ViewModels → Business Logic → Interop/Services → OS Subsystems
- Business Logic modules call into:
- ComManager (via COM interfaces) for BitLocker, firewall, virtualization
- DISMService for feature provisioning
- QuantumRelayHSS for kernel-mode policy enforcement tasks
- RustInterop functions for XML ↔ CIP policy transformations and signing
- Business Logic also reads/writes local policy template files and system logs.
- External: policy JSON files under Intune Files are pushed via Graph API from the app.

##### Architectural patterns & design principles
- MVVM separates UI (Views/CustomUIElements) from state & commands (ViewModels) and core logic.
- Layered architecture: Presentation → Application Services → Platform/Interop → OS.
- IPC patterns: COM for synchronous privileged operations, named pipes for asynchronous tasks.
- Extensibility: JSON/XML templates for policy definitions, plugin-like modules for different hardening categories.

##### Relevant technologies/frameworks
- .NET 9, WPF/UWP (XAML), C#
- MVVM (ViewModels, RelayCommand)
- COM interop (C++/Win32) via ComManager.exe
- .NET background services (DISMService)
- Rust + FFI (RustInterop crates)
- Named pipes (QuantumRelayHSS)
- Microsoft Graph SDK/REST for Intune integration
- AppX/MSIX packaging (Package.appxmanifest)
- CI/CD: GitHub Actions for build, scan, package, attestation

## Diagram (Mermaid)

```mermaid
flowchart TB
  %% Presentation Layer
  subgraph "Presentation Layer"
    subgraph "Harden System Security UI"
      HS_App["App.xaml"]:::frontend
      HS_Pages["Pages"]:::frontend
      HS_ViewModels["ViewModels"]:::frontend
      HS_CustomUI["CustomUIElements"]:::frontend
      HS_Animated["Animated Icon Sources"]:::frontend
    end
    subgraph "AppControl Manager UI"
      ACM_App["App.xaml"]:::frontend
      ACM_Pages["Pages"]:::frontend
      ACM_ViewModels["ViewModels"]:::frontend
      ACM_CustomUI["CustomUIElements"]:::frontend
      ACM_Animated["Animated Icon Sources"]:::frontend
    end
  end

  %% Application Services (Business Logic)
  subgraph "Application Services (Business Logic)"
    Intel["IntelGathering"]:::biz
    XMLOps["XMLOps"]:::biz
    SiPolicy["SiPolicy"]:::biz
    SiPolicyIntel["SiPolicyIntel"]:::biz
    Signing["Signing"]:::biz
    Simulation["SimulationMethods"]:::biz
    CorePolicy["Main"]:::biz
  end

  %% Interop/Native Layer
  subgraph "Interop/Native Layer"
    COM["ComManager.exe"]:::native
    DISM["DISMService.exe"]:::native
    RustFFI["RustInterop"]:::native
    Quantum["QuantumRelayHSS"]:::native
  end

  %% Data & Configuration
  subgraph "Data & Config"
    Resources["Resources/Templates"]:::data
    IntuneFiles["Intune Files"]:::data
  end

  %% OS Subsystems
  subgraph "OS Subsystems"
    FS["File System"]:::os
    Registry["Registry"]:::os
    EventLogs["Event Logs"]:::os
    CertStore["Certificates Store"]:::os
  end

  %% External Services
  subgraph "External Services"
    GraphAPI["Microsoft Graph API (Intune)"]:::external
  end

  %% DevOps
  subgraph "DevOps"
    CI1["Build Harden System Security for Store"]:::devops
    CI2["Build AppControl Manager for Store"]:::devops
  end

  %% Relationships
  HS_App -->|"binds via MVVM"| HS_ViewModels
  HS_ViewModels -->|"invokes"| CorePolicy
  ACM_App -->|"binds via MVVM"| ACM_ViewModels
  ACM_ViewModels -->|"invokes"| CorePolicy

  CorePolicy -->|"gather intelligence"| Intel
  CorePolicy -->|"perform XML ops"| XMLOps
  CorePolicy -->|"manage SiPolicy"| SiPolicy
  CorePolicy -->|"manage SiPolicyIntel"| SiPolicyIntel
  CorePolicy -->|"sign policies"| Signing
  CorePolicy -->|"simulate"| Simulation

  CorePolicy -->|"read/write templates"| Resources
  Resources -->|"store files"| FS

  CorePolicy -->|"calls COM"| COM
  COM -->|"modify settings"| Registry
  COM -->|"manage features"| FS
  COM -->|"log events"| EventLogs

  CorePolicy -->|"calls DISM"| DISM
  DISM -->|"provision features"| FS

  CorePolicy -->|"calls Rust FFI"| RustFFI
  RustFFI -->|"serialize/validate"| FS

  CorePolicy -->|"async relay"| Quantum
  Quantum -->|"enforce kernel tasks"| Registry

  CorePolicy -->|"REST to Intune"| GraphAPI
  GraphAPI -->|"push JSON policies"| IntuneFiles

  CI1 --> HS_App
  CI2 --> ACM_App

  %% Click Events
  click HS_App "https://github.com/hotcakex/harden-windows-security/blob/main/Harden System Security/App.xaml"
  click HS_Pages "https://github.com/hotcakex/harden-windows-security/tree/main/Harden System Security/Pages/"
  click HS_ViewModels "https://github.com/hotcakex/harden-windows-security/tree/main/Harden System Security/ViewModels/"
  click HS_CustomUI "https://github.com/hotcakex/harden-windows-security/tree/main/Harden System Security/CustomUIElements/"
  click HS_Animated "https://github.com/hotcakex/harden-windows-security/tree/main/Harden System Security/Animated Icon Sources/"
  click ACM_App "https://github.com/hotcakex/harden-windows-security/blob/main/AppControl Manager/App.xaml"
  click ACM_Pages "https://github.com/hotcakex/harden-windows-security/tree/main/AppControl Manager/Pages/"
  click ACM_ViewModels "https://github.com/hotcakex/harden-windows-security/tree/main/AppControl Manager/ViewModels/"
  click ACM_CustomUI "https://github.com/hotcakex/harden-windows-security/tree/main/AppControl Manager/CustomUIElements/"
  click ACM_Animated "https://github.com/hotcakex/harden-windows-security/tree/main/AppControl Manager/Animated Icon Sources/"
  click Intel "https://github.com/hotcakex/harden-windows-security/tree/main/AppControl Manager/IntelGathering/"
  click XMLOps "https://github.com/hotcakex/harden-windows-security/tree/main/AppControl Manager/XMLOps/"
  click SiPolicy "https://github.com/hotcakex/harden-windows-security/tree/main/AppControl Manager/SiPolicy/"
  click SiPolicyIntel "https://github.com/hotcakex/harden-windows-security/tree/main/AppControl Manager/SiPolicyIntel/"
  click Signing "https://github.com/hotcakex/harden-windows-security/tree/main/AppControl Manager/Signing/"
  click Simulation "https://github.com/hotcakex/harden-windows-security/tree/main/AppControl Manager/SimulationMethods/"
  click CorePolicy "https://github.com/hotcakex/harden-windows-security/tree/main/AppControl Manager/Main/"
  click COM "https://github.com/hotcakex/harden-windows-security/blob/main/AppControl Manager/CppInterop/ComManager.exe"
  click COM "https://github.com/hotcakex/harden-windows-security/blob/main/Harden System Security/CppInterop/ComManager.exe"
  click COM "https://github.com/hotcakex/harden-windows-security/tree/main/AppControl Manager/eXclude/ComManager/"
  click DISM "https://github.com/hotcakex/harden-windows-security/blob/main/Harden System Security/DISMService.exe"
  click DISM "https://github.com/hotcakex/harden-windows-security/tree/main/AppControl Manager/eXclude/DISMService/"
  click RustFFI "https://github.com/hotcakex/harden-windows-security/tree/main/AppControl Manager/RustInterop/"
  click RustFFI "https://github.com/hotcakex/harden-windows-security/tree/main/Harden System Security/RustInterop/"
  click Quantum "https://github.com/hotcakex/harden-windows-security/blob/main/Harden System Security/QuantumRelayHSS.exe"
  click Quantum "https://github.com/hotcakex/harden-windows-security/tree/main/Harden System Security/QuantumRelayHSS/"
  click Quantum "https://github.com/hotcakex/harden-windows-security/tree/main/AppControl Manager/eXclude/QuantumRelayHSS/"
  click GraphAPI "https://github.com/hotcakex/harden-windows-security/tree/main/AppControl Manager/eXclude/CommonCore/MicrosoftGraph/"
  click Resources "https://github.com/hotcakex/harden-windows-security/tree/main/Harden System Security/Resources/"
  click IntuneFiles "https://github.com/hotcakex/harden-windows-security/tree/main/Intune Files/"
  click CI1 "https://github.com/hotcakex/harden-windows-security/blob/main/.github/workflows/Build Harden System Security for Store.yml"
  click CI2 "https://github.com/hotcakex/harden-windows-security/blob/main/.github/workflows/Build AppControl Manager for Store.yml"

  %% Styles
  classDef frontend fill:#D0E6FF,stroke:#0057B8,color:#000000
  classDef biz fill:#DFF2BF,stroke:#4F8A10,color:#000000
  classDef native fill:#FBE7C6,stroke:#E68A00,color:#000000
  classDef data fill:#EEEEEE,stroke:#666666,color:#000000
  classDef os fill:#F0F0F0,stroke:#888888,color:#000000
  classDef external fill:#E5D0FF,stroke:#7F00FF,color:#000000
  classDef devops fill:#FFF2CC,stroke:#D6B656,color:#000000
```
