From 0d294d6306004a495317d21a220e1a64f392fdc4 Mon Sep 17 00:00:00 2001 From: Bob Arnson <bob@joyofsetup.com> Date: Sun, 17 May 2020 17:33:00 -0400 Subject: Port wix3 ARM64 fix. --- src/dutil/procutil.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/dutil/procutil.cpp b/src/dutil/procutil.cpp index 4b34c773..9833d0ec 100644 --- a/src/dutil/procutil.cpp +++ b/src/dutil/procutil.cpp @@ -68,6 +68,24 @@ extern "C" HRESULT DAPI ProcWow64( HRESULT hr = S_OK; BOOL fIsWow64 = FALSE; + typedef BOOL(WINAPI* LPFN_ISWOW64PROCESS2)(HANDLE, USHORT *, USHORT *); + LPFN_ISWOW64PROCESS2 pfnIsWow64Process2 = (LPFN_ISWOW64PROCESS2)::GetProcAddress(::GetModuleHandleW(L"kernel32"), "IsWow64Process2"); + + if (pfnIsWow64Process2) + { + USHORT pProcessMachine = IMAGE_FILE_MACHINE_UNKNOWN; + if (!pfnIsWow64Process2(hProcess, &pProcessMachine, nullptr)) + { + ExitWithLastError(hr, "Failed to check WOW64 process - IsWow64Process2."); + } + + if (pProcessMachine != IMAGE_FILE_MACHINE_UNKNOWN) + { + fIsWow64 = TRUE; + } + } + else + { typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS)(HANDLE, PBOOL); LPFN_ISWOW64PROCESS pfnIsWow64Process = (LPFN_ISWOW64PROCESS)::GetProcAddress(::GetModuleHandleW(L"kernel32"), "IsWow64Process"); @@ -75,7 +93,8 @@ extern "C" HRESULT DAPI ProcWow64( { if (!pfnIsWow64Process(hProcess, &fIsWow64)) { - ExitWithLastError(hr, "Failed to check WOW64 process."); + ExitWithLastError(hr, "Failed to check WOW64 process - IsWow64Process."); + } } } -- cgit v1.2.3-55-g6feb