14
18
!include FileFunc.nsh
17
!ifndef CallArtificialFunction
18
; The CallArtificialFunction and CallArtificialFunction2 macros are from
19
; Util.nsh in NSIS v2.46-Unicode and have not been modified. They are needed
20
; by TextCompareNoDetail when compiling an installer / uninstaller with NSIS
22
; See <NSIS v2.46-Unicode App Dir >/include/Util.nsh for more information.
24
# see WinVer.nsh and *Func.nsh for usage examples
25
!macro CallArtificialFunction NAME
27
!define CallArtificialFunction_TYPE inst
29
!define CallArtificialFunction_TYPE uninst
31
Call :.${NAME}${CallArtificialFunction_TYPE}
32
!ifndef ${NAME}${CallArtificialFunction_TYPE}_DEFINED
33
Goto ${NAME}${CallArtificialFunction_TYPE}_DONE
34
!define ${NAME}${CallArtificialFunction_TYPE}_DEFINED
35
.${NAME}${CallArtificialFunction_TYPE}:
38
${NAME}${CallArtificialFunction_TYPE}_DONE:
40
!undef CallArtificialFunction_TYPE
42
!define CallArtificialFunction `!insertmacro CallArtificialFunction`
44
# for usage of artificial functions inside artificial functions
45
# macro recursion is prohibited
46
!macro CallArtificialFunction2 NAME
48
!define CallArtificialFunction2_TYPE inst
50
!define CallArtificialFunction2_TYPE uninst
52
Call :.${NAME}${CallArtificialFunction2_TYPE}
53
!ifndef ${NAME}${CallArtificialFunction2_TYPE}_DEFINED
54
Goto ${NAME}${CallArtificialFunction2_TYPE}_DONE
55
!define ${NAME}${CallArtificialFunction2_TYPE}_DEFINED
56
.${NAME}${CallArtificialFunction2_TYPE}:
59
${NAME}${CallArtificialFunction2_TYPE}_DONE:
61
!undef CallArtificialFunction2_TYPE
63
!define CallArtificialFunction2 `!insertmacro CallArtificialFunction2`
67
!ifndef _WINVER_VERXBIT
68
; The following defines and macros are for service pack detection support and
69
; are from WinVer.nsh in NSIS 2.46. They can be removed after building with
70
; NSIS 2.33 is deprecated.
72
!define _WINVER_VERXBIT 0x00000001
74
!define _WINVER_NTBIT 0x80000000
75
!define _WINVER_NTSRVBIT 0x40000000
76
!define _WINVER_MASKSP 0x000F0000
78
!define OSVERSIONINFOW_SIZE 276
79
!define OSVERSIONINFOEXW_SIZE 284
80
!define VER_PLATFORM_WIN32_NT 2
81
!define VER_NT_WORKSTATION 1
83
!macro __WinVer_DeclareVars
85
!ifndef __WINVER_VARS_DECLARED
87
!define __WINVER_VARS_DECLARED
90
Var /GLOBAL __WINVERSP
96
# lazy initialization macro
98
!ifmacrondef __WinVer_Call_GetVersionEx
100
!macro __WinVer_Call_GetVersionEx STRUCT_SIZE
102
System::Call '*$0(i ${STRUCT_SIZE})'
103
System::Call kernel32::GetVersionEx(ir0)i.r3
109
!macro __WinVer_InitVars
111
!insertmacro __WinVer_DeclareVars
113
# only calculate version once
114
StrCmp $__WINVERV "" _winver_noveryet
118
# push used registers on the stack
126
System::Alloc ${OSVERSIONINFOEXW_SIZE}
129
# use OSVERSIONINFOEX
130
!insertmacro __WinVer_Call_GetVersionEx ${OSVERSIONINFOEXW_SIZE}
132
IntCmp $3 0 "" _winver_ex _winver_ex
133
# OSVERSIONINFOEX not allowed (Win9x or NT4 w/SP < 6), use OSVERSIONINFO
134
!insertmacro __WinVer_Call_GetVersionEx ${OSVERSIONINFOW_SIZE}
137
# The original struct formatting string here was:
138
# '*$0(i.s,i.r1,i.r2,i.r3,i.s,&t128.s,&i2.s,&i2,&i2,&i1.s,&i1)'
139
# but in NSIS v2.33u strings take the size in bytes instead of size in chars
140
# so the 128 char '&t128.s' is changed here to '&t256.s'.
141
System::Call '*$0(i.s,i.r1,i.r2,i.r3,i.s,&t256.s,&i2.s,&i2,&i2,&i1.s,&i1)'
146
# win9x has major and minor info in high word of dwBuildNumber - remove it
149
# get dwOSVersionInfoSize
156
IntCmp $0 ${VER_PLATFORM_WIN32_NT} "" _winver_notnt _winver_notnt
157
IntOp $__WINVERSP $__WINVERSP | ${_WINVER_NTBIT}
158
IntOp $__WINVERV $__WINVERV | ${_WINVER_NTBIT}
161
# get service pack information
162
IntCmp $0 ${VER_PLATFORM_WIN32_NT} _winver_nt "" _winver_nt # win9x
170
# discard invalid wServicePackMajor and wProductType
189
IntCmp $R0 ${OSVERSIONINFOEXW_SIZE} "" _winver_sp_noex _winver_sp_noex
191
# discard szCSDVersion
199
IntCmp $0 ${VER_NT_WORKSTATION} _winver_noserver _winver_noserver ""
200
IntOp $__WINVERSP $__WINVERSP | ${_WINVER_NTSRVBIT}
203
# get wServicePackMajor
209
_winver_sp_noex: # OSVERSIONINFO, not OSVERSIONINFOEX
212
## For IsServer to support < NT4SP6, we need to check the registry
213
## here to see if we are a server and/or DC
218
# discard invalid wServicePackMajor and wProductType
222
# get service pack number from text
224
StrCmp $R0 "Service Pack " "" +3
225
StrCpy $0 $0 "" 13 # cut "Service Pack "
227
StrCpy $0 0 # no service pack
229
!ifdef WINVER_NT4_OVER_W95
230
IntOp $__WINVERV $__WINVERV | ${_WINVER_VERXBIT}
237
IntOp $__WINVERSP $__WINVERSP | $0
239
### now for the version
242
IntOp $0 $__WINVERSP & ${_WINVER_NTSRVBIT}
245
IntCmp $0 0 "" _winver_not_xp_x64 _winver_not_xp_x64 # not server
246
IntCmp $1 5 "" _winver_not_xp_x64 _winver_not_xp_x64 # maj 5
247
IntCmp $2 2 "" _winver_not_xp_x64 _winver_not_xp_x64 # min 2
248
# change XP x64 from 5.2 to 5.1 so it's still XP
253
IntCmp $0 0 _winver_not_ntserver # server
254
IntCmp 6 $1 "" "" _winver_not_ntserver # maj 6
255
# extra bit so Server 2008 comes after Vista SP1 that has the same minor version, same for Win7 vs 2008R2
256
IntOp $__WINVERV $__WINVERV | ${_WINVER_VERXBIT}
257
_winver_not_ntserver:
260
IntOp $1 $1 << 24 # VerMajor
261
IntOp $__WINVERV $__WINVERV | $1
263
IntOp $__WINVERV $__WINVERV | $0 # VerMinor
264
IntOp $__WINVERSP $__WINVERSP | $3 # VerBuild
275
!macro _WinVer_GetServicePackLevel OUTVAR
276
${CallArtificialFunction} __WinVer_InitVars
277
IntOp ${OUTVAR} $__WINVERSP & ${_WINVER_MASKSP}
278
IntOp ${OUTVAR} ${OUTVAR} >> 16
280
!define WinVerGetServicePackLevel '!insertmacro _WinVer_GetServicePackLevel '
282
!macro _AtLeastServicePack _a _b _t _f
283
!insertmacro _LOGICLIB_TEMP
284
${WinVerGetServicePackLevel} $_LOGICLIB_TEMP
285
!insertmacro _>= $_LOGICLIB_TEMP `${_b}` `${_t}` `${_f}`
287
!define AtLeastServicePack `"" AtLeastServicePack`
289
!macro _AtMostServicePack _a _b _t _f
290
!insertmacro _LOGICLIB_TEMP
291
${WinVerGetServicePackLevel} $_LOGICLIB_TEMP
292
!insertmacro _<= $_LOGICLIB_TEMP `${_b}` `${_t}` `${_f}`
294
!define AtMostServicePack `"" AtMostServicePack`
296
!macro _IsServicePack _a _b _t _f
297
!insertmacro _LOGICLIB_TEMP
298
${WinVerGetServicePackLevel} $_LOGICLIB_TEMP
299
!insertmacro _= $_LOGICLIB_TEMP `${_b}` `${_t}` `${_f}`
301
!define IsServicePack `"" IsServicePack`
303
!endif # _WINVER_VERXBIT
21
!macro __MOZ__WinVer_DefineOSTests WinVer
22
!insertmacro __WinVer_DefineOSTest AtLeast ${WinVer} ""
23
!insertmacro __WinVer_DefineOSTest AtMost ${WinVer} ""
24
!insertmacro __WinVer_DefineOSTest Is ${WinVer} ""
28
!define WINVER_7 0x06010000 ;6.01.????
29
!insertmacro __MOZ__WinVer_DefineOSTests 7
33
!define WINVER_2008R2 0x06010001 ;6.01.????
34
!insertmacro __MOZ__WinVer_DefineOSTests 2008R2
38
!define WINVER_8 0x06020000 ;6.02.????
39
!insertmacro __MOZ__WinVer_DefineOSTests 8