diff --git a/CHANGELOG.md b/CHANGELOG.md index 4dea723..c22f73a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,13 @@ alongside 0.5.4; macOS remains at 0.5.1. ### Fixed +- **The launcher no longer rejects a 64-bit PC started from a 32-bit parent.** + The platform check read `PROCESSOR_ARCHITECTURE`, which a WOW64 process reports + as `x86`. Starting Luminary from the setup's own finish page (a 32-bit NSIS + process) therefore stopped at "Luminary ships a 64-bit runtime; this PC reports + 'x86'" on ordinary 64-bit Windows. It now reads the machine architecture from + `PROCESSOR_ARCHITEW6432` and `Is64BitOperatingSystem`, so launch context no + longer changes the answer. - **The setup now starts Luminary when "Start Luminary" is ticked.** The finish page ran the launcher with NSIS `Exec`, which passes the path straight to `CreateProcess`. This build ships the PowerShell launcher, so the target was diff --git a/windows/launcher/Luminary.ps1 b/windows/launcher/Luminary.ps1 index d0c487a..be8cc8b 100644 --- a/windows/launcher/Luminary.ps1 +++ b/windows/launcher/Luminary.ps1 @@ -239,6 +239,25 @@ function Get-WindowsBuild { # node.exe ships with it (and -Repair re-downloads it), libvips needs only the # Universal C Runtime that Windows 10/11 already has, and no admin rights are # involved. Verified against the PE imports of node.exe and libvips-42.dll. +# The architecture of the machine, not of this process. Started from a 32-bit +# parent - the setup's finish page, or a SysWOW64 shell - a 64-bit PC still +# reports PROCESSOR_ARCHITECTURE=x86; the real value is in the WOW64 copy, and +# Is64BitOperatingSystem settles it. +function Get-MachineArch { + $arch = $env:PROCESSOR_ARCHITEW6432 + if (-not $arch) { $arch = $env:PROCESSOR_ARCHITECTURE } + $is64 = $false + try { $is64 = [Environment]::Is64BitOperatingSystem } catch { } + if (-not $arch) { $arch = if ($is64) { 'AMD64' } else { 'x86' } } + if ($is64) { + if ($arch -eq 'x86') { $arch = 'AMD64' } + } elseif ($arch -eq 'AMD64' -or $arch -eq 'ARM64') { + # The OS says 32-bit; believe it rather than a stale variable. + $arch = 'x86' + } + return $arch +} + function Test-Platform { $problems = @() $notes = @() @@ -248,7 +267,7 @@ function Test-Platform { $problems += ("Luminary needs Windows 10 or 11. This PC reports build {0}." -f $build) } - $arch = $env:PROCESSOR_ARCHITECTURE + $arch = Get-MachineArch if ($arch -and $arch -ne 'AMD64' -and $arch -ne 'ARM64') { $problems += ("Luminary ships a 64-bit runtime; this PC reports '{0}'." -f $arch) } elseif ($arch -eq 'ARM64') { @@ -521,7 +540,7 @@ if ($Status) { Write-Host 'Luminary is not running.' } $platform = Test-Platform - Write-Host ("System: Windows build {0}, {1}" -f (Get-WindowsBuild), $env:PROCESSOR_ARCHITECTURE) + Write-Host ("System: Windows build {0}, {1}" -f (Get-WindowsBuild), (Get-MachineArch)) foreach ($note in $platform.notes) { Write-Host ("Note: {0}" -f $note) } foreach ($problem in $platform.problems) { Write-Host ("Problem: {0}" -f $problem) } $node = Resolve-Node