Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 7 additions & 20 deletions installer/ArSonMix.iss
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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;
Expand Down
46 changes: 29 additions & 17 deletions installer/ArSonMixVBCableInstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -21,35 +20,47 @@ 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
}
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
Expand Down Expand Up @@ -98,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 {
Expand Down
49 changes: 49 additions & 0 deletions scripts/test_inno_graceful_update_windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,54 @@ $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'; 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('RecordedBoot')) {
New-Item -ItemType Directory -Force -Path (Split-Path -Parent $status) | Out-Null
@{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): $($result.state) ($($result.reason))"
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 |
Expand All @@ -41,6 +89,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"
Expand Down
26 changes: 11 additions & 15 deletions tests/windows_installer_contract_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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=/);
Expand Down Expand Up @@ -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/);
Expand Down
Loading