Statistiques
| Révision :

root / tmp / org.txm.setups / nsis / Include / x64.nsh @ 3128

Historique | Voir | Annoter | Télécharger (3,87 ko)

1 728 mdecorde
; ---------------------
2 728 mdecorde
;       x64.nsh
3 728 mdecorde
; ---------------------
4 728 mdecorde
;
5 728 mdecorde
; A few simple macros to handle installations on x64 machines.
6 728 mdecorde
;
7 2956 mdecorde
; RunningX64 checks if the installer is running on a 64-bit OS.
8 2956 mdecorde
; IsWow64 checks if the installer is a 32-bit application running on a 64-bit OS.
9 728 mdecorde
;
10 728 mdecorde
;   ${If} ${RunningX64}
11 2956 mdecorde
;     MessageBox MB_OK "Running on 64-bit Windows"
12 728 mdecorde
;   ${EndIf}
13 728 mdecorde
;
14 2956 mdecorde
; IsNative* checks the OS native CPU architecture.
15 2956 mdecorde
;
16 2956 mdecorde
;   ${If} ${IsNativeAMD64}
17 2956 mdecorde
;     ; Install AMD64 64-bit driver/library
18 2956 mdecorde
;   ${ElseIf} ${IsNativeARM64}
19 2956 mdecorde
;     ; Install ARM64 64-bit driver/library
20 2956 mdecorde
;   ${ElseIf} ${IsNativeIA32}
21 2956 mdecorde
;     ; Install i386 32-bit driver/library
22 2956 mdecorde
;   ${Else}
23 2956 mdecorde
;     Abort "Unsupported CPU architecture!"
24 2956 mdecorde
;   ${EndIf}
25 2956 mdecorde
;
26 2956 mdecorde
;   ${If} ${IsNativeAMD64}
27 2956 mdecorde
;       File "amd64\myapp.exe"
28 2956 mdecorde
;   ${ElseIf} ${IsNativeIA32}
29 2956 mdecorde
;   ${OrIf} ${IsWow64}
30 2956 mdecorde
;       File "x86\myapp.exe"
31 2956 mdecorde
;   ${Else}
32 2956 mdecorde
;       Abort "Unsupported CPU architecture!"
33 2956 mdecorde
;   ${EndIf}
34 2956 mdecorde
;
35 728 mdecorde
; DisableX64FSRedirection disables file system redirection.
36 728 mdecorde
; EnableX64FSRedirection enables file system redirection.
37 728 mdecorde
;
38 728 mdecorde
;   SetOutPath $SYSDIR
39 728 mdecorde
;   ${DisableX64FSRedirection}
40 2956 mdecorde
;   File something.bin # extracts to C:\Windows\System32
41 728 mdecorde
;   ${EnableX64FSRedirection}
42 2956 mdecorde
;   File something.bin # extracts to C:\Windows\SysWOW64
43 728 mdecorde
;
44 728 mdecorde
45 728 mdecorde
!ifndef ___X64__NSH___
46 728 mdecorde
!define ___X64__NSH___
47 728 mdecorde
48 728 mdecorde
!include LogicLib.nsh
49 728 mdecorde
50 2956 mdecorde
51 2956 mdecorde
!define IsWow64 `"" IsWow64 ""`
52 2956 mdecorde
!macro _IsWow64 _a _b _t _f
53 728 mdecorde
  !insertmacro _LOGICLIB_TEMP
54 2956 mdecorde
  System::Call kernel32::GetCurrentProcess()p.s
55 2956 mdecorde
  System::Call kernel32::IsWow64Process2(ps,*i0s,*i) ; [Win10.1511+] 0 if not WOW64
56 2956 mdecorde
  Push |
57 2956 mdecorde
  System::Call kernel32::IsWow64Process(p-1,*i0s) ; [WinXP+] FALSE for a 32-bit application on ARM64!
58 2956 mdecorde
  System::Int64Op
59 728 mdecorde
  Pop $_LOGICLIB_TEMP
60 728 mdecorde
  !insertmacro _!= $_LOGICLIB_TEMP 0 `${_t}` `${_f}`
61 728 mdecorde
!macroend
62 728 mdecorde
63 2956 mdecorde
64 728 mdecorde
!define RunningX64 `"" RunningX64 ""`
65 2956 mdecorde
!macro _RunningX64 _a _b _t _f
66 2956 mdecorde
  !if ${NSIS_PTR_SIZE} > 4
67 2956 mdecorde
    !insertmacro LogicLib_JumpToBranch `${_t}` `${_f}`
68 2956 mdecorde
  !else
69 2956 mdecorde
    !insertmacro _IsWow64 `${_a}` `${_b}` `${_t}` `${_f}`
70 2956 mdecorde
  !endif
71 2956 mdecorde
!macroend
72 728 mdecorde
73 728 mdecorde
74 2956 mdecorde
!define GetNativeMachineArchitecture "!insertmacro GetNativeMachineArchitecture "
75 2956 mdecorde
!macro GetNativeMachineArchitecture outvar
76 2956 mdecorde
  !define GetNativeMachineArchitecture_lbl lbl_GNMA_${__COUNTER__}
77 2956 mdecorde
  System::Call kernel32::GetCurrentProcess()p.s
78 2956 mdecorde
  System::Call kernel32::IsWow64Process2(ps,*i,*i0s)
79 2956 mdecorde
  Pop ${outvar}
80 2956 mdecorde
  IntCmp ${outvar} 0 "" ${GetNativeMachineArchitecture_lbl}_done ${GetNativeMachineArchitecture_lbl}_done
81 2956 mdecorde
    !if "${NSIS_PTR_SIZE}" <= 4
82 2956 mdecorde
    !if "${NSIS_CHAR_SIZE}" <= 1
83 2956 mdecorde
    System::Call 'USER32::CharNextW(w"")p.s'
84 2956 mdecorde
    Pop ${outvar}
85 2956 mdecorde
    IntPtrCmpU ${outvar} 0 "" ${GetNativeMachineArchitecture_lbl}_oldnt ${GetNativeMachineArchitecture_lbl}_oldnt
86 2956 mdecorde
      StrCpy ${outvar} 332 ; Always IMAGE_FILE_MACHINE_I386 on Win9x
87 2956 mdecorde
      Goto ${GetNativeMachineArchitecture_lbl}_done
88 2956 mdecorde
    ${GetNativeMachineArchitecture_lbl}_oldnt:
89 2956 mdecorde
    !endif
90 2956 mdecorde
    !endif
91 2956 mdecorde
    System::Call '*0x7FFE002E(&i2.s)'
92 2956 mdecorde
    Pop ${outvar}
93 2956 mdecorde
  ${GetNativeMachineArchitecture_lbl}_done:
94 2956 mdecorde
  !undef GetNativeMachineArchitecture_lbl
95 2956 mdecorde
!macroend
96 728 mdecorde
97 2956 mdecorde
!macro _IsNativeMachineArchitecture _ignore _arc _t _f
98 2956 mdecorde
  !insertmacro _LOGICLIB_TEMP
99 2956 mdecorde
  ${GetNativeMachineArchitecture} $_LOGICLIB_TEMP
100 2956 mdecorde
  !insertmacro _= $_LOGICLIB_TEMP ${_arc} `${_t}` `${_f}`
101 728 mdecorde
!macroend
102 728 mdecorde
103 2956 mdecorde
!define IsNativeMachineArchitecture `"" IsNativeMachineArchitecture `
104 2956 mdecorde
!define IsNativeIA32 '${IsNativeMachineArchitecture} 332' ; Intel x86
105 2956 mdecorde
!define IsNativeAMD64 '${IsNativeMachineArchitecture} 34404' ; x86-64/x64
106 2956 mdecorde
!define IsNativeARM64 '${IsNativeMachineArchitecture} 43620'
107 2956 mdecorde
108 2956 mdecorde
109 728 mdecorde
!define DisableX64FSRedirection "!insertmacro DisableX64FSRedirection"
110 2956 mdecorde
!macro DisableX64FSRedirection
111 2956 mdecorde
  System::Call kernel32::Wow64EnableWow64FsRedirection(i0)
112 2956 mdecorde
!macroend
113 728 mdecorde
114 2956 mdecorde
!define EnableX64FSRedirection "!insertmacro EnableX64FSRedirection"
115 728 mdecorde
!macro EnableX64FSRedirection
116 728 mdecorde
  System::Call kernel32::Wow64EnableWow64FsRedirection(i1)
117 728 mdecorde
!macroend
118 728 mdecorde
119 728 mdecorde
120 728 mdecorde
!endif # !___X64__NSH___