1# NSIS Script for creating the Windows Vulkan RT installer. 2# 3# Copyright (c) 2015-2016 The Khronos Group Inc. 4# Copyright (c) 2015-2016 Valve Corporation 5# Copyright (c) 2015-2016 LunarG, Inc. 6# 7# Licensed under the Apache License, Version 2.0 (the "License"); 8# you may not use this file except in compliance with the License. 9# You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, software 14# distributed under the License is distributed on an "AS IS" BASIS, 15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16# See the License for the specific language governing permissions and 17# limitations under the License. 18# 19# Author: David Pinedo <david@LunarG.com> 20# Author: Mark Young <mark@LunarG.com> 21# 22 23 24# Version information 25# Set VERSION_BUILDNO to: 26# x.devbuild.z for development builds 27# x for releases 28# 29 30# Set the default name to "Vulkan", but allow this to be overriden 31!ifndef APINAME 32 !define APINAME "Vulkan" 33 !define APILOWER "vulkan" 34!endif 35 36!define PRODUCTNAME "${APINAME}RT" 37 38!ifndef HIDE_VERSION 39 !define VERSION_ABI_MAJOR "1" 40 !define VERSION_API_MAJOR "1" 41 !define VERSION_MINOR "0" 42 !define VERSION_PATCH "12" 43 !define VERSION_BUILDNO "0.devbuild.1" 44!endif 45!ifndef HIDE_PUBLISHER 46 !define PUBLISHER "YourCompany, Inc." 47!endif 48!ifndef COPYRIGHT 49 !define COPYRIGHT "" 50!endif 51#!define VERSION_BUILDNO "0" 52!define PRODUCTVERSION "${VERSION_API_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_BUILDNO}" 53 54# Includes 55!include LogicLib.nsh 56 57# This number is determined by doing an install, and then from Windows Explorer, 58# doing a "Properties" on the install directory. Add to this the size of the 59# files installed to C:\Windows\System32. And then add a little bit more. 60# The units are 1K bytes. 61!define ESTIMATEDSIZE "1700" 62 63# This is used for the error message if a problem occurs during install. 64!define errorMessage1 "Installation of ${PRODUCTNAME} failed!$\r$\n" 65!define errorMessage1un "Uninstall of ${PRODUCTNAME} failed!$\r$\n" 66!define errorMessage2 "Uninstalling any installed items and exiting.$\r$\n" 67 68# Set the icon 69!define ICOFILE "V.ico" 70Icon ${ICOFILE} 71UninstallIcon ${ICOFILE} 72WindowIcon off 73 74# If /DUNINSTALLER was specified, Create the uinstaller 75!ifdef UNINSTALLER 76 !echo "Creating RT uninstaller...." 77 OutFile "$%TEMP%\tempinstaller.exe" 78 SetCompress off 79!else 80 !echo "Creating RT installer...." 81 82 # Define name of installer 83 OutFile "${PRODUCTNAME}-${PRODUCTVERSION}-Installer.exe" 84 SetCompressor /SOLID lzma 85 86!endif 87 88# Define default installation directory 89InstallDir "$PROGRAMFILES\${PRODUCTNAME}\${PRODUCTVERSION}" 90 91# Version string used in file names 92Var FileVersion 93 94# Directory RT was installed to. 95# The uninstaller can't just use $INSTDIR because it is set to the 96# directory the uninstaller exe file is located in. 97!ifdef UNINSTALLER 98Var IDir 99!endif 100 101# Install count 102Var IC 103 104############################################# 105# StrRep - string replace 106 107!define StrRep "!insertmacro StrRep" 108!macro StrRep output string old new 109 Push `${string}` 110 Push `${old}` 111 Push `${new}` 112 !ifdef __UNINSTALL__ 113 Call un.StrRep 114 !else 115 Call StrRep 116 !endif 117 Pop ${output} 118!macroend 119 120!macro Func_StrRep un 121 Function ${un}StrRep 122 Exch $R2 ;new 123 Exch 1 124 Exch $R1 ;old 125 Exch 2 126 Exch $R0 ;string 127 Push $R3 128 Push $R4 129 Push $R5 130 Push $R6 131 Push $R7 132 Push $R8 133 Push $R9 134 135 StrCpy $R3 0 136 StrLen $R4 $R1 137 StrLen $R6 $R0 138 StrLen $R9 $R2 139 loop: 140 StrCpy $R5 $R0 $R4 $R3 141 StrCmp $R5 $R1 found 142 StrCmp $R3 $R6 done 143 IntOp $R3 $R3 + 1 ;move offset by 1 to check the next character 144 Goto loop 145 found: 146 StrCpy $R5 $R0 $R3 147 IntOp $R8 $R3 + $R4 148 StrCpy $R7 $R0 "" $R8 149 StrCpy $R0 $R5$R2$R7 150 StrLen $R6 $R0 151 IntOp $R3 $R3 + $R9 ;move offset by length of the replacement string 152 Goto loop 153 done: 154 155 Pop $R9 156 Pop $R8 157 Pop $R7 158 Pop $R6 159 Pop $R5 160 Pop $R4 161 Pop $R3 162 Push $R0 163 Push $R1 164 Pop $R0 165 Pop $R1 166 Pop $R0 167 Pop $R2 168 Exch $R1 169 FunctionEnd 170!macroend 171!insertmacro Func_StrRep "" 172!insertmacro Func_StrRep "un." 173 174############################################# 175# x64 macros 176 177!define IsWow64 `"" IsWow64 ""` 178!macro _IsWow64 _a _b _t _f 179 !insertmacro _LOGICLIB_TEMP 180 System::Call kernel32::GetCurrentProcess()p.s 181 System::Call kernel32::IsWow64Process(ps,*i0s) 182 Pop $_LOGICLIB_TEMP 183 !insertmacro _!= $_LOGICLIB_TEMP 0 `${_t}` `${_f}` 184!macroend 185 186!define RunningX64 `"" RunningX64 ""` 187!macro _RunningX64 _a _b _t _f 188 !if ${NSIS_PTR_SIZE} > 4 189 !insertmacro LogicLib_JumpToBranch `${_t}` `${_f}` 190 !else 191 !insertmacro _IsWow64 `${_a}` `${_b}` `${_t}` `${_f}` 192 !endif 193!macroend 194 195!define DisableX64FSRedirection "!insertmacro DisableX64FSRedirection" 196!macro DisableX64FSRedirection 197 System::Call kernel32::Wow64EnableWow64FsRedirection(i0) 198!macroend 199 200!define EnableX64FSRedirection "!insertmacro EnableX64FSRedirection" 201!macro EnableX64FSRedirection 202 System::Call kernel32::Wow64EnableWow64FsRedirection(i1) 203!macroend 204 205 206# Need admin to write to C:\Windows\System32 and install dir 207RequestExecutionLevel admin 208 209Function .onInit 210 211!ifdef UNINSTALLER 212 ; Write out the uinstaller and quit 213 WriteUninstaller "$%TEMP%\Uninstall${PRODUCTNAME}.exe" 214 Quit 215!endif 216 217FunctionEnd 218 219; Initialize Explode variables 220Var /GLOBAL explString 221Var /GLOBAL explSeparator 222Var /GLOBAL explStrLen 223Var /GLOBAL explSepLen 224Var /GLOBAL explOffset 225Var /GLOBAL explTmp 226Var /GLOBAL explTmp2 227Var /GLOBAL explTmp3 228Var /GLOBAL explArrCount 229 230!macro Func_Explode un 231Function ${un}Explode 232 ; Get input from user 233 Pop $explString 234 Pop $explSeparator 235 236 ; Calculates initial values 237 StrLen $explStrLen $explString 238 StrLen $explSepLen $explSeparator 239 StrCpy $explArrCount 1 240 241 ${If} $explStrLen <= 1 ; If we got a single character 242 ${OrIf} $explSepLen > $explStrLen ; or separator is larger than the string, 243 Push $explString ; then we return initial string with no change 244 Push 1 ; and set array's length to 1 245 Return 246 ${EndIf} 247 248 ; Set offset to the last symbol of the string 249 StrCpy $explOffset $explStrLen 250 IntOp $explOffset $explOffset - 1 251 252 ; Clear temp string to exclude the possibility of appearance of occasional data 253 StrCpy $explTmp "" 254 StrCpy $explTmp2 "" 255 StrCpy $explTmp3 "" 256 257 ; Loop until the offset becomes negative 258 ${Do} 259 ; If offset becomes negative, it is time to leave the function 260 ${IfThen} $explOffset == -1 ${|} ${ExitDo} ${|} 261 262 ; Remove everything before and after the searched part ("TempStr") 263 StrCpy $explTmp $explString $explSepLen $explOffset 264 265 ${If} $explTmp == $explSeparator 266 ; Calculating offset to start copy from 267 IntOp $explTmp2 $explOffset + $explSepLen ; Offset equals to the current offset plus length of separator 268 StrCpy $explTmp3 $explString "" $explTmp2 269 270 Push $explTmp3 ; Throwing array item to the stack 271 IntOp $explArrCount $explArrCount + 1 ; Increasing array's counter 272 273 StrCpy $explString $explString $explOffset 0 ; Cutting all characters beginning with the separator entry 274 StrLen $explStrLen $explString 275 ${EndIf} 276 277 ${If} $explOffset = 0 ; If the beginning of the line met and there is no separator, 278 ; copying the rest of the string 279 ${If} $explSeparator == "" ; Fix for the empty separator 280 IntOp $explArrCount $explArrCount - 1 281 ${Else} 282 Push $explString 283 ${EndIf} 284 ${EndIf} 285 286 IntOp $explOffset $explOffset - 1 287 ${Loop} 288 289 Push $explArrCount 290FunctionEnd 291!macroend 292!insertmacro Func_Explode "" 293!insertmacro Func_Explode "un." 294 295AddBrandingImage left 150 296Caption "${PRODUCTNAME} ${PRODUCTVERSION} Setup" 297Name "${PRODUCTNAME} ${PRODUCTVERSION}" 298LIcenseData "VULKANRT_LICENSE.rtf" 299Page custom brandimage "" ": Brand Image" 300Page license 301Page directory 302Page instfiles 303UninstallCaption "\${PRODUCTNAME} ${PRODUCTVERSION} Uninstall" 304UninstallText "This wizard will uninstall ${PRODUCTNAME} ${PRODUCTVERSION} from your computer. Click Uninstall to start the uninstallation." 305UninstPage custom un.brandimage "" ": Brand Image" 306UninstPage uninstConfirm 307UninstPage instFiles 308 309# File Properties 310VIProductVersion "${PRODUCTVERSION}" 311VIAddVersionKey "ProductName" "${APINAME} Runtime" 312VIAddVersionKey "FileVersion" "${PRODUCTVERSION}" 313VIAddVersionKey "ProductVersion" "${PRODUCTVERSION}" 314VIAddVersionKey "LegalCopyright" "${COPYRIGHT}" 315 316!ifdef UNINSTALLER 317 VIAddVersionKey "FileDescription" "${APINAME} Runtime Uninstaller" 318!else 319 VIAddVersionKey "FileDescription" "${APINAME} Runtime Installer" 320!endif 321 322 323# Function to run ConfigureRT program. 324# Return value is in $0 - 0 is success, all else is failure. 325!macro ConfigLayersAndVulkanDLL un 326Function ${un}ConfigLayersAndVulkanDLL 327 328 # Execute the configuration program 329 nsExec::ExecToStack 'ConfigureRT.exe --abi-major ${VERSION_ABI_MAJOR} --api-name ${APINAME}' 330 Delete "$TEMP\VulkanRT\configure_rt.log" 331 Rename "configure_rt.log" "$TEMP\VulkanRT\configure_rt.log" 332 pop $0 333 334 ${IF} $0 == 0 335 Pop $1 336 LogText "Output from ConfigureRT: $1" 337 Push ";" 338 Push "$1" 339 Call ${un}Explode 340 Pop $2 341 ${For} $4 1 $2 342 Pop $3 343 Push ">" 344 Push "$3" 345 Call ${un}Explode 346 Pop $5 347 ${IF} "$5" == "2" 348 Pop $6 349 Pop $7 350 CopyFiles /SILENT "$6" "$7" 351 ${ENDIF} 352 ${Next} 353 ${ENDIF} 354 355 # Ignore errors. If something went wrong, the return value will indicate it. 356 ClearErrors 357 358FunctionEnd 359!macroend 360!insertmacro ConfigLayersAndVulkanDLL "" 361!insertmacro ConfigLayersAndVulkanDLL "un." 362 363 364# Function to run diagnostics if ConfigureRT program failed. 365# On entry $0, contains the return value from ConfigureRT.exe. It shouldn't be changed. 366!macro DiagConfigLayersAndVulkanDLL un 367Function ${un}DiagConfigLayersAndVulkanDLL 368 # Report the failure 369 LogText "ConfigureRT.exe failed with return code $0" 370 371 # Ignore errors 372 ClearErrors 373 374FunctionEnd 375!macroend 376!insertmacro DiagConfigLayersAndVulkanDLL "" 377!insertmacro DiagConfigLayersAndVulkanDLL "un." 378 379# Start default section 380Section 381 382 # Turn on logging 383 LogSet on 384 385 # If running on a 64-bit OS machine, disable registry re-direct since we're running as a 32-bit executable. 386 ${If} ${RunningX64} 387 388 ${DisableX64FSRedirection} 389 SetRegView 64 390 391 ${Endif} 392 393 # Create our temp directory, with minimal permissions 394 RmDir /R "$TEMP\VulkanRT" 395 SetOutPath "$TEMP\VulkanRT" 396 AccessControl::DisableFileInheritance $TEMP\VulkanRT 397 AccessControl::SetFileOwner $TEMP\VulkanRT "Administrators" 398 AccessControl::ClearOnFile $TEMP\VulkanRT "Administrators" "FullAccess" 399 AccessControl::SetOnFile $TEMP\VulkanRT "SYSTEM" "FullAccess" 400 AccessControl::GrantOnFile $TEMP\VulkanRT "Everyone" "ListDirectory" 401 AccessControl::GrantOnFile $TEMP\VulkanRT "Everyone" "GenericExecute" 402 AccessControl::GrantOnFile $TEMP\VulkanRT "Everyone" "GenericRead" 403 AccessControl::GrantOnFile $TEMP\VulkanRT "Everyone" "ReadAttributes" 404 StrCpy $1 10 405 Call CheckForError 406 407 # Check the registry to see if we are already installed 408 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "InstallDir" 409 410 # If the registry entry isn't there, it will throw an error as well as return a blank value. So, clear the errors. 411 ${If} ${Errors} 412 413 # Nothing else to do since there is no previous install 414 ClearErrors 415 416 ${Else} 417 418 # Use the previous install directory, so we don't have to keep tracking every possible runtime install. 419 strcmp $INSTDIR $0 notinstalled 420 421 ${If} $0 != "" 422 MessageBox MB_OK "The Windows ${APINAME} Runtime is already installed to $0. It will be re-installed to the same folder." /SD IDOK 423 Strcpy $INSTDIR $0 424 ${Endif} 425 426 notinstalled: 427 428 ${EndIf} 429 430 SetOutPath "$INSTDIR" 431 AccessControl::DisableFileInheritance $INSTDIR 432 AccessControl::SetFileOwner $INSTDIR "Administrators" 433 AccessControl::ClearOnFile $INSTDIR "Administrators" "FullAccess" 434 AccessControl::SetOnFile $INSTDIR "SYSTEM" "FullAccess" 435 AccessControl::GrantOnFile $INSTDIR "Everyone" "ListDirectory" 436 AccessControl::GrantOnFile $INSTDIR "Everyone" "GenericExecute" 437 AccessControl::GrantOnFile $INSTDIR "Everyone" "GenericRead" 438 AccessControl::GrantOnFile $INSTDIR "Everyone" "ReadAttributes" 439 File ${ICOFILE} 440 File VULKANRT_LICENSE.RTF 441 File /oname=LICENSE.txt ..\COPYRIGHT.txt 442 File Release\ConfigureRT.exe 443 StrCpy $1 15 444 Call CheckForError 445 446 # Add the signed uninstaller 447 !ifndef UNINSTALLER 448 SetOutPath $INSTDIR 449 File "Uninstall${PRODUCTNAME}.exe" 450 !endif 451 452 StrCpy $1 20 453 Call CheckForError 454 455 # Reference count the number of times we have been installed. 456 # The reference count is stored in the registry value InstallCount 457 ReadRegDword $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "InstallCount" 458 IntOp $1 $1 + 1 459 StrCpy $IC $1 460 461 # We need to create a new folder for each install. Since we are using counted installs, 462 # an uninstall when the count is greater than one would result in the install 463 # count being decremented and nothing being removed. But Windows Add/Remove Programs 464 # generates a warning Window if the install dir for a package that is removed is not 465 # deleted. So we create a unique folder for each counted install. 466 # We fudge it a little and only create one folder, and rename it after each 467 # install/uninstall. 468 469 # Create the install instance folder. We rename the install instance folder if it already exists. 470 # Then copy the uninstaller to it. 471 ${If} $IC > 2 472 IntOp $1 $IC - 1 473 Rename "$INSTDIR\Instance_$1" "$INSTDIR\Instance_$IC" 474 CopyFiles /SILENT "$INSTDIR\Uninstall${PRODUCTNAME}.exe" "$INSTDIR\Instance_$IC" 475 ${ElseIf} $IC = 2 476 CreateDirectory "$INSTDIR\Instance_$IC" 477 CopyFiles /SILENT "$INSTDIR\Uninstall${PRODUCTNAME}.exe" "$INSTDIR\Instance_$IC" 478 ${EndIf} 479 480 481 # If the registry entry isn't there, it will throw an error as well as return a blank value. So, clear the errors. 482 ${If} ${Errors} 483 ClearErrors 484 ${EndIf} 485 486 # Modify registry for Programs and Features 487 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "DisplayName" "${APINAME} Run Time Libraries ${PRODUCTVERSION}" 488 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "UninstallString" "$INSTDIR\Uninstall${PRODUCTNAME}.exe" 489 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "Publisher" "${PUBLISHER}" 490 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "DisplayVersion" "${PRODUCTVERSION}" 491 WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "EstimatedSize" ${ESTIMATEDSIZE} 492 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "DisplayIcon" "$\"$INSTDIR\${ICOFILE}$\"" 493 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "InstallDir" "$INSTDIR" 494 WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "InstallCount" $IC 495 496 ${If} $IC > 1 497 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "DisplayName" "${APINAME} Run Time Libraries ${PRODUCTVERSION}" 498 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "UninstallString" "$INSTDIR\Instance_$IC\Uninstall${PRODUCTNAME}.exe" 499 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "Publisher" "${PUBLISHER}" 500 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "DisplayVersion" "${PRODUCTVERSION}" 501 WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "EstimatedSize" ${ESTIMATEDSIZE} 502 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "DisplayIcon" "$\"$INSTDIR\${ICOFILE}$\"" 503 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "InstallDir" "$INSTDIR\Instance_$IC" 504 WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "InstallCount" $IC 505 ${EndIf} 506 507 # Set SystemComponent to 1 for those instances that are not to be visible to Add/Remove Programs. 508 # Set SystemComponent to 0 for the instance that is to be visible to Add/Remove Programs. 509 ${If} $IC > 1 510 WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "SystemComponent" 1 511 ${Else} 512 WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "SystemComponent" 1 513 ${EndIf} 514 515 StrCpy $1 25 516 Call CheckForError 517 518 # Set up version number for file names 519 ${StrRep} $0 ${VERSION_BUILDNO} "." "-" 520 StrCpy $FileVersion ${VERSION_ABI_MAJOR}-${VERSION_API_MAJOR}-${VERSION_MINOR}-${VERSION_PATCH}-$0 521 522 # Complete remove the Vulkan Start Menu. Prior version of the Vulkan RT 523 # created Start Menu items, we don't do that anymore. 524 SetShellVarContext all 525 RmDir /R "$SMPROGRAMS\Vulkan" 526 ClearErrors 527 528 # If running on a 64-bit OS machine 529 ${If} ${RunningX64} 530 531 # 32-bit DLLs/EXEs destined for SysWOW64 532 ########################################## 533 SetOutPath $WINDIR\SysWow64 534 File /oname=${APILOWER}-$FileVersion.dll ..\build32\loader\RelWithDebInfo\${APILOWER}-${VERSION_ABI_MAJOR}.dll 535 File /oname=${APILOWER}info-$FileVersion.exe ..\build32\demos\RelWithDebInfo\${APILOWER}info.exe 536 StrCpy $1 30 537 Call CheckForError 538 539 # 64-bit DLLs/EXEs 540 ########################################## 541 SetOutPath $WINDIR\System32 542 File /oname=${APILOWER}-$FileVersion.dll ..\build\loader\RelWithDebInfo\${APILOWER}-${VERSION_ABI_MAJOR}.dll 543 StrCpy $1 35 544 Call CheckForError 545 546 # vulkaninfo.exe 547 File /oname=${APILOWER}info-$FileVersion.exe ..\build\demos\RelWithDebInfo\${APILOWER}info.exe 548 SetOutPath "$INSTDIR" 549 File /oname=${APILOWER}info.exe ..\build\demos\RelWithDebInfo\${APILOWER}info.exe 550 File /oname=${APILOWER}info32.exe ..\build32\demos\RelWithDebInfo\${APILOWER}info.exe 551 StrCpy $1 40 552 Call CheckForError 553 554 # Else, running on a 32-bit OS machine 555 ${Else} 556 557 # 32-bit DLLs/EXEs destined for SysWOW64 558 ########################################## 559 SetOutPath $WINDIR\System32 560 File /oname=${APILOWER}-$FileVersion.dll ..\build32\loader\RelWithDebInfo\${APILOWER}-${VERSION_ABI_MAJOR}.dll 561 StrCpy $1 50 562 Call CheckForError 563 564 # vulkaninfo.exe 565 File /oname=${APILOWER}info-$FileVersion.exe ..\build32\demos\RelWithDebInfo\${APILOWER}info.exe 566 SetOutPath "$INSTDIR" 567 File /oname=${APILOWER}info.exe ..\build32\demos\RelWithDebInfo\${APILOWER}info.exe 568 StrCpy $1 55 569 Call CheckForError 570 571 ${Endif} 572 573 # Run the ConfigureRT program to copy the most recent version of 574 # vulkan-<abimajor>-*.dll to vulkan-<abimajor>.dll, and to set up layer registry 575 # entries to use layers from the corresponding SDK 576 SetOutPath "$INSTDIR" 577 Call ConfigLayersAndVulkanDLL 578 ${If} $0 != 0 579 SetOutPath "$INSTDIR" 580 Call DiagConfigLayersAndVulkanDLL 581 582 # The program failed, and we don't know why. 583 # Simply configure system to use our loader and vulkaninfo. 584 MessageBox MB_OK "Warning!$\n$\nConfigureRT program called by VulkanRT Installer failed with error $0. This may result in an incomplete installation.$\n$\nWill configure system with Vulkan $FileVersion." /SD IDOK 585 ${If} ${RunningX64} 586 Delete $WINDIR\SysWow64\${APILOWER}-${VERSION_ABI_MAJOR}.dll 587 Delete $WINDIR\SysWow64\${APILOWER}info.exe 588 CopyFiles /SILENT $WINDIR\SysWow64\${APILOWER}-$FileVersion.dll $WINDIR\SysWow64\${APILOWER}-${VERSION_ABI_MAJOR}.dll 589 CopyFiles /SILENT $WINDIR\SysWow64\${APILOWER}info-$FileVersion.exe $WINDIR\SysWow64\${APILOWER}info.exe 590 ${Endif} 591 Delete $WINDIR\System32\${APILOWER}-${VERSION_ABI_MAJOR}.dll 592 Delete $WINDIR\System32\${APILOWER}info.exe 593 CopyFiles /SILENT $WINDIR\System32\${APILOWER}-$FileVersion.dll $WINDIR\System32\${APILOWER}-${VERSION_ABI_MAJOR}.dll 594 CopyFiles /SILENT $WINDIR\System32\${APILOWER}info-$FileVersion.exe $WINDIR\System32\${APILOWER}info.exe 595 ClearErrors 596 ${Endif} 597 StrCpy $1 60 598 Call CheckForError 599 600 # We are done using ConfigureRT.exe, delete it. It will be re-installed 601 # by the uninstaller when it needs to be run again during uninstall. 602 Delete ConfigureRT.exe 603 604 # Finish logging and move log file to TEMP dir 605 LogSet off 606 Rename "$INSTDIR\install.log" "$TEMP\VulkanRT\installer.log" 607 608SectionEnd 609 610# Uninstaller section start 611!ifdef UNINSTALLER 612Section "uninstall" 613 # Turn on logging 614 SetOutPath "$TEMP\VulkanRT" 615 StrCpy $INSTDIR "$TEMP\VulkanRT" 616 LogSet on 617 618 # If running on a 64-bit OS machine, disable registry re-direct since we're running as a 32-bit executable. 619 ${If} ${RunningX64} 620 621 ${DisableX64FSRedirection} 622 SetRegView 64 623 624 ${Endif} 625 626 # Look up the install dir and remove files from that directory. 627 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "InstallDir" 628 StrCpy $IDir $0 629 630 StrCpy $1 65 631 Call un.CheckForError 632 633 SetOutPath "$IDir" 634 635 # Set up version number for file names 636 ${StrRep} $0 ${VERSION_BUILDNO} "." "-" 637 StrCpy $FileVersion ${VERSION_ABI_MAJOR}-${VERSION_API_MAJOR}-${VERSION_MINOR}-${VERSION_PATCH}-$0 638 639 # Decrement the number of times we have been installed. 640 ReadRegDword $IC HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "InstallCount" 641 IntOp $1 $IC - 1 642 WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "InstallCount" $1 643 644 # Rename the install dir for this instance if is not the last uninstall 645 ${If} $IC > 2 646 IntOp $1 $IC - 1 647 Rename "$IDir\Instance_$IC" "$IDir\Instance_$1" 648 ${ElseIf} $IC = 2 649 Delete /REBOOTOK "$IDir\Instance_$IC\Uninstall${PRODUCTNAME}.exe" 650 Rmdir /REBOOTOK "$IDir\Instance_$IC" 651 ${Endif} 652 StrCpy $1 70 653 Call un.CheckForError 654 655 # Modify registry for Programs and Features 656 657 ${If} $IC > 1 658 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" 659 ${EndIf} 660 ${If} $IC > 2 661 IntOp $IC $IC - 1 662 WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "SystemComponent" 1 663 ${ElseIf} $IC = 2 664 WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "SystemComponent" 1 665 ${Else} 666 # Last uninstall 667 IntOp $IC $IC - 1 668 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" 669 ${EndIf} 670 StrCpy $1 75 671 Call un.CheckForError 672 673 674 # Install ConfigureRT.exe so we can run it. 675 # It will be deleted later when we remove the install directory. 676 File Release\ConfigureRT.exe 677 678 # If running on a 64-bit OS machine 679 ${If} ${RunningX64} 680 681 # Delete vulkaninfo.exe in C:\Windows\System32 and C:\Windows\SysWOW64 682 Delete /REBOOTOK $WINDIR\SysWow64\${APILOWER}info.exe 683 Delete /REBOOTOK $WINDIR\System32\${APILOWER}info.exe 684 685 # Delete vulkan-<majorabi>.dll in C:\Windows\System32 and C:\Windows\SysWOW64 686 Delete /REBOOTOK $WINDIR\SysWow64\${APILOWER}-${VERSION_ABI_MAJOR}.dll 687 Delete /REBOOTOK $WINDIR\System32\${APILOWER}-${VERSION_ABI_MAJOR}.dll 688 689 # Else, running on a 32-bit OS machine 690 ${Else} 691 692 # Delete vulkaninfo.exe in C:\Windows\System32 693 Delete /REBOOTOK $WINDIR\System32\${APILOWER}info.exe 694 695 # Delete vulkan-<majorabi>.dll in C:\Windows\System32 696 Delete /REBOOTOK $WINDIR\System32\${APILOWER}-${VERSION_ABI_MAJOR}.dll 697 698 ${EndIf} 699 StrCpy $1 80 700 Call un.CheckForError 701 702 # If Ref Count is zero, remove files in C:\Windows\System32 and C:\Windows\SysWow64 703 ${If} $IC <= 0 704 705 ${If} ${RunningX64} 706 # Delete vulkaninfo.exe in C:\Windows\System32 and C:\Windows\SysWOW64 707 Delete /REBOOTOK "$WINDIR\SysWow64\${APILOWER}info-$FileVersion.exe" 708 Delete /REBOOTOK "$WINDIR\System32\${APILOWER}info-$FileVersion.exe" 709 # Delete vulkan-<majorabi>-<major>-<minor>-<patch>-<buildno>.dll from sys dirs 710 Delete /REBOOTOK $WINDIR\SysWow64\${APILOWER}-$FileVersion.dll 711 Delete /REBOOTOK $WINDIR\System32\${APILOWER}-$FileVersion.dll 712 ${Else} 713 # Delete vulkaninfo.exe in C:\Windows\System32 714 Delete /REBOOTOK "$WINDIR\System32\${APILOWER}info-$FileVersion.exe" 715 # Delete vulkan-<majorabi>-<major>-<minor>-<patch>-<buildno>.dll from sys dir 716 Delete /REBOOTOK $WINDIR\System32\${APILOWER}-$FileVersion.dll 717 ${EndIf} 718 719 ${Endif} 720 721 # Run the ConfigureRT.exe program to copy the most recent version of 722 # vulkan-<abimajor>-*.dll to vulkan-<abimajor>.dll, and to set up layer registry 723 # entries to use layers from the corresponding SDK 724 SetOutPath "$IDir" 725 Call un.ConfigLayersAndVulkanDLL 726 ${If} $0 != 0 727 SetOutPath "$IDir" 728 Call un.DiagConfigLayersAndVulkanDLL 729 MessageBox MB_OK "Warning!$\n$\nConfigureRT program called by ${APILOWER} Runtime Installer failed with error $0. This may result in an incomplete uninstall.$\n$\nVulkan $FileVersion has been uninstalled from your system." /SD IDOK 730 ${If} ${RunningX64} 731 Delete $WINDIR\SysWow64\${APILOWER}-${VERSION_ABI_MAJOR}.dll 732 Delete $WINDIR\SysWow64\${APILOWER}info.exe 733 ${Endif} 734 Delete $WINDIR\System32\${APILOWER}-${VERSION_ABI_MAJOR}.dll 735 Delete $WINDIR\System32\${APILOWER}info.exe 736 ClearErrors 737 ${Else} 738 StrCpy $1 85 739 ${Endif} 740 Call un.CheckForError 741 742 # Remove ConfigureRT regardless of the ref count 743 Delete /REBOOTOK "$IDir\ConfigureRT.exe" 744 745 # If Ref Count is zero, remove install dir 746 ${If} $IC <= 0 747 748 # Remove files in install dir 749 Delete /REBOOTOK "$IDir\VULKANRT_LICENSE.rtf" 750 Delete /REBOOTOK "$IDir\LICENSE.txt" 751 Delete /REBOOTOK "$IDir\Uninstall${PRODUCTNAME}.exe" 752 Delete /REBOOTOK "$IDir\V.ico" 753 Delete /REBOOTOK "$IDir\${APILOWER}info.exe" 754 755 # If running on a 64-bit OS machine 756 ${If} ${RunningX64} 757 Delete /REBOOTOK "$IDir\${APILOWER}info32.exe" 758 ${EndIf} 759 760 StrCpy $1 90 761 Call un.CheckForError 762 763 # Need to do a SetOutPath to something outside of install dir, 764 # or the uninstall will think install dir is busy 765 SetOutPath "$TEMP" 766 767 # Remove install directories 768 StrCpy $0 "$IDir" 769 Call un.DeleteDirIfEmpty 770 StrCpy $0 "$PROGRAMFILES\${PRODUCTNAME}" 771 Call un.DeleteDirIfEmpty 772 ClearErrors 773 774 # If any of the remove commands failed, request a reboot 775 IfRebootFlag 0 noreboot 776 MessageBox MB_YESNO "A reboot is required to finish the uninstall. Do you wish to reboot now?" /SD IDNO IDNO returnerror 777 Reboot 778 779 returnerror: 780 781 # Set an error message to output because we should reboot but didn't (whether because silent uninstall or user choice) 782 SetErrorLevel 3 # ERROR_TOO_MANY_OPEN_FILES 783 784 noreboot: 785 786 ${Endif} 787 788 StrCpy $1 95 789 Call un.CheckForError 790 791 # Finish logging 792 LogSet off 793 Rename "$INSTDIR\install.log" "$TEMP\VulkanRT\uninstaller.log" 794 795SectionEnd 796!endif 797 798Function brandimage 799 SetOutPath "$TEMP" 800 SetFileAttributes V.bmp temporary 801 File V.bmp 802 SetBrandingImage "$TEMP/V.bmp" 803Functionend 804 805 806Function un.brandimage 807 SetOutPath "$TEMP" 808 SetFileAttributes V.bmp temporary 809 File V.bmp 810 SetBrandingImage "$TEMP/V.bmp" 811Functionend 812 813Function un.DeleteDirIfEmpty 814 FindFirst $R0 $R1 "$0\*.*" 815 strcmp $R1 "." 0 NoDelete 816 FindNext $R0 $R1 817 strcmp $R1 ".." 0 NoDelete 818 ClearErrors 819 FindNext $R0 $R1 820 IfErrors 0 NoDelete 821 FindClose $R0 822 Sleep 1000 823 RMDir "$0" 824 NoDelete: 825 FindClose $R0 826FunctionEnd 827 828# Check for errors during install. If we hit an error, stop, uninstall what we've put in so far, and quit. 829# NOTE: We return a non-zero error code as well. 830Function CheckForError 831 ${If} ${Errors} 832 # IHV's using this install may want no message box. 833 MessageBox MB_OK|MB_ICONSTOP "${errorMessage1}${errorMessage2}Errorcode: $1$\r$\n" /SD IDOK 834 835 # Finish logging and move log file to TEMP dir 836 LogSet off 837 Rename "$INSTDIR\install.log" "$TEMP\VulkanRT\installer.log" 838 839 # Copy the uninstaller to a temp folder of our own creation so we can completely 840 # delete the old contents. 841 SetOutPath "$TEMP\VulkanRT" 842 CopyFiles "$INSTDIR\Uninstall${PRODUCTNAME}.exe" "$TEMP\VulkanRT" 843 844 # Do uninstall using the version in the temporary folder. 845 ExecWait '"$TEMP\VulkanRT\Uninstall${PRODUCTNAME}.exe" /S _?=$INSTDIR' 846 847 # Delete the copy of the uninstaller we ran 848 Delete /REBOOTOK "$TEMP\VulkanRT\Uninstall${PRODUCTNAME}.exe" 849 850 # Set an error message to output 851 SetErrorLevel $1 852 853 Quit 854 ${EndIf} 855FunctionEnd 856 857# Check for errors during uninstall. If we hit an error, don't attempt 858# to do anything. Just set a non-zero return code and continue. 859Function un.CheckForError 860 ${If} ${Errors} 861 # IHV's using this install may want no message box. 862 MessageBox MB_OK|MB_ICONSTOP "${errorMessage1un}${errorMessage2}Errorcode: $1$\r$\n" /SD IDOK 863 864 # Set an error message to output 865 SetErrorLevel $1 866 867 ${EndIf} 868FunctionEnd 869