Protect shared MPC-HC settings from running x86 and x64 players

This commit is contained in:
Dandaedre 2026-10-19 15:47:34 +02:00
parent 00afa8fa47
commit 6ee43de515
4 changed files with 33 additions and 0 deletions

View File

@ -140,3 +140,4 @@ open until it is run on disposable machines with the required account setups.
- [x] Record the cross-script output and error-handling convention in AGENTS.md and the advanced guide.
- [x] Simplify the Ontime event timer: hide event cards, enlarge countdown and bottom message equally, and blink the background red; checked in a local Firefox fixture.
- [x] Reduce Ontime countdown/message sizing by 30%, enlarge the clock, and bottom-align fullscreen messages; preview both layouts in Firefox.
- [x] Verify the shared MPC-HC x86/x64 registry target and block apply while either player is running to prevent settings being overwritten on exit.

View File

@ -22,6 +22,17 @@ preferences.
MPC-HC normally stores preferences below
`HKCU\Software\MPC-HC\MPC-HC`. Config Central applies only values listed in
`configs/mpc-hc/settings.json`; it does not delete other values or registry keys.
The standard x86 and x64 builds use this same settings key for the same Windows
user: applying once configures both. This HKCU location is shared across registry
views; do not add a speculative Wow6432Node or "MPC-HC x64" target.
See [MPC-HC's settings store](https://github.com/clsid2/mpc-hc/blob/develop/src/mpc-hc/Profile.cpp)
and [Windows registry sharing rules](https://learn.microsoft.com/en-us/windows/win32/winprog64/shared-registry-keys).
Close **both** `mpc-hc.exe` and `mpc-hc64.exe` before applying. The adapter refuses
writes while either process is running, to prevent an open player from saving
stale settings over the new values. If the two players still differ, check each
one's settings-storage option and Windows account: separate INI files are not
managed by this registry adapter.
This adapter supports **registry mode only**. MPC-HC also supports an INI file
next to its executable (`mpc-hc.ini` or `mpc-hc64.ini`). Check the player's

View File

@ -192,6 +192,10 @@ function Get-AdapterPlan {
function Set-RegistryDeclaration {
param([string]$Root, $Declaration)
# Standard x86 and x64 MPC-HC share this HKCU settings store.
if (Get-Process -Name 'mpc-hc', 'mpc-hc64' -ErrorAction SilentlyContinue) {
throw 'Close both MPC-HC and MPC-HC x64 before applying settings, then rerun the update.'
}
foreach ($entry in $Declaration.values) {
$path = if ([string]::IsNullOrWhiteSpace([string]$entry.path)) { $Root } else { Join-Path $Root $entry.path }
if (-not (Test-Path -LiteralPath $path)) { [void](New-Item -Path $path -ErrorAction Stop) }

View File

@ -121,3 +121,20 @@ Describe 'Registry key preservation' {
}
}
}
Describe 'MPC-HC running player protection' {
It 'refuses registry writes when either player is running' {
InModuleScope Adapters {
Mock Get-Process { [pscustomobject]@{ ProcessName = 'mpc-hc64' } }
Mock New-Item {}
Mock New-ItemProperty {}
$declaration = [pscustomobject]@{ values = @(
[pscustomobject]@{ path = ''; name = 'Volume'; type = 'DWord'; value = 80 }
) }
{ Set-RegistryDeclaration -Root 'TestRoot' -Declaration $declaration } | Should -Throw '*Close both MPC-HC and MPC-HC x64*'
Should -Invoke Get-Process -Times 1 -ParameterFilter { $Name -contains 'mpc-hc' -and $Name -contains 'mpc-hc64' }
Should -Invoke New-Item -Times 0
Should -Invoke New-ItemProperty -Times 0
}
}
}