Skip to content

fix(FxController): validate and repair startup Run registry key path on stale binary locations#536

Open
akai07 wants to merge 5 commits into
fxsound2:mainfrom
akai07:fix/startup-registry-path-validation
Open

fix(FxController): validate and repair startup Run registry key path on stale binary locations#536
akai07 wants to merge 5 commits into
fxsound2:mainfrom
akai07:fix/startup-registry-path-validation

Conversation

@akai07

@akai07 akai07 commented May 27, 2026

Copy link
Copy Markdown

Summary

Fixes issue #483: after updating FxSound, the app no longer starts at boot even though the "Launch on system startup" checkbox shows as enabled. The root cause was that the Run registry key stored the old binary path from the previous install location.

Root Cause

When FxSound updates, the installer may place the new binary in a different path or the old binary location becomes stale. The HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run key still points to the old path, so Windows tries to launch a non-existent binary at boot. The settings checkbox showed "on" because isLaunchOnStartup() only checked if the registry key exists (size > 0), not whether the path was valid.

Changes

1. isLaunchOnStartup() — Path validation

  • Added error checking on RegOpenKeyEx (was silently ignoring failures)
  • Now reads and verifies the stored path matches the current executable path
  • Returns false if the path is stale (binary moved/updated), so the checkbox shows the correct state

2. setLaunchOnStartup() — Correct REG_SZ size

  • Fixed RegSetValueEx cbData from sizeof(szPath) (520 bytes = uninitialized stack data) to (wcslen(szPath) + 1) * sizeof(wchar_t)
  • Added error checking for GetModuleFileName and RegOpenKeyEx

3. syncLaunchOnStartup() — Auto-repair stale paths

  • New method called during FxController::init() on every startup
  • Detects a Run key with stale path and re-writes it with the current executable path
  • Ensures startup continues to work seamlessly after updates without user intervention

Files Changed

  • fxsound/Source/GUI/FxController.h — Added syncLaunchOnStartup() declaration
  • fxsound/Source/GUI/FxController.cpp — Rewrote startup registry handling with path validation and auto-repair

Related Issues

akai07 added 5 commits May 28, 2026 02:50
… in OnDeviceStateChanged

- Filter capture (eRender) device events in OnDeviceStateChanged via IMMEndpoint.GetDataFlow
  to prevent unnecessary playback reinit when input devices change state
- Track reconnected device GUID when state transitions to ACTIVE
- Add reconnection detection in sndDevicesImplementDeviceRules to auto-select
  reconnected playback devices (fixes BT headset reconnect after UNPLUGGED)
- Clear reconnection state on reinit
… system resume

- Call SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED)
  when audio processing starts to prevent system sleep during playback
- Revert to SetThreadExecutionState(ES_CONTINUOUS) when processing stops
- Handle PBT_APMRESUMEAUTOMATIC power event: check device changes and
  restore power state after system resume from sleep
- Clear execution state on controller destruction
…sizing and alpha

Replaced LoadIcon with LoadImage using explicit SM_CXSMICON/SM_CYSMICON
dimensions so tray icons are rendered at the correct size for the
notification area. LoadIcon uses default icon size which can cause
scaling artifacts and improper alpha blending on Windows 10/11,
especially in dark theme mode where transparency is critical.
…nges to same device

When video applications (Plex, etc.) switch between audio tracks with
different formats, Windows fires OnDefaultDeviceChanged even if the
device itself hasn't changed — only the format/role has. This was
causing the audio processing thread to restart unnecessarily, resulting
in audible pauses during video playback.

Fix: compare the new default device ID against our current playback
device. If they match, skip the re-init since it's a format change
on the same device, not an actual device switch.
After an update relocates the binary, the stale Run key path in
HKCU\...\Run causes the app to not launch at boot even though the
settings checkbox shows 'on' (the key exists but points to nowhere).

Fixes:
- isLaunchOnStartup: add error checking on all registry calls and
  validate the stored path matches the current executable path
- setLaunchOnStartup: write REG_SZ with correct cbData size
  ((wcslen+1)*sizeof) instead of sizeof(szPath)=520 bytes which
  appended uninitialized stack data to the registry value
- syncLaunchOnStartup: on each app init, detect stale Run key paths
  and re-write with the current executable path — automatically
  repairs startup after updates without user intervention
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Startup Issue

1 participant