Use Win10 WoW64 API to work around ARM64 lies.

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7016 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2018-10-12 20:51:43 +00:00
parent 916f1e4863
commit 000ce91737
4 changed files with 41 additions and 23 deletions

View file

@ -212,6 +212,13 @@
!define PROCESSOR_ARCHITECTURE_ARM64 12
!define PROCESSOR_ARCHITECTURE_ARM32_ON_WIN64 13
!define IMAGE_FILE_MACHINE_UNKNOWN 0
!define IMAGE_FILE_MACHINE_I386 332 ; x86
!define IMAGE_FILE_MACHINE_ARMNT 452
!define IMAGE_FILE_MACHINE_IA64 512 ; Itanium
!define IMAGE_FILE_MACHINE_AMD64 34404 ; x86-64/x64
!define IMAGE_FILE_MACHINE_ARM64 43620
!endif /* __WIN_NOINC_WINNT */
!verbose pop
!endif /* __WIN_WINNT__INC */

View file

@ -43,7 +43,10 @@
!macro _IsWow64 _a _b _t _f
!insertmacro _LOGICLIB_TEMP
System::Call kernel32::GetCurrentProcess()p.s
System::Call kernel32::IsWow64Process(ps,*i0s)
System::Call kernel32::IsWow64Process2(ps,*i0s,*i) ; [Win10.1511+] 0 if not WOW64
Push |
System::Call kernel32::IsWow64Process(p-1,*i0s) ; [WinXP+] FALSE for a 32-bit application on ARM64!
System::Int64Op
Pop $_LOGICLIB_TEMP
!insertmacro _!= $_LOGICLIB_TEMP 0 `${_t}` `${_f}`
!macroend
@ -59,31 +62,39 @@
!macroend
!define GetNativeProcessorArchitecture "!insertmacro GetNativeProcessorArchitecture "
!macro GetNativeProcessorArchitecture outvar
!if ${outvar} != $1
Push $1
!endif
!if "${NSIS_PTR_SIZE}" <= 4
System::Call 'KERNEL32::GetSystemInfo(@r1)' ; < XP
!endif
System::Call 'KERNEL32::GetNativeSystemInfo(@r1)'
System::Call '*$1(&i2.s)' ; Extract wProcessorArchitecture (PROCESSOR_ARCHITECTURE_*)
!define GetNativeMachineArchitecture "!insertmacro GetNativeMachineArchitecture "
!macro GetNativeMachineArchitecture outvar
!define GetNativeMachineArchitecture_lbl lbl_GNMA_${__COUNTER__}
System::Call kernel32::GetCurrentProcess()p.s
System::Call kernel32::IsWow64Process2(ps,*i,*i0s)
Pop ${outvar}
!if ${outvar} != $1
Pop $1
!endif
IntCmp ${outvar} 0 "" ${GetNativeMachineArchitecture_lbl}_done ${GetNativeMachineArchitecture_lbl}_done
!if "${NSIS_PTR_SIZE}" <= 4
!if "${NSIS_CHAR_SIZE}" <= 1
System::Call 'USER32::CharNextW(w"")p.s'
Pop ${outvar}
IntPtrCmpU ${outvar} 0 "" ${GetNativeMachineArchitecture_lbl}_oldnt ${GetNativeMachineArchitecture_lbl}_oldnt
StrCpy ${outvar} 332 ; Always IMAGE_FILE_MACHINE_I386 on Win9x
Goto ${GetNativeMachineArchitecture_lbl}_done
${GetNativeMachineArchitecture_lbl}_oldnt:
!endif
!endif
System::Call '*0x7FFE002E(&i2.s)'
Pop ${outvar}
${GetNativeMachineArchitecture_lbl}_done:
!undef GetNativeMachineArchitecture_lbl
!macroend
!define IsNativeProcessorArchitecture `"" IsNativeProcessorArchitecture `
!macro _IsNativeProcessorArchitecture _ignore _arc _t _f
!macro _IsNativeMachineArchitecture _ignore _arc _t _f
!insertmacro _LOGICLIB_TEMP
${GetNativeProcessorArchitecture} $_LOGICLIB_TEMP
${GetNativeMachineArchitecture} $_LOGICLIB_TEMP
!insertmacro _= $_LOGICLIB_TEMP ${_arc} `${_t}` `${_f}`
!macroend
!define IsNativeIA32 '${IsNativeProcessorArchitecture} 0' ; Intel x86
!define IsNativeAMD64 '${IsNativeProcessorArchitecture} 9' ; x86-64/x64
!define IsNativeARM64 '${IsNativeProcessorArchitecture} 12'
!define IsNativeMachineArchitecture `"" IsNativeMachineArchitecture `
!define IsNativeIA32 '${IsNativeMachineArchitecture} 332' ; Intel x86
!define IsNativeAMD64 '${IsNativeMachineArchitecture} 34404' ; x86-64/x64
!define IsNativeARM64 '${IsNativeMachineArchitecture} 43620'
!define DisableX64FSRedirection "!insertmacro DisableX64FSRedirection"