From 043019367dbf7f81fc02e617e391108db72b5f85 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 21 Nov 2026 02:31:01 +0700 Subject: [PATCH 1/2] fix(installer): restore automatic VB-CABLE detection without gating mixer startup --- installer/ArSonMix.iss | 27 +++-------- installer/ArSonMixVBCableInstall.ps1 | 6 +-- scripts/test_inno_graceful_update_windows.ps1 | 46 +++++++++++++++++++ tests/windows_installer_contract_test.mjs | 26 +++++------ 4 files changed, 65 insertions(+), 40 deletions(-) diff --git a/installer/ArSonMix.iss b/installer/ArSonMix.iss index 796051149..4d29b4330 100644 --- a/installer/ArSonMix.iss +++ b/installer/ArSonMix.iss @@ -44,6 +44,8 @@ SetupMutex=ArSonMix.PerUserInstaller.SingleInstance ; WM_CLOSE followed by full process exit is required before replacing EXE. CloseApplications=no RestartApplications=no +; The vendor can queue driver files for the next boot. Setup still opens ArSonMix. +RestartIfNeededByRun=no ; Clean only the exact legacy top-level documents installed by <= alpha.24. ; No wildcards, recursion, Studio data, shows, presets or third-party dirs. ; Inno processes [InstallDelete] before [Files], including in-place upgrades. @@ -91,18 +93,13 @@ Name: "{autoprograms}\Start ArSonMix with Recovery Profile"; Filename: "{app}\Ar ; preflight closes the prior verified app before [Files]; [Run] launches exactly ; one new executable only after a successful interactive install/update. ; Silent enterprise/FAT installs deliberately do not launch desktop audio. -[Tasks] -; P0 Win10 first-run: VB-CABLE is an OPTIONAL virtual-audio feature, not -; a dependency of the ASIO/WASAPI mixer. Never silently elevate/replace an -; audio driver or block a first launch for a driver reboot. Owner opt-in only. -Name: "installvbcable_driver"; Description: "Install optional VB-CABLE virtual audio driver (may require administrator approval and restart)"; GroupDescription: "Optional audio driver:"; Flags: unchecked dontinheritcheck - [Run] -; Check on interactive Setup before opening the mixer. Only a missing driver -; can reach the independently verified vendor EXE and its Windows approval. +; Interactive Setup automatically checks installed and pending VB-CABLE devices. +; Only a missing driver can reach the verified vendor installer and Windows UAC. +; The next entry opens ArSonMix even if the driver needs a restart or is declined. ; Silent updates and enterprise installs retain their noninteractive behavior. -Filename: "{sys}\WindowsPowerShell\v1.0\powershell.exe"; Parameters: "-NoLogo -NoProfile -ExecutionPolicy Bypass -File ""{app}\ThirdParty\VB-Audio\ArSonMixVBCableInstall.ps1"" -Archive ""{app}\ThirdParty\VB-Audio\VBCABLE_Driver_Pack45.zip"" -ExpectedSha256 ""{#VBCableSha256}"" -RestartMarker ""{tmp}\ArSonMixVBCableRestart"""; WorkingDir: "{app}"; StatusMsg: "Installing OPTIONAL VB-CABLE audio driver..."; Tasks: installvbcable_driver; Flags: runasoriginaluser skipifsilent waituntilterminated runhidden -Filename: "{app}\ArSonMix.exe"; WorkingDir: "{app}"; Flags: nowait runasoriginaluser skipifsilent; Check: CanLaunchMixer +Filename: "{sys}\WindowsPowerShell\v1.0\powershell.exe"; Parameters: "-NoLogo -NoProfile -ExecutionPolicy Bypass -File ""{app}\ThirdParty\VB-Audio\ArSonMixVBCableInstall.ps1"" -Archive ""{app}\ThirdParty\VB-Audio\VBCABLE_Driver_Pack45.zip"" -ExpectedSha256 ""{#VBCableSha256}"""; WorkingDir: "{app}"; StatusMsg: "Checking VB-Audio VB-CABLE for automatic audio setup..."; Flags: runasoriginaluser skipifsilent waituntilterminated runhidden +Filename: "{app}\ArSonMix.exe"; WorkingDir: "{app}"; Flags: nowait runasoriginaluser skipifsilent ; Never delete private Studio data on install/update/uninstall; never install ; portable_mode.txt or silently ARM an audio output. @@ -111,16 +108,6 @@ Filename: "{app}\ArSonMix.exe"; WorkingDir: "{app}"; Flags: nowait runasoriginal ; legacy versions with no shutdown handshake, verify the EXE is replaceable. ; Never force-terminate, never skip an occupied file, and never erase Studio. [Code] -function NeedRestart(): Boolean; -begin - Result := FileExists(ExpandConstant('{tmp}\ArSonMixVBCableRestart')); -end; - -function CanLaunchMixer(): Boolean; -begin - Result := not NeedRestart(); -end; - function OpenEventW(Access: LongWord; InheritHandle: Boolean; Name: string): THandle; external 'OpenEventW@kernel32.dll stdcall'; function SignalEvent(EventHandle: THandle): Boolean; diff --git a/installer/ArSonMixVBCableInstall.ps1 b/installer/ArSonMixVBCableInstall.ps1 index d0b69365c..63dd55607 100644 --- a/installer/ArSonMixVBCableInstall.ps1 +++ b/installer/ArSonMixVBCableInstall.ps1 @@ -4,8 +4,7 @@ # endpoint default changes, silent UAC bypass or driver uninstall. [CmdletBinding()]param( [Parameter(Mandatory=$true)][string]$Archive, - [Parameter(Mandatory=$true)][ValidatePattern('^[A-Fa-f0-9]{64}$')][string]$ExpectedSha256, - [Parameter(Mandatory=$true)][string]$RestartMarker + [Parameter(Mandatory=$true)][ValidatePattern('^[A-Fa-f0-9]{64}$')][string]$ExpectedSha256 ) Set-StrictMode -Version Latest $ErrorActionPreference="Stop" @@ -21,9 +20,6 @@ function Record([string]$stateName,[string]$reason) { rebootRequired=($stateName -eq 'PENDING_REBOOT')} | ConvertTo-Json | Set-Content -LiteralPath $temp -Encoding UTF8 Move-Item -LiteralPath $temp -Destination $statusPath -Force - if($stateName -eq 'PENDING_REBOOT'){ - New-Item -ItemType File -Path $RestartMarker -Force | Out-Null - } } $dir=Join-Path $env:TEMP ("armix-cable-"+[guid]::NewGuid().ToString("N")) try { diff --git a/scripts/test_inno_graceful_update_windows.ps1 b/scripts/test_inno_graceful_update_windows.ps1 index d88c420c7..56a4cf722 100644 --- a/scripts/test_inno_graceful_update_windows.ps1 +++ b/scripts/test_inno_graceful_update_windows.ps1 @@ -32,6 +32,51 @@ $privateSentinel=Join-Path $studio ("installer-smoke-"+[guid]::NewGuid().ToStrin function Assert-Condition([bool]$condition,[string]$message) { if(-not $condition){throw $message} } +function Test-VBCableSmartDetection { + $bootstrap=Join-Path $root "installer/ArSonMixVBCableInstall.ps1" + $originalAppData=$env:APPDATA + $boot=[DateTime]::SpecifyKind([DateTime]"2026-11-01", [DateTimeKind]::Utc) + function Get-CimInstance { + [CmdletBinding()] param([string]$ClassName) + [pscustomobject]@{LastBootUpTime=$boot} + } + function Get-PnpDevice { + [CmdletBinding()] param([switch]$PresentOnly) + if ($case.Device -eq 'error') { throw "Fixture PnP query denied" } + if ($case.Device -eq 'absent' -or ($case.Device -eq 'offline' -and $PresentOnly)) { return } + [pscustomobject]@{FriendlyName="CABLE Output (VB-Audio Virtual Cable)";Status="OK"} + } + # Guard the fixture from every attempt to launch a vendor process. + function Start-Process { throw "Unexpected vendor launch in detection fixture" } + try { + foreach ($case in @( + @{Name='healthy'; Device='present'; Expected='ALREADY_PRESENT'}, + @{Name='offline'; Device='offline'; Expected='REPAIR_REQUIRED'}, + @{Name='pending'; Device='absent'; Expected='PENDING_REBOOT'; Pending=$true}, + @{Name='missing'; Device='absent'; Expected='FAILED'; Reason='Bundled driver ZIP absent'}, + @{Name='query-failure'; Device='error'; Expected='FAILED'; Reason='Fixture PnP query denied'} + )) { + $env:APPDATA=Join-Path $work ("cable-"+$case.Name) + $status=Join-Path $env:APPDATA "AR-MIX-Studio/VB-CABLE-STATUS.json" + if ($case.ContainsKey('Pending')) { + New-Item -ItemType Directory -Force -Path (Split-Path -Parent $status) | Out-Null + @{state='PENDING_REBOOT';bootUtc=$boot.ToString('o')} | + ConvertTo-Json | Set-Content -LiteralPath $status + } + # Deliberately absent payload: the missing-device case alone should + # check for the archive. Presence and pending must return earlier. + & $bootstrap -Archive (Join-Path $work 'absent-vendor.zip') -ExpectedSha256 ('0'*64) + $result=Get-Content -LiteralPath $status -Raw | ConvertFrom-Json + Assert-Condition ($result.state -ceq $case.Expected) "VB-CABLE state mismatch for $($case.Name)" + if ($case.ContainsKey('Reason')) { + Assert-Condition ($result.reason -ceq $case.Reason) "VB-CABLE reason mismatch for $($case.Name)" + } + } + } finally { + $env:APPDATA=$originalAppData + } + Write-Host 'VBCABLE_SMART_DETECTION_PASS' +} function Show-UpgradeDiagnostics([string]$logFile){ if(Test-Path -LiteralPath $logFile){ Get-Content -LiteralPath $logFile | @@ -41,6 +86,7 @@ function Show-UpgradeDiagnostics([string]$logFile){ }else{Write-Host "INNO_RESTART_MANAGER_LOG_MISSING"} } try { + Test-VBCableSmartDetection New-Item -ItemType Directory -Force -Path $stage,$out,$install,$studio | Out-Null "private-user-data" | Set-Content -LiteralPath $privateSentinel $csc=Join-Path $env:WINDIR "Microsoft.NET/Framework/v4.0.30319/csc.exe" diff --git a/tests/windows_installer_contract_test.mjs b/tests/windows_installer_contract_test.mjs index 90157d5c9..a69905755 100644 --- a/tests/windows_installer_contract_test.mjs +++ b/tests/windows_installer_contract_test.mjs @@ -33,7 +33,7 @@ test('per-user Inno Setup upgrades the same app and retains private Studio data' assert.match(iss, /Source: "\.\.\\docs\\THIRD_PARTY_8D_SONKU_HRTF\.md"; Flags: dontcopy/); }); -test('optional signed VB-CABLE driver does not block clean Windows 10 first launch', () => { +test('interactive Setup automatically checks for signed VB-CABLE while mixer launch stays independent', () => { const m = JSON.parse(read('config/vbcable-official-package.json')); const pack = read('scripts/prepare_vbcable_package.ps1'); const bootstrap = read('installer/ArSonMixVBCableInstall.ps1'); @@ -43,21 +43,17 @@ test('optional signed VB-CABLE driver does not block clean Windows 10 first laun assert.match(m.sha256, /^[a-f0-9]{64}$/); assert.match(m.proof, /actions\/runs\/43079930924/); assert.match(iss, /^PrivilegesRequired=lowest$/m); - assert.match(iss, /^\[Tasks\]$/m); - assert.match(iss, /Name: "installvbcable_driver";[^\n]*Flags: unchecked/); - assert.equal((iss.match(/Name: "installvbcable_driver"/g) || []).length, 1); + assert.doesNotMatch(iss, /^\[Tasks\]$/m); assert.match(iss, /VBCABLE_Driver_Pack45\.zip/); - assert.match(iss, /ArSonMixVBCableInstall\.ps1/); const run = iss.slice(iss.indexOf('[Run]'), iss.indexOf('[Code]')); - assert.match(run, /StatusMsg: "Installing OPTIONAL VB-CABLE[^"]*"; Tasks: installvbcable_driver; Flags: runasoriginaluser skipifsilent waituntilterminated runhidden/); - assert.ok(run.indexOf('ArSonMixVBCableInstall.ps1') < run.indexOf('Filename: "{app}\\ArSonMix.exe"')); - const vendorRunLine=run.split('\n').find(s=>s.includes('ArSonMixVBCableInstall.ps1')); - assert.ok(vendorRunLine,'optional vendor installer remains available'); - assert.match(vendorRunLine,/Tasks: installvbcable_driver/); - assert.equal((run.match(/Tasks: installvbcable_driver/g)||[]).length,1); - assert.match(iss, /Check: CanLaunchMixer/); - assert.match(iss, /function NeedRestart\(\): Boolean;[\s\S]*?FileExists/); - assert.match(bootstrap, /if\(\$stateName -eq 'PENDING_REBOOT'\)\{[\s\S]*?New-Item -ItemType File -Path \$RestartMarker/); + const entries = run.split('\n').filter(line => line.startsWith('Filename:')); + assert.equal(entries.length, 2); + assert.match(entries[0], /ArSonMixVBCableInstall\.ps1/); + assert.match(entries[0], /Flags: runasoriginaluser skipifsilent waituntilterminated runhidden/); + assert.match(entries[1], /^Filename: "\{app\}\\ArSonMix\.exe"/); + for (const entry of entries) assert.doesNotMatch(entry, /;\s*(Check|Tasks):/i); + assert.match(iss, /^RestartIfNeededByRun=no$/m); + assert.doesNotMatch(iss + bootstrap, /VBCableRestart|RestartMarker|CanLaunchMixer|function NeedRestart/); assert.match(iss, /-ExpectedSha256 ""\{#VBCableSha256\}""/); assert.match(ps, /prepare_vbcable_package\.ps1/); assert.match(ps, /DVBCableSha256=/); @@ -497,7 +493,7 @@ test('P0 Windows 10 fresh install needs no VC redistributable and reports missin assert.match(native,/Download \/ Repair WebView2/); assert.match(native,/developer\.microsoft\.com\/en-us\/microsoft-edge\/webview2/); assert.match(native,/if \(result == 0\)/); - assert.match(iss,/Flags: unchecked/); + assert.match(iss,/^RestartIfNeededByRun=no$/m); const packaged=read('scripts/build_verify_windows_installer.ps1'); const pe=read('scripts/verify_win10_pe_runtime.py'); assert.match(packaged,/verify_win10_pe_runtime\.py --exe \$exe/); From d92119cd63e4a2aa02c9da12159c04ea62f3e2c6 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 21 Nov 2026 02:32:48 +0700 Subject: [PATCH 2/2] fix(installer): compare pending VB-CABLE boot times in canonical UTC --- installer/ArSonMixVBCableInstall.ps1 | 42 +++++++++++++------ scripts/test_inno_graceful_update_windows.ps1 | 11 +++-- 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/installer/ArSonMixVBCableInstall.ps1 b/installer/ArSonMixVBCableInstall.ps1 index 63dd55607..e42473f9e 100644 --- a/installer/ArSonMixVBCableInstall.ps1 +++ b/installer/ArSonMixVBCableInstall.ps1 @@ -21,31 +21,46 @@ function Record([string]$stateName,[string]$reason) { ConvertTo-Json | Set-Content -LiteralPath $temp -Encoding UTF8 Move-Item -LiteralPath $temp -Destination $statusPath -Force } +function Read-BootEpoch($value) { + if($value -is [DateTime] -or $value -is [DateTimeOffset]){ + return ([DateTimeOffset]$value).UtcDateTime.ToString('o') + } + [DateTimeOffset]$parsed=[DateTimeOffset]::MinValue + if([DateTimeOffset]::TryParseExact([string]$value,'o', + [Globalization.CultureInfo]::InvariantCulture, + [Globalization.DateTimeStyles]::AssumeUniversal,[ref]$parsed)){ + return $parsed.UtcDateTime.ToString('o') + } + return "" +} $dir=Join-Path $env:TEMP ("armix-cable-"+[guid]::NewGuid().ToString("N")) +$pending=$false try { # A driver already queued for reboot must NOT be run again: the VB-Audio # setup utility can switch into REMOVE mode on a second invocation. - # Record the Windows boot epoch and only clear pending after *another* boot - # AND a healthy PnP readback. Never infer installation from a process exit. - $os=Get-CimInstance Win32_OperatingSystem -ErrorAction Stop - $script:bootUtc=$os.LastBootUpTime.ToUniversalTime().ToString('o') $previous=$null if(Test-Path -LiteralPath $statusPath -PathType Leaf){ $previous=Get-Content -LiteralPath $statusPath -Raw -ErrorAction Stop | ConvertFrom-Json } + $pending=$null -ne $previous -and $previous.state -eq 'PENDING_REBOOT' + $os=Get-CimInstance Win32_OperatingSystem -ErrorAction Stop + $script:bootUtc=$os.LastBootUpTime.ToUniversalTime().ToString('o') + if($pending){ + # Windows PowerShell and newer pwsh can deserialize the same JSON field + # as text or as a date. Compare canonical UTC instants, before PnP reads. + $bootProperty=$previous.PSObject.Properties['bootUtc'] + $recordedBoot=if($null -ne $bootProperty){Read-BootEpoch $bootProperty.Value}else{""} + if([string]::IsNullOrEmpty($recordedBoot) -or $recordedBoot -ceq $script:bootUtc){ + Record "PENDING_REBOOT" "Restart Windows to complete the already-launched VB-CABLE installation" + exit 0 + } + } $isCable={ $_.FriendlyName -match '(?i)VB-Audio Virtual Cable|CABLE (Output|Input).*VB-Audio' } # Include non-present devices. Only examining PresentOnly can accidentally # launch the vendor setup in REMOVE mode when a driver awaits reboot. $all=@(Get-PnpDevice -ErrorAction Stop | Where-Object $isCable) $present=@(Get-PnpDevice -PresentOnly -ErrorAction Stop | Where-Object $isCable) - if($null -ne $previous -and $previous.state -eq 'PENDING_REBOOT'){ - $bootProperty=$previous.PSObject.Properties['bootUtc'] - if($null -eq $bootProperty -or - [string]::IsNullOrWhiteSpace([string]$bootProperty.Value) -or - [string]$bootProperty.Value -eq $script:bootUtc){ - Record "PENDING_REBOOT" "Restart Windows to complete the already-launched VB-CABLE installation" - exit 0 - } + if($pending){ if($present.Count -eq 0 -or @($present | Where-Object {$_.Status -ne 'OK'}).Count -gt 0){ Record "REPAIR_REQUIRED" "After reboot, VB-CABLE did not expose healthy PnP endpoints; do not rerun vendor setup automatically" exit 3 @@ -94,7 +109,8 @@ try { Record "PENDING_REBOOT" "Reboot Windows, then verify CABLE Output and physical speaker" exit 0 } catch { - Record "FAILED" $_.Exception.Message + # A failed OS/PnP query is not proof a recorded installation vanished. + if(-not $pending){Record "FAILED" $_.Exception.Message} Write-Warning ("Optional VB-Audio driver step incomplete: "+$_.Exception.Message) exit 2 } finally { diff --git a/scripts/test_inno_graceful_update_windows.ps1 b/scripts/test_inno_graceful_update_windows.ps1 index 56a4cf722..0e5595863 100644 --- a/scripts/test_inno_graceful_update_windows.ps1 +++ b/scripts/test_inno_graceful_update_windows.ps1 @@ -52,22 +52,25 @@ function Test-VBCableSmartDetection { foreach ($case in @( @{Name='healthy'; Device='present'; Expected='ALREADY_PRESENT'}, @{Name='offline'; Device='offline'; Expected='REPAIR_REQUIRED'}, - @{Name='pending'; Device='absent'; Expected='PENDING_REBOOT'; Pending=$true}, + @{Name='pending'; Device='absent'; Expected='PENDING_REBOOT'; RecordedBoot=$boot}, + @{Name='pending-query-denied'; Device='error'; Expected='PENDING_REBOOT'; RecordedBoot=$boot}, + @{Name='after-reboot'; Device='present'; Expected='ALREADY_PRESENT'; RecordedBoot=$boot.AddDays(-1)}, + @{Name='missing-after-reboot'; Device='absent'; Expected='REPAIR_REQUIRED'; RecordedBoot=$boot.AddDays(-1)}, @{Name='missing'; Device='absent'; Expected='FAILED'; Reason='Bundled driver ZIP absent'}, @{Name='query-failure'; Device='error'; Expected='FAILED'; Reason='Fixture PnP query denied'} )) { $env:APPDATA=Join-Path $work ("cable-"+$case.Name) $status=Join-Path $env:APPDATA "AR-MIX-Studio/VB-CABLE-STATUS.json" - if ($case.ContainsKey('Pending')) { + if ($case.ContainsKey('RecordedBoot')) { New-Item -ItemType Directory -Force -Path (Split-Path -Parent $status) | Out-Null - @{state='PENDING_REBOOT';bootUtc=$boot.ToString('o')} | + @{state='PENDING_REBOOT';bootUtc=$case.RecordedBoot.ToString('o')} | ConvertTo-Json | Set-Content -LiteralPath $status } # Deliberately absent payload: the missing-device case alone should # check for the archive. Presence and pending must return earlier. & $bootstrap -Archive (Join-Path $work 'absent-vendor.zip') -ExpectedSha256 ('0'*64) $result=Get-Content -LiteralPath $status -Raw | ConvertFrom-Json - Assert-Condition ($result.state -ceq $case.Expected) "VB-CABLE state mismatch for $($case.Name)" + Assert-Condition ($result.state -ceq $case.Expected) "VB-CABLE state mismatch for $($case.Name): $($result.state) ($($result.reason))" if ($case.ContainsKey('Reason')) { Assert-Condition ($result.reason -ceq $case.Reason) "VB-CABLE reason mismatch for $($case.Name)" }