WinAPI / WIX - How to detect if the MSI installer is running on ARM64 or x86?

66 views Asked by At

I'm updating an existing installer and want to install specific ARM64 binaries when the OS is running on ARM64. I'm using WIX 3.11 (a bit old, I know) to create the installer. The custom actions are all written in C++.

I've tried:

  • Using QueryNativeMachine from WiX, but I'm not sure how exactly to use it and how to make sure it's performed before the conditions are computed. The documentation also doesn't really specify whether it's supported in 3.11 or if that's something that requires WIX 3.14 or higher.
  • Using GetSystemInfo and GetNativeSystemInfo WinAPI from a custom installer action - both of those return x86 even when running on ARM. I'm guessing that's because the installer itself is built as an x86 WIX project so is probably ran emulated.
  • Currently I'm trying to use IsWow64Process2, but that requires that I update the minimum supported version of the app to Windows 10 (#define _WIN32_WINNT 0x0A00), which is something I'd prefer not to do.

I'd love to get some help on what's the best general way to detect if the current process is running on an ARM64 machine, preferably using the WinAPI. If the QueryNativeMachine is the best option in the context of the installer, I'd love to get some example of its usage. I couldn't find anything on the web related to that.

2

There are 2 answers

0
Christopher Painter On

Windows Installer doesn't support multiple arch packages. You should build x86, x64 and arm64 installers each with binaries compiled for that platform. You can offer your users multiple downloads or wrap them all inside of a bootstrapper package (burn) that conditionally installs the correct MSI for the platform it's being ran on. The bootstrapper can dynamically download the MSI from a website or have all three self contained. It all depends on how big the installers are and what you want to optimize for.

0
Loqaritm On

Thank you for all the answers. The comments helped a bit, but in the meantime, I've been able to answer my questions myself, so I'm going to answer them for posterity if anybody stumbles here:

  1. 'QueryNativeMachine' is available in Wix 3.14 (which is a simple update from 3.11 - please note, I haven't actually checked if this is available on 3.11, you can do so yourself, dear reader, by checking the open source repo for WIX by searching for this function/element), but I haven't been able to understand how to include it as an <element>. There probably is a way, but I've instead opted into using its underlying Custom Action explicitly called in my MSI code.
  2. and 3. - From my investigation, it looks like the only way right now to differentiate between 64bit and ARM64 in the current MSI is to call 'IsWowProcess2' - it's exactly what the WIX uses when calling the above-mentioned element.