stub.nsi (5287B)
1 Unicode true 2 3 OutFile "setup-stub.exe" 4 5 ; On real installer executables, test breakpoint checks are no-ops. 6 ; See test_stub.nsi for the test version of this macro. 7 !macro IsTestBreakpointSet breakpointNumber 8 !macroend 9 10 Icon "firefox64.ico" 11 PEAddResource "firefox64.ico" "#Icon" "#0007" 12 !define ICON_ID 0x0007 13 14 !include "LogicLib.nsh" 15 !include "FileFunc.nsh" 16 !include "TextFunc.nsh" 17 !include "WinVer.nsh" 18 !include "WordFunc.nsh" 19 20 !include "stub_shared_defs.nsh" 21 22 Function CheckCpuSupportsSSE 23 ; Don't install on systems that don't support SSE2. The parameter value of 24 ; 10 is for PF_XMMI64_INSTRUCTIONS_AVAILABLE which will check whether the 25 ; SSE2 instruction set is available. 26 System::Call "kernel32::IsProcessorFeaturePresent(i 10)i .R7" 27 StrCpy $CpuSupportsSSE "$R7" 28 FunctionEnd 29 30 !include "stub.nsh" 31 32 Page custom createProfileCleanup 33 Page custom createInstall ; Download / Installation page 34 35 Function CanWrite 36 StrCpy $CanWriteToInstallDir "false" 37 38 StrCpy $0 "$INSTDIR" 39 ; Use the existing directory when it exists 40 ${Unless} ${FileExists} "$INSTDIR" 41 ; Get the topmost directory that exists for new installs 42 ${DoUntil} ${FileExists} "$0" 43 ${GetParent} "$0" $0 44 ${If} "$0" == "" 45 Return 46 ${EndIf} 47 ${Loop} 48 ${EndUnless} 49 50 GetTempFileName $2 "$0" 51 Delete $2 52 CreateDirectory "$2" 53 54 ${If} ${FileExists} "$2" 55 ${If} ${FileExists} "$INSTDIR" 56 GetTempFileName $3 "$INSTDIR" 57 ${Else} 58 GetTempFileName $3 "$2" 59 ${EndIf} 60 ${If} ${FileExists} "$3" 61 Delete "$3" 62 StrCpy $CanWriteToInstallDir "true" 63 ${EndIf} 64 RmDir "$2" 65 ${EndIf} 66 FunctionEnd 67 68 69 70 !define SIZEOF_TASKDIALOGCONFIG_32BIT 96 71 !define TDF_ALLOW_DIALOG_CANCELLATION 0x0008 72 !define TDF_USE_HICON_MAIN 0x0002 73 !define TD_DW_COMMON_BUTTONS_YESNO 6 74 !define TDF_RTL_LAYOUT 0x02000 75 !define TD_WARNING_ICON 0x0FFFF 76 !define TD_IDYES 6 77 78 !insertmacro SetBrandNameVars 79 80 Function PromptForInstall 81 ; Set variables that may not be set yet 82 StrCpy $BrandFullName "${BrandFullName}" 83 StrCpy $BrandShortName "${BrandShortName}" 84 StrCpy $BrandProductName "${BrandProductName}" 85 86 ; Set up flags 87 StrCpy $3 ${TDF_ALLOW_DIALOG_CANCELLATION} 88 IntOp $3 $3 | ${TDF_USE_HICON_MAIN} 89 !ifdef ${AB_CD}_rtl 90 IntOp $3 $3 | ${TDF_RTL_LAYOUT} 91 !endif 92 93 Var /global prompt_hinst 94 Var /global prompt_icon 95 96 System::Call "kernel32::GetModuleHandleW(i 0) i.s" 97 Pop $prompt_hinst 98 99 ; Load the icon 100 System::Call "user32::LoadIconW(i $prompt_hinst, p ${ICON_ID}) p.s" 101 Pop $prompt_icon 102 103 ; Build a TASKDIALOGCONFIG struct 104 System::Call "*(i ${SIZEOF_TASKDIALOGCONFIG_32BIT}, \ 105 p $HWNDPARENT, \ 106 p 0, \ 107 i $3, \ 108 i ${TD_DW_COMMON_BUTTONS_YESNO}, \ 109 w '${BrandFullName}', \ 110 p $prompt_icon, \ 111 w '$(STUB_CANCEL_PROMPT_HEADING)', \ 112 p 0, \ 113 i 0, \ 114 p 0, \ 115 i ${TD_IDYES}, \ 116 i 0, \ 117 p 0, \ 118 i 0, \ 119 p 0, \ 120 p 0, \ 121 p 0, \ 122 p 0, \ 123 p 0, \ 124 p 0, \ 125 p 0, \ 126 p 0, \ 127 i 0 \ 128 ) p.r1" 129 System::Call "comctl32::TaskDialogIndirect(p r1, *i 0 r7, p 0, p 0)" 130 System::Free $1 131 132 ${If} $7 == ${TD_IDYES} 133 Push "yes" 134 ${Else} 135 Push "no" 136 ${EndIf} 137 FunctionEnd 138 139 Function .onInit 140 ; After elevation, this is re-run with /UAC: on the command line. In this 141 ; case, we do not want to prompt the user---they've already been prompted! 142 ${GetParameters} $0 143 ClearErrors 144 ${GetOptions} "$0" "/UAC:" $1 145 ${If} ${Errors} 146 ClearErrors 147 ${GetOptions} "$0" "/Prompt" $1 148 ${IfNot} ${Errors} 149 Call PromptForInstall 150 Pop $0 151 ${If} $0 != "yes" 152 StrCpy $AbortInstallation "true" 153 Quit 154 ${EndIf} 155 ${EndIf} 156 ${EndIf} 157 Call CommonOnInit 158 FunctionEnd 159 160 Function .onUserAbort 161 WebBrowser::CancelTimer $TimerHandle 162 163 ${If} "$IsDownloadFinished" != "" 164 ; Go ahead and cancel the download so it doesn't keep running while this 165 ; prompt is up. We'll resume it if the user decides to continue. 166 InetBgDL::Get /RESET /END 167 168 ${ShowTaskDialog} $(STUB_CANCEL_PROMPT_HEADING) \ 169 $(STUB_CANCEL_PROMPT_MESSAGE) \ 170 $(STUB_CANCEL_PROMPT_BUTTON_CONTINUE) \ 171 $(STUB_CANCEL_PROMPT_BUTTON_EXIT) 172 Pop $0 173 ${If} $0 == 1002 174 ; The cancel button was clicked 175 StrCpy $ExitCode "${ERR_DOWNLOAD_CANCEL}" 176 Call LaunchHelpPage 177 Call SendPing 178 ${Else} 179 ; Either the continue button was clicked or the dialog was dismissed 180 Call StartDownload 181 ${EndIf} 182 ${Else} 183 Call SendPing 184 ${EndIf} 185 186 ; Aborting the abort will allow SendPing to hide the installer window and 187 ; close the installer after it sends the metrics ping, or allow us to just go 188 ; back to installing if that's what the user selected. 189 Abort 190 FunctionEnd 191 192 193 Section 194 SectionEnd