# jackiezheng/watermarkservice architecture

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

- Interactive diagram: https://gitdiagram.com/jackiezheng/watermarkservice
- Repository: https://github.com/jackiezheng/watermarkservice

## Overview

ExplorerWatermarkService is a Windows service that reapplies a reversible in-memory watermark patch whenever Explorer restarts. Its main workflow monitors Explorer, enters a guarded execution path, prepares and validates the target RVA, runs the original patching executable, and verifies the result when needed. Other documented capabilities include installation, status checks, and manual execution. Several scripts are not sampled, so their connections are shown only where the README documents them.

Main entry points: [`bin/run-watermark-guarded.ps1`](https://github.com/jackiezheng/watermarkservice/blob/main/bin/run-watermark-guarded.ps1) (Execution guard), [`bin/prewarm-rva.py`](https://github.com/jackiezheng/watermarkservice/blob/main/bin/prewarm-rva.py) (RVA prewarmer), [`bin/monitor.ps1`](https://github.com/jackiezheng/watermarkservice/blob/main/bin/monitor.ps1) (Restart monitor), [`bin/clear-watermark.cmd`](https://github.com/jackiezheng/watermarkservice/blob/main/bin/clear-watermark.cmd) (Command entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_supervision["Monitoring and Control"]
  node_monitor["Restart monitor<br/>[monitor.ps1]"]
  node_config["Runtime config<br/>[config.json]"]
  node_cmd["Command entry"]
  node_guard["Execution guard"]
end

subgraph group_rva["RVA Preparation"]
  node_prewarm["RVA prewarmer<br/>[prewarm-rva.py]"]
  node_profiles[("Profile cache")]
  node_symbols["Microsoft symbol server"]
  node_winbindex["WinbIndex"]
  node_fallback["Symbol probe fallback<br/>[check-symbols.ps1]"]
end

subgraph group_patch["Injection and Verification"]
  node_patcher["Watermark patcher"]
  node_verifier["Memory verifier<br/>[verify-inject.py]"]
end

subgraph group_operations["Service Operations"]
  node_status["Status check<br/>[status.ps1]"]
  node_manual["Manual run<br/>[RunManual.ps1]"]
  node_installer["Service installer<br/>[install.bat]"]
  node_uninstaller["Service uninstaller<br/>[uninstall.bat]"]
  node_service_manager["NSSM service manager<br/>[nssm.exe]"]
end

node_explorer(("Explorer process"))
node_watermark["Desktop watermark"]

node_monitor -->|"monitors restarts"| node_explorer
node_monitor -->|"reads settings"| node_config
node_monitor -->|"invokes target"| node_cmd
node_cmd -->|"forwards execution"| node_guard
node_guard -->|"checks and prepares"| node_prewarm
node_prewarm -->|"seeds from cache"| node_profiles
node_prewarm -->|"fetches PDB"| node_symbols
node_prewarm -->|"finds reference builds"| node_winbindex
node_guard -.->|"uses if Python unavailable"| node_fallback
node_guard -->|"runs patcher"| node_patcher
node_guard -->|"checks failed run"| node_verifier
node_verifier -->|"reads process memory"| node_explorer
node_patcher -->|"patches process memory"| node_explorer
node_explorer -->|"stops drawing"| node_watermark
node_manual -->|"runs guarded path"| node_guard
node_status -.->|"checks cache"| node_prewarm
node_installer -.->|"registers service"| node_service_manager
node_uninstaller -.->|"removes service"| node_service_manager

click node_monitor "https://github.com/jackiezheng/watermarkservice/blob/main/bin/monitor.ps1"
click node_config "https://github.com/jackiezheng/watermarkservice/blob/main/bin/config.json"
click node_cmd "https://github.com/jackiezheng/watermarkservice/blob/main/bin/clear-watermark.cmd"
click node_guard "https://github.com/jackiezheng/watermarkservice/blob/main/bin/run-watermark-guarded.ps1"
click node_prewarm "https://github.com/jackiezheng/watermarkservice/blob/main/bin/prewarm-rva.py"
click node_fallback "https://github.com/jackiezheng/watermarkservice/blob/main/bin/check-symbols.ps1"
click node_patcher "https://github.com/jackiezheng/watermarkservice/blob/main/tools/ClearWinWatermark.exe"
click node_verifier "https://github.com/jackiezheng/watermarkservice/blob/main/bin/verify-inject.py"
click node_status "https://github.com/jackiezheng/watermarkservice/blob/main/bin/status.ps1"
click node_manual "https://github.com/jackiezheng/watermarkservice/blob/main/bin/RunManual.ps1"
click node_installer "https://github.com/jackiezheng/watermarkservice/blob/main/install.bat"
click node_uninstaller "https://github.com/jackiezheng/watermarkservice/blob/main/uninstall.bat"
click node_service_manager "https://github.com/jackiezheng/watermarkservice/blob/main/tools/nssm.exe"

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_monitor,node_config,node_cmd,node_guard toneBlue
class node_prewarm,node_profiles,node_symbols,node_winbindex,node_fallback toneAmber
class node_patcher,node_verifier toneMint
class node_status,node_manual,node_installer,node_uninstaller,node_service_manager toneRose
class node_explorer,node_watermark toneIndigo
```

## Components

### Monitoring and Control

- [Restart monitor](https://github.com/jackiezheng/watermarkservice/blob/main/bin/monitor.ps1): `bin/monitor.ps1`
- [Runtime config](https://github.com/jackiezheng/watermarkservice/blob/main/bin/config.json): `bin/config.json`
- [Command entry](https://github.com/jackiezheng/watermarkservice/blob/main/bin/clear-watermark.cmd): `bin/clear-watermark.cmd`
- [Execution guard](https://github.com/jackiezheng/watermarkservice/blob/main/bin/run-watermark-guarded.ps1): `bin/run-watermark-guarded.ps1`

### RVA Preparation

- [RVA prewarmer](https://github.com/jackiezheng/watermarkservice/blob/main/bin/prewarm-rva.py): `bin/prewarm-rva.py`
- **Profile cache**
- **Microsoft symbol server**
- **WinbIndex**
- [Symbol probe fallback](https://github.com/jackiezheng/watermarkservice/blob/main/bin/check-symbols.ps1): `bin/check-symbols.ps1`

### Injection and Verification

- [Watermark patcher](https://github.com/jackiezheng/watermarkservice/blob/main/tools/ClearWinWatermark.exe): `tools/ClearWinWatermark.exe`
- [Memory verifier](https://github.com/jackiezheng/watermarkservice/blob/main/bin/verify-inject.py): `bin/verify-inject.py`

### Service Operations

- [Status check](https://github.com/jackiezheng/watermarkservice/blob/main/bin/status.ps1): `bin/status.ps1`
- [Manual run](https://github.com/jackiezheng/watermarkservice/blob/main/bin/RunManual.ps1): `bin/RunManual.ps1`
- [Service installer](https://github.com/jackiezheng/watermarkservice/blob/main/install.bat): `install.bat`
- [Service uninstaller](https://github.com/jackiezheng/watermarkservice/blob/main/uninstall.bat): `uninstall.bat`
- [NSSM service manager](https://github.com/jackiezheng/watermarkservice/blob/main/tools/nssm.exe): `tools/nssm.exe`

### Other components

- **Explorer process**
- **Desktop watermark**

## Connections

- Restart monitor → Explorer process: monitors restarts (evidence: `README.md`)
- Restart monitor → Runtime config: reads settings (evidence: `README.md`)
- Restart monitor → Command entry: invokes target (evidence: `README.md`)
- Command entry → Execution guard: forwards execution (evidence: `README.md`)
- Execution guard → RVA prewarmer: checks and prepares (evidence: `README.md`)
- RVA prewarmer → Profile cache: seeds from cache (evidence: `README.md`)
- RVA prewarmer → Microsoft symbol server: fetches PDB (evidence: `README.md`)
- RVA prewarmer → WinbIndex: finds reference builds (evidence: `README.md`)
- Execution guard → Symbol probe fallback: uses if Python unavailable (evidence: `README.md`)
- Execution guard → Watermark patcher: runs patcher (evidence: `README.md`)
- Execution guard → Memory verifier: checks failed run (evidence: `README.md`)
- Memory verifier → Explorer process: reads process memory (evidence: `README.md`)
- Watermark patcher → Explorer process: patches process memory (evidence: `README.md`)
- Explorer process → Desktop watermark: stops drawing (evidence: `README.md`)
- Manual run → Execution guard: runs guarded path (evidence: `README.md`)
- Status check → RVA prewarmer: checks cache (evidence: `README.md`)
- Service installer → NSSM service manager: registers service (evidence: `README.md`)
- Service uninstaller → NSSM service manager: removes service (evidence: `README.md`)
