Skip to content

Source file reference

Carter edited this page May 8, 2026 · 1 revision

Source file reference

Every meaningful file in src/GamerGuardian/, grouped by directory.

Top level

File What it does
App.xaml(.cs) App entry. Single-instance mutex, theme bootstrap, monitor list, tray, exception logging, auto-update check. Dispatches --test and --show-settings CLI flags.
GamerGuardian.csproj Build config — target framework, package refs (WPF-UI, ServiceProcess), single-file/self-contained settings.
app.manifest Per-monitor V2 DPI awareness, requestedExecutionLevel asInvoker (no UAC at startup).

Models/

Pure data — no behavior, no I/O.

File Contents
AppConfig.cs The JSON-serialized config root. Per-display preferences, global gaming preferences, services preferences, theme, polling interval.
DriftReport.cs DriftItem record — a single setting that's drifted from preference, with the Apply lambda baked in.
ApplyResult.cs Returned by ChangeApplier after Apply+verify. Drives both the Apply Results window and changes.log.
ServiceDefinition.cs Static metadata for a Windows service in the catalog (name, display name, default start type, recommended target).

Monitors/

Each IMonitoredSetting is ~30 lines — read raw, compute desired, yield a DriftItem. Each file maps 1:1 to a row in the Settings UI.

File What it watches
IMonitoredSetting.cs The interface — Id + CheckDrift(config).
HdrMonitor.cs Per-display HDR via the CCD DISPLAYCONFIG_GET_ADVANCED_COLOR_INFO API.
RefreshRateMonitor.cs Per-display refresh rate via EnumDisplaySettingsEx/ChangeDisplaySettingsEx.
ResolutionMonitor.cs Per-display resolution.
HagsMonitor.cs Hardware-accelerated GPU Scheduling (HKLM, reboot required). The canonical example for new monitors.
MemoryIntegrityMonitor.cs VBS / HVCI (HKLM, reboot required).
SystemResponsivenessMonitor.cs MMCSS reservation percentage (HKLM, reboot required).
NetworkThrottlingMonitor.cs MMCSS network throttling index (HKLM).
UsbSelectiveSuspendMonitor.cs Global USB selective suspend toggle (HKLM, reboot required).
GamesTaskProfileMonitor.cs MMCSS Games task profile values (HKLM).
GameModeMonitor.cs Windows Game Mode (HKCU).
GameDvrMonitor.cs Game DVR background recording (HKCU).
MousePrecisionMonitor.cs Mouse acceleration ("Enhance pointer precision") via SystemParametersInfo + HKCU.
FullscreenOptimizationsMonitor.cs Global FSE compositor toggle (HKCU).
VrrMonitor.cs DirectX Variable Refresh Rate (HKLM).
PowerPlanMonitor.cs Active power scheme via powrprof P/Invoke. Enumerates installed schemes for the dropdown.
WindowsServiceMonitor.cs One instance per service in ServiceCatalog. Maps ServicePref.Desired (Default/Manual/Disabled) to the matching elevated sc.exe call.

Native/

P/Invoke wrappers — every Windows API the app touches.

File Surface
DisplayConfig.cs CCD APIs (QueryDisplayConfig, DisplayConfigGetDeviceInfo, DisplayConfigSetDeviceInfo) for HDR + display enumeration.
DisplayHelper.cs Higher-level enumeration that pairs CCD source/target info with GDI device names.
User32.cs EnumDisplaySettingsEx, ChangeDisplaySettingsEx, SystemParametersInfo, foreground-window helpers.
Powrprof.cs PowerGetActiveScheme, PowerEnumerate, PowerSetActiveScheme, PowerReadFriendlyName.
Shell32.cs SHQueryUserNotificationState for fullscreen detection, plus borderless-fullscreen detection via foreground rect / monitor rect comparison.
Psapi.cs EmptyWorkingSet for working-set trimming.

Services/

Behavior — orchestration, polling, IPC, persistence.

File What it does
ConfigStore.cs JSON load/save for AppConfig.
MonitorService.cs The 30s polling loop. Pause-detection (fullscreen / benchmark / manual), drift collection, auto-apply dispatch, periodic working-set trim.
ChangeApplier.cs Shared apply+verify path used by manual Apply and the auto-apply loop. Re-runs CheckDrift after applying to confirm the value landed.
ChangeLogger.cs Writes changes.log entries. Handles rotation.
SettingDocs.cs Per-setting MechanismFor/VerifyCommandFor — drives both the Apply Results window and the change log "Mechanism" + "Verify" lines.
BenchmarkDetector.cs Process list scan against an allowlist of common benchmark executables.
ElevatedRegistry.cs Spawns reg.exe with Verb=runas for HKLM writes (single UAC prompt; supports chained writes).
WindowsServiceController.cs Reads service start type from registry; spawns sc.exe with Verb=runas for stop+disable / stop+set-manual / restore-default.
ServiceCatalog.cs The static list of Windows services GamerGuardian knows about.
TempCleanup.cs Sweeps stale auto-update installer EXEs from %TEMP% (>1 day old).
ThemeService.cs Light/dark/system theme switch via Wpf.Ui.Appearance.ApplicationThemeManager.
UpdateService.cs GitHub Releases API check + installer download. Strips prerelease suffixes when comparing semver.
StartupRegistration.cs Adds/removes the HKCU\...\Run\GamerGuardian autostart entry.
Notifier.cs Bottom-right drift popup window.

Tray/

File What it does
TrayIconHost.cs Win32 NotifyIcon wrapper. Right-click menu, double-click → settings, paused-icon variant.

UI/

WPF windows, all using WPF-UI Fluent styles.

File Window
SettingsWindow.xaml(.cs) The main UI — General / Global gaming / Windows services / Display tabs. Holds GlobalToggleRow, ServiceRow, DisplayRow view-models.
NotificationWindow.xaml(.cs) Bottom-right drift popup with one-click Apply + Dismiss.
ApplyResultsWindow.xaml(.cs) Per-setting verification with copyable PowerShell snippets.
UpdateAvailableWindow.xaml(.cs) Auto-update prompt with download progress and one-click install-and-restart.
RebootPendingWindow.xaml(.cs) Non-modal "reboot pending" notice shown after auto-apply of reboot-required settings.

Assets/

File Purpose
AppIcon.ico Multi-res application icon (tray + window + installer)
AppIcon-128.png Banner version used in README

Both are generated from tools/generate-icon.ps1 — see that script if you want to regenerate.

Clone this wiki locally