| 1 |
; --------------------- |
| 2 |
; WinVer.nsh |
| 3 |
; --------------------- |
| 4 |
; |
| 5 |
; LogicLib extensions for handling Windows versions and service packs. |
| 6 |
; |
| 7 |
; IsNT checks if the installer is running on Windows NT family (NT4, 2000, XP, etc.) |
| 8 |
; |
| 9 |
; ${If} ${IsNT} |
| 10 |
; DetailPrint "Running on NT. Installing Unicode enabled application." |
| 11 |
; ${Else} |
| 12 |
; DetailPrint "Not running on NT. Installing ANSI application." |
| 13 |
; ${EndIf} |
| 14 |
; |
| 15 |
; IsServerOS checks if the installer is running on a server version of Windows (2000, 2003, 2008, etc.) |
| 16 |
; IsDomainController checks if the server is a domain controller |
| 17 |
; |
| 18 |
; AtLeastWin<version> checks if the installer is running on Windows version at least as specified. |
| 19 |
; IsWin<version> checks if the installer is running on Windows version exactly as specified. |
| 20 |
; AtMostWin<version> checks if the installer is running on Windows version at most as specified. |
| 21 |
; AtLeastBuild <number> checks if the installer is running on a Windows version with a minimum build number. |
| 22 |
; AtMostBuild <number> checks if the installer is running on a Windows version with a maximum build number. |
| 23 |
; AtLeastWaaS <name> and AtMostWaaS <name> checks Windows 10 "friendly names" against the build number. |
| 24 |
; |
| 25 |
; <version> can be replaced with the following values: |
| 26 |
; |
| 27 |
; 95 |
| 28 |
; 98 |
| 29 |
; ME |
| 30 |
; |
| 31 |
; NT4 |
| 32 |
; 2000 |
| 33 |
; XP |
| 34 |
; 2003 |
| 35 |
; Vista |
| 36 |
; 2008 |
| 37 |
; 7 |
| 38 |
; 2008R2 |
| 39 |
; 8 |
| 40 |
; 2012 |
| 41 |
; 8.1 |
| 42 |
; 2012R2 |
| 43 |
; 10 |
| 44 |
; 11 |
| 45 |
; |
| 46 |
; Note: Windows 8.1 and later will be detected as Windows 8 unless ManifestSupportedOS is set correctly! |
| 47 |
; |
| 48 |
; AtLeastServicePack checks if the installer is running on Windows service pack version at least as specified. |
| 49 |
; IsServicePack checks if the installer is running on Windows service pack version exactly as specified. |
| 50 |
; AtMostServicePack checks if the installer is running on Windows service version pack at most as specified. |
| 51 |
; |
| 52 |
; Usage examples: |
| 53 |
; |
| 54 |
; ${If} ${IsNT} |
| 55 |
; DetailPrint "Running on NT family." |
| 56 |
; DetailPrint "Surely not running on 95, 98 or ME." |
| 57 |
; ${AndIf} ${AtLeastWinNT4} |
| 58 |
; DetailPrint "Running on NT4 or better. Could even be 2003." |
| 59 |
; ${EndIf} |
| 60 |
; |
| 61 |
; ${If} ${AtLeastWinXP} |
| 62 |
; DetailPrint "Running on XP or better." |
| 63 |
; ${EndIf} |
| 64 |
; |
| 65 |
; ${If} ${IsWin2000} |
| 66 |
; DetailPrint "Running on 2000." |
| 67 |
; ${EndIf} |
| 68 |
; |
| 69 |
; ${If} ${IsWin2000} |
| 70 |
; ${AndIf} ${AtLeastServicePack} 3 |
| 71 |
; ${OrIf} ${AtLeastWinXP} |
| 72 |
; DetailPrint "Running Win2000 SP3 or above" |
| 73 |
; ${EndIf} |
| 74 |
; |
| 75 |
; ${If} ${AtMostWinXP} |
| 76 |
; DetailPrint "Running on XP or older. Surely not running on Vista. Maybe 98, or even 95." |
| 77 |
; ${EndIf} |
| 78 |
; |
| 79 |
; Warning: |
| 80 |
; |
| 81 |
; Windows 95 and NT both use the same version number. To avoid getting NT4 misidentified |
| 82 |
; as Windows 95 and vice-versa or 98 as a version higher than NT4, always use IsNT to |
| 83 |
; check if running on the NT family. |
| 84 |
; |
| 85 |
; ${If} ${AtLeastWin95} |
| 86 |
; ${AndIf} ${AtMostWinME} |
| 87 |
; DetailPrint "Running 95, 98 or ME." |
| 88 |
; DetailPrint "Actually, maybe it's NT4?" |
| 89 |
; ${If} ${IsNT} |
| 90 |
; DetailPrint "Yes, it's NT4! oops..." |
| 91 |
; ${Else} |
| 92 |
; DetailPrint "Nope, not NT4. phew..." |
| 93 |
; ${EndIf} |
| 94 |
; ${EndIf} |
| 95 |
; |
| 96 |
; |
| 97 |
; Other useful extensions are: |
| 98 |
; |
| 99 |
; * IsWin2003R2 |
| 100 |
; * IsStarterEdition |
| 101 |
; * OSHasMediaCenter |
| 102 |
; * OSHasTabletSupport |
| 103 |
; |
| 104 |
|
| 105 |
!verbose push |
| 106 |
!verbose 3 |
| 107 |
|
| 108 |
!ifndef ___WINVER__NSH___ |
| 109 |
!define ___WINVER__NSH___ |
| 110 |
|
| 111 |
!include LogicLib.nsh |
| 112 |
!include Util.nsh |
| 113 |
|
| 114 |
# masks for our variables |
| 115 |
|
| 116 |
!define _WINVER_VERXBIT 0x00000001 ; Used to boost $__WINVERV |
| 117 |
!define _WINVER_MASKVMAJ 0x7F000000 ; $__WINVERV mask |
| 118 |
!define _WINVER_MASKVMIN 0x00FF0000 ; $__WINVERV mask |
| 119 |
!define _WINVER_NTMASK 0x7FFFFFFF ; $__WINVERV mask used by AtMost/AtLeast |
| 120 |
!define _WINVER_NTBIT 0x80000000 ; $__WINVERV bit used by Is and $__WINVERSP bit used by IsNT |
| 121 |
!define _WINVER_NTSRVBIT 0x40000000 ; $__WINVERSP bit for !VER_NT_WORKSTATION |
| 122 |
!define _WINVER_NTDCBIT 0x20000000 ; $__WINVERSP bit for VER_NT_DOMAIN_CONTROLLER |
| 123 |
!define _WINVER_MASKVBLD 0x0000FFFF ; $__WINVERSP mask for OS build number |
| 124 |
!define _WINVER_MASKSP 0x000F0000 ; $__WINVERSP mask for OS service pack |
| 125 |
|
| 126 |
# possible variable values for different versions |
| 127 |
|
| 128 |
!define WINVER_95_NT 0x04000000 ;4.00.0950 |
| 129 |
!define WINVER_95 0x04000000 ;4.00.0950 |
| 130 |
!define WINVER_98_NT 0x040a0000 ;4.10.1998 |
| 131 |
!define WINVER_98 0x040a0000 ;4.10.1998 |
| 132 |
;define WINVER_98SE 0x040a0000 ;4.10.2222 |
| 133 |
!define WINVER_ME_NT 0x045a0000 ;4.90.3000 |
| 134 |
!define WINVER_ME 0x045a0000 ;4.90.3000 |
| 135 |
;define WINVER_NT3.51 ;3.51.1057 |
| 136 |
!define WINVER_NT4_NT 0x84000000 ;4.00.1381 |
| 137 |
!define WINVER_NT4 0x04000000 ;4.00.1381 |
| 138 |
!define WINVER_2000_NT 0x85000000 ;5.00.2195 |
| 139 |
!define WINVER_2000 0x05000000 ;5.00.2195 |
| 140 |
!define WINVER_XP_NT 0x85010000 ;5.01.2600 |
| 141 |
!define WINVER_XP 0x05010000 ;5.01.2600 |
| 142 |
;define WINVER_XP64 ;5.02.3790 |
| 143 |
!define WINVER_2003_NT 0x85020000 ;5.02.3790 |
| 144 |
!define WINVER_2003 0x05020000 ;5.02.3790 |
| 145 |
!define WINVER_VISTA_NT 0x86000000 ;6.00.6000 |
| 146 |
!define WINVER_VISTA 0x06000000 ;6.00.6000 |
| 147 |
!define WINVER_2008_NT 0x86000001 ;6.00.6001 |
| 148 |
!define WINVER_2008 0x06000001 ;6.00.6001 |
| 149 |
!define WINVER_7_NT 0x86010000 ;6.01.7600 |
| 150 |
!define WINVER_7 0x06010000 ;6.01.7600 |
| 151 |
!define WINVER_2008R2_NT 0x86010001 ;6.01.7600 |
| 152 |
!define WINVER_2008R2 0x06010001 ;6.01.7600 |
| 153 |
!define WINVER_8_NT 0x86020000 ;6.02.9200 |
| 154 |
!define WINVER_8 0x06020000 ;6.02.9200 |
| 155 |
!define WINVER_2012_NT 0x86020001 ;6.02.9200 |
| 156 |
!define WINVER_2012 0x06020001 ;6.02.9200 |
| 157 |
!define WINVER_8.1_NT 0x86030000 ;6.03.9600 |
| 158 |
!define WINVER_8.1 0x06030000 ;6.03.9600 |
| 159 |
!define WINVER_2012R2_NT 0x86030001 ;6.03.9600 |
| 160 |
!define WINVER_2012R2 0x06030001 ;6.03.9600 |
| 161 |
!define WINVER_10_NT 0x8A000000 ;10.0.10240 |
| 162 |
!define WINVER_10 0x0A000000 ;10.0.10240 |
| 163 |
!define WINVER_2016_NT 0x8A000001 ;10.0.14393 |
| 164 |
!define WINVER_2016 0x0A000001 ;10.0.14393 |
| 165 |
|
| 166 |
|
| 167 |
# use this to make all nt > 9x |
| 168 |
|
| 169 |
!ifdef WINVER_NT4_OVER_W95 |
| 170 |
!define /redef /math WINVER_NT4 ${WINVER_NT4} | ${_WINVER_VERXBIT} |
| 171 |
!endif |
| 172 |
|
| 173 |
# some definitions from header files |
| 174 |
|
| 175 |
!define OSVERSIONINFOW_SIZE 276 |
| 176 |
!define OSVERSIONINFOEXW_SIZE 284 |
| 177 |
!define OSVERSIONINFOA_SIZE 148 |
| 178 |
!define OSVERSIONINFOEXA_SIZE 156 |
| 179 |
!define /ifndef VER_PLATFORM_WIN32_NT 2 |
| 180 |
!define /ifndef VER_NT_WORKSTATION 1 |
| 181 |
!define /ifndef VER_NT_DOMAIN_CONTROLLER 2 |
| 182 |
!define /ifndef VER_NT_SERVER 3 |
| 183 |
|
| 184 |
!define SM_TABLETPC 86 |
| 185 |
!define SM_MEDIACENTER 87 |
| 186 |
!define SM_STARTER 88 |
| 187 |
!define SM_SERVERR2 89 |
| 188 |
|
| 189 |
# variable declaration |
| 190 |
|
| 191 |
!macro __WinVer_DeclareVars |
| 192 |
|
| 193 |
!ifndef __WINVER_VARS_DECLARED |
| 194 |
|
| 195 |
!define __WINVER_VARS_DECLARED |
| 196 |
|
| 197 |
Var /GLOBAL __WINVERV |
| 198 |
Var /GLOBAL __WINVERSP |
| 199 |
|
| 200 |
!endif |
| 201 |
|
| 202 |
!macroend |
| 203 |
|
| 204 |
!macro __WinVer_Optimize |
| 205 |
!ifndef __WINVER_NOOPTIMIZE |
| 206 |
!if "${NSIS_CHAR_SIZE}" > 1 |
| 207 |
!define /ReDef AtMostWin95 '"" LogicLib_AlwaysFalse ""' |
| 208 |
!define /ReDef AtMostWin98 '"" LogicLib_AlwaysFalse ""' |
| 209 |
!define /ReDef AtMostWinME '"" LogicLib_AlwaysFalse ""' |
| 210 |
!define /ReDef IsWin95 '"" LogicLib_AlwaysFalse ""' |
| 211 |
!define /ReDef IsWin98 '"" LogicLib_AlwaysFalse ""' |
| 212 |
!define /ReDef IsWinME '"" LogicLib_AlwaysFalse ""' |
| 213 |
!endif |
| 214 |
!if "${NSIS_PTR_SIZE}" > 4 |
| 215 |
!define /ReDef AtMostWin95 '"" LogicLib_AlwaysFalse ""' |
| 216 |
!define /ReDef AtMostWin98 '"" LogicLib_AlwaysFalse ""' |
| 217 |
!define /ReDef AtMostWinME '"" LogicLib_AlwaysFalse ""' |
| 218 |
!define /ReDef AtMostWinNT4 '"" LogicLib_AlwaysFalse ""' |
| 219 |
!define /ReDef IsWin95 '"" LogicLib_AlwaysFalse ""' |
| 220 |
!define /ReDef IsWin98 '"" LogicLib_AlwaysFalse ""' |
| 221 |
!define /ReDef IsWinME '"" LogicLib_AlwaysFalse ""' |
| 222 |
!define /ReDef IsWinNT4 '"" LogicLib_AlwaysFalse ""' |
| 223 |
!define /ReDef AtLeastWin95 '"" LogicLib_AlwaysTrue ""' |
| 224 |
!define /ReDef AtLeastWin98 '"" LogicLib_AlwaysTrue ""' |
| 225 |
!define /ReDef AtLeastWinME '"" LogicLib_AlwaysTrue ""' |
| 226 |
!define /ReDef AtLeastWinNT4 '"" LogicLib_AlwaysTrue ""' |
| 227 |
!define /ReDef AtLeastWin2000 '"" LogicLib_AlwaysTrue ""' |
| 228 |
!endif |
| 229 |
!ifdef NSIS_ARM | NSIS_ARM32 | NSIS_ARMNT | NSIS_ARM64 |
| 230 |
!define /ReDef AtMostWin2000 '"" LogicLib_AlwaysFalse ""' |
| 231 |
!define /ReDef AtMostWinXP '"" LogicLib_AlwaysFalse ""' |
| 232 |
!define /ReDef AtMostWin2003 '"" LogicLib_AlwaysFalse ""' |
| 233 |
!define /ReDef AtMostWinVista '"" LogicLib_AlwaysFalse ""' |
| 234 |
!define /ReDef AtMostWin7 '"" LogicLib_AlwaysFalse ""' |
| 235 |
!define /ReDef IsWin95 '"" LogicLib_AlwaysFalse ""' |
| 236 |
!define /ReDef IsWin98 '"" LogicLib_AlwaysFalse ""' |
| 237 |
!define /ReDef IsWinME '"" LogicLib_AlwaysFalse ""' |
| 238 |
!define /ReDef IsWinNT4 '"" LogicLib_AlwaysFalse ""' |
| 239 |
!define /ReDef IsWin2000 '"" LogicLib_AlwaysFalse ""' |
| 240 |
!define /ReDef IsWinXP '"" LogicLib_AlwaysFalse ""' |
| 241 |
!define /ReDef IsWin2003 '"" LogicLib_AlwaysFalse ""' |
| 242 |
!define /ReDef IsWinVista '"" LogicLib_AlwaysFalse ""' |
| 243 |
!define /ReDef IsWin2008 '"" LogicLib_AlwaysFalse ""' |
| 244 |
!define /ReDef IsWin7 '"" LogicLib_AlwaysFalse ""' |
| 245 |
!define /ReDef IsWin2008R2 '"" LogicLib_AlwaysFalse ""' |
| 246 |
!define /ReDef AtLeastWin95 '"" LogicLib_AlwaysTrue ""' |
| 247 |
!define /ReDef AtLeastWin98 '"" LogicLib_AlwaysTrue ""' |
| 248 |
!define /ReDef AtLeastWinME '"" LogicLib_AlwaysTrue ""' |
| 249 |
!define /ReDef AtLeastWinNT4 '"" LogicLib_AlwaysTrue ""' |
| 250 |
!define /ReDef AtLeastWin2000 '"" LogicLib_AlwaysTrue ""' |
| 251 |
!define /ReDef AtLeastWinXP '"" LogicLib_AlwaysTrue ""' |
| 252 |
!define /ReDef AtLeastWin2003 '"" LogicLib_AlwaysTrue ""' |
| 253 |
!define /ReDef AtLeastWinVista '"" LogicLib_AlwaysTrue ""' |
| 254 |
!define /ReDef AtLeastWin2008 '"" LogicLib_AlwaysTrue ""' |
| 255 |
!define /ReDef AtLeastWin7 '"" LogicLib_AlwaysTrue ""' |
| 256 |
!define /ReDef AtLeastWin2008R2 '"" LogicLib_AlwaysTrue ""' |
| 257 |
!define /ReDef AtLeastWin8 '"" LogicLib_AlwaysTrue ""' |
| 258 |
!endif |
| 259 |
!endif |
| 260 |
!macroend |
| 261 |
|
| 262 |
# lazy initialization macro |
| 263 |
|
| 264 |
!define /IfNDef __WinVer_GWV GetWinVer |
| 265 |
|
| 266 |
!macro __WinVer_InitVars_NEW |
| 267 |
!insertmacro __WinVer_DeclareVars |
| 268 |
!insertmacro __WinVer_Optimize |
| 269 |
|
| 270 |
# only calculate version once |
| 271 |
StrCmp $__WINVERV "" _winver_noveryet |
| 272 |
Return |
| 273 |
_winver_noveryet: |
| 274 |
|
| 275 |
Push $0 |
| 276 |
${__WinVer_GWV} $0 Product |
| 277 |
${__WinVer_GWV} $__WINVERV NTDDIMajMin |
| 278 |
IntOp $__WINVERV $__WINVERV << 16 ; _WINVER_MASKVMAJ & _WINVER_MASKVMIN |
| 279 |
IntOp $__WINVERSP $0 & 2 |
| 280 |
IntOp $__WINVERSP $__WINVERSP << 29 ; _WINVER_NTSRVBIT & _WINVER_NTDCBIT |
| 281 |
!ifndef NSIS_ARM64 |
| 282 |
IntCmp $__WINVERSP 0 notServer |
| 283 |
IntCmpU 0x06000000 $__WINVERV "" "" not2008 ; ${If} $__WINVERV U>= 0x06000000 |
| 284 |
IntCmpU 0x09000000 $__WINVERV not2008 not2008 "" ; ${AndIf} $__WINVERV U< 0x09000000 |
| 285 |
IntOp $__WINVERV $__WINVERV | ${_WINVER_VERXBIT} ; Extra bit so Server 2008 comes after Vista SP1 that has the same minor version, same for Win7 vs 2008R2 |
| 286 |
not2008: |
| 287 |
Goto endServer |
| 288 |
notServer: |
| 289 |
IntCmp $__WINVERV 0x05020000 "" notXP64 notXP64 |
| 290 |
StrCpy $__WINVERV 0x05010000 ; Change XP 64-bit from 5.2 to 5.1 so it's still XP |
| 291 |
notXP64: |
| 292 |
endServer: |
| 293 |
!endif |
| 294 |
|
| 295 |
IntCmp $0 0 notNT |
| 296 |
!if "${NSIS_PTR_SIZE}" <= 4 |
| 297 |
!ifdef WINVER_NT4_OVER_W95 |
| 298 |
IntCmp $__WINVERV 0x04000000 "" nt4eq95 nt4eq95 |
| 299 |
IntOp $__WINVERV $__WINVERV | ${_WINVER_VERXBIT} ; change NT 4.0.reserved.0 to 4.0.reserved.1 |
| 300 |
nt4eq95: |
| 301 |
!endif |
| 302 |
!endif |
| 303 |
IntOp $__WINVERSP $__WINVERSP | ${_WINVER_NTBIT} ; _WINVER_NTBIT |
| 304 |
IntOp $__WINVERV $__WINVERV | ${_WINVER_NTBIT} ; _WINVER_NTBIT |
| 305 |
notNT: |
| 306 |
|
| 307 |
${__WinVer_GWV} $0 Build |
| 308 |
IntOp $__WINVERSP $__WINVERSP | $0 ; _WINVER_MASKVBLD |
| 309 |
${__WinVer_GWV} $0 ServicePack |
| 310 |
IntOp $0 $0 << 16 |
| 311 |
IntOp $__WINVERSP $__WINVERSP | $0 ; _WINVER_MASKSP |
| 312 |
Pop $0 |
| 313 |
!macroend |
| 314 |
|
| 315 |
!ifmacrondef __WinVer_Call_GetVersionEx |
| 316 |
|
| 317 |
!macro __WinVer_Call_GetVersionEx STRUCT_SIZE |
| 318 |
|
| 319 |
System::Call '*$0(i ${STRUCT_SIZE})' |
| 320 |
System::Call kernel32::GetVersionEx(pr0)i.r3 |
| 321 |
|
| 322 |
!macroend |
| 323 |
|
| 324 |
!endif |
| 325 |
|
| 326 |
!macro __WinVer_InitVars_OLD |
| 327 |
# variables |
| 328 |
!insertmacro __WinVer_DeclareVars |
| 329 |
!insertmacro __WinVer_Optimize |
| 330 |
|
| 331 |
# only calculate version once |
| 332 |
StrCmp $__WINVERV "" _winver_noveryet |
| 333 |
Return |
| 334 |
_winver_noveryet: |
| 335 |
|
| 336 |
# push used registers on the stack |
| 337 |
Push $0 |
| 338 |
Push $1 ;maj |
| 339 |
Push $2 ;min |
| 340 |
Push $3 ;bld |
| 341 |
Push $R0 ;temp |
| 342 |
|
| 343 |
# a plugin call will lock the Unicode mode, it is now safe to set the struct size |
| 344 |
!ifdef NSIS_UNICODE |
| 345 |
!define /redef OSVERSIONINFO_SIZE ${OSVERSIONINFOW_SIZE} |
| 346 |
!define /redef OSVERSIONINFOEX_SIZE ${OSVERSIONINFOEXW_SIZE} |
| 347 |
!else |
| 348 |
!define /redef OSVERSIONINFO_SIZE ${OSVERSIONINFOA_SIZE} |
| 349 |
!define /redef OSVERSIONINFOEX_SIZE ${OSVERSIONINFOEXA_SIZE} |
| 350 |
!endif |
| 351 |
|
| 352 |
# allocate memory |
| 353 |
System::Call '*(&i${OSVERSIONINFOEX_SIZE})p.r0' |
| 354 |
|
| 355 |
# use OSVERSIONINFOEX |
| 356 |
!insertmacro __WinVer_Call_GetVersionEx ${OSVERSIONINFOEX_SIZE} |
| 357 |
|
| 358 |
IntCmp $3 0 "" _winver_ex _winver_ex |
| 359 |
# OSVERSIONINFOEX not allowed (Win9x or NT4 w/SP < 6), use OSVERSIONINFO |
| 360 |
!insertmacro __WinVer_Call_GetVersionEx ${OSVERSIONINFO_SIZE} |
| 361 |
_winver_ex: |
| 362 |
|
| 363 |
# get results from struct |
| 364 |
System::Call '*$0(i.s,i.r1,i.r2,i.r3,i.s,&t128.s,&i2.s,&i2,&i2,&i1.s,&i1)' |
| 365 |
|
| 366 |
# free struct |
| 367 |
System::Free $0 |
| 368 |
|
| 369 |
# win9x has major and minor info in high word of dwBuildNumber - remove it |
| 370 |
IntOp $3 $3 & 0xFFFF |
| 371 |
|
| 372 |
# get dwOSVersionInfoSize |
| 373 |
Pop $R0 |
| 374 |
|
| 375 |
# get dwPlatformId |
| 376 |
Pop $0 |
| 377 |
|
| 378 |
# NT? |
| 379 |
IntCmp $0 ${VER_PLATFORM_WIN32_NT} "" _winver_notnt _winver_notnt |
| 380 |
IntOp $__WINVERSP $__WINVERSP | ${_WINVER_NTBIT} |
| 381 |
IntOp $__WINVERV $__WINVERV | ${_WINVER_NTBIT} |
| 382 |
_winver_notnt: |
| 383 |
!ifndef NSIS_UNICODE |
| 384 |
!if "${NSIS_PTR_SIZE}" <= 4 |
| 385 |
# get service pack information |
| 386 |
IntCmp $0 ${VER_PLATFORM_WIN32_NT} _winver_nt "" _winver_nt # win9x |
| 387 |
|
| 388 |
# get szCSDVersion |
| 389 |
Pop $0 |
| 390 |
|
| 391 |
# copy second char |
| 392 |
StrCpy $0 $0 1 1 |
| 393 |
|
| 394 |
# discard invalid wServicePackMajor and wProductType |
| 395 |
Pop $R0 |
| 396 |
Pop $R0 |
| 397 |
|
| 398 |
# switch |
| 399 |
StrCmp $0 'A' "" +3 |
| 400 |
StrCpy $0 1 |
| 401 |
Goto _winver_sp_done |
| 402 |
StrCmp $0 'B' "" +3 |
| 403 |
StrCpy $0 2 |
| 404 |
Goto _winver_sp_done |
| 405 |
StrCmp $0 'C' "" +3 |
| 406 |
StrCpy $0 3 |
| 407 |
Goto _winver_sp_done |
| 408 |
StrCpy $0 0 |
| 409 |
Goto _winver_sp_done |
| 410 |
|
| 411 |
_winver_nt: # nt |
| 412 |
!endif #~ 32-bit |
| 413 |
!endif #~ ANSI |
| 414 |
IntCmp $R0 ${OSVERSIONINFOEX_SIZE} "" _winver_sp_noex _winver_sp_noex |
| 415 |
|
| 416 |
# discard szCSDVersion |
| 417 |
Pop $0 |
| 418 |
|
| 419 |
# get wProductType |
| 420 |
Exch |
| 421 |
Pop $0 |
| 422 |
|
| 423 |
# is server? |
| 424 |
IntCmp $0 ${VER_NT_WORKSTATION} _winver_nt_notsrv |
| 425 |
IntOp $__WINVERSP $__WINVERSP | ${_WINVER_NTSRVBIT} |
| 426 |
IntCmp $0 ${VER_NT_DOMAIN_CONTROLLER} "" _winver_nt_notdc _winver_nt_notdc |
| 427 |
IntOp $__WINVERSP $__WINVERSP | ${_WINVER_NTDCBIT} |
| 428 |
_winver_nt_notdc: |
| 429 |
_winver_nt_notsrv: |
| 430 |
|
| 431 |
# get wServicePackMajor |
| 432 |
Pop $0 |
| 433 |
|
| 434 |
# done with sp |
| 435 |
Goto _winver_sp_done |
| 436 |
|
| 437 |
_winver_sp_noex: # OSVERSIONINFO, not OSVERSIONINFOEX |
| 438 |
|
| 439 |
#### TODO |
| 440 |
## For IsServerOS to support < NT4SP6, we need to check the registry |
| 441 |
## here to see if we are a server and/or DC |
| 442 |
|
| 443 |
# get szCSDVersion |
| 444 |
Pop $0 |
| 445 |
|
| 446 |
# discard invalid wServicePackMajor and wProductType |
| 447 |
Pop $R0 |
| 448 |
Pop $R0 |
| 449 |
|
| 450 |
# get service pack number from text |
| 451 |
StrCpy $R0 $0 13 |
| 452 |
StrCmp $R0 "Service Pack " "" +3 |
| 453 |
StrCpy $0 $0 "" 13 # cut "Service Pack " |
| 454 |
Goto +2 |
| 455 |
StrCpy $0 0 # no service pack |
| 456 |
|
| 457 |
!ifdef WINVER_NT4_OVER_W95 |
| 458 |
IntOp $__WINVERV $__WINVERV | ${_WINVER_VERXBIT} ; change NT 4.0.reserved.0 to 4.0.reserved.1 |
| 459 |
!endif |
| 460 |
|
| 461 |
_winver_sp_done: |
| 462 |
|
| 463 |
# store service pack |
| 464 |
IntOp $0 $0 << 16 |
| 465 |
IntOp $__WINVERSP $__WINVERSP | $0 |
| 466 |
|
| 467 |
### now for the version |
| 468 |
|
| 469 |
# is server? |
| 470 |
IntOp $0 $__WINVERSP & ${_WINVER_NTSRVBIT} |
| 471 |
|
| 472 |
# windows xp x64? |
| 473 |
IntCmp $0 0 "" _winver_not_xp_x64 _winver_not_xp_x64 # not server |
| 474 |
IntCmp $1 5 "" _winver_not_xp_x64 _winver_not_xp_x64 # maj 5 |
| 475 |
IntCmp $2 2 "" _winver_not_xp_x64 _winver_not_xp_x64 # min 2 |
| 476 |
# change XP x64 from 5.2 to 5.1 so it's still XP |
| 477 |
StrCpy $2 1 |
| 478 |
_winver_not_xp_x64: |
| 479 |
|
| 480 |
# server 2008? |
| 481 |
IntCmp $0 0 _winver_not_ntserver # server |
| 482 |
IntCmp 6 $1 "" "" _winver_not_ntserver # maj 6 |
| 483 |
# extra bit so Server 2008 comes after Vista SP1 that has the same minor version, same for Win7 vs 2008R2 |
| 484 |
IntOp $__WINVERV $__WINVERV | ${_WINVER_VERXBIT} |
| 485 |
_winver_not_ntserver: |
| 486 |
|
| 487 |
# pack version |
| 488 |
IntOp $1 $1 << 24 # VerMajor |
| 489 |
IntOp $__WINVERV $__WINVERV | $1 |
| 490 |
IntOp $0 $2 << 16 |
| 491 |
IntOp $__WINVERV $__WINVERV | $0 # VerMinor |
| 492 |
IntOp $__WINVERSP $__WINVERSP | $3 # VerBuild |
| 493 |
|
| 494 |
# restore registers |
| 495 |
Pop $R0 |
| 496 |
Pop $3 |
| 497 |
Pop $2 |
| 498 |
Pop $1 |
| 499 |
Pop $0 |
| 500 |
|
| 501 |
!macroend |
| 502 |
|
| 503 |
!macro __WinVer_InitVars |
| 504 |
!ifndef WinVer_v3_7 |
| 505 |
!insertmacro __WinVer_InitVars_NEW |
| 506 |
!else |
| 507 |
!insertmacro __WinVer_InitVars_OLD |
| 508 |
!endif |
| 509 |
!macroend |
| 510 |
|
| 511 |
# version comparison LogicLib macros |
| 512 |
|
| 513 |
!macro _WinVerAtLeast _a _b _t _f |
| 514 |
!insertmacro _LOGICLIB_TEMP |
| 515 |
${CallArtificialFunction} __WinVer_InitVars |
| 516 |
IntOp $_LOGICLIB_TEMP $__WINVERV & ${_WINVER_NTMASK} |
| 517 |
!insertmacro _>= $_LOGICLIB_TEMP `${_b}` `${_t}` `${_f}` |
| 518 |
!macroend |
| 519 |
!macro _WinVerIs _a _b _t _f |
| 520 |
${CallArtificialFunction} __WinVer_InitVars |
| 521 |
!insertmacro _= $__WINVERV `${_b}` `${_t}` `${_f}` |
| 522 |
!macroend |
| 523 |
!macro _WinVerAtMost _a _b _t _f |
| 524 |
!insertmacro _LOGICLIB_TEMP |
| 525 |
${CallArtificialFunction} __WinVer_InitVars |
| 526 |
IntOp $_LOGICLIB_TEMP $__WINVERV & ${_WINVER_NTMASK} |
| 527 |
!insertmacro _<= $_LOGICLIB_TEMP `${_b}` `${_t}` `${_f}` |
| 528 |
!macroend |
| 529 |
|
| 530 |
!macro __WinVer_DefineOSTest Test OS Suffix |
| 531 |
!define ${Test}Win${OS} `"" WinVer${Test} ${WINVER_${OS}${Suffix}}` |
| 532 |
!macroend |
| 533 |
|
| 534 |
!macro __WinVer_DefineOSTests Test Suffix |
| 535 |
!insertmacro __WinVer_DefineOSTest ${Test} 95 '${Suffix}' |
| 536 |
!insertmacro __WinVer_DefineOSTest ${Test} 98 '${Suffix}' |
| 537 |
!insertmacro __WinVer_DefineOSTest ${Test} ME '${Suffix}' |
| 538 |
!insertmacro __WinVer_DefineOSTest ${Test} NT4 '${Suffix}' |
| 539 |
!insertmacro __WinVer_DefineOSTest ${Test} 2000 '${Suffix}' |
| 540 |
!insertmacro __WinVer_DefineOSTest ${Test} XP '${Suffix}' |
| 541 |
!insertmacro __WinVer_DefineOSTest ${Test} 2003 '${Suffix}' |
| 542 |
!insertmacro __WinVer_DefineOSTest ${Test} VISTA '${Suffix}' |
| 543 |
!insertmacro __WinVer_DefineOSTest ${Test} 2008 '${Suffix}' |
| 544 |
!insertmacro __WinVer_DefineOSTest ${Test} 7 '${Suffix}' |
| 545 |
!insertmacro __WinVer_DefineOSTest ${Test} 2008R2 '${Suffix}' |
| 546 |
!insertmacro __WinVer_DefineOSTest ${Test} 8 '${Suffix}' |
| 547 |
!insertmacro __WinVer_DefineOSTest ${Test} 2012 '${Suffix}' |
| 548 |
!insertmacro __WinVer_DefineOSTest ${Test} 8.1 '${Suffix}' |
| 549 |
!insertmacro __WinVer_DefineOSTest ${Test} 2012R2 '${Suffix}' |
| 550 |
!insertmacro __WinVer_DefineOSTest ${Test} 10 '${Suffix}' |
| 551 |
!insertmacro __WinVer_DefineOSTest ${Test} 2016 '${Suffix}' |
| 552 |
!define /IfNDef AtLeastWin11 'U>= WinVer_BuildNumCheck 22000' |
| 553 |
!define /IfNDef AtMostWin11 'U<= WinVer_BuildNumCheck 22000' |
| 554 |
!macroend |
| 555 |
|
| 556 |
!insertmacro __WinVer_DefineOSTests AtLeast "" |
| 557 |
!insertmacro __WinVer_DefineOSTests Is _NT |
| 558 |
!insertmacro __WinVer_DefineOSTests AtMost "" |
| 559 |
|
| 560 |
# version feature LogicLib macros |
| 561 |
|
| 562 |
!macro __WinVer_LL_IsBitSet _v _b _t _f |
| 563 |
!insertmacro _LOGICLIB_TEMP |
| 564 |
${CallArtificialFunction} __WinVer_InitVars |
| 565 |
IntOp $_LOGICLIB_TEMP ${_v} & ${_b} |
| 566 |
!insertmacro _!= $_LOGICLIB_TEMP 0 `${_t}` `${_f}` |
| 567 |
!macroend |
| 568 |
|
| 569 |
!define IsNT `$__WINVERSP _WinVer_LL_IsBitSet ${_WINVER_NTBIT}` |
| 570 |
!define IsServerOS `$__WINVERSP _WinVer_LL_IsBitSet ${_WINVER_NTSRVBIT}` |
| 571 |
!define IsDomainController `$__WINVERSP _WinVer_LL_IsBitSet ${_WINVER_NTDCBIT}` |
| 572 |
|
| 573 |
# service pack macros |
| 574 |
|
| 575 |
!macro _WinVer_GetServicePackLevel OUTVAR |
| 576 |
!ifndef WinVer_v3_7 |
| 577 |
${__WinVer_GWV} ${OUTVAR} ServicePack |
| 578 |
!else |
| 579 |
${CallArtificialFunction} __WinVer_InitVars |
| 580 |
IntOp ${OUTVAR} $__WINVERSP & ${_WINVER_MASKSP} |
| 581 |
IntOp ${OUTVAR} ${OUTVAR} >> 16 |
| 582 |
!endif |
| 583 |
!macroend |
| 584 |
!define WinVerGetServicePackLevel '!insertmacro _WinVer_GetServicePackLevel ' |
| 585 |
|
| 586 |
!macro _AtLeastServicePack _a _b _t _f |
| 587 |
!insertmacro _LOGICLIB_TEMP |
| 588 |
${WinVerGetServicePackLevel} $_LOGICLIB_TEMP |
| 589 |
!insertmacro _>= $_LOGICLIB_TEMP `${_b}` `${_t}` `${_f}` |
| 590 |
!macroend |
| 591 |
!define AtLeastServicePack `"" AtLeastServicePack` |
| 592 |
|
| 593 |
!macro _AtMostServicePack _a _b _t _f |
| 594 |
!insertmacro _LOGICLIB_TEMP |
| 595 |
${WinVerGetServicePackLevel} $_LOGICLIB_TEMP |
| 596 |
!insertmacro _<= $_LOGICLIB_TEMP `${_b}` `${_t}` `${_f}` |
| 597 |
!macroend |
| 598 |
!define AtMostServicePack `"" AtMostServicePack` |
| 599 |
|
| 600 |
!macro _IsServicePack _a _b _t _f |
| 601 |
!insertmacro _LOGICLIB_TEMP |
| 602 |
${WinVerGetServicePackLevel} $_LOGICLIB_TEMP |
| 603 |
!insertmacro _= $_LOGICLIB_TEMP `${_b}` `${_t}` `${_f}` |
| 604 |
!macroend |
| 605 |
!define IsServicePack `"" IsServicePack` |
| 606 |
|
| 607 |
# special feature LogicLib macros |
| 608 |
|
| 609 |
!macro _WinVer_SysMetricCheck m _b _t _f |
| 610 |
!insertmacro _LOGICLIB_TEMP |
| 611 |
System::Call user32::GetSystemMetrics(i${m})i.s |
| 612 |
pop $_LOGICLIB_TEMP |
| 613 |
!insertmacro _!= $_LOGICLIB_TEMP 0 `${_t}` `${_f}` |
| 614 |
!macroend |
| 615 |
|
| 616 |
!define IsWin2003R2 `${SM_SERVERR2} WinVer_SysMetricCheck ""` |
| 617 |
!define IsStarterEdition `${SM_STARTER} WinVer_SysMetricCheck ""` |
| 618 |
!define OSHasMediaCenter `${SM_MEDIACENTER} WinVer_SysMetricCheck ""` |
| 619 |
!define OSHasTabletSupport `${SM_TABLETPC} WinVer_SysMetricCheck ""` |
| 620 |
!define IsSafeBootMode `67 WinVer_SysMetricCheck ""` |
| 621 |
|
| 622 |
# version retrieval macros |
| 623 |
|
| 624 |
!macro __WinVer_GetVer var rshift mask outvar |
| 625 |
${CallArtificialFunction} __WinVer_InitVars |
| 626 |
!if "${mask}" != "" |
| 627 |
IntOp ${outvar} ${var} & ${mask} |
| 628 |
!if "${rshift}" != "" |
| 629 |
IntOp ${outvar} ${outvar} >> ${rshift} |
| 630 |
!endif |
| 631 |
!else |
| 632 |
IntOp ${outvar} ${var} >> ${rshift} |
| 633 |
!endif |
| 634 |
!macroend |
| 635 |
|
| 636 |
!define WinVerGetMajor '!insertmacro __WinVer_GetVer $__WINVERV 24 ${_WINVER_MASKVMAJ}' |
| 637 |
!define WinVerGetMinor '!insertmacro __WinVer_GetVer $__WINVERV 16 ${_WINVER_MASKVMIN}' |
| 638 |
!ifndef WinVer_v3_7 |
| 639 |
!macro __WinVer_GetVerBuild outvar |
| 640 |
${__WinVer_GWV} ${outvar} Build |
| 641 |
!macroend |
| 642 |
!define WinVerGetBuild '!insertmacro __WinVer_GetVerBuild ' |
| 643 |
!else |
| 644 |
!define WinVerGetBuild '!insertmacro __WinVer_GetVer $__WINVERSP "" ${_WINVER_MASKVBLD}' |
| 645 |
!endif |
| 646 |
|
| 647 |
!macro _WinVer_BuildNumCheck op num _t _f |
| 648 |
!insertmacro _LOGICLIB_TEMP |
| 649 |
${WinVerGetBuild} $_LOGICLIB_TEMP |
| 650 |
!insertmacro _${op} $_LOGICLIB_TEMP ${num} `${_t}` `${_f}` |
| 651 |
!macroend |
| 652 |
!define AtLeastBuild `U>= WinVer_BuildNumCheck ` |
| 653 |
!define AtMostBuild `U<= WinVer_BuildNumCheck ` |
| 654 |
|
| 655 |
# Windows as a Service macros |
| 656 |
|
| 657 |
!macro WinVer_WaaS id build fu codename marketingname |
| 658 |
!if "${id}" == "?" |
| 659 |
# Ignore |
| 660 |
!else if "${id}" == ${fu} |
| 661 |
!define WinVer_WaaS_Build ${build} |
| 662 |
!else if "${id}" == "${codename}" |
| 663 |
!define WinVer_WaaS_Build ${build} |
| 664 |
!else if "${id}" == "${marketingname}" |
| 665 |
!define WinVer_WaaS_Build ${build} |
| 666 |
!endif |
| 667 |
!macroend |
| 668 |
|
| 669 |
!macro _WinVer_WaaS op id _t _f |
| 670 |
!insertmacro WinVer_WaaS "${id}" 10240 1507 "Threshold" "Windows 10" ; 10240.16384 |
| 671 |
!insertmacro WinVer_WaaS "${id}" 10586 1511 "Threshold 2" "November Update" ; 10586.0? |
| 672 |
!insertmacro WinVer_WaaS "${id}" 14393 1607 "Redstone" "Anniversary Update" ; 14393.10 |
| 673 |
!insertmacro WinVer_WaaS "${id}" 15063 1703 "Redstone 2" "Creators Update" ; 15063.13 |
| 674 |
!insertmacro WinVer_WaaS "${id}" 16299 1709 "Redstone 3" "Fall Creators Update" ; 16299.19 |
| 675 |
!insertmacro WinVer_WaaS "${id}" 17134 1803 "Redstone 4" "April 2018 Update" ; 17134.1 |
| 676 |
!insertmacro WinVer_WaaS "${id}" 17763 1809 "Redstone 5" "October 2018 Update" ; 17763.1 |
| 677 |
!insertmacro WinVer_WaaS "${id}" 18362 1903 "19H1" "May 2019 Update" ; 18362.116 |
| 678 |
!insertmacro WinVer_WaaS "${id}" 18363 1909 "19H2" "November 2019 Update" ; 18363.418 |
| 679 |
!insertmacro WinVer_WaaS "${id}" 19041 2004 "20H1" "May 2020 Update" ; 19041.264? |
| 680 |
!insertmacro WinVer_WaaS "${id}" 19042 20H2 "20H2" "October 2020 Update" ; 19042.572? A.K.A. 2009 |
| 681 |
!insertmacro WinVer_WaaS "${id}" 19043 21H1 "21H1" "May 2021 Update" ; 19043.928 |
| 682 |
!insertmacro WinVer_WaaS "${id}" 19044 21H2 "21H2" "November 2021 Update" ; 19044.1288 |
| 683 |
!insertmacro WinVer_WaaS "${id}" 19045 "?" "?" "October 2022 Update" ; 19045.2130 22H2 |
| 684 |
!insertmacro WinVer_WaaS "${id}" 22000 "?" "Sun Valley" "Windows 11" ; 10.0.22000.194 21H2 |
| 685 |
!insertmacro WinVer_WaaS "${id}" 22621 22H2 "Sun Valley 2" "2022 Update" ; 10.0.22621.521 |
| 686 |
!insertmacro WinVer_WaaS "${id}" 22631 23H2 "Sun Valley 3" "2023 Update" |
| 687 |
!insertmacro WinVer_WaaS "${id}" 26100 24H2 "Hudson Valley" "2024 Update" |
| 688 |
|
| 689 |
!ifmacrodef WinVerExternal_WaaS_MapToBuild |
| 690 |
!insertmacro WinVerExternal_WaaS_MapToBuild ${op} "${id}" WinVer_WaaS_Build |
| 691 |
!endif |
| 692 |
!define /IfNDef WinVer_WaaS_Build 0 |
| 693 |
!if "${WinVer_WaaS_Build}" <= 9600 |
| 694 |
!error 'WinVer: Unknown WaaS name: ${id}' |
| 695 |
!endif |
| 696 |
!insertmacro _WinVer_BuildNumCheck ${op} ${WinVer_WaaS_Build} `${_t}` `${_f}` |
| 697 |
!undef WinVer_WaaS_Build |
| 698 |
!macroend |
| 699 |
|
| 700 |
!define AtLeastWaaS `U>= WinVer_WaaS ` |
| 701 |
!define AtMostWaaS `U<= WinVer_WaaS ` |
| 702 |
|
| 703 |
!endif # !___WINVER__NSH___ |
| 704 |
|
| 705 |
!verbose pop |