Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 ################################################################################
7 # Helper defines and macros for toolkit applications
9 /**
10 * Avoid creating macros / functions that overwrite registers (see the
11 * GetLongPath macro for one way to avoid this)!
12 *
13 * Before using the registers exchange the passed in params and save existing
14 * register values to the stack.
15 *
16 * Exch $R9 ; exhange the original $R9 with the top of the stack
17 * Exch 1 ; exchange the top of the stack with 1 below the top of the stack
18 * Exch $R8 ; exchange the original $R8 with the top of the stack
19 * Exch 2 ; exchange the top of the stack with 2 below the top of the stack
20 * Exch $R7 ; exchange the original $R7 with the top of the stack
21 * Push $R6 ; push the original $R6 onto the top of the stack
22 * Push $R5 ; push the original $R5 onto the top of the stack
23 * Push $R4 ; push the original $R4 onto the top of the stack
24 *
25 * <do stuff>
26 *
27 * ; Restore the values.
28 * Pop $R4 ; restore the value for $R4 from the top of the stack
29 * Pop $R5 ; restore the value for $R5 from the top of the stack
30 * Pop $R6 ; restore the value for $R6 from the top of the stack
31 * Exch $R7 ; exchange the new $R7 value with the top of the stack
32 * Exch 2 ; exchange the top of the stack with 2 below the top of the stack
33 * Exch $R8 ; exchange the new $R8 value with the top of the stack
34 * Exch 1 ; exchange the top of the stack with 2 below the top of the stack
35 * Exch $R9 ; exchange the new $R9 value with the top of the stack
36 *
37 *
38 * When inserting macros in common.nsh from another macro in common.nsh that
39 * can be used from the uninstaller _MOZFUNC_UN will be undefined when it is
40 * inserted. Use the following to redefine _MOZFUNC_UN with its original value
41 * (see the RegCleanMain macro for an example).
42 *
43 * !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
44 * !insertmacro ${_MOZFUNC_UN_TMP}FileJoin
45 * !insertmacro ${_MOZFUNC_UN_TMP}LineFind
46 * !insertmacro ${_MOZFUNC_UN_TMP}TextCompareNoDetails
47 * !insertmacro ${_MOZFUNC_UN_TMP}TrimNewLines
48 * !undef _MOZFUNC_UN
49 * !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
50 * !undef _MOZFUNC_UN_TMP
51 */
53 ; When including a file provided by NSIS check if its verbose macro is defined
54 ; to prevent loading the file a second time.
55 !ifmacrondef TEXTFUNC_VERBOSE
56 !include TextFunc.nsh
57 !endif
59 !ifmacrondef FILEFUNC_VERBOSE
60 !include FileFunc.nsh
61 !endif
63 !ifmacrondef LOGICLIB_VERBOSITY
64 !include LogicLib.nsh
65 !endif
67 !ifndef WINMESSAGES_INCLUDED
68 !include WinMessages.nsh
69 !endif
71 ; When including WinVer.nsh check if ___WINVER__NSH___ is defined to prevent
72 ; loading the file a second time.
73 !ifndef ___WINVER__NSH___
74 !include WinVer.nsh
75 !endif
77 !include x64.nsh
79 ; NSIS provided macros that we have overridden.
80 !include overrides.nsh
82 !define SHORTCUTS_LOG "shortcuts_log.ini"
83 !define TO_BE_DELETED "tobedeleted"
85 ; !define SHCNF_DWORD 0x0003
86 ; !define SHCNF_FLUSH 0x1000
87 !ifndef SHCNF_DWORDFLUSH
88 !define SHCNF_DWORDFLUSH 0x1003
89 !endif
90 !ifndef SHCNE_ASSOCCHANGED
91 !define SHCNE_ASSOCCHANGED 0x08000000
92 !endif
94 ################################################################################
95 # Macros for debugging
97 /**
98 * The following two macros assist with verifying that a macro doesn't
99 * overwrite any registers.
100 *
101 * Usage:
102 * ${debugSetRegisters}
103 * <do stuff>
104 * ${debugDisplayRegisters}
105 */
107 /**
108 * Sets all register values to their name to assist with verifying that a macro
109 * doesn't overwrite any registers.
110 */
111 !macro debugSetRegisters
112 StrCpy $0 "$$0"
113 StrCpy $1 "$$1"
114 StrCpy $2 "$$2"
115 StrCpy $3 "$$3"
116 StrCpy $4 "$$4"
117 StrCpy $5 "$$5"
118 StrCpy $6 "$$6"
119 StrCpy $7 "$$7"
120 StrCpy $8 "$$8"
121 StrCpy $9 "$$9"
122 StrCpy $R0 "$$R0"
123 StrCpy $R1 "$$R1"
124 StrCpy $R2 "$$R2"
125 StrCpy $R3 "$$R3"
126 StrCpy $R4 "$$R4"
127 StrCpy $R5 "$$R5"
128 StrCpy $R6 "$$R6"
129 StrCpy $R7 "$$R7"
130 StrCpy $R8 "$$R8"
131 StrCpy $R9 "$$R9"
132 !macroend
133 !define debugSetRegisters "!insertmacro debugSetRegisters"
135 /**
136 * Displays all register values to assist with verifying that a macro doesn't
137 * overwrite any registers.
138 */
139 !macro debugDisplayRegisters
140 MessageBox MB_OK \
141 "Register Values:$\n\
142 $$0 = $0$\n$$1 = $1$\n$$2 = $2$\n$$3 = $3$\n$$4 = $4$\n\
143 $$5 = $5$\n$$6 = $6$\n$$7 = $7$\n$$8 = $8$\n$$9 = $9$\n\
144 $$R0 = $R0$\n$$R1 = $R1$\n$$R2 = $R2$\n$$R3 = $R3$\n$$R4 = $R4$\n\
145 $$R5 = $R5$\n$$R6 = $R6$\n$$R7 = $R7$\n$$R8 = $R8$\n$$R9 = $R9"
146 !macroend
147 !define debugDisplayRegisters "!insertmacro debugDisplayRegisters"
150 ################################################################################
151 # Modern User Interface (MUI) override macros
153 ; Removed macros in nsis 2.33u (ported from nsis 2.22)
154 ; MUI_LANGUAGEFILE_DEFINE
155 ; MUI_LANGUAGEFILE_LANGSTRING_PAGE
156 ; MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE
157 ; MUI_LANGUAGEFILE_LANGSTRING_DEFINE
158 ; MUI_LANGUAGEFILE_UNLANGSTRING_PAGE
160 !macro MOZ_MUI_LANGUAGEFILE_DEFINE DEFINE NAME
162 !ifndef "${DEFINE}"
163 !define "${DEFINE}" "${${NAME}}"
164 !endif
165 !undef "${NAME}"
167 !macroend
169 !macro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE PAGE NAME
171 !ifdef MUI_${PAGE}PAGE
172 LangString "${NAME}" 0 "${${NAME}}"
173 !undef "${NAME}"
174 !else
175 !undef "${NAME}"
176 !endif
178 !macroend
180 !macro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE PAGE NAME
182 !ifdef MUI_${PAGE}PAGE | MUI_UN${PAGE}PAGE
183 LangString "${NAME}" 0 "${${NAME}}"
184 !undef "${NAME}"
185 !else
186 !undef "${NAME}"
187 !endif
189 !macroend
191 !macro MOZ_MUI_LANGUAGEFILE_LANGSTRING_DEFINE DEFINE NAME
193 !ifdef "${DEFINE}"
194 LangString "${NAME}" 0 "${${NAME}}"
195 !endif
196 !undef "${NAME}"
198 !macroend
200 !macro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE PAGE NAME
202 !ifdef MUI_UNINSTALLER
203 !ifdef MUI_UN${PAGE}PAGE
204 LangString "${NAME}" 0 "${${NAME}}"
205 !undef "${NAME}"
206 !else
207 !undef "${NAME}"
208 !endif
209 !else
210 !undef "${NAME}"
211 !endif
213 !macroend
215 ; Modified version of the following MUI macros to support Mozilla localization.
216 ; MUI_LANGUAGE
217 ; MUI_LANGUAGEFILE_BEGIN
218 ; MOZ_MUI_LANGUAGEFILE_END
219 ; See <NSIS App Dir>/Contrib/Modern UI/System.nsh for more information
220 !define MUI_INSTALLOPTIONS_READ "!insertmacro MUI_INSTALLOPTIONS_READ"
222 !macro MOZ_MUI_LANGUAGE LANGUAGE
223 !verbose push
224 !verbose ${MUI_VERBOSE}
225 !include "${LANGUAGE}.nsh"
226 !verbose pop
227 !macroend
229 !macro MOZ_MUI_LANGUAGEFILE_BEGIN LANGUAGE
230 !insertmacro MUI_INSERT
231 !ifndef "MUI_LANGUAGEFILE_${LANGUAGE}_USED"
232 !define "MUI_LANGUAGEFILE_${LANGUAGE}_USED"
233 LoadLanguageFile "${LANGUAGE}.nlf"
234 !else
235 !error "Modern UI language file ${LANGUAGE} included twice!"
236 !endif
237 !macroend
239 ; Custom version of MUI_LANGUAGEFILE_END. The macro to add the default MUI
240 ; strings and the macros for several strings that are part of the NSIS MUI and
241 ; not in our locale files have been commented out.
242 !macro MOZ_MUI_LANGUAGEFILE_END
244 # !include "${NSISDIR}\Contrib\Modern UI\Language files\Default.nsh"
245 !ifdef MUI_LANGUAGEFILE_DEFAULT_USED
246 !undef MUI_LANGUAGEFILE_DEFAULT_USED
247 !warning "${LANGUAGE} Modern UI language file version doesn't match. Using default English texts for missing strings."
248 !endif
250 !insertmacro MOZ_MUI_LANGUAGEFILE_DEFINE "MUI_${LANGUAGE}_LANGNAME" "MUI_LANGNAME"
252 !ifndef MUI_LANGDLL_PUSHLIST
253 !define MUI_LANGDLL_PUSHLIST "'${MUI_${LANGUAGE}_LANGNAME}' ${LANG_${LANGUAGE}} "
254 !else
255 !ifdef MUI_LANGDLL_PUSHLIST_TEMP
256 !undef MUI_LANGDLL_PUSHLIST_TEMP
257 !endif
258 !define MUI_LANGDLL_PUSHLIST_TEMP "${MUI_LANGDLL_PUSHLIST}"
259 !undef MUI_LANGDLL_PUSHLIST
260 !define MUI_LANGDLL_PUSHLIST "'${MUI_${LANGUAGE}_LANGNAME}' ${LANG_${LANGUAGE}} ${MUI_LANGDLL_PUSHLIST_TEMP}"
261 !endif
263 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE WELCOME "MUI_TEXT_WELCOME_INFO_TITLE"
264 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE WELCOME "MUI_TEXT_WELCOME_INFO_TEXT"
266 !ifdef MUI_TEXT_LICENSE_TITLE
267 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE LICENSE "MUI_TEXT_LICENSE_TITLE"
268 !endif
269 !ifdef MUI_TEXT_LICENSE_SUBTITLE
270 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE LICENSE "MUI_TEXT_LICENSE_SUBTITLE"
271 !endif
272 !ifdef MUI_INNERTEXT_LICENSE_TOP
273 !insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE LICENSE "MUI_INNERTEXT_LICENSE_TOP"
274 !endif
276 # !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE LICENSE "MUI_INNERTEXT_LICENSE_BOTTOM"
278 !ifdef MUI_INNERTEXT_LICENSE_BOTTOM_CHECKBOX
279 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE LICENSE "MUI_INNERTEXT_LICENSE_BOTTOM_CHECKBOX"
280 !endif
282 !ifdef MUI_INNERTEXT_LICENSE_BOTTOM_RADIOBUTTONS
283 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE LICENSE "MUI_INNERTEXT_LICENSE_BOTTOM_RADIOBUTTONS"
284 !endif
286 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE COMPONENTS "MUI_TEXT_COMPONENTS_TITLE"
287 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE COMPONENTS "MUI_TEXT_COMPONENTS_SUBTITLE"
288 !insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE COMPONENTS "MUI_INNERTEXT_COMPONENTS_DESCRIPTION_TITLE"
289 !insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE COMPONENTS "MUI_INNERTEXT_COMPONENTS_DESCRIPTION_INFO"
291 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE DIRECTORY "MUI_TEXT_DIRECTORY_TITLE"
292 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE DIRECTORY "MUI_TEXT_DIRECTORY_SUBTITLE"
294 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE STARTMENU "MUI_TEXT_STARTMENU_TITLE"
295 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE STARTMENU "MUI_TEXT_STARTMENU_SUBTITLE"
296 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE STARTMENU "MUI_INNERTEXT_STARTMENU_TOP"
297 # !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE STARTMENU "MUI_INNERTEXT_STARTMENU_CHECKBOX"
299 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_INSTALLING_TITLE"
300 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_INSTALLING_SUBTITLE"
302 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_FINISH_TITLE"
303 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_FINISH_SUBTITLE"
305 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_ABORT_TITLE"
306 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_ABORT_SUBTITLE"
308 !insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE FINISH "MUI_BUTTONTEXT_FINISH"
309 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_INFO_TITLE"
310 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_INFO_TEXT"
311 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_INFO_REBOOT"
312 !insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_REBOOTNOW"
313 !insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_REBOOTLATER"
314 # !insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_RUN"
315 # !insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_SHOWREADME"
317 ; Support for using the existing MUI_TEXT_ABORTWARNING string
318 !ifdef MOZ_MUI_CUSTOM_ABORT
319 LangString MOZ_MUI_TEXT_ABORTWARNING 0 "${MUI_TEXT_ABORTWARNING}"
320 !endif
322 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_DEFINE MUI_ABORTWARNING "MUI_TEXT_ABORTWARNING"
325 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE WELCOME "MUI_UNTEXT_WELCOME_INFO_TITLE"
326 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE WELCOME "MUI_UNTEXT_WELCOME_INFO_TEXT"
328 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE CONFIRM "MUI_UNTEXT_CONFIRM_TITLE"
329 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE CONFIRM "MUI_UNTEXT_CONFIRM_SUBTITLE"
331 # !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE LICENSE "MUI_UNTEXT_LICENSE_TITLE"
332 # !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE LICENSE "MUI_UNTEXT_LICENSE_SUBTITLE"
334 # !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE LICENSE "MUI_UNINNERTEXT_LICENSE_BOTTOM"
335 # !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE LICENSE "MUI_UNINNERTEXT_LICENSE_BOTTOM_CHECKBOX"
336 # !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE LICENSE "MUI_UNINNERTEXT_LICENSE_BOTTOM_RADIOBUTTONS"
338 # !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE COMPONENTS "MUI_UNTEXT_COMPONENTS_TITLE"
339 # !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE COMPONENTS "MUI_UNTEXT_COMPONENTS_SUBTITLE"
341 # !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE DIRECTORY "MUI_UNTEXT_DIRECTORY_TITLE"
342 # !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE DIRECTORY "MUI_UNTEXT_DIRECTORY_SUBTITLE"
344 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_UNINSTALLING_TITLE"
345 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_UNINSTALLING_SUBTITLE"
347 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_FINISH_TITLE"
348 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_FINISH_SUBTITLE"
350 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_ABORT_TITLE"
351 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_ABORT_SUBTITLE"
353 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE FINISH "MUI_UNTEXT_FINISH_INFO_TITLE"
354 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE FINISH "MUI_UNTEXT_FINISH_INFO_TEXT"
355 !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE FINISH "MUI_UNTEXT_FINISH_INFO_REBOOT"
357 !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_DEFINE MUI_UNABORTWARNING "MUI_UNTEXT_ABORTWARNING"
359 !ifndef MUI_LANGDLL_LANGUAGES
360 !define MUI_LANGDLL_LANGUAGES "'${LANGFILE_${LANGUAGE}_NAME}' '${LANG_${LANGUAGE}}' "
361 !define MUI_LANGDLL_LANGUAGES_CP "'${LANGFILE_${LANGUAGE}_NAME}' '${LANG_${LANGUAGE}}' '${LANG_${LANGUAGE}_CP}' "
362 !else
363 !ifdef MUI_LANGDLL_LANGUAGES_TEMP
364 !undef MUI_LANGDLL_LANGUAGES_TEMP
365 !endif
366 !define MUI_LANGDLL_LANGUAGES_TEMP "${MUI_LANGDLL_LANGUAGES}"
367 !undef MUI_LANGDLL_LANGUAGES
369 !ifdef MUI_LANGDLL_LANGUAGES_CP_TEMP
370 !undef MUI_LANGDLL_LANGUAGES_CP_TEMP
371 !endif
372 !define MUI_LANGDLL_LANGUAGES_CP_TEMP "${MUI_LANGDLL_LANGUAGES_CP}"
373 !undef MUI_LANGDLL_LANGUAGES_CP
375 !define MUI_LANGDLL_LANGUAGES "'${LANGFILE_${LANGUAGE}_NAME}' '${LANG_${LANGUAGE}}' ${MUI_LANGDLL_LANGUAGES_TEMP}"
376 !define MUI_LANGDLL_LANGUAGES_CP "'${LANGFILE_${LANGUAGE}_NAME}' '${LANG_${LANGUAGE}}' '${LANG_${LANGUAGE}_CP}' ${MUI_LANGDLL_LANGUAGES_CP_TEMP}"
377 !endif
379 !macroend
381 /**
382 * Creates an InstallOptions file with a UTF-16LE BOM and adds the RTL value
383 * to the Settings section.
384 *
385 * @param _FILE
386 * The name of the file to be created in $PLUGINSDIR.
387 */
388 !macro InitInstallOptionsFile _FILE
389 Push $R9
391 FileOpen $R9 "$PLUGINSDIR\${_FILE}" w
392 FileWriteWord $R9 "65279"
393 FileClose $R9
394 WriteIniStr "$PLUGINSDIR\${_FILE}" "Settings" "RTL" "$(^RTL)"
396 Pop $R9
397 !macroend
400 ################################################################################
401 # Macros for handling files in use
403 /**
404 * Checks for files in use in the $INSTDIR directory. To check files in
405 * sub-directories this macro would need to be rewritten to create
406 * sub-directories in the temporary directory used to backup the files that are
407 * checked.
408 *
409 * Example usage:
410 *
411 * ; The first string to be pushed onto the stack MUST be "end" to indicate
412 * ; that there are no more files in the $INSTDIR directory to check.
413 * Push "end"
414 * Push "freebl3.dll"
415 * ; The last file pushed should be the app's main exe so if it is in use this
416 * ; macro will return after the first check.
417 * Push "${FileMainEXE}"
418 * ${CheckForFilesInUse} $R9
419 *
420 * !IMPORTANT - this macro uses the $R7, $R8, and $R9 registers and makes no
421 * attempt to restore their original values.
422 *
423 * @return _RESULT
424 * false if all of the files popped from the stack are not in use.
425 * True if any of the files popped from the stack are in use.
426 * $R7 = Temporary backup directory where the files will be copied to.
427 * $R8 = value popped from the stack. This will either be a file name for a file
428 * in the $INSTDIR directory or "end" to indicate that there are no
429 * additional files to check.
430 * $R9 = _RESULT
431 */
432 !macro CheckForFilesInUse
434 !ifndef ${_MOZFUNC_UN}CheckForFilesInUse
435 !verbose push
436 !verbose ${_MOZFUNC_VERBOSE}
437 !define ${_MOZFUNC_UN}CheckForFilesInUse "!insertmacro ${_MOZFUNC_UN}CheckForFilesInUseCall"
439 Function ${_MOZFUNC_UN}CheckForFilesInUse
440 ; Create a temporary backup directory.
441 GetTempFileName $R7 "$INSTDIR"
442 Delete "$R7"
443 SetOutPath "$R7"
444 StrCpy $R9 "false"
446 Pop $R8
447 ${While} $R8 != "end"
448 ${Unless} ${FileExists} "$INSTDIR\$R8"
449 Pop $R8 ; get next file to check before continuing
450 ${Continue}
451 ${EndUnless}
453 ClearErrors
454 CopyFiles /SILENT "$INSTDIR\$R8" "$R7\$R8" ; try to copy
455 ${If} ${Errors}
456 ; File is in use
457 StrCpy $R9 "true"
458 ${Break}
459 ${EndIf}
461 Delete "$INSTDIR\$R8" ; delete original
462 ${If} ${Errors}
463 ; File is in use
464 StrCpy $R9 "true"
465 Delete "$R7\$R8" ; delete temp copy
466 ${Break}
467 ${EndIf}
469 Pop $R8 ; get next file to check
470 ${EndWhile}
472 ; clear stack
473 ${While} $R8 != "end"
474 Pop $R8
475 ${EndWhile}
477 ; restore everything
478 SetOutPath "$INSTDIR"
479 CopyFiles /SILENT "$R7\*" "$INSTDIR\"
480 RmDir /r "$R7"
481 SetOutPath "$EXEDIR"
482 ClearErrors
484 Push $R9
485 FunctionEnd
487 !verbose pop
488 !endif
489 !macroend
491 !macro CheckForFilesInUseCall _RESULT
492 !verbose push
493 !verbose ${_MOZFUNC_VERBOSE}
494 Call CheckForFilesInUse
495 Pop ${_RESULT}
496 !verbose pop
497 !macroend
499 !macro un.CheckForFilesInUseCall _RESULT
500 !verbose push
501 !verbose ${_MOZFUNC_VERBOSE}
502 Call un.CheckForFilesInUse
503 Pop ${_RESULT}
504 !verbose pop
505 !macroend
507 !macro un.CheckForFilesInUse
508 !ifndef un.CheckForFilesInUse
509 !verbose push
510 !verbose ${_MOZFUNC_VERBOSE}
511 !undef _MOZFUNC_UN
512 !define _MOZFUNC_UN "un."
514 !insertmacro CheckForFilesInUse
516 !undef _MOZFUNC_UN
517 !define _MOZFUNC_UN
518 !verbose pop
519 !endif
520 !macroend
522 /**
523 * The macros below will automatically prepend un. to the function names when
524 * they are defined (e.g. !define un.RegCleanMain).
525 */
526 !verbose push
527 !verbose 3
528 !ifndef _MOZFUNC_VERBOSE
529 !define _MOZFUNC_VERBOSE 3
530 !endif
531 !verbose ${_MOZFUNC_VERBOSE}
532 !define MOZFUNC_VERBOSE "!insertmacro MOZFUNC_VERBOSE"
533 !define _MOZFUNC_UN
534 !define _MOZFUNC_S
535 !verbose pop
537 !macro MOZFUNC_VERBOSE _VERBOSE
538 !verbose push
539 !verbose 3
540 !undef _MOZFUNC_VERBOSE
541 !define _MOZFUNC_VERBOSE ${_VERBOSE}
542 !verbose pop
543 !macroend
545 /**
546 * Displays a MessageBox and then calls abort to prevent continuing to the
547 * next page when the specified Window Class is found.
548 *
549 * @param _WINDOW_CLASS
550 * The Window Class to search for with FindWindow.
551 * @param _MSG
552 * The message text to display in the message box.
553 *
554 * $R7 = return value from FindWindow
555 * $R8 = _WINDOW_CLASS
556 * $R9 = _MSG
557 */
558 !macro ManualCloseAppPrompt
560 !ifndef ${_MOZFUNC_UN}ManualCloseAppPrompt
561 !verbose push
562 !verbose ${_MOZFUNC_VERBOSE}
563 !define ${_MOZFUNC_UN}ManualCloseAppPrompt "!insertmacro ${_MOZFUNC_UN}ManualCloseAppPromptCall"
565 Function ${_MOZFUNC_UN}ManualCloseAppPrompt
566 Exch $R9
567 Exch 1
568 Exch $R8
569 Push $R7
571 FindWindow $R7 "$R8"
572 ${If} $R7 <> 0 ; integer comparison
573 MessageBox MB_OK|MB_ICONQUESTION "$R9"
574 Abort
575 ${EndIf}
577 Pop $R7
578 Exch $R8
579 Exch 1
580 Exch $R9
581 FunctionEnd
583 !verbose pop
584 !endif
585 !macroend
587 !macro ManualCloseAppPromptCall _WINDOW_CLASS _MSG
588 !verbose push
589 !verbose ${_MOZFUNC_VERBOSE}
590 Push "${_WINDOW_CLASS}"
591 Push "${_MSG}"
592 Call ManualCloseAppPrompt
593 !verbose pop
594 !macroend
596 !macro un.ManualCloseAppPromptCall _WINDOW_CLASS _MSG
597 !verbose push
598 !verbose ${_MOZFUNC_VERBOSE}
599 Push "${_WINDOW_CLASS}"
600 Push "${_MSG}"
601 Call un.ManualCloseAppPrompt
602 !verbose pop
603 !macroend
605 !macro un.ManualCloseAppPrompt
606 !ifndef un.ManualCloseAppPrompt
607 !verbose push
608 !verbose ${_MOZFUNC_VERBOSE}
609 !undef _MOZFUNC_UN
610 !define _MOZFUNC_UN "un."
612 !insertmacro ManualCloseAppPrompt
614 !undef _MOZFUNC_UN
615 !define _MOZFUNC_UN
616 !verbose pop
617 !endif
618 !macroend
621 ################################################################################
622 # Macros for working with the registry
624 /**
625 * Writes a registry string using SHCTX and the supplied params and logs the
626 * action to the install log and the uninstall log if _LOG_UNINSTALL equals 1.
627 *
628 * Define NO_LOG to prevent all logging when calling this from the uninstaller.
629 *
630 * @param _ROOT
631 * The registry key root as defined by NSIS (e.g. HKLM, HKCU, etc.).
632 * This will only be used for logging.
633 * @param _KEY
634 * The subkey in relation to the key root.
635 * @param _NAME
636 * The key value name to write to.
637 * @param _STR
638 * The string to write to the key value name.
639 * @param _LOG_UNINSTALL
640 * 0 = don't add to uninstall log, 1 = add to uninstall log.
641 *
642 * $R5 = _ROOT
643 * $R6 = _KEY
644 * $R7 = _NAME
645 * $R8 = _STR
646 * $R9 = _LOG_UNINSTALL
647 */
648 !macro WriteRegStr2
650 !ifndef ${_MOZFUNC_UN}WriteRegStr2
651 !verbose push
652 !verbose ${_MOZFUNC_VERBOSE}
653 !define ${_MOZFUNC_UN}WriteRegStr2 "!insertmacro ${_MOZFUNC_UN}WriteRegStr2Call"
655 Function ${_MOZFUNC_UN}WriteRegStr2
656 Exch $R9
657 Exch 1
658 Exch $R8
659 Exch 2
660 Exch $R7
661 Exch 3
662 Exch $R6
663 Exch 4
664 Exch $R5
666 ClearErrors
667 WriteRegStr SHCTX "$R6" "$R7" "$R8"
669 !ifndef NO_LOG
670 ${If} ${Errors}
671 ${LogMsg} "** ERROR Adding Registry String: $R5 | $R6 | $R7 | $R8 **"
672 ${Else}
673 ${If} $R9 == 1 ; add to the uninstall log?
674 ${LogUninstall} "RegVal: $R5 | $R6 | $R7"
675 ${EndIf}
676 ${LogMsg} "Added Registry String: $R5 | $R6 | $R7 | $R8"
677 ${EndIf}
678 !endif
680 Exch $R5
681 Exch 4
682 Exch $R6
683 Exch 3
684 Exch $R7
685 Exch 2
686 Exch $R8
687 Exch 1
688 Exch $R9
689 FunctionEnd
691 !verbose pop
692 !endif
693 !macroend
695 !macro WriteRegStr2Call _ROOT _KEY _NAME _STR _LOG_UNINSTALL
696 !verbose push
697 !verbose ${_MOZFUNC_VERBOSE}
698 Push "${_ROOT}"
699 Push "${_KEY}"
700 Push "${_NAME}"
701 Push "${_STR}"
702 Push "${_LOG_UNINSTALL}"
703 Call WriteRegStr2
704 !verbose pop
705 !macroend
707 !macro un.WriteRegStr2Call _ROOT _KEY _NAME _STR _LOG_UNINSTALL
708 !verbose push
709 !verbose ${_MOZFUNC_VERBOSE}
710 Push "${_ROOT}"
711 Push "${_KEY}"
712 Push "${_NAME}"
713 Push "${_STR}"
714 Push "${_LOG_UNINSTALL}"
715 Call un.WriteRegStr2
716 !verbose pop
717 !macroend
719 !macro un.WriteRegStr2
720 !ifndef un.WriteRegStr2
721 !verbose push
722 !verbose ${_MOZFUNC_VERBOSE}
723 !undef _MOZFUNC_UN
724 !define _MOZFUNC_UN "un."
726 !insertmacro WriteRegStr2
728 !undef _MOZFUNC_UN
729 !define _MOZFUNC_UN
730 !verbose pop
731 !endif
732 !macroend
734 /**
735 * Writes a registry dword using SHCTX and the supplied params and logs the
736 * action to the install log and the uninstall log if _LOG_UNINSTALL equals 1.
737 *
738 * Define NO_LOG to prevent all logging when calling this from the uninstaller.
739 *
740 * @param _ROOT
741 * The registry key root as defined by NSIS (e.g. HKLM, HKCU, etc.).
742 * This will only be used for logging.
743 * @param _KEY
744 * The subkey in relation to the key root.
745 * @param _NAME
746 * The key value name to write to.
747 * @param _DWORD
748 * The dword to write to the key value name.
749 * @param _LOG_UNINSTALL
750 * 0 = don't add to uninstall log, 1 = add to uninstall log.
751 *
752 * $R5 = _ROOT
753 * $R6 = _KEY
754 * $R7 = _NAME
755 * $R8 = _DWORD
756 * $R9 = _LOG_UNINSTALL
757 */
758 !macro WriteRegDWORD2
760 !ifndef ${_MOZFUNC_UN}WriteRegDWORD2
761 !verbose push
762 !verbose ${_MOZFUNC_VERBOSE}
763 !define ${_MOZFUNC_UN}WriteRegDWORD2 "!insertmacro ${_MOZFUNC_UN}WriteRegDWORD2Call"
765 Function ${_MOZFUNC_UN}WriteRegDWORD2
766 Exch $R9
767 Exch 1
768 Exch $R8
769 Exch 2
770 Exch $R7
771 Exch 3
772 Exch $R6
773 Exch 4
774 Exch $R5
776 ClearErrors
777 WriteRegDWORD SHCTX "$R6" "$R7" "$R8"
779 !ifndef NO_LOG
780 ${If} ${Errors}
781 ${LogMsg} "** ERROR Adding Registry DWord: $R5 | $R6 | $R7 | $R8 **"
782 ${Else}
783 ${If} $R9 == 1 ; add to the uninstall log?
784 ${LogUninstall} "RegVal: $R5 | $R6 | $R7"
785 ${EndIf}
786 ${LogMsg} "Added Registry DWord: $R5 | $R6 | $R7 | $R8"
787 ${EndIf}
788 !endif
790 Exch $R5
791 Exch 4
792 Exch $R6
793 Exch 3
794 Exch $R7
795 Exch 2
796 Exch $R8
797 Exch 1
798 Exch $R9
799 FunctionEnd
801 !verbose pop
802 !endif
803 !macroend
805 !macro WriteRegDWORD2Call _ROOT _KEY _NAME _DWORD _LOG_UNINSTALL
806 !verbose push
807 !verbose ${_MOZFUNC_VERBOSE}
808 Push "${_ROOT}"
809 Push "${_KEY}"
810 Push "${_NAME}"
811 Push "${_DWORD}"
812 Push "${_LOG_UNINSTALL}"
813 Call WriteRegDWORD2
814 !verbose pop
815 !macroend
817 !macro un.WriteRegDWORD2Call _ROOT _KEY _NAME _DWORD _LOG_UNINSTALL
818 !verbose push
819 !verbose ${_MOZFUNC_VERBOSE}
820 Push "${_ROOT}"
821 Push "${_KEY}"
822 Push "${_NAME}"
823 Push "${_DWORD}"
824 Push "${_LOG_UNINSTALL}"
825 Call un.WriteRegDWORD2
826 !verbose pop
827 !macroend
829 !macro un.WriteRegDWORD2
830 !ifndef un.WriteRegDWORD2
831 !verbose push
832 !verbose ${_MOZFUNC_VERBOSE}
833 !undef _MOZFUNC_UN
834 !define _MOZFUNC_UN "un."
836 !insertmacro WriteRegDWORD2
838 !undef _MOZFUNC_UN
839 !define _MOZFUNC_UN
840 !verbose pop
841 !endif
842 !macroend
844 /**
845 * Writes a registry string to HKCR using the supplied params and logs the
846 * action to the install log and the uninstall log if _LOG_UNINSTALL equals 1.
847 *
848 * Define NO_LOG to prevent all logging when calling this from the uninstaller.
849 *
850 * @param _ROOT
851 * The registry key root as defined by NSIS (e.g. HKLM, HKCU, etc.).
852 * This will only be used for logging.
853 * @param _KEY
854 * The subkey in relation to the key root.
855 * @param _NAME
856 * The key value name to write to.
857 * @param _STR
858 * The string to write to the key value name.
859 * @param _LOG_UNINSTALL
860 * 0 = don't add to uninstall log, 1 = add to uninstall log.
861 *
862 * $R5 = _ROOT
863 * $R6 = _KEY
864 * $R7 = _NAME
865 * $R8 = _STR
866 * $R9 = _LOG_UNINSTALL
867 */
868 !macro WriteRegStrHKCR
870 !ifndef ${_MOZFUNC_UN}WriteRegStrHKCR
871 !verbose push
872 !verbose ${_MOZFUNC_VERBOSE}
873 !define ${_MOZFUNC_UN}WriteRegStrHKCR "!insertmacro ${_MOZFUNC_UN}WriteRegStrHKCRCall"
875 Function ${_MOZFUNC_UN}WriteRegStrHKCR
876 Exch $R9
877 Exch 1
878 Exch $R8
879 Exch 2
880 Exch $R7
881 Exch 3
882 Exch $R6
883 Exch 4
884 Exch $R5
886 ClearErrors
887 WriteRegStr HKCR "$R6" "$R7" "$R8"
889 !ifndef NO_LOG
890 ${If} ${Errors}
891 ${LogMsg} "** ERROR Adding Registry String: $R5 | $R6 | $R7 | $R8 **"
892 ${Else}
893 ${If} $R9 == 1 ; add to the uninstall log?
894 ${LogUninstall} "RegVal: $R5 | $R6 | $R7"
895 ${EndIf}
896 ${LogMsg} "Added Registry String: $R5 | $R6 | $R7 | $R8"
897 ${EndIf}
898 !endif
900 Exch $R5
901 Exch 4
902 Exch $R6
903 Exch 3
904 Exch $R7
905 Exch 2
906 Exch $R8
907 Exch 1
908 Exch $R9
909 FunctionEnd
911 !verbose pop
912 !endif
913 !macroend
915 !macro WriteRegStrHKCRCall _ROOT _KEY _NAME _STR _LOG_UNINSTALL
916 !verbose push
917 !verbose ${_MOZFUNC_VERBOSE}
918 Push "${_ROOT}"
919 Push "${_KEY}"
920 Push "${_NAME}"
921 Push "${_STR}"
922 Push "${_LOG_UNINSTALL}"
923 Call WriteRegStrHKCR
924 !verbose pop
925 !macroend
927 !macro un.WriteRegStrHKCRCall _ROOT _KEY _NAME _STR _LOG_UNINSTALL
928 !verbose push
929 !verbose ${_MOZFUNC_VERBOSE}
930 Push "${_ROOT}"
931 Push "${_KEY}"
932 Push "${_NAME}"
933 Push "${_STR}"
934 Push "${_LOG_UNINSTALL}"
935 Call un.WriteRegStrHKCR
936 !verbose pop
937 !macroend
939 !macro un.WriteRegStrHKCR
940 !ifndef un.WriteRegStrHKCR
941 !verbose push
942 !verbose ${_MOZFUNC_VERBOSE}
943 !undef _MOZFUNC_UN
944 !define _MOZFUNC_UN "un."
946 !insertmacro WriteRegStrHKCR
948 !undef _MOZFUNC_UN
949 !define _MOZFUNC_UN
950 !verbose pop
951 !endif
952 !macroend
954 !ifndef KEY_SET_VALUE
955 !define KEY_SET_VALUE 0x0002
956 !endif
957 !ifndef KEY_WOW64_64KEY
958 !define KEY_WOW64_64KEY 0x0100
959 !endif
960 !ifndef HAVE_64BIT_OS
961 !define CREATE_KEY_SAM ${KEY_SET_VALUE}
962 !else
963 !define CREATE_KEY_SAM ${KEY_SET_VALUE}|${KEY_WOW64_64KEY}
964 !endif
966 /**
967 * Creates a registry key. This will log the actions to the install and
968 * uninstall logs. Alternatively you can set a registry value to create the key
969 * and then delete the value.
970 *
971 * Define NO_LOG to prevent all logging when calling this from the uninstaller.
972 *
973 * @param _ROOT
974 * The registry key root as defined by NSIS (e.g. HKLM, HKCU, etc.).
975 * @param _KEY
976 * The subkey in relation to the key root.
977 * @param _LOG_UNINSTALL
978 * 0 = don't add to uninstall log, 1 = add to uninstall log.
979 *
980 * $R4 = [out] handle to newly created registry key. If this is not a key
981 * located in one of the predefined registry keys this must be closed
982 * with RegCloseKey (this should not be needed unless someone decides to
983 * do something extremely squirrelly with NSIS).
984 * $R5 = return value from RegCreateKeyExW (represented by R5 in the system call).
985 * $R6 = [in] hKey passed to RegCreateKeyExW.
986 * $R7 = _ROOT
987 * $R8 = _KEY
988 * $R9 = _LOG_UNINSTALL
989 */
990 !macro CreateRegKey
992 !ifndef ${_MOZFUNC_UN}CreateRegKey
993 !verbose push
994 !verbose ${_MOZFUNC_VERBOSE}
995 !define ${_MOZFUNC_UN}CreateRegKey "!insertmacro ${_MOZFUNC_UN}CreateRegKeyCall"
997 Function ${_MOZFUNC_UN}CreateRegKey
998 Exch $R9
999 Exch 1
1000 Exch $R8
1001 Exch 2
1002 Exch $R7
1003 Push $R6
1004 Push $R5
1005 Push $R4
1007 StrCmp $R7 "HKCR" +1 +2
1008 StrCpy $R6 "0x80000000"
1009 StrCmp $R7 "HKCU" +1 +2
1010 StrCpy $R6 "0x80000001"
1011 StrCmp $R7 "HKLM" +1 +2
1012 StrCpy $R6 "0x80000002"
1014 ; see definition of RegCreateKey
1015 System::Call "Advapi32::RegCreateKeyExW(i R6, w R8, i 0, i 0, i 0,\
1016 i ${CREATE_KEY_SAM}, i 0, *i .R4,\
1017 i 0) i .R5"
1019 !ifndef NO_LOG
1020 ; if $R5 is not 0 then there was an error creating the registry key.
1021 ${If} $R5 <> 0
1022 ${LogMsg} "** ERROR Adding Registry Key: $R7 | $R8 **"
1023 ${Else}
1024 ${If} $R9 == 1 ; add to the uninstall log?
1025 ${LogUninstall} "RegKey: $R7 | $R8"
1026 ${EndIf}
1027 ${LogMsg} "Added Registry Key: $R7 | $R8"
1028 ${EndIf}
1029 !endif
1031 StrCmp $R5 0 +1 +2
1032 System::Call "Advapi32::RegCloseKey(iR4)"
1034 Pop $R4
1035 Pop $R5
1036 Pop $R6
1037 Exch $R7
1038 Exch 2
1039 Exch $R8
1040 Exch 1
1041 Exch $R9
1042 FunctionEnd
1044 !verbose pop
1045 !endif
1046 !macroend
1048 !macro CreateRegKeyCall _ROOT _KEY _LOG_UNINSTALL
1049 !verbose push
1050 !verbose ${_MOZFUNC_VERBOSE}
1051 Push "${_ROOT}"
1052 Push "${_KEY}"
1053 Push "${_LOG_UNINSTALL}"
1054 Call CreateRegKey
1055 !verbose pop
1056 !macroend
1058 !macro un.CreateRegKeyCall _ROOT _KEY _LOG_UNINSTALL
1059 !verbose push
1060 !verbose ${_MOZFUNC_VERBOSE}
1061 Push "${_ROOT}"
1062 Push "${_KEY}"
1063 Push "${_LOG_UNINSTALL}"
1064 Call un.CreateRegKey
1065 !verbose pop
1066 !macroend
1068 !macro un.CreateRegKey
1069 !ifndef un.CreateRegKey
1070 !verbose push
1071 !verbose ${_MOZFUNC_VERBOSE}
1072 !undef _MOZFUNC_UN
1073 !define _MOZFUNC_UN "un."
1075 !insertmacro CreateRegKey
1077 !undef _MOZFUNC_UN
1078 !define _MOZFUNC_UN
1079 !verbose pop
1080 !endif
1081 !macroend
1083 /**
1084 * Helper for checking for the existence of a registry key.
1085 * SHCTX is the root key to search.
1086 *
1087 * @param _MAIN_KEY
1088 * Sub key to iterate for the key in question
1089 * @param _KEY
1090 * Key name to search for
1091 * @return _RESULT
1092 * 'true' / 'false' result
1093 */
1094 !macro CheckIfRegistryKeyExists
1095 !ifndef CheckIfRegistryKeyExists
1096 !verbose push
1097 !verbose ${_MOZFUNC_VERBOSE}
1098 !define CheckIfRegistryKeyExists "!insertmacro CheckIfRegistryKeyExistsCall"
1100 Function CheckIfRegistryKeyExists
1101 ; stack: main key, key
1102 Exch $R9 ; main key, stack: old R9, key
1103 Exch 1 ; stack: key, old R9
1104 Exch $R8 ; key, stack: old R8, old R9
1105 Push $R7
1106 Push $R6
1107 Push $R5
1109 StrCpy $R5 "false"
1110 StrCpy $R7 "0" # loop index
1111 ${Do}
1112 EnumRegKey $R6 SHCTX "$R9" "$R7"
1113 ${If} "$R6" == "$R8"
1114 StrCpy $R5 "true"
1115 ${Break}
1116 ${EndIf}
1117 IntOp $R7 $R7 + 1
1118 ${LoopWhile} $R6 != ""
1119 ClearErrors
1121 StrCpy $R9 $R5
1123 Pop $R5
1124 Pop $R6
1125 Pop $R7 ; stack: old R8, old R9
1126 Pop $R8 ; stack: old R9
1127 Exch $R9 ; stack: result
1128 FunctionEnd
1130 !verbose pop
1131 !endif
1132 !macroend
1134 !macro CheckIfRegistryKeyExistsCall _MAIN_KEY _KEY _RESULT
1135 !verbose push
1136 !verbose ${_MOZFUNC_VERBOSE}
1137 Push "${_KEY}"
1138 Push "${_MAIN_KEY}"
1139 Call CheckIfRegistryKeyExists
1140 Pop ${_RESULT}
1141 !verbose pop
1142 !macroend
1144 ################################################################################
1145 # Macros for adding file and protocol handlers
1147 /**
1148 * Writes common registry values for a handler using SHCTX.
1149 *
1150 * @param _KEY
1151 * The subkey in relation to the key root.
1152 * @param _VALOPEN
1153 * The path and args to launch the application.
1154 * @param _VALICON
1155 * The path to the binary that contains the icon group for the default icon
1156 * followed by a comma and either the icon group's resource index or the icon
1157 * group's resource id prefixed with a minus sign
1158 * @param _DISPNAME
1159 * The display name for the handler. If emtpy no value will be set.
1160 * @param _ISPROTOCOL
1161 * Sets protocol handler specific registry values when "true".
1162 * Deletes protocol handler specific registry values when "delete".
1163 * Otherwise doesn't touch handler specific registry values.
1164 * @param _ISDDE
1165 * Sets DDE specific registry values when "true".
1166 *
1167 * $R3 = string value of the current registry key path.
1168 * $R4 = _KEY
1169 * $R5 = _VALOPEN
1170 * $R6 = _VALICON
1171 * $R7 = _DISPNAME
1172 * $R8 = _ISPROTOCOL
1173 * $R9 = _ISDDE
1174 */
1175 !macro AddHandlerValues
1177 !ifndef ${_MOZFUNC_UN}AddHandlerValues
1178 !verbose push
1179 !verbose ${_MOZFUNC_VERBOSE}
1180 !define ${_MOZFUNC_UN}AddHandlerValues "!insertmacro ${_MOZFUNC_UN}AddHandlerValuesCall"
1182 Function ${_MOZFUNC_UN}AddHandlerValues
1183 Exch $R9
1184 Exch 1
1185 Exch $R8
1186 Exch 2
1187 Exch $R7
1188 Exch 3
1189 Exch $R6
1190 Exch 4
1191 Exch $R5
1192 Exch 5
1193 Exch $R4
1194 Push $R3
1196 StrCmp "$R7" "" +6 +1
1197 ReadRegStr $R3 SHCTX "$R4" "FriendlyTypeName"
1199 StrCmp "$R3" "" +1 +3
1200 WriteRegStr SHCTX "$R4" "" "$R7"
1201 WriteRegStr SHCTX "$R4" "FriendlyTypeName" "$R7"
1203 StrCmp "$R8" "true" +1 +2
1204 WriteRegStr SHCTX "$R4" "URL Protocol" ""
1205 StrCmp "$R8" "delete" +1 +2
1206 DeleteRegValue SHCTX "$R4" "URL Protocol"
1207 StrCpy $R3 ""
1208 ReadRegDWord $R3 SHCTX "$R4" "EditFlags"
1209 StrCmp $R3 "" +1 +3 ; Only add EditFlags if a value doesn't exist
1210 DeleteRegValue SHCTX "$R4" "EditFlags"
1211 WriteRegDWord SHCTX "$R4" "EditFlags" 0x00000002
1213 StrCmp "$R6" "" +2 +1
1214 WriteRegStr SHCTX "$R4\DefaultIcon" "" "$R6"
1216 StrCmp "$R5" "" +2 +1
1217 WriteRegStr SHCTX "$R4\shell\open\command" "" "$R5"
1219 !ifdef DDEApplication
1220 StrCmp "$R9" "true" +1 +11
1221 WriteRegStr SHCTX "$R4\shell\open\ddeexec" "" "$\"%1$\",,0,0,,,,"
1222 WriteRegStr SHCTX "$R4\shell\open\ddeexec" "NoActivateHandler" ""
1223 WriteRegStr SHCTX "$R4\shell\open\ddeexec\Application" "" "${DDEApplication}"
1224 WriteRegStr SHCTX "$R4\shell\open\ddeexec\Topic" "" "WWW_OpenURL"
1225 ; The ifexec key may have been added by another application so try to
1226 ; delete it to prevent it from breaking this app's shell integration.
1227 ; Also, IE 6 and below doesn't remove this key when it sets itself as the
1228 ; default handler and if this key exists IE's shell integration breaks.
1229 DeleteRegKey HKLM "$R4\shell\open\ddeexec\ifexec"
1230 DeleteRegKey HKCU "$R4\shell\open\ddeexec\ifexec"
1231 !endif
1233 ClearErrors
1235 Pop $R3
1236 Exch $R4
1237 Exch 5
1238 Exch $R5
1239 Exch 4
1240 Exch $R6
1241 Exch 3
1242 Exch $R7
1243 Exch 2
1244 Exch $R8
1245 Exch 1
1246 Exch $R9
1247 FunctionEnd
1249 !verbose pop
1250 !endif
1251 !macroend
1253 !macro AddHandlerValuesCall _KEY _VALOPEN _VALICON _DISPNAME _ISPROTOCOL _ISDDE
1254 !verbose push
1255 !verbose ${_MOZFUNC_VERBOSE}
1256 Push "${_KEY}"
1257 Push "${_VALOPEN}"
1258 Push "${_VALICON}"
1259 Push "${_DISPNAME}"
1260 Push "${_ISPROTOCOL}"
1261 Push "${_ISDDE}"
1262 Call AddHandlerValues
1263 !verbose pop
1264 !macroend
1266 !macro un.AddHandlerValuesCall _KEY _VALOPEN _VALICON _DISPNAME _ISPROTOCOL _ISDDE
1267 !verbose push
1268 !verbose ${_MOZFUNC_VERBOSE}
1269 Push "${_KEY}"
1270 Push "${_VALOPEN}"
1271 Push "${_VALICON}"
1272 Push "${_DISPNAME}"
1273 Push "${_ISPROTOCOL}"
1274 Push "${_ISDDE}"
1275 Call un.AddHandlerValues
1276 !verbose pop
1277 !macroend
1279 !macro un.AddHandlerValues
1280 !ifndef un.AddHandlerValues
1281 !verbose push
1282 !verbose ${_MOZFUNC_VERBOSE}
1283 !undef _MOZFUNC_UN
1284 !define _MOZFUNC_UN "un."
1286 !insertmacro AddHandlerValues
1288 !undef _MOZFUNC_UN
1289 !define _MOZFUNC_UN
1290 !verbose pop
1291 !endif
1292 !macroend
1294 /**
1295 * Writes common registry values for a handler that uses DDE using SHCTX.
1296 *
1297 * @param _KEY
1298 * The key name in relation to the HKCR root. SOFTWARE\Classes is
1299 * prefixed to this value when using SHCTX.
1300 * @param _VALOPEN
1301 * The path and args to launch the application.
1302 * @param _VALICON
1303 * The path to the binary that contains the icon group for the default icon
1304 * followed by a comma and either the icon group's resource index or the icon
1305 * group's resource id prefixed with a minus sign
1306 * @param _DISPNAME
1307 * The display name for the handler. If emtpy no value will be set.
1308 * @param _ISPROTOCOL
1309 * Sets protocol handler specific registry values when "true".
1310 * Deletes protocol handler specific registry values when "delete".
1311 * Otherwise doesn't touch handler specific registry values.
1312 * @param _DDE_APPNAME
1313 * Sets DDE specific registry values when not an empty string.
1314 *
1315 * $R0 = storage for SOFTWARE\Classes
1316 * $R1 = string value of the current registry key path.
1317 * $R2 = _KEY
1318 * $R3 = _VALOPEN
1319 * $R4 = _VALICON
1320 * $R5 = _DISPNAME
1321 * $R6 = _ISPROTOCOL
1322 * $R7 = _DDE_APPNAME
1323 * $R8 = _DDE_DEFAULT
1324 * $R9 = _DDE_TOPIC
1325 */
1326 !macro AddDDEHandlerValues
1328 !ifndef ${_MOZFUNC_UN}AddDDEHandlerValues
1329 !verbose push
1330 !verbose ${_MOZFUNC_VERBOSE}
1331 !define ${_MOZFUNC_UN}AddDDEHandlerValues "!insertmacro ${_MOZFUNC_UN}AddDDEHandlerValuesCall"
1333 Function ${_MOZFUNC_UN}AddDDEHandlerValues
1334 Exch $R9
1335 Exch 1
1336 Exch $R8
1337 Exch 2
1338 Exch $R7
1339 Exch 3
1340 Exch $R6
1341 Exch 4
1342 Exch $R5
1343 Exch 5
1344 Exch $R4
1345 Exch 6
1346 Exch $R3
1347 Exch 7
1348 Exch $R2
1349 Push $R1
1350 Push $R0
1352 StrCpy $R0 "SOFTWARE\Classes"
1353 StrCmp "$R5" "" +6 +1
1354 ReadRegStr $R1 SHCTX "$R2" "FriendlyTypeName"
1356 StrCmp "$R1" "" +1 +3
1357 WriteRegStr SHCTX "$R0\$R2" "" "$R5"
1358 WriteRegStr SHCTX "$R0\$R2" "FriendlyTypeName" "$R5"
1360 StrCmp "$R6" "true" +1 +2
1361 WriteRegStr SHCTX "$R0\$R2" "URL Protocol" ""
1362 StrCmp "$R6" "delete" +1 +2
1363 DeleteRegValue SHCTX "$R0\$R2" "URL Protocol"
1364 StrCpy $R1 ""
1365 ReadRegDWord $R1 SHCTX "$R0\$R2" "EditFlags"
1366 StrCmp $R1 "" +1 +3 ; Only add EditFlags if a value doesn't exist
1367 DeleteRegValue SHCTX "$R0\$R2" "EditFlags"
1368 WriteRegDWord SHCTX "$R0\$R2" "EditFlags" 0x00000002
1370 StrCmp "$R4" "" +2 +1
1371 WriteRegStr SHCTX "$R0\$R2\DefaultIcon" "" "$R4"
1373 WriteRegStr SHCTX "$R0\$R2\shell" "" "open"
1374 WriteRegStr SHCTX "$R0\$R2\shell\open\command" "" "$R3"
1376 WriteRegStr SHCTX "$R0\$R2\shell\open\ddeexec" "" "$R8"
1377 WriteRegStr SHCTX "$R0\$R2\shell\open\ddeexec" "NoActivateHandler" ""
1378 WriteRegStr SHCTX "$R0\$R2\shell\open\ddeexec\Application" "" "$R7"
1379 WriteRegStr SHCTX "$R0\$R2\shell\open\ddeexec\Topic" "" "$R9"
1381 ; The ifexec key may have been added by another application so try to
1382 ; delete it to prevent it from breaking this app's shell integration.
1383 ; Also, IE 6 and below doesn't remove this key when it sets itself as the
1384 ; default handler and if this key exists IE's shell integration breaks.
1385 DeleteRegKey HKLM "$R0\$R2\shell\open\ddeexec\ifexec"
1386 DeleteRegKey HKCU "$R0\$R2\shell\open\ddeexec\ifexec"
1387 ClearErrors
1389 Pop $R0
1390 Pop $R1
1391 Exch $R2
1392 Exch 7
1393 Exch $R3
1394 Exch 6
1395 Exch $R4
1396 Exch 5
1397 Exch $R5
1398 Exch 4
1399 Exch $R6
1400 Exch 3
1401 Exch $R7
1402 Exch 2
1403 Exch $R8
1404 Exch 1
1405 Exch $R9
1406 FunctionEnd
1408 !verbose pop
1409 !endif
1410 !macroend
1412 !macro AddDDEHandlerValuesCall _KEY _VALOPEN _VALICON _DISPNAME _ISPROTOCOL _DDE_APPNAME _DDE_DEFAULT _DDE_TOPIC
1413 !verbose push
1414 !verbose ${_MOZFUNC_VERBOSE}
1415 Push "${_KEY}"
1416 Push "${_VALOPEN}"
1417 Push "${_VALICON}"
1418 Push "${_DISPNAME}"
1419 Push "${_ISPROTOCOL}"
1420 Push "${_DDE_APPNAME}"
1421 Push "${_DDE_DEFAULT}"
1422 Push "${_DDE_TOPIC}"
1423 Call AddDDEHandlerValues
1424 !verbose pop
1425 !macroend
1427 !macro un.AddDDEHandlerValuesCall _KEY _VALOPEN _VALICON _DISPNAME _ISPROTOCOL _DDE_APPNAME _DDE_DEFAULT _DDE_TOPIC
1428 !verbose push
1429 !verbose ${_MOZFUNC_VERBOSE}
1430 Push "${_KEY}"
1431 Push "${_VALOPEN}"
1432 Push "${_VALICON}"
1433 Push "${_DISPNAME}"
1434 Push "${_ISPROTOCOL}"
1435 Push "${_DDE_APPNAME}"
1436 Push "${_DDE_DEFAULT}"
1437 Push "${_DDE_TOPIC}"
1438 Call un.AddDDEHandlerValues
1439 !verbose pop
1440 !macroend
1442 !macro un.AddDDEHandlerValues
1443 !ifndef un.AddDDEHandlerValues
1444 !verbose push
1445 !verbose ${_MOZFUNC_VERBOSE}
1446 !undef _MOZFUNC_UN
1447 !define _MOZFUNC_UN "un."
1449 !insertmacro AddDDEHandlerValues
1451 !undef _MOZFUNC_UN
1452 !define _MOZFUNC_UN
1453 !verbose pop
1454 !endif
1455 !macroend
1457 /**
1458 * Writes common registry values for a handler that DOES NOT use DDE using SHCTX.
1459 *
1460 * @param _KEY
1461 * The key name in relation to the HKCR root. SOFTWARE\Classes is
1462 * prefixed to this value when using SHCTX.
1463 * @param _VALOPEN
1464 * The path and args to launch the application.
1465 * @param _VALICON
1466 * The path to the binary that contains the icon group for the default icon
1467 * followed by a comma and either the icon group's resource index or the icon
1468 * group's resource id prefixed with a minus sign
1469 * @param _DISPNAME
1470 * The display name for the handler. If emtpy no value will be set.
1471 * @param _ISPROTOCOL
1472 * Sets protocol handler specific registry values when "true".
1473 * Deletes protocol handler specific registry values when "delete".
1474 * Otherwise doesn't touch handler specific registry values.
1475 *
1476 * $R3 = storage for SOFTWARE\Classes
1477 * $R4 = string value of the current registry key path.
1478 * $R5 = _KEY
1479 * $R6 = _VALOPEN
1480 * $R7 = _VALICON
1481 * $R8 = _DISPNAME
1482 * $R9 = _ISPROTOCOL
1483 */
1484 !macro AddDisabledDDEHandlerValues
1486 !ifndef ${_MOZFUNC_UN}AddDisabledDDEHandlerValues
1487 !verbose push
1488 !verbose ${_MOZFUNC_VERBOSE}
1489 !define ${_MOZFUNC_UN}AddDisabledDDEHandlerValues "!insertmacro ${_MOZFUNC_UN}AddDisabledDDEHandlerValuesCall"
1491 Function ${_MOZFUNC_UN}AddDisabledDDEHandlerValues
1492 Exch $R9 ; _ISPROTOCOL
1493 Exch 1
1494 Exch $R8 ; FriendlyTypeName
1495 Exch 2
1496 Exch $R7 ; icon index
1497 Exch 3
1498 Exch $R6 ; shell\open\command
1499 Exch 4
1500 Exch $R5 ; reg key
1501 Push $R4 ;
1502 Push $R3 ; base reg class
1504 StrCpy $R3 "SOFTWARE\Classes"
1505 StrCmp "$R8" "" +6 +1
1506 ReadRegStr $R4 SHCTX "$R5" "FriendlyTypeName"
1508 StrCmp "$R4" "" +1 +3
1509 WriteRegStr SHCTX "$R3\$R5" "" "$R8"
1510 WriteRegStr SHCTX "$R3\$R5" "FriendlyTypeName" "$R8"
1512 StrCmp "$R9" "true" +1 +2
1513 WriteRegStr SHCTX "$R3\$R5" "URL Protocol" ""
1514 StrCmp "$R9" "delete" +1 +2
1515 DeleteRegValue SHCTX "$R3\$R5" "URL Protocol"
1516 StrCpy $R4 ""
1517 ReadRegDWord $R4 SHCTX "$R3\$R5" "EditFlags"
1518 StrCmp $R4 "" +1 +3 ; Only add EditFlags if a value doesn't exist
1519 DeleteRegValue SHCTX "$R3\$R5" "EditFlags"
1520 WriteRegDWord SHCTX "$R3\$R5" "EditFlags" 0x00000002
1522 StrCmp "$R7" "" +2 +1
1523 WriteRegStr SHCTX "$R3\$R5\DefaultIcon" "" "$R7"
1525 ; Main command handler for the app
1526 WriteRegStr SHCTX "$R3\$R5\shell" "" "open"
1527 WriteRegStr SHCTX "$R3\$R5\shell\open\command" "" "$R6"
1529 ; Drop support for DDE (bug 491947), and remove old dde entries if
1530 ; they exist.
1531 ;
1532 ; Note, changes in SHCTX should propegate to hkey classes root when
1533 ; current user or local machine entries are written. Windows will also
1534 ; attempt to propegate entries when a handler is used. CR entries are a
1535 ; combination of LM and CU, with CU taking priority.
1536 ;
1537 ; To disable dde, an empty shell/ddeexec key must be created in current
1538 ; user or local machine. Unfortunately, settings have various different
1539 ; behaviors depending on the windows version. The following code attempts
1540 ; to address these differences.
1541 ;
1542 ; On XP (no SP, SP1, SP2), Vista: An empty default string
1543 ; must be set under ddeexec. Empty strings propagate to CR.
1544 ;
1545 ; Win7: IE does not configure ddeexec, so issues with left over ddeexec keys
1546 ; in LM are reduced. We configure an empty ddeexec key with an empty default
1547 ; string in CU to be sure.
1548 ;
1549 DeleteRegKey SHCTX "SOFTWARE\Classes\$R5\shell\open\ddeexec"
1550 WriteRegStr SHCTX "SOFTWARE\Classes\$R5\shell\open\ddeexec" "" ""
1552 ClearErrors
1554 Pop $R3
1555 Pop $R4
1556 Exch $R5
1557 Exch 4
1558 Exch $R6
1559 Exch 3
1560 Exch $R7
1561 Exch 2
1562 Exch $R8
1563 Exch 1
1564 Exch $R9
1565 FunctionEnd
1567 !verbose pop
1568 !endif
1569 !macroend
1571 !macro AddDisabledDDEHandlerValuesCall _KEY _VALOPEN _VALICON _DISPNAME _ISPROTOCOL
1572 !verbose push
1573 !verbose ${_MOZFUNC_VERBOSE}
1574 Push "${_KEY}"
1575 Push "${_VALOPEN}"
1576 Push "${_VALICON}"
1577 Push "${_DISPNAME}"
1578 Push "${_ISPROTOCOL}"
1579 Call AddDisabledDDEHandlerValues
1580 !verbose pop
1581 !macroend
1583 !macro un.AddDisabledDDEHandlerValuesCall _KEY _VALOPEN _VALICON _DISPNAME _ISPROTOCOL
1584 !verbose push
1585 !verbose ${_MOZFUNC_VERBOSE}
1586 Push "${_KEY}"
1587 Push "${_VALOPEN}"
1588 Push "${_VALICON}"
1589 Push "${_DISPNAME}"
1590 Push "${_ISPROTOCOL}"
1591 Call un.AddDisabledDDEHandlerValues
1592 !verbose pop
1593 !macroend
1595 !macro un.AddDisabledDDEHandlerValues
1596 !ifndef un.AddDisabledDDEHandlerValues
1597 !verbose push
1598 !verbose ${_MOZFUNC_VERBOSE}
1599 !undef _MOZFUNC_UN
1600 !define _MOZFUNC_UN "un."
1602 !insertmacro AddDisabledDDEHandlerValues
1604 !undef _MOZFUNC_UN
1605 !define _MOZFUNC_UN
1606 !verbose pop
1607 !endif
1608 !macroend
1611 ################################################################################
1612 # Macros for handling DLL registration
1614 !macro RegisterDLL DLL
1616 ; The x64 regsvr32.exe registers x86 DLL's properly on Windows Vista and above
1617 ; (not on Windows XP http://support.microsoft.com/kb/282747) so just use it
1618 ; when installing on an x64 systems even when installing an x86 application.
1619 ${If} ${RunningX64}
1620 ${DisableX64FSRedirection}
1621 ExecWait '"$SYSDIR\regsvr32.exe" /s "${DLL}"'
1622 ${EnableX64FSRedirection}
1623 ${Else}
1624 RegDLL "${DLL}"
1625 ${EndIf}
1627 !macroend
1629 !macro UnregisterDLL DLL
1631 ; The x64 regsvr32.exe registers x86 DLL's properly on Windows Vista and above
1632 ; (not on Windows XP http://support.microsoft.com/kb/282747) so just use it
1633 ; when installing on an x64 systems even when installing an x86 application.
1634 ${If} ${RunningX64}
1635 ${DisableX64FSRedirection}
1636 ExecWait '"$SYSDIR\regsvr32.exe" /s /u "${DLL}"'
1637 ${EnableX64FSRedirection}
1638 ${Else}
1639 UnRegDLL "${DLL}"
1640 ${EndIf}
1642 !macroend
1644 !define RegisterDLL `!insertmacro RegisterDLL`
1645 !define UnregisterDLL `!insertmacro UnregisterDLL`
1648 ################################################################################
1649 # Macros for retrieving existing install paths
1651 /**
1652 * Finds a second installation of the application so we can make informed
1653 * decisions about registry operations. This uses SHCTX to determine the
1654 * registry hive so you must call SetShellVarContext first.
1655 *
1656 * @param _KEY
1657 * The registry subkey (typically this will be Software\Mozilla).
1658 * @return _RESULT
1659 * false if a second install isn't found, path to the main exe if a
1660 * second install is found.
1661 *
1662 * $R3 = stores the long path to $INSTDIR
1663 * $R4 = counter for the outer loop's EnumRegKey
1664 * $R5 = return value from ReadRegStr and RemoveQuotesFromPath
1665 * $R6 = return value from GetParent
1666 * $R7 = return value from the loop's EnumRegKey
1667 * $R8 = storage for _KEY
1668 * $R9 = _KEY and _RESULT
1669 */
1670 !macro GetSecondInstallPath
1672 !ifndef ${_MOZFUNC_UN}GetSecondInstallPath
1673 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
1674 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
1675 !insertmacro ${_MOZFUNC_UN_TMP}GetParent
1676 !insertmacro ${_MOZFUNC_UN_TMP}RemoveQuotesFromPath
1677 !undef _MOZFUNC_UN
1678 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
1679 !undef _MOZFUNC_UN_TMP
1681 !verbose push
1682 !verbose ${_MOZFUNC_VERBOSE}
1683 !define ${_MOZFUNC_UN}GetSecondInstallPath "!insertmacro ${_MOZFUNC_UN}GetSecondInstallPathCall"
1685 Function ${_MOZFUNC_UN}GetSecondInstallPath
1686 Exch $R9
1687 Push $R8
1688 Push $R7
1689 Push $R6
1690 Push $R5
1691 Push $R4
1692 Push $R3
1694 ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR" $R3
1696 StrCpy $R4 0 ; set the counter for the loop to 0
1697 StrCpy $R8 "$R9" ; Registry key path to search
1698 StrCpy $R9 "false" ; default return value
1700 loop:
1701 EnumRegKey $R7 SHCTX $R8 $R4
1702 StrCmp $R7 "" end +1 ; if empty there are no more keys to enumerate
1703 IntOp $R4 $R4 + 1 ; increment the loop's counter
1704 ClearErrors
1705 ReadRegStr $R5 SHCTX "$R8\$R7\bin" "PathToExe"
1706 IfErrors loop
1708 ${${_MOZFUNC_UN}RemoveQuotesFromPath} "$R5" $R5
1710 IfFileExists "$R5" +1 loop
1711 ${${_MOZFUNC_UN}GetLongPath} "$R5" $R5
1712 ${${_MOZFUNC_UN}GetParent} "$R5" $R6
1713 StrCmp "$R6" "$R3" loop +1
1714 StrCmp "$R6\${FileMainEXE}" "$R5" +1 loop
1715 StrCpy $R9 "$R5"
1717 end:
1718 ClearErrors
1720 Pop $R3
1721 Pop $R4
1722 Pop $R5
1723 Pop $R6
1724 Pop $R7
1725 Pop $R8
1726 Exch $R9
1727 FunctionEnd
1729 !verbose pop
1730 !endif
1731 !macroend
1733 !macro GetSecondInstallPathCall _KEY _RESULT
1734 !verbose push
1735 !verbose ${_MOZFUNC_VERBOSE}
1736 Push "${_KEY}"
1737 Call GetSecondInstallPath
1738 Pop ${_RESULT}
1739 !verbose pop
1740 !macroend
1742 !macro un.GetSecondInstallPathCall _KEY _RESULT
1743 !verbose push
1744 !verbose ${_MOZFUNC_VERBOSE}
1745 Push "${_KEY}"
1746 Call un.GetSecondInstallPath
1747 Pop ${_RESULT}
1748 !verbose pop
1749 !macroend
1751 !macro un.GetSecondInstallPath
1752 !ifndef un.GetSecondInstallPath
1753 !verbose push
1754 !verbose ${_MOZFUNC_VERBOSE}
1755 !undef _MOZFUNC_UN
1756 !define _MOZFUNC_UN "un."
1758 !insertmacro GetSecondInstallPath
1760 !undef _MOZFUNC_UN
1761 !define _MOZFUNC_UN
1762 !verbose pop
1763 !endif
1764 !macroend
1766 /**
1767 * Finds an existing installation path for the application based on the
1768 * application's executable name so we can default to using this path for the
1769 * install. If there is zero or more than one installation of the application
1770 * then we default to the default installation path. This uses SHCTX to
1771 * determine the registry hive to read from so you must call SetShellVarContext
1772 * first.
1773 *
1774 * @param _KEY
1775 * The registry subkey (typically this will be Software\Mozilla\App Name).
1776 * @return _RESULT
1777 * false if a single install location for this app name isn't found,
1778 * path to the install directory if a single install location is found.
1779 *
1780 * $R5 = counter for the loop's EnumRegKey
1781 * $R6 = return value from EnumRegKey
1782 * $R7 = return value from ReadRegStr
1783 * $R8 = storage for _KEY
1784 * $R9 = _KEY and _RESULT
1785 */
1786 !macro GetSingleInstallPath
1788 !ifndef ${_MOZFUNC_UN}GetSingleInstallPath
1789 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
1790 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
1791 !insertmacro ${_MOZFUNC_UN_TMP}GetParent
1792 !insertmacro ${_MOZFUNC_UN_TMP}RemoveQuotesFromPath
1793 !undef _MOZFUNC_UN
1794 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
1795 !undef _MOZFUNC_UN_TMP
1797 !verbose push
1798 !verbose ${_MOZFUNC_VERBOSE}
1799 !define ${_MOZFUNC_UN}GetSingleInstallPath "!insertmacro ${_MOZFUNC_UN}GetSingleInstallPathCall"
1801 Function ${_MOZFUNC_UN}GetSingleInstallPath
1802 Exch $R9
1803 Push $R8
1804 Push $R7
1805 Push $R6
1806 Push $R5
1808 StrCpy $R8 $R9
1809 StrCpy $R9 "false"
1810 StrCpy $R5 0 ; set the counter for the loop to 0
1812 loop:
1813 ClearErrors
1814 EnumRegKey $R6 SHCTX $R8 $R5
1815 IfErrors cleanup
1816 StrCmp $R6 "" cleanup +1 ; if empty there are no more keys to enumerate
1817 IntOp $R5 $R5 + 1 ; increment the loop's counter
1818 ClearErrors
1819 ReadRegStr $R7 SHCTX "$R8\$R6\Main" "PathToExe"
1820 IfErrors loop
1821 ${${_MOZFUNC_UN}RemoveQuotesFromPath} "$R7" $R7
1822 GetFullPathName $R7 "$R7"
1823 IfErrors loop
1825 StrCmp "$R9" "false" +1 +3
1826 StrCpy $R9 "$R7"
1827 GoTo Loop
1829 StrCpy $R9 "false"
1831 cleanup:
1832 StrCmp $R9 "false" end +1
1833 ${${_MOZFUNC_UN}GetLongPath} "$R9" $R9
1834 ${${_MOZFUNC_UN}GetParent} "$R9" $R9
1836 end:
1837 ClearErrors
1839 Pop $R5
1840 Pop $R6
1841 Pop $R7
1842 Pop $R8
1843 Exch $R9
1844 FunctionEnd
1846 !verbose pop
1847 !endif
1848 !macroend
1850 !macro GetSingleInstallPathCall _KEY _RESULT
1851 !verbose push
1852 !verbose ${_MOZFUNC_VERBOSE}
1853 Push "${_KEY}"
1854 Call GetSingleInstallPath
1855 Pop ${_RESULT}
1856 !verbose pop
1857 !macroend
1859 !macro un.GetSingleInstallPathCall _KEY _RESULT
1860 !verbose push
1861 !verbose ${_MOZFUNC_VERBOSE}
1862 Push "${_KEY}"
1863 Call un.GetSingleInstallPath
1864 Pop ${_RESULT}
1865 !verbose pop
1866 !macroend
1868 !macro un.GetSingleInstallPath
1869 !ifndef un.GetSingleInstallPath
1870 !verbose push
1871 !verbose ${_MOZFUNC_VERBOSE}
1872 !undef _MOZFUNC_UN
1873 !define _MOZFUNC_UN "un."
1875 !insertmacro GetSingleInstallPath
1877 !undef _MOZFUNC_UN
1878 !define _MOZFUNC_UN
1879 !verbose pop
1880 !endif
1881 !macroend
1884 ################################################################################
1885 # Macros for working with the file system
1887 /**
1888 * Attempts to delete a file if it exists. This will fail if the file is in use.
1889 *
1890 * @param _FILE
1891 * The path to the file that is to be deleted.
1892 */
1893 !macro DeleteFile _FILE
1894 ${If} ${FileExists} "${_FILE}"
1895 Delete "${_FILE}"
1896 ${EndIf}
1897 !macroend
1898 !define DeleteFile "!insertmacro DeleteFile"
1900 /**
1901 * Removes a directory if it exists and is empty.
1902 *
1903 * @param _DIR
1904 * The path to the directory that is to be removed.
1905 */
1906 !macro RemoveDir _DIR
1907 ${If} ${FileExists} "${_DIR}"
1908 RmDir "${_DIR}"
1909 ${EndIf}
1910 !macroend
1911 !define RemoveDir "!insertmacro RemoveDir"
1913 /**
1914 * Checks whether it is possible to create and delete a directory and a file in
1915 * the install directory. Creation and deletion of files and directories are
1916 * checked since a user may have rights for one and not the other. If creation
1917 * and deletion of a file and a directory are successful this macro will return
1918 * true... if not, this it return false.
1919 *
1920 * @return _RESULT
1921 * true if files and directories can be created and deleted in the
1922 * install directory otherwise false.
1923 *
1924 * $R8 = temporary filename in the installation directory returned from
1925 * GetTempFileName.
1926 * $R9 = _RESULT
1927 */
1928 !macro CanWriteToInstallDir
1930 !ifndef ${_MOZFUNC_UN}CanWriteToInstallDir
1931 !verbose push
1932 !verbose ${_MOZFUNC_VERBOSE}
1933 !define ${_MOZFUNC_UN}CanWriteToInstallDir "!insertmacro ${_MOZFUNC_UN}CanWriteToInstallDirCall"
1935 Function ${_MOZFUNC_UN}CanWriteToInstallDir
1936 Push $R9
1937 Push $R8
1939 StrCpy $R9 "true"
1941 ; IfFileExists returns false for $INSTDIR when $INSTDIR is the root of a
1942 ; UNC path so always try to create $INSTDIR
1943 CreateDirectory "$INSTDIR\"
1944 GetTempFileName $R8 "$INSTDIR\"
1946 ${Unless} ${FileExists} $R8 ; Can files be created?
1947 StrCpy $R9 "false"
1948 Goto done
1949 ${EndUnless}
1951 Delete $R8
1952 ${If} ${FileExists} $R8 ; Can files be deleted?
1953 StrCpy $R9 "false"
1954 Goto done
1955 ${EndIf}
1957 CreateDirectory $R8
1958 ${Unless} ${FileExists} $R8 ; Can directories be created?
1959 StrCpy $R9 "false"
1960 Goto done
1961 ${EndUnless}
1963 RmDir $R8
1964 ${If} ${FileExists} $R8 ; Can directories be deleted?
1965 StrCpy $R9 "false"
1966 Goto done
1967 ${EndIf}
1969 done:
1971 RmDir "$INSTDIR\" ; Only remove $INSTDIR if it is empty
1972 ClearErrors
1974 Pop $R8
1975 Exch $R9
1976 FunctionEnd
1978 !verbose pop
1979 !endif
1980 !macroend
1982 !macro CanWriteToInstallDirCall _RESULT
1983 !verbose push
1984 !verbose ${_MOZFUNC_VERBOSE}
1985 Call CanWriteToInstallDir
1986 Pop ${_RESULT}
1987 !verbose pop
1988 !macroend
1990 !macro un.CanWriteToInstallDirCall _RESULT
1991 !verbose push
1992 !verbose ${_MOZFUNC_VERBOSE}
1993 Call un.CanWriteToInstallDir
1994 Pop ${_RESULT}
1995 !verbose pop
1996 !macroend
1998 !macro un.CanWriteToInstallDir
1999 !ifndef un.CanWriteToInstallDir
2000 !verbose push
2001 !verbose ${_MOZFUNC_VERBOSE}
2002 !undef _MOZFUNC_UN
2003 !define _MOZFUNC_UN "un."
2005 !insertmacro CanWriteToInstallDir
2007 !undef _MOZFUNC_UN
2008 !define _MOZFUNC_UN
2009 !verbose pop
2010 !endif
2011 !macroend
2013 /**
2014 * Checks whether there is sufficient free space available for the installation
2015 * directory using GetDiskFreeSpaceExW which respects disk quotas. This macro
2016 * will calculate the size of all sections that are selected, compare that with
2017 * the free space available, and if there is sufficient free space it will
2018 * return true... if not, it will return false.
2019 *
2020 * @return _RESULT
2021 * "true" if there is sufficient free space otherwise "false".
2022 *
2023 * $R5 = return value from SectionGetSize
2024 * $R6 = return value from SectionGetFlags
2025 * return value from an 'and' comparison of SectionGetFlags (1=selected)
2026 * return value for lpFreeBytesAvailable from GetDiskFreeSpaceExW
2027 * return value for System::Int64Op $R6 / 1024
2028 * return value for System::Int64Op $R6 > $R8
2029 * $R7 = the counter for enumerating the sections
2030 * the temporary file name for the directory created under $INSTDIR passed
2031 * to GetDiskFreeSpaceExW.
2032 * $R8 = sum in KB of all selected sections
2033 * $R9 = _RESULT
2034 */
2035 !macro CheckDiskSpace
2037 !ifndef ${_MOZFUNC_UN}CheckDiskSpace
2038 !verbose push
2039 !verbose ${_MOZFUNC_VERBOSE}
2040 !define ${_MOZFUNC_UN}CheckDiskSpace "!insertmacro ${_MOZFUNC_UN}CheckDiskSpaceCall"
2042 Function ${_MOZFUNC_UN}CheckDiskSpace
2043 Push $R9
2044 Push $R8
2045 Push $R7
2046 Push $R6
2047 Push $R5
2049 ClearErrors
2051 StrCpy $R9 "true" ; default return value
2052 StrCpy $R8 "0" ; sum in KB of all selected sections
2053 StrCpy $R7 "0" ; counter for enumerating sections
2055 ; Enumerate the sections and sum up the sizes of the sections that are
2056 ; selected.
2057 SectionGetFlags $R7 $R6
2058 IfErrors +7 +1
2059 IntOp $R6 ${SF_SELECTED} & $R6
2060 IntCmp $R6 0 +3 +1 +1
2061 SectionGetSize $R7 $R5
2062 IntOp $R8 $R8 + $R5
2063 IntOp $R7 $R7 + 1
2064 GoTo -7
2066 ; The directory passed to GetDiskFreeSpaceExW must exist for the call to
2067 ; succeed. Since the CanWriteToInstallDir macro is called prior to this
2068 ; macro the call to CreateDirectory will always succeed.
2070 ; IfFileExists returns false for $INSTDIR when $INSTDIR is the root of a
2071 ; UNC path so always try to create $INSTDIR
2072 CreateDirectory "$INSTDIR\"
2073 GetTempFileName $R7 "$INSTDIR\"
2074 Delete "$R7"
2075 CreateDirectory "$R7"
2077 System::Call 'kernel32::GetDiskFreeSpaceExW(w, *l, *l, *l) i(R7, .R6, ., .) .'
2079 ; Convert to KB for comparison with $R8 which is in KB
2080 System::Int64Op $R6 / 1024
2081 Pop $R6
2083 System::Int64Op $R6 > $R8
2084 Pop $R6
2086 IntCmp $R6 1 end +1 +1
2087 StrCpy $R9 "false"
2089 end:
2090 RmDir "$R7"
2091 RmDir "$INSTDIR\" ; Only remove $INSTDIR if it is empty
2093 ClearErrors
2095 Pop $R5
2096 Pop $R6
2097 Pop $R7
2098 Pop $R8
2099 Exch $R9
2100 FunctionEnd
2102 !verbose pop
2103 !endif
2104 !macroend
2106 !macro CheckDiskSpaceCall _RESULT
2107 !verbose push
2108 !verbose ${_MOZFUNC_VERBOSE}
2109 Call CheckDiskSpace
2110 Pop ${_RESULT}
2111 !verbose pop
2112 !macroend
2114 !macro un.CheckDiskSpaceCall _RESULT
2115 !verbose push
2116 !verbose ${_MOZFUNC_VERBOSE}
2117 Call un.CheckDiskSpace
2118 Pop ${_RESULT}
2119 !verbose pop
2120 !macroend
2122 !macro un.CheckDiskSpace
2123 !ifndef un.CheckDiskSpace
2124 !verbose push
2125 !verbose ${_MOZFUNC_VERBOSE}
2126 !undef _MOZFUNC_UN
2127 !define _MOZFUNC_UN "un."
2129 !insertmacro CheckDiskSpace
2131 !undef _MOZFUNC_UN
2132 !define _MOZFUNC_UN
2133 !verbose pop
2134 !endif
2135 !macroend
2137 /**
2138 * Returns the path found within a passed in string. The path is quoted or not
2139 * with the exception of an unquoted non 8dot3 path without arguments that is
2140 * also not a DefaultIcon path, is a 8dot3 path or not, has command line
2141 * arguments, or is a registry DefaultIcon path (e.g. <path to binary>,# where #
2142 * is the icon's resuorce id). The string does not need to be a valid path or
2143 * exist. It is up to the caller to pass in a string of one of the forms noted
2144 * above and to verify existence if necessary.
2145 *
2146 * Examples:
2147 * In: C:\PROGRA~1\MOZILL~1\FIREFOX.EXE -flag "%1"
2148 * In: C:\PROGRA~1\MOZILL~1\FIREFOX.EXE,0
2149 * In: C:\PROGRA~1\MOZILL~1\FIREFOX.EXE
2150 * In: "C:\PROGRA~1\MOZILL~1\FIREFOX.EXE"
2151 * In: "C:\PROGRA~1\MOZILL~1\FIREFOX.EXE" -flag "%1"
2152 * Out: C:\PROGRA~1\MOZILL~1\FIREFOX.EXE
2153 *
2154 * In: "C:\Program Files\Mozilla Firefox\firefox.exe" -flag "%1"
2155 * In: C:\Program Files\Mozilla Firefox\firefox.exe,0
2156 * In: "C:\Program Files\Mozilla Firefox\firefox.exe"
2157 * Out: C:\Program Files\Mozilla Firefox\firefox.exe
2158 *
2159 * @param _IN_PATH
2160 * The string containing the path.
2161 * @param _OUT_PATH
2162 * The register to store the path to.
2163 *
2164 * $R7 = counter for the outer loop's EnumRegKey
2165 * $R8 = return value from ReadRegStr
2166 * $R9 = _IN_PATH and _OUT_PATH
2167 */
2168 !macro GetPathFromString
2170 !ifndef ${_MOZFUNC_UN}GetPathFromString
2171 !verbose push
2172 !verbose ${_MOZFUNC_VERBOSE}
2173 !define ${_MOZFUNC_UN}GetPathFromString "!insertmacro ${_MOZFUNC_UN}GetPathFromStringCall"
2175 Function ${_MOZFUNC_UN}GetPathFromString
2176 Exch $R9
2177 Push $R8
2178 Push $R7
2180 StrCpy $R7 0 ; Set the counter to 0.
2182 ; Handle quoted paths with arguments.
2183 StrCpy $R8 $R9 1 ; Copy the first char.
2184 StrCmp $R8 '"' +2 +1 ; Is it a "?
2185 StrCmp $R8 "'" +1 +9 ; Is it a '?
2186 StrCpy $R9 $R9 "" 1 ; Remove the first char.
2187 IntOp $R7 $R7 + 1 ; Increment the counter.
2188 StrCpy $R8 $R9 1 $R7 ; Starting from the counter copy the next char.
2189 StrCmp $R8 "" end +1 ; Are there no more chars?
2190 StrCmp $R8 '"' +2 +1 ; Is it a " char?
2191 StrCmp $R8 "'" +1 -4 ; Is it a ' char?
2192 StrCpy $R9 $R9 $R7 ; Copy chars up to the counter.
2193 GoTo end
2195 ; Handle DefaultIcon paths. DefaultIcon paths are not quoted and end with
2196 ; a , and a number.
2197 IntOp $R7 $R7 - 1 ; Decrement the counter.
2198 StrCpy $R8 $R9 1 $R7 ; Copy one char from the end minus the counter.
2199 StrCmp $R8 '' +4 +1 ; Are there no more chars?
2200 StrCmp $R8 ',' +1 -3 ; Is it a , char?
2201 StrCpy $R9 $R9 $R7 ; Copy chars up to the end minus the counter.
2202 GoTo end
2204 ; Handle unquoted paths with arguments. An unquoted path with arguments
2205 ; must be an 8dot3 path.
2206 StrCpy $R7 -1 ; Set the counter to -1 so it will start at 0.
2207 IntOp $R7 $R7 + 1 ; Increment the counter.
2208 StrCpy $R8 $R9 1 $R7 ; Starting from the counter copy the next char.
2209 StrCmp $R8 "" end +1 ; Are there no more chars?
2210 StrCmp $R8 " " +1 -3 ; Is it a space char?
2211 StrCpy $R9 $R9 $R7 ; Copy chars up to the counter.
2213 end:
2214 ClearErrors
2216 Pop $R7
2217 Pop $R8
2218 Exch $R9
2219 FunctionEnd
2221 !verbose pop
2222 !endif
2223 !macroend
2225 !macro GetPathFromStringCall _IN_PATH _OUT_PATH
2226 !verbose push
2227 !verbose ${_MOZFUNC_VERBOSE}
2228 Push "${_IN_PATH}"
2229 Call GetPathFromString
2230 Pop ${_OUT_PATH}
2231 !verbose pop
2232 !macroend
2234 !macro un.GetPathFromStringCall _IN_PATH _OUT_PATH
2235 !verbose push
2236 !verbose ${_MOZFUNC_VERBOSE}
2237 Push "${_IN_PATH}"
2238 Call un.GetPathFromString
2239 Pop ${_OUT_PATH}
2240 !verbose pop
2241 !macroend
2243 !macro un.GetPathFromString
2244 !ifndef un.GetPathFromString
2245 !verbose push
2246 !verbose ${_MOZFUNC_VERBOSE}
2247 !undef _MOZFUNC_UN
2248 !define _MOZFUNC_UN "un."
2250 !insertmacro GetPathFromString
2252 !undef _MOZFUNC_UN
2253 !define _MOZFUNC_UN
2254 !verbose pop
2255 !endif
2256 !macroend
2258 /**
2259 * Removes the quotes from each end of a string if present.
2260 *
2261 * @param _IN_PATH
2262 * The string containing the path.
2263 * @param _OUT_PATH
2264 * The register to store the long path.
2265 *
2266 * $R7 = storage for single character comparison
2267 * $R8 = storage for _IN_PATH
2268 * $R9 = _IN_PATH and _OUT_PATH
2269 */
2270 !macro RemoveQuotesFromPath
2272 !ifndef ${_MOZFUNC_UN}RemoveQuotesFromPath
2273 !verbose push
2274 !verbose ${_MOZFUNC_VERBOSE}
2275 !define ${_MOZFUNC_UN}RemoveQuotesFromPath "!insertmacro ${_MOZFUNC_UN}RemoveQuotesFromPathCall"
2277 Function ${_MOZFUNC_UN}RemoveQuotesFromPath
2278 Exch $R9
2279 Push $R8
2280 Push $R7
2282 StrCpy $R7 "$R9" 1
2283 StrCmp $R7 "$\"" +1 +2
2284 StrCpy $R9 "$R9" "" 1
2286 StrCpy $R7 "$R9" "" -1
2287 StrCmp $R7 "$\"" +1 +2
2288 StrCpy $R9 "$R9" -1
2290 Pop $R7
2291 Pop $R8
2292 Exch $R9
2293 FunctionEnd
2295 !verbose pop
2296 !endif
2297 !macroend
2299 !macro RemoveQuotesFromPathCall _IN_PATH _OUT_PATH
2300 !verbose push
2301 !verbose ${_MOZFUNC_VERBOSE}
2302 Push "${_IN_PATH}"
2303 Call RemoveQuotesFromPath
2304 Pop ${_OUT_PATH}
2305 !verbose pop
2306 !macroend
2308 !macro un.RemoveQuotesFromPathCall _IN_PATH _OUT_PATH
2309 !verbose push
2310 !verbose ${_MOZFUNC_VERBOSE}
2311 Push "${_IN_PATH}"
2312 Call un.RemoveQuotesFromPath
2313 Pop ${_OUT_PATH}
2314 !verbose pop
2315 !macroend
2317 !macro un.RemoveQuotesFromPath
2318 !ifndef un.RemoveQuotesFromPath
2319 !verbose push
2320 !verbose ${_MOZFUNC_VERBOSE}
2321 !undef _MOZFUNC_UN
2322 !define _MOZFUNC_UN "un."
2324 !insertmacro RemoveQuotesFromPath
2326 !undef _MOZFUNC_UN
2327 !define _MOZFUNC_UN
2328 !verbose pop
2329 !endif
2330 !macroend
2332 /**
2333 * Returns the long path for an existing file or directory. GetLongPathNameW
2334 * may not be available on Win95 if Microsoft Layer for Unicode is not
2335 * installed and GetFullPathName only returns a long path for the last file or
2336 * directory that doesn't end with a \ in the path that it is passed. If the
2337 * path does not exist on the file system this will return an empty string. To
2338 * provide a consistent result trailing back-slashes are always removed.
2339 *
2340 * Note: 1024 used by GetLongPathNameW is the maximum NSIS string length.
2341 *
2342 * @param _IN_PATH
2343 * The string containing the path.
2344 * @param _OUT_PATH
2345 * The register to store the long path.
2346 *
2347 * $R4 = counter value when the previous \ was found
2348 * $R5 = directory or file name found during loop
2349 * $R6 = return value from GetLongPathNameW and loop counter
2350 * $R7 = long path from GetLongPathNameW and single char from path for comparison
2351 * $R8 = storage for _IN_PATH
2352 * $R9 = _IN_PATH _OUT_PATH
2353 */
2354 !macro GetLongPath
2356 !ifndef ${_MOZFUNC_UN}GetLongPath
2357 !verbose push
2358 !verbose ${_MOZFUNC_VERBOSE}
2359 !define ${_MOZFUNC_UN}GetLongPath "!insertmacro ${_MOZFUNC_UN}GetLongPathCall"
2361 Function ${_MOZFUNC_UN}GetLongPath
2362 Exch $R9
2363 Push $R8
2364 Push $R7
2365 Push $R6
2366 Push $R5
2367 Push $R4
2369 ClearErrors
2371 GetFullPathName $R8 "$R9"
2372 IfErrors end_GetLongPath +1 ; If the path doesn't exist return an empty string.
2374 System::Call 'kernel32::GetLongPathNameW(w R8, w .R7, i 1024)i .R6'
2375 StrCmp "$R7" "" +4 +1 ; Empty string when GetLongPathNameW is not present.
2376 StrCmp $R6 0 +3 +1 ; Should never equal 0 since the path exists.
2377 StrCpy $R9 "$R7"
2378 GoTo end_GetLongPath
2380 ; Do it the hard way.
2381 StrCpy $R4 0 ; Stores the position in the string of the last \ found.
2382 StrCpy $R6 -1 ; Set the counter to -1 so it will start at 0.
2384 loop_GetLongPath:
2385 IntOp $R6 $R6 + 1 ; Increment the counter.
2386 StrCpy $R7 $R8 1 $R6 ; Starting from the counter copy the next char.
2387 StrCmp $R7 "" +2 +1 ; Are there no more chars?
2388 StrCmp $R7 "\" +1 -3 ; Is it a \?
2390 ; Copy chars starting from the previously found \ to the counter.
2391 StrCpy $R5 $R8 $R6 $R4
2393 ; If this is the first \ found we want to swap R9 with R5 so a \ will
2394 ; be appended to the drive letter and colon (e.g. C: will become C:\).
2395 StrCmp $R4 0 +1 +3
2396 StrCpy $R9 $R5
2397 StrCpy $R5 ""
2399 GetFullPathName $R9 "$R9\$R5"
2401 StrCmp $R7 "" end_GetLongPath +1 ; Are there no more chars?
2403 ; Store the counter for the current \ and prefix it for StrCpy operations.
2404 StrCpy $R4 "+$R6"
2405 IntOp $R6 $R6 + 1 ; Increment the counter so we skip over the \.
2406 StrCpy $R8 $R8 "" $R6 ; Copy chars starting from the counter to the end.
2407 StrCpy $R6 -1 ; Reset the counter to -1 so it will start over at 0.
2408 GoTo loop_GetLongPath
2410 end_GetLongPath:
2411 ; If there is a trailing slash remove it
2412 StrCmp $R9 "" +4 +1
2413 StrCpy $R8 "$R9" "" -1
2414 StrCmp $R8 "\" +1 +2
2415 StrCpy $R9 "$R9" -1
2417 ClearErrors
2419 Pop $R4
2420 Pop $R5
2421 Pop $R6
2422 Pop $R7
2423 Pop $R8
2424 Exch $R9
2425 FunctionEnd
2427 !verbose pop
2428 !endif
2429 !macroend
2431 !macro GetLongPathCall _IN_PATH _OUT_PATH
2432 !verbose push
2433 !verbose ${_MOZFUNC_VERBOSE}
2434 Push "${_IN_PATH}"
2435 Call GetLongPath
2436 Pop ${_OUT_PATH}
2437 !verbose pop
2438 !macroend
2440 !macro un.GetLongPathCall _IN_PATH _OUT_PATH
2441 !verbose push
2442 !verbose ${_MOZFUNC_VERBOSE}
2443 Push "${_IN_PATH}"
2444 Call un.GetLongPath
2445 Pop ${_OUT_PATH}
2446 !verbose pop
2447 !macroend
2449 !macro un.GetLongPath
2450 !ifndef un.GetLongPath
2451 !verbose push
2452 !verbose ${_MOZFUNC_VERBOSE}
2453 !undef _MOZFUNC_UN
2454 !define _MOZFUNC_UN "un."
2456 !insertmacro GetLongPath
2458 !undef _MOZFUNC_UN
2459 !define _MOZFUNC_UN
2460 !verbose pop
2461 !endif
2462 !macroend
2465 ################################################################################
2466 # Macros for cleaning up the registry and file system
2468 /**
2469 * Removes registry keys that reference this install location and for paths that
2470 * no longer exist. This uses SHCTX to determine the registry hive so you must
2471 * call SetShellVarContext first.
2472 *
2473 * @param _KEY
2474 * The registry subkey (typically this will be Software\Mozilla).
2475 *
2476 * XXXrstrong - there is the potential for Key: Software/Mozilla/AppName,
2477 * ValueName: CurrentVersion, ValueData: AppVersion to reference a key that is
2478 * no longer available due to this cleanup. This should be no worse than prior
2479 * to this reg cleanup since the referenced key would be for an app that is no
2480 * longer installed on the system.
2481 *
2482 * $R0 = on x64 systems set to 'false' at the beginning of the macro when
2483 * enumerating the x86 registry view and set to 'true' when enumerating
2484 * the x64 registry view.
2485 * $R1 = stores the long path to $INSTDIR
2486 * $R2 = return value from the stack from the GetParent and GetLongPath macros
2487 * $R3 = return value from the outer loop's EnumRegKey
2488 * $R4 = return value from the inner loop's EnumRegKey
2489 * $R5 = return value from ReadRegStr
2490 * $R6 = counter for the outer loop's EnumRegKey
2491 * $R7 = counter for the inner loop's EnumRegKey
2492 * $R8 = return value from the stack from the RemoveQuotesFromPath macro
2493 * $R9 = _KEY
2494 */
2495 !macro RegCleanMain
2497 !ifndef ${_MOZFUNC_UN}RegCleanMain
2498 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
2499 !insertmacro ${_MOZFUNC_UN_TMP}GetParent
2500 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
2501 !insertmacro ${_MOZFUNC_UN_TMP}RemoveQuotesFromPath
2502 !undef _MOZFUNC_UN
2503 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
2504 !undef _MOZFUNC_UN_TMP
2506 !verbose push
2507 !verbose ${_MOZFUNC_VERBOSE}
2508 !define ${_MOZFUNC_UN}RegCleanMain "!insertmacro ${_MOZFUNC_UN}RegCleanMainCall"
2510 Function ${_MOZFUNC_UN}RegCleanMain
2511 Exch $R9
2512 Push $R8
2513 Push $R7
2514 Push $R6
2515 Push $R5
2516 Push $R4
2517 Push $R3
2518 Push $R2
2519 Push $R1
2520 Push $R0
2522 ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR" $R1
2523 StrCpy $R6 0 ; set the counter for the outer loop to 0
2525 ${If} ${RunningX64}
2526 StrCpy $R0 "false"
2527 ; Set the registry to the 32 bit registry for 64 bit installations or to
2528 ; the 64 bit registry for 32 bit installations at the beginning so it can
2529 ; easily be set back to the correct registry view when finished.
2530 !ifdef HAVE_64BIT_OS
2531 SetRegView 32
2532 !else
2533 SetRegView 64
2534 !endif
2535 ${EndIf}
2537 outerloop:
2538 EnumRegKey $R3 SHCTX $R9 $R6
2539 StrCmp $R3 "" end +1 ; if empty there are no more keys to enumerate
2540 IntOp $R6 $R6 + 1 ; increment the outer loop's counter
2541 ClearErrors
2542 ReadRegStr $R5 SHCTX "$R9\$R3\bin" "PathToExe"
2543 IfErrors 0 outercontinue
2544 StrCpy $R7 0 ; set the counter for the inner loop to 0
2546 innerloop:
2547 EnumRegKey $R4 SHCTX "$R9\$R3" $R7
2548 StrCmp $R4 "" outerloop +1 ; if empty there are no more keys to enumerate
2549 IntOp $R7 $R7 + 1 ; increment the inner loop's counter
2550 ClearErrors
2551 ReadRegStr $R5 SHCTX "$R9\$R3\$R4\Main" "PathToExe"
2552 IfErrors innerloop
2554 ${${_MOZFUNC_UN}RemoveQuotesFromPath} "$R5" $R8
2555 ${${_MOZFUNC_UN}GetParent} "$R8" $R2
2556 ${${_MOZFUNC_UN}GetLongPath} "$R2" $R2
2557 IfFileExists "$R2" +1 innerloop
2558 StrCmp "$R2" "$R1" +1 innerloop
2560 ClearErrors
2561 DeleteRegKey SHCTX "$R9\$R3\$R4"
2562 IfErrors innerloop
2563 IntOp $R7 $R7 - 1 ; decrement the inner loop's counter when the key is deleted successfully.
2564 ClearErrors
2565 DeleteRegKey /ifempty SHCTX "$R9\$R3"
2566 IfErrors innerloop outerdecrement
2568 outercontinue:
2569 ${${_MOZFUNC_UN}RemoveQuotesFromPath} "$R5" $R8
2570 ${${_MOZFUNC_UN}GetParent} "$R8" $R2
2571 ${${_MOZFUNC_UN}GetLongPath} "$R2" $R2
2572 IfFileExists "$R2" +1 outerloop
2573 StrCmp "$R2" "$R1" +1 outerloop
2575 ClearErrors
2576 DeleteRegKey SHCTX "$R9\$R3"
2577 IfErrors outerloop
2579 outerdecrement:
2580 IntOp $R6 $R6 - 1 ; decrement the outer loop's counter when the key is deleted successfully.
2581 GoTo outerloop
2583 end:
2584 ${If} ${RunningX64}
2585 ${AndIf} "$R0" == "false"
2586 ; Set the registry to the correct view.
2587 !ifdef HAVE_64BIT_OS
2588 SetRegView 64
2589 !else
2590 SetRegView 32
2591 !endif
2593 StrCpy $R6 0 ; set the counter for the outer loop to 0
2594 StrCpy $R0 "true"
2595 GoTo outerloop
2596 ${EndIf}
2598 ClearErrors
2600 Pop $R0
2601 Pop $R1
2602 Pop $R2
2603 Pop $R3
2604 Pop $R4
2605 Pop $R5
2606 Pop $R6
2607 Pop $R7
2608 Pop $R8
2609 Exch $R9
2610 FunctionEnd
2612 !verbose pop
2613 !endif
2614 !macroend
2616 !macro RegCleanMainCall _KEY
2617 !verbose push
2618 !verbose ${_MOZFUNC_VERBOSE}
2619 Push "${_KEY}"
2620 Call RegCleanMain
2621 !verbose pop
2622 !macroend
2624 !macro un.RegCleanMainCall _KEY
2625 !verbose push
2626 !verbose ${_MOZFUNC_VERBOSE}
2627 Push "${_KEY}"
2628 Call un.RegCleanMain
2629 !verbose pop
2630 !macroend
2632 !macro un.RegCleanMain
2633 !ifndef un.RegCleanMain
2634 !verbose push
2635 !verbose ${_MOZFUNC_VERBOSE}
2636 !undef _MOZFUNC_UN
2637 !define _MOZFUNC_UN "un."
2639 !insertmacro RegCleanMain
2641 !undef _MOZFUNC_UN
2642 !define _MOZFUNC_UN
2643 !verbose pop
2644 !endif
2645 !macroend
2647 /**
2648 * Removes all registry keys from \Software\Windows\CurrentVersion\Uninstall
2649 * that reference this install location in both the 32 bit and 64 bit registry
2650 * view. This macro uses SHCTX to determine the registry hive so you must call
2651 * SetShellVarContext first.
2652 *
2653 * $R3 = on x64 systems set to 'false' at the beginning of the macro when
2654 * enumerating the x86 registry view and set to 'true' when enumerating
2655 * the x64 registry view.
2656 * $R4 = stores the long path to $INSTDIR
2657 * $R5 = return value from ReadRegStr
2658 * $R6 = string for the base reg key (e.g. Software\Microsoft\Windows\CurrentVersion\Uninstall)
2659 * $R7 = return value from EnumRegKey
2660 * $R8 = counter for EnumRegKey
2661 * $R9 = return value from the stack from the RemoveQuotesFromPath and GetLongPath macros
2662 */
2663 !macro RegCleanUninstall
2665 !ifndef ${_MOZFUNC_UN}RegCleanUninstall
2666 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
2667 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
2668 !insertmacro ${_MOZFUNC_UN_TMP}RemoveQuotesFromPath
2669 !undef _MOZFUNC_UN
2670 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
2671 !undef _MOZFUNC_UN_TMP
2673 !verbose push
2674 !verbose ${_MOZFUNC_VERBOSE}
2675 !define ${_MOZFUNC_UN}RegCleanUninstall "!insertmacro ${_MOZFUNC_UN}RegCleanUninstallCall"
2677 Function ${_MOZFUNC_UN}RegCleanUninstall
2678 Push $R9
2679 Push $R8
2680 Push $R7
2681 Push $R6
2682 Push $R5
2683 Push $R4
2684 Push $R3
2686 ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR" $R4
2687 StrCpy $R6 "Software\Microsoft\Windows\CurrentVersion\Uninstall"
2688 StrCpy $R7 ""
2689 StrCpy $R8 0
2691 ${If} ${RunningX64}
2692 StrCpy $R3 "false"
2693 ; Set the registry to the 32 bit registry for 64 bit installations or to
2694 ; the 64 bit registry for 32 bit installations at the beginning so it can
2695 ; easily be set back to the correct registry view when finished.
2696 !ifdef HAVE_64BIT_OS
2697 SetRegView 32
2698 !else
2699 SetRegView 64
2700 !endif
2701 ${EndIf}
2703 loop:
2704 EnumRegKey $R7 SHCTX $R6 $R8
2705 StrCmp $R7 "" end +1
2706 IntOp $R8 $R8 + 1 ; Increment the counter
2707 ClearErrors
2708 ReadRegStr $R5 SHCTX "$R6\$R7" "InstallLocation"
2709 IfErrors loop
2710 ${${_MOZFUNC_UN}RemoveQuotesFromPath} "$R5" $R9
2711 ${${_MOZFUNC_UN}GetLongPath} "$R9" $R9
2712 StrCmp "$R9" "$R4" +1 loop
2713 ClearErrors
2714 DeleteRegKey SHCTX "$R6\$R7"
2715 IfErrors loop +1
2716 IntOp $R8 $R8 - 1 ; Decrement the counter on successful deletion
2717 GoTo loop
2719 end:
2720 ${If} ${RunningX64}
2721 ${AndIf} "$R3" == "false"
2722 ; Set the registry to the correct view.
2723 !ifdef HAVE_64BIT_OS
2724 SetRegView 64
2725 !else
2726 SetRegView 32
2727 !endif
2729 StrCpy $R7 ""
2730 StrCpy $R8 0
2731 StrCpy $R3 "true"
2732 GoTo loop
2733 ${EndIf}
2735 ClearErrors
2737 Pop $R3
2738 Pop $R4
2739 Pop $R5
2740 Pop $R6
2741 Pop $R7
2742 Pop $R8
2743 Pop $R9
2744 FunctionEnd
2746 !verbose pop
2747 !endif
2748 !macroend
2750 !macro RegCleanUninstallCall
2751 !verbose push
2752 !verbose ${_MOZFUNC_VERBOSE}
2753 Call RegCleanUninstall
2754 !verbose pop
2755 !macroend
2757 !macro un.RegCleanUninstallCall
2758 !verbose push
2759 !verbose ${_MOZFUNC_VERBOSE}
2760 Call un.RegCleanUninstall
2761 !verbose pop
2762 !macroend
2764 !macro un.RegCleanUninstall
2765 !ifndef un.RegCleanUninstall
2766 !verbose push
2767 !verbose ${_MOZFUNC_VERBOSE}
2768 !undef _MOZFUNC_UN
2769 !define _MOZFUNC_UN "un."
2771 !insertmacro RegCleanUninstall
2773 !undef _MOZFUNC_UN
2774 !define _MOZFUNC_UN
2775 !verbose pop
2776 !endif
2777 !macroend
2779 /**
2780 * Removes an application specific handler registry key under Software\Classes
2781 * for both HKCU and HKLM when its open command refers to this install
2782 * location or the install location doesn't exist.
2783 *
2784 * @param _HANDLER_NAME
2785 * The registry name for the handler.
2786 *
2787 * $R7 = stores the long path to the $INSTDIR
2788 * $R8 = stores the path to the open command's parent directory
2789 * $R9 = _HANDLER_NAME
2790 */
2791 !macro RegCleanAppHandler
2793 !ifndef ${_MOZFUNC_UN}RegCleanAppHandler
2794 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
2795 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
2796 !insertmacro ${_MOZFUNC_UN_TMP}GetParent
2797 !insertmacro ${_MOZFUNC_UN_TMP}GetPathFromString
2798 !undef _MOZFUNC_UN
2799 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
2800 !undef _MOZFUNC_UN_TMP
2802 !verbose push
2803 !verbose ${_MOZFUNC_VERBOSE}
2804 !define ${_MOZFUNC_UN}RegCleanAppHandler "!insertmacro ${_MOZFUNC_UN}RegCleanAppHandlerCall"
2806 Function ${_MOZFUNC_UN}RegCleanAppHandler
2807 Exch $R9
2808 Push $R8
2809 Push $R7
2811 ClearErrors
2812 ReadRegStr $R8 HKCU "Software\Classes\$R9\shell\open\command" ""
2813 IfErrors next +1
2814 ${${_MOZFUNC_UN}GetPathFromString} "$R8" $R8
2815 ${${_MOZFUNC_UN}GetParent} "$R8" $R8
2816 IfFileExists "$R8" +3 +1
2817 DeleteRegKey HKCU "Software\Classes\$R9"
2818 GoTo next
2820 ${${_MOZFUNC_UN}GetLongPath} "$R8" $R8
2821 ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR" $R7
2822 StrCmp "$R7" "$R8" +1 next
2823 DeleteRegKey HKCU "Software\Classes\$R9"
2825 next:
2826 ReadRegStr $R8 HKLM "Software\Classes\$R9\shell\open\command" ""
2827 IfErrors end
2828 ${${_MOZFUNC_UN}GetPathFromString} "$R8" $R8
2829 ${${_MOZFUNC_UN}GetParent} "$R8" $R8
2830 IfFileExists "$R8" +3 +1
2831 DeleteRegKey HKLM "Software\Classes\$R9"
2832 GoTo end
2834 ${${_MOZFUNC_UN}GetLongPath} "$R8" $R8
2835 ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR" $R7
2836 StrCmp "$R7" "$R8" +1 end
2837 DeleteRegKey HKLM "Software\Classes\$R9"
2839 end:
2841 Pop $R7
2842 Pop $R8
2843 Exch $R9
2844 FunctionEnd
2846 !verbose pop
2847 !endif
2848 !macroend
2850 !macro RegCleanAppHandlerCall _HANDLER_NAME
2851 !verbose push
2852 !verbose ${_MOZFUNC_VERBOSE}
2853 Push "${_HANDLER_NAME}"
2854 Call RegCleanAppHandler
2855 !verbose pop
2856 !macroend
2858 !macro un.RegCleanAppHandlerCall _HANDLER_NAME
2859 !verbose push
2860 !verbose ${_MOZFUNC_VERBOSE}
2861 Push "${_HANDLER_NAME}"
2862 Call un.RegCleanAppHandler
2863 !verbose pop
2864 !macroend
2866 !macro un.RegCleanAppHandler
2867 !ifndef un.RegCleanAppHandler
2868 !verbose push
2869 !verbose ${_MOZFUNC_VERBOSE}
2870 !undef _MOZFUNC_UN
2871 !define _MOZFUNC_UN "un."
2873 !insertmacro RegCleanAppHandler
2875 !undef _MOZFUNC_UN
2876 !define _MOZFUNC_UN
2877 !verbose pop
2878 !endif
2879 !macroend
2881 /**
2882 * Cleans up the registry for a protocol handler when its open command
2883 * refers to this install location. For HKCU the registry key is deleted
2884 * and for HKLM the values set by the application are deleted.
2885 *
2886 * @param _HANDLER_NAME
2887 * The registry name for the handler.
2888 *
2889 * $R7 = stores the long path to $INSTDIR
2890 * $R8 = stores the the long path to the open command's parent directory
2891 * $R9 = _HANDLER_NAME
2892 */
2893 !macro un.RegCleanProtocolHandler
2895 !ifndef un.RegCleanProtocolHandler
2896 !insertmacro un.GetLongPath
2897 !insertmacro un.GetParent
2898 !insertmacro un.GetPathFromString
2900 !verbose push
2901 !verbose ${_MOZFUNC_VERBOSE}
2902 !define un.RegCleanProtocolHandler "!insertmacro un.RegCleanProtocolHandlerCall"
2904 Function un.RegCleanProtocolHandler
2905 Exch $R9
2906 Push $R8
2907 Push $R7
2909 ReadRegStr $R8 HKCU "Software\Classes\$R9\shell\open\command" ""
2910 ${un.GetLongPath} "$INSTDIR" $R7
2912 StrCmp "$R8" "" next +1
2913 ${un.GetPathFromString} "$R8" $R8
2914 ${un.GetParent} "$R8" $R8
2915 ${un.GetLongPath} "$R8" $R8
2916 StrCmp "$R7" "$R8" +1 next
2917 DeleteRegKey HKCU "Software\Classes\$R9"
2919 next:
2920 ReadRegStr $R8 HKLM "Software\Classes\$R9\shell\open\command" ""
2921 StrCmp "$R8" "" end +1
2922 ${un.GetLongPath} "$INSTDIR" $R7
2923 ${un.GetPathFromString} "$R8" $R8
2924 ${un.GetParent} "$R8" $R8
2925 ${un.GetLongPath} "$R8" $R8
2926 StrCmp "$R7" "$R8" +1 end
2927 DeleteRegValue HKLM "Software\Classes\$R9\DefaultIcon" ""
2928 DeleteRegValue HKLM "Software\Classes\$R9\shell\open" ""
2929 DeleteRegValue HKLM "Software\Classes\$R9\shell\open\command" ""
2930 DeleteRegValue HKLM "Software\Classes\$R9\shell\ddeexec" ""
2931 DeleteRegValue HKLM "Software\Classes\$R9\shell\ddeexec\Application" ""
2932 DeleteRegValue HKLM "Software\Classes\$R9\shell\ddeexec\Topic" ""
2934 end:
2936 Pop $R7
2937 Pop $R8
2938 Exch $R9
2939 FunctionEnd
2941 !verbose pop
2942 !endif
2943 !macroend
2945 !macro un.RegCleanProtocolHandlerCall _HANDLER_NAME
2946 !verbose push
2947 !verbose ${_MOZFUNC_VERBOSE}
2948 Push "${_HANDLER_NAME}"
2949 Call un.RegCleanProtocolHandler
2950 !verbose pop
2951 !macroend
2953 /**
2954 * Cleans up the registry for a file handler when the passed in value equals
2955 * the default value for the file handler. For HKCU the registry key is deleted
2956 * and for HKLM the default value is deleted.
2957 *
2958 * @param _HANDLER_NAME
2959 * The registry name for the handler.
2960 * @param _DEFAULT_VALUE
2961 * The value to check for against the handler's default value.
2962 *
2963 * $R6 = stores the long path to $INSTDIR
2964 * $R7 = _DEFAULT_VALUE
2965 * $R9 = _HANDLER_NAME
2966 */
2967 !macro RegCleanFileHandler
2969 !ifndef ${_MOZFUNC_UN}RegCleanFileHandler
2970 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
2971 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
2972 !insertmacro ${_MOZFUNC_UN_TMP}GetParent
2973 !insertmacro ${_MOZFUNC_UN_TMP}GetPathFromString
2974 !undef _MOZFUNC_UN
2975 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
2976 !undef _MOZFUNC_UN_TMP
2978 !verbose push
2979 !verbose ${_MOZFUNC_VERBOSE}
2980 !define ${_MOZFUNC_UN}RegCleanFileHandler "!insertmacro ${_MOZFUNC_UN}RegCleanFileHandlerCall"
2982 Function ${_MOZFUNC_UN}RegCleanFileHandler
2983 Exch $R9
2984 Exch 1
2985 Exch $R8
2986 Push $R7
2988 ReadRegStr $R7 HKCU "Software\Classes\$R9" ""
2989 StrCmp "$R7" "$R8" +1 +2
2990 DeleteRegKey HKCU "Software\Classes\$R9"
2992 ReadRegStr $R7 HKLM "Software\Classes\$R9" ""
2993 StrCmp "$R7" "$R8" +1 +2
2994 DeleteRegValue HKLM "Software\Classes\$R9" ""
2996 ClearErrors
2998 Pop $R7
2999 Exch $R8
3000 Exch 1
3001 Exch $R9
3002 FunctionEnd
3004 !verbose pop
3005 !endif
3006 !macroend
3008 !macro RegCleanFileHandlerCall _HANDLER_NAME _DEFAULT_VALUE
3009 !verbose push
3010 !verbose ${_MOZFUNC_VERBOSE}
3011 Push "${_DEFAULT_VALUE}"
3012 Push "${_HANDLER_NAME}"
3013 Call RegCleanFileHandler
3014 !verbose pop
3015 !macroend
3017 !macro un.RegCleanFileHandlerCall _HANDLER_NAME _DEFAULT_VALUE
3018 !verbose push
3019 !verbose ${_MOZFUNC_VERBOSE}
3020 Push "${_DEFAULT_VALUE}"
3021 Push "${_HANDLER_NAME}"
3022 Call un.RegCleanFileHandler
3023 !verbose pop
3024 !macroend
3026 !macro un.RegCleanFileHandler
3027 !ifndef un.RegCleanFileHandler
3028 !verbose push
3029 !verbose ${_MOZFUNC_VERBOSE}
3030 !undef _MOZFUNC_UN
3031 !define _MOZFUNC_UN "un."
3033 !insertmacro RegCleanFileHandler
3035 !undef _MOZFUNC_UN
3036 !define _MOZFUNC_UN
3037 !verbose pop
3038 !endif
3039 !macroend
3041 /**
3042 * Checks if a handler's open command points to this installation directory.
3043 * Uses SHCTX to determine the registry hive (e.g. HKLM or HKCU) to check.
3044 *
3045 * @param _HANDLER_NAME
3046 * The registry name for the handler.
3047 * @param _RESULT
3048 * true if it is the handler's open command points to this
3049 * installation directory and false if it does not.
3050 *
3051 * $R7 = stores the value of the open command and the path macros return values
3052 * $R8 = stores the handler's registry key name
3053 * $R9 = _DEFAULT_VALUE and _RESULT
3054 */
3055 !macro IsHandlerForInstallDir
3057 !ifndef ${_MOZFUNC_UN}IsHandlerForInstallDir
3058 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
3059 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
3060 !insertmacro ${_MOZFUNC_UN_TMP}GetParent
3061 !insertmacro ${_MOZFUNC_UN_TMP}GetPathFromString
3062 !undef _MOZFUNC_UN
3063 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
3064 !undef _MOZFUNC_UN_TMP
3066 !verbose push
3067 !verbose ${_MOZFUNC_VERBOSE}
3068 !define ${_MOZFUNC_UN}IsHandlerForInstallDir "!insertmacro ${_MOZFUNC_UN}IsHandlerForInstallDirCall"
3070 Function ${_MOZFUNC_UN}IsHandlerForInstallDir
3071 Exch $R9
3072 Push $R8
3073 Push $R7
3075 StrCpy $R8 "$R9"
3076 StrCpy $R9 "false"
3077 ReadRegStr $R7 SHCTX "Software\Classes\$R8\shell\open\command" ""
3079 ${If} $R7 != ""
3080 ${GetPathFromString} "$R7" $R7
3081 ${GetParent} "$R7" $R7
3082 ${GetLongPath} "$R7" $R7
3083 ${If} $R7 == $INSTDIR
3084 StrCpy $R9 "true"
3085 ${EndIf}
3086 ${EndIf}
3088 ClearErrors
3090 Pop $R7
3091 Pop $R8
3092 Exch $R9
3093 FunctionEnd
3095 !verbose pop
3096 !endif
3097 !macroend
3099 !macro IsHandlerForInstallDirCall _HANDLER_NAME _RESULT
3100 !verbose push
3101 !verbose ${_MOZFUNC_VERBOSE}
3102 Push "${_HANDLER_NAME}"
3103 Call IsHandlerForInstallDir
3104 Pop "${_RESULT}"
3105 !verbose pop
3106 !macroend
3108 !macro un.IsHandlerForInstallDirCall _HANDLER_NAME _RESULT
3109 !verbose push
3110 !verbose ${_MOZFUNC_VERBOSE}
3111 Push "${_HANDLER_NAME}"
3112 Call un.IsHandlerForInstallDir
3113 Pop "${_RESULT}"
3114 !verbose pop
3115 !macroend
3117 !macro un.IsHandlerForInstallDir
3118 !ifndef un.IsHandlerForInstallDir
3119 !verbose push
3120 !verbose ${_MOZFUNC_VERBOSE}
3121 !undef _MOZFUNC_UN
3122 !define _MOZFUNC_UN "un."
3124 !insertmacro IsHandlerForInstallDir
3126 !undef _MOZFUNC_UN
3127 !define _MOZFUNC_UN
3128 !verbose pop
3129 !endif
3130 !macroend
3132 /**
3133 * Removes the application's VirtualStore directory if present when the
3134 * installation directory is a sub-directory of the program files directory.
3135 *
3136 * $R4 = $PROGRAMFILES/$PROGRAMFILES64 for CleanVirtualStore_Internal
3137 * $R5 = various path values.
3138 * $R6 = length of the long path to $PROGRAMFILES32 or $PROGRAMFILES64
3139 * $R7 = long path to $PROGRAMFILES32 or $PROGRAMFILES64
3140 * $R8 = length of the long path to $INSTDIR
3141 * $R9 = long path to $INSTDIR
3142 */
3143 !macro CleanVirtualStore
3145 !ifndef ${_MOZFUNC_UN}CleanVirtualStore
3146 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
3147 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
3148 !undef _MOZFUNC_UN
3149 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
3150 !undef _MOZFUNC_UN_TMP
3152 !verbose push
3153 !verbose ${_MOZFUNC_VERBOSE}
3154 !define ${_MOZFUNC_UN}CleanVirtualStore "!insertmacro ${_MOZFUNC_UN}CleanVirtualStoreCall"
3156 Function ${_MOZFUNC_UN}CleanVirtualStore
3157 Push $R9
3158 Push $R8
3159 Push $R7
3160 Push $R6
3161 Push $R5
3162 Push $R4
3164 ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR" $R9
3165 ${If} "$R9" != ""
3166 StrLen $R8 "$R9"
3168 StrCpy $R4 $PROGRAMFILES32
3169 Call ${_MOZFUNC_UN}CleanVirtualStore_Internal
3171 ${If} ${RunningX64}
3172 StrCpy $R4 $PROGRAMFILES64
3173 Call ${_MOZFUNC_UN}CleanVirtualStore_Internal
3174 ${EndIf}
3176 ${EndIf}
3178 ClearErrors
3180 Pop $R4
3181 Pop $R5
3182 Pop $R6
3183 Pop $R7
3184 Pop $R8
3185 Pop $R9
3186 FunctionEnd
3188 Function ${_MOZFUNC_UN}CleanVirtualStore_Internal
3189 ${${_MOZFUNC_UN}GetLongPath} "" $R7
3190 ${If} "$R7" != ""
3191 StrLen $R6 "$R7"
3192 ${If} $R8 < $R6
3193 ; Copy from the start of $INSTDIR the length of $PROGRAMFILES64
3194 StrCpy $R5 "$R9" $R6
3195 ${If} "$R5" == "$R7"
3196 ; Remove the drive letter and colon from the $INSTDIR long path
3197 StrCpy $R5 "$R9" "" 2
3198 StrCpy $R5 "$LOCALAPPDATA\VirtualStore$R5"
3199 ${${_MOZFUNC_UN}GetLongPath} "$R5" $R5
3200 ${If} "$R5" != ""
3201 ${AndIf} ${FileExists} "$R5"
3202 RmDir /r "$R5"
3203 ${EndIf}
3204 ${EndIf}
3205 ${EndIf}
3206 ${EndIf}
3207 FunctionEnd
3209 !verbose pop
3210 !endif
3211 !macroend
3213 !macro CleanVirtualStoreCall
3214 !verbose push
3215 !verbose ${_MOZFUNC_VERBOSE}
3216 Call CleanVirtualStore
3217 !verbose pop
3218 !macroend
3220 !macro un.CleanVirtualStoreCall
3221 !verbose push
3222 !verbose ${_MOZFUNC_VERBOSE}
3223 Call un.CleanVirtualStore
3224 !verbose pop
3225 !macroend
3227 !macro un.CleanVirtualStore
3228 !ifndef un.CleanVirtualStore
3229 !verbose push
3230 !verbose ${_MOZFUNC_VERBOSE}
3231 !undef _MOZFUNC_UN
3232 !define _MOZFUNC_UN "un."
3234 !insertmacro CleanVirtualStore
3236 !undef _MOZFUNC_UN
3237 !define _MOZFUNC_UN
3238 !verbose pop
3239 !endif
3240 !macroend
3242 /**
3243 * If present removes the updates directory located in the profile's local
3244 * directory for this installation.
3245 * This macro is obsolete and should no longer be used. Please see
3246 * CleanUpdateDirectories.
3247 *
3248 * @param _REL_PROFILE_PATH
3249 * The relative path to the profile directory from $LOCALAPPDATA.
3250 *
3251 * $R4 = various path values.
3252 * $R5 = length of the long path to $PROGRAMFILES
3253 * $R6 = length of the long path to $INSTDIR
3254 * $R7 = long path to $PROGRAMFILES
3255 * $R8 = long path to $INSTDIR
3256 * $R9 = _REL_PROFILE_PATH
3257 */
3258 !macro CleanUpdatesDir
3260 !ifndef ${_MOZFUNC_UN}CleanUpdatesDir
3261 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
3262 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
3263 !undef _MOZFUNC_UN
3264 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
3265 !undef _MOZFUNC_UN_TMP
3267 !verbose push
3268 !verbose ${_MOZFUNC_VERBOSE}
3269 !define ${_MOZFUNC_UN}CleanUpdatesDir "!insertmacro ${_MOZFUNC_UN}CleanUpdatesDirCall"
3271 Function ${_MOZFUNC_UN}CleanUpdatesDir
3272 Exch $R9
3273 Push $R8
3274 Push $R7
3275 Push $R6
3276 Push $R5
3277 Push $R4
3279 StrCmp $R9 "" end +1 ; The relative path to the app's profiles is required
3280 ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR" $R8
3281 StrCmp $R8 "" end +1
3282 ${${_MOZFUNC_UN}GetLongPath} "$PROGRAMFILES" $R7
3283 StrCmp $R7 "" end +1
3285 StrLen $R6 "$R8"
3286 StrLen $R5 "$R7"
3287 ; Only continue If the length of $INSTDIR is greater than the length of
3288 ; $PROGRAMFILES
3289 IntCmp $R6 $R5 end end +1
3291 ; Copy from the start of $INSTDIR the length of $PROGRAMFILES
3292 StrCpy $R4 "$R8" $R5
3293 StrCmp "$R4" "$R7" +1 end ; Check if $INSTDIR is under $PROGRAMFILES
3295 ; Copy the relative path to $INSTDIR from $PROGRAMFILES
3296 StrCpy $R4 "$R8" "" $R5
3298 ; Concatenate the path to $LOCALAPPDATA the relative profile path and the
3299 ; relative path to $INSTDIR from $PROGRAMFILES
3300 StrCpy $R4 "$LOCALAPPDATA\$R9$R4"
3301 ${${_MOZFUNC_UN}GetLongPath} "$R4" $R4
3302 StrCmp $R4 "" end +1
3304 IfFileExists "$R4\updates" +1 end
3305 RmDir /r "$R4"
3307 end:
3308 ClearErrors
3310 Pop $R4
3311 Pop $R5
3312 Pop $R6
3313 Pop $R7
3314 Pop $R8
3315 Exch $R9
3316 FunctionEnd
3318 !verbose pop
3319 !endif
3320 !macroend
3322 !macro CleanUpdatesDirCall _REL_PROFILE_PATH
3323 !verbose push
3324 !verbose ${_MOZFUNC_VERBOSE}
3325 Push "${_REL_PROFILE_PATH}"
3326 Call CleanUpdatesDir
3327 !verbose pop
3328 !macroend
3330 !macro un.CleanUpdatesDirCall _REL_PROFILE_PATH
3331 !verbose push
3332 !verbose ${_MOZFUNC_VERBOSE}
3333 Push "${_REL_PROFILE_PATH}"
3334 Call un.CleanUpdatesDir
3335 !verbose pop
3336 !macroend
3338 !macro un.CleanUpdatesDir
3339 !ifndef un.CleanUpdatesDir
3340 !verbose push
3341 !verbose ${_MOZFUNC_VERBOSE}
3342 !undef _MOZFUNC_UN
3343 !define _MOZFUNC_UN "un."
3345 !insertmacro CleanUpdatesDir
3347 !undef _MOZFUNC_UN
3348 !define _MOZFUNC_UN
3349 !verbose pop
3350 !endif
3351 !macroend
3353 /**
3354 * If present removes the updates directory located in the profile's local
3355 * directory for this installation.
3356 *
3357 * @param _OLD_REL_PATH
3358 * The relative path to the profile directory from $LOCALAPPDATA.
3359 * Calculated for the old update directory not based on a hash.
3360 * @param _NEW_REL_PATH
3361 * The relative path to the profile directory from $LOCALAPPDATA.
3362 * Calculated for the new update directory based on a hash.
3363 *
3364 * $R8 = _NEW_REL_PATH
3365 * $R7 = _OLD_REL_PATH
3366 * $R1 = taskBar ID hash located in registry at SOFTWARE\_OLD_REL_PATH\TaskBarIDs
3367 * $R2 = various path values.
3368 * $R3 = length of the long path to $PROGRAMFILES
3369 * $R4 = length of the long path to $INSTDIR
3370 * $R5 = long path to $PROGRAMFILES
3371 * $R6 = long path to $INSTDIR
3372 * $R0 = path to the new update directory built from _NEW_REL_PATH and
3373 * the taskbar ID.
3374 */
3375 !macro CleanUpdateDirectories
3377 !ifndef ${_MOZFUNC_UN}CleanUpdateDirectories
3378 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
3379 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
3380 !undef _MOZFUNC_UN
3381 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
3382 !undef _MOZFUNC_UN_TMP
3384 !verbose push
3385 !verbose ${_MOZFUNC_VERBOSE}
3386 !define ${_MOZFUNC_UN}CleanUpdateDirectories "!insertmacro ${_MOZFUNC_UN}CleanUpdateDirectoriesCall"
3388 Function ${_MOZFUNC_UN}CleanUpdateDirectories
3389 Exch $R8
3390 Exch 1
3391 Exch $R7
3392 Push $R6
3393 Push $R5
3394 Push $R4
3395 Push $R3
3396 Push $R2
3397 Push $R1
3398 Push $R0
3400 ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR" $R6
3401 StrLen $R4 "$R6"
3403 ${${_MOZFUNC_UN}GetLongPath} "$PROGRAMFILES" $R5
3404 StrLen $R3 "$R5"
3406 ${If} $R7 != "" ; _OLD_REL_PATH was passed
3407 ${AndIf} $R6 != "" ; We have the install dir path
3408 ${AndIf} $R5 != "" ; We the program files path
3409 ${AndIf} $R4 > $R3 ; The length of $INSTDIR > the length of $PROGRAMFILES
3411 ; Copy from the start of $INSTDIR the length of $PROGRAMFILES
3412 StrCpy $R2 "$R6" $R3
3414 ; Check if $INSTDIR is under $PROGRAMFILES
3415 ${If} $R2 == $R5
3417 ; Copy the relative path to $INSTDIR from $PROGRAMFILES
3418 StrCpy $R2 "$R6" "" $R3
3420 ; Concatenate the path $LOCALAPPDATA to the relative profile path and
3421 ; the relative path to $INSTDIR from $PROGRAMFILES
3422 StrCpy $R2 "$LOCALAPPDATA\$R7$R2"
3423 ${${_MOZFUNC_UN}GetLongPath} "$R2" $R2
3425 ${If} $R2 != ""
3426 ; Backup the old update directory logs and delete the directory
3427 ${If} ${FileExists} "$R2\updates\last-update.log"
3428 Rename "$R2\updates\last-update.log" "$TEMP\moz-update-old-last-update.log"
3429 ${EndIf}
3431 ${If} ${FileExists} "$R2\updates\backup-update.log"
3432 Rename "$R2\updates\backup-update.log" "$TEMP\moz-update-old-backup-update.log"
3433 ${EndIf}
3435 ${If} ${FileExists} "$R2\updates"
3436 RmDir /r "$R2"
3437 ${EndIf}
3438 ${EndIf}
3440 ; Get the taskbar ID hash for this installation path
3441 ReadRegStr $R1 HKLM "SOFTWARE\$R7\TaskBarIDs" $R6
3442 ${If} $R1 == ""
3443 ReadRegStr $R1 HKCU "SOFTWARE\$R7\TaskBarIDs" $R6
3444 ${EndIf}
3446 ; If the taskbar ID hash exists then delete the new update directory
3447 ; Backup its logs before deleting it.
3448 ${If} $R1 != ""
3449 StrCpy $R0 "$LOCALAPPDATA\$R8\$R1"
3451 ${If} ${FileExists} "$R0\updates\last-update.log"
3452 Rename "$R0\updates\last-update.log" "$TEMP\moz-update-new-last-update.log"
3453 ${EndIf}
3455 ${If} ${FileExists} "$R0\updates\backup-update.log"
3456 Rename "$R0\updates\backup-update.log" "$TEMP\moz-update-new-backup-update.log"
3457 ${EndIf}
3459 ; Remove the old updates directory
3460 ${If} ${FileExists} "$R0\updates"
3461 RmDir /r "$R0"
3462 ${EndIf}
3463 ${EndIf}
3464 ${EndIf}
3465 ${EndIf}
3467 ClearErrors
3469 Pop $R0
3470 Pop $R1
3471 Pop $R2
3472 Pop $R3
3473 Pop $R4
3474 Pop $R5
3475 Pop $R6
3476 Exch $R7
3477 Exch 1
3478 Exch $R8
3479 FunctionEnd
3481 !verbose pop
3482 !endif
3483 !macroend
3485 !macro CleanUpdateDirectoriesCall _OLD_REL_PATH _NEW_REL_PATH
3486 !verbose push
3487 !verbose ${_MOZFUNC_VERBOSE}
3488 Push "${_OLD_REL_PATH}"
3489 Push "${_NEW_REL_PATH}"
3490 Call CleanUpdateDirectories
3491 !verbose pop
3492 !macroend
3494 !macro un.CleanUpdateDirectoriesCall _OLD_REL_PATH _NEW_REL_PATH
3495 !verbose push
3496 !verbose ${_MOZFUNC_VERBOSE}
3497 Push "${_OLD_REL_PATH}"
3498 Push "${_NEW_REL_PATH}"
3499 Call un.CleanUpdateDirectories
3500 !verbose pop
3501 !macroend
3503 !macro un.CleanUpdateDirectories
3504 !ifndef un.CleanUpdateDirectories
3505 !verbose push
3506 !verbose ${_MOZFUNC_VERBOSE}
3507 !undef _MOZFUNC_UN
3508 !define _MOZFUNC_UN "un."
3510 !insertmacro CleanUpdateDirectories
3512 !undef _MOZFUNC_UN
3513 !define _MOZFUNC_UN
3514 !verbose pop
3515 !endif
3516 !macroend
3518 /**
3519 * Deletes all relative profiles specified in an application's profiles.ini and
3520 * performs various other cleanup.
3521 *
3522 * @param _REL_PROFILE_PATH
3523 * The relative path to the profile directory.
3524 *
3525 * $R6 = value of IsRelative read from profiles.ini
3526 * $R7 = value of Path to profile read from profiles.ini
3527 * $R8 = counter for reading profiles (e.g. Profile0, Profile1, etc.)
3528 * $R9 = _REL_PROFILE_PATH
3529 */
3530 !macro DeleteRelativeProfiles
3532 !ifndef ${_MOZFUNC_UN}DeleteRelativeProfiles
3533 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
3534 !insertmacro ${_MOZFUNC_UN_TMP}WordReplace
3535 !undef _MOZFUNC_UN
3536 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
3537 !undef _MOZFUNC_UN_TMP
3539 !verbose push
3540 !verbose ${_MOZFUNC_VERBOSE}
3541 !define ${_MOZFUNC_UN}DeleteRelativeProfiles "!insertmacro ${_MOZFUNC_UN}DeleteRelativeProfilesCall"
3543 Function ${_MOZFUNC_UN}DeleteRelativeProfiles
3544 Exch $R9
3545 Push $R8
3546 Push $R7
3547 Push $R6
3549 SetShellVarContext current
3550 StrCpy $R8 -1
3552 loop:
3553 IntOp $R8 $R8 + 1 ; Increment the counter.
3554 ReadINIStr $R7 "$APPDATA\$R9\profiles.ini" "Profile$R8" "Path"
3555 IfErrors end +1
3557 ; Only remove relative profiles
3558 ReadINIStr $R6 "$APPDATA\$R9\profiles.ini" "Profile$R8" "IsRelative"
3559 StrCmp "$R6" "1" +1 loop
3561 ; Relative paths in profiles.ini use / as a separator
3562 ${${_MOZFUNC_UN}WordReplace} "$R7" "/" "\" "+" $R7
3564 IfFileExists "$LOCALAPPDATA\$R9\$R7" +1 +2
3565 RmDir /r "$LOCALAPPDATA\$R9\$R7"
3566 IfFileExists "$APPDATA\$R9\$R7" +1 +2
3567 RmDir /r "$APPDATA\$R9\$R7"
3568 GoTo loop
3570 end:
3571 ; Remove profiles directory under LOCALAPPDATA (e.g. cache, etc.) since
3572 ; they are at times abandoned.
3573 RmDir /r "$LOCALAPPDATA\$R9\Profiles"
3574 RmDir /r "$APPDATA\$R9\Crash Reports"
3575 Delete "$APPDATA\$R9\profiles.ini"
3576 Delete "$APPDATA\$R9\console.log"
3577 Delete "$APPDATA\$R9\pluginreg.dat"
3578 RmDir "$APPDATA\$R9\Profiles"
3579 RmDir "$APPDATA\$R9"
3581 Pop $R6
3582 Pop $R7
3583 Pop $R8
3584 Exch $R9
3585 FunctionEnd
3587 !verbose pop
3588 !endif
3589 !macroend
3591 !macro DeleteRelativeProfilesCall _REL_PROFILE_PATH
3592 !verbose push
3593 !verbose ${_MOZFUNC_VERBOSE}
3594 Push "${_REL_PROFILE_PATH}"
3595 Call DeleteRelativeProfiles
3596 !verbose pop
3597 !macroend
3599 !macro un.DeleteRelativeProfilesCall _REL_PROFILE_PATH
3600 !verbose push
3601 !verbose ${_MOZFUNC_VERBOSE}
3602 Push "${_REL_PROFILE_PATH}"
3603 Call un.DeleteRelativeProfiles
3604 !verbose pop
3605 !macroend
3607 !macro un.DeleteRelativeProfiles
3608 !ifndef un.DeleteRelativeProfiles
3609 !verbose push
3610 !verbose ${_MOZFUNC_VERBOSE}
3611 !undef _MOZFUNC_UN
3612 !define _MOZFUNC_UN "un."
3614 !insertmacro DeleteRelativeProfiles
3616 !undef _MOZFUNC_UN
3617 !define _MOZFUNC_UN
3618 !verbose pop
3619 !endif
3620 !macroend
3622 /**
3623 * Deletes shortcuts and Start Menu directories under Programs as specified by
3624 * the shortcuts log ini file and on Windows 7 unpins TaskBar and Start Menu
3625 * shortcuts. The shortcuts will not be deleted if the shortcut target isn't for
3626 * this install location which is determined by the shortcut having a target of
3627 * $INSTDIR\${FileMainEXE}. The context (All Users or Current User) of the
3628 * $DESKTOP and $SMPROGRAMS constants depends on the
3629 * SetShellVarContext setting and must be set by the caller of this macro. There
3630 * is no All Users context for $QUICKLAUNCH but this will not cause a problem
3631 * since the macro will just continue past the $QUICKLAUNCH shortcut deletion
3632 * section on subsequent calls.
3633 *
3634 * The ini file sections must have the following format (the order of the
3635 * sections in the ini file is not important):
3636 * [SMPROGRAMS]
3637 * ; RelativePath is the directory relative from the Start Menu
3638 * ; Programs directory.
3639 * RelativePath=Mozilla App
3640 * ; Shortcut1 is the first shortcut, Shortcut2 is the second shortcut, and so
3641 * ; on. There must not be a break in the sequence of the numbers.
3642 * Shortcut1=Mozilla App.lnk
3643 * Shortcut2=Mozilla App (Safe Mode).lnk
3644 * [DESKTOP]
3645 * ; Shortcut1 is the first shortcut, Shortcut2 is the second shortcut, and so
3646 * ; on. There must not be a break in the sequence of the numbers.
3647 * Shortcut1=Mozilla App.lnk
3648 * Shortcut2=Mozilla App (Safe Mode).lnk
3649 * [QUICKLAUNCH]
3650 * ; Shortcut1 is the first shortcut, Shortcut2 is the second shortcut, and so
3651 * ; on. There must not be a break in the sequence of the numbers for the
3652 * ; suffix.
3653 * Shortcut1=Mozilla App.lnk
3654 * Shortcut2=Mozilla App (Safe Mode).lnk
3655 * [STARTMENU]
3656 * ; Shortcut1 is the first shortcut, Shortcut2 is the second shortcut, and so
3657 * ; on. There must not be a break in the sequence of the numbers for the
3658 * ; suffix.
3659 * Shortcut1=Mozilla App.lnk
3660 * Shortcut2=Mozilla App (Safe Mode).lnk
3661 *
3662 * $R4 = counter for appending to Shortcut for enumerating the ini file entries
3663 * $R5 = return value from ShellLink::GetShortCutTarget and
3664 * ApplicationID::UninstallPinnedItem
3665 * $R6 = find handle and the long path to the Start Menu Programs directory
3666 * (e.g. $SMPROGRAMS)
3667 * $R7 = path to the $QUICKLAUNCH\User Pinned directory and the return value
3668 * from ReadINIStr for the relative path to the applications directory
3669 * under the Start Menu Programs directory and the long path to this
3670 * directory
3671 * $R8 = return filename from FindFirst / FindNext and the return value from
3672 * ReadINIStr for enumerating shortcuts
3673 * $R9 = long path to the shortcuts log ini file
3674 */
3675 !macro DeleteShortcuts
3677 !ifndef ${_MOZFUNC_UN}DeleteShortcuts
3678 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
3679 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
3680 !insertmacro ${_MOZFUNC_UN_TMP}GetParent
3681 !undef _MOZFUNC_UN
3682 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
3683 !undef _MOZFUNC_UN_TMP
3685 !verbose push
3686 !verbose ${_MOZFUNC_VERBOSE}
3687 !define ${_MOZFUNC_UN}DeleteShortcuts "!insertmacro ${_MOZFUNC_UN}DeleteShortcutsCall"
3689 Function ${_MOZFUNC_UN}DeleteShortcuts
3690 Push $R9
3691 Push $R8
3692 Push $R7
3693 Push $R6
3694 Push $R5
3695 Push $R4
3697 ${If} ${AtLeastWin7}
3698 ; Since shortcuts that are pinned can later be removed without removing
3699 ; the pinned shortcut unpin the pinned shortcuts for the application's
3700 ; main exe using the pinned shortcuts themselves.
3701 StrCpy $R7 "$QUICKLAUNCH\User Pinned"
3703 ${If} ${FileExists} "$R7\TaskBar"
3704 ; Delete TaskBar pinned shortcuts for the application's main exe
3705 FindFirst $R6 $R8 "$R7\TaskBar\*.lnk"
3706 ${Do}
3707 ${If} ${FileExists} "$R7\TaskBar\$R8"
3708 ShellLink::GetShortCutTarget "$R7\TaskBar\$R8"
3709 Pop $R5
3710 ${${_MOZFUNC_UN}GetLongPath} "$R5" $R5
3711 ${If} "$R5" == "$INSTDIR\${FileMainEXE}"
3712 ApplicationID::UninstallPinnedItem "$R7\TaskBar\$R8"
3713 Pop $R5
3714 ${EndIf}
3715 ${EndIf}
3716 ClearErrors
3717 FindNext $R6 $R8
3718 ${If} ${Errors}
3719 ${ExitDo}
3720 ${EndIf}
3721 ${Loop}
3722 FindClose $R6
3723 ${EndIf}
3725 ${If} ${FileExists} "$R7\StartMenu"
3726 ; Delete Start Menu pinned shortcuts for the application's main exe
3727 FindFirst $R6 $R8 "$R7\StartMenu\*.lnk"
3728 ${Do}
3729 ${If} ${FileExists} "$R7\StartMenu\$R8"
3730 ShellLink::GetShortCutTarget "$R7\StartMenu\$R8"
3731 Pop $R5
3732 ${${_MOZFUNC_UN}GetLongPath} "$R5" $R5
3733 ${If} "$R5" == "$INSTDIR\${FileMainEXE}"
3734 ApplicationID::UninstallPinnedItem "$R7\StartMenu\$R8"
3735 Pop $R5
3736 ${EndIf}
3737 ${EndIf}
3738 ClearErrors
3739 FindNext $R6 $R8
3740 ${If} ${Errors}
3741 ${ExitDo}
3742 ${EndIf}
3743 ${Loop}
3744 FindClose $R6
3745 ${EndIf}
3746 ${EndIf}
3748 ; Don't call ApplicationID::UninstallPinnedItem since pinned items for
3749 ; this application were removed above and removing them below will remove
3750 ; the association of side by side installations.
3751 ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR\uninstall\${SHORTCUTS_LOG}" $R9
3752 ${If} ${FileExists} "$R9"
3753 ; Delete Start Menu shortcuts for this application
3754 StrCpy $R4 -1
3755 ${Do}
3756 IntOp $R4 $R4 + 1 ; Increment the counter
3757 ClearErrors
3758 ReadINIStr $R8 "$R9" "STARTMENU" "Shortcut$R4"
3759 ${If} ${Errors}
3760 ${ExitDo}
3761 ${EndIf}
3763 ${If} ${FileExists} "$SMPROGRAMS\$R8"
3764 ShellLink::GetShortCutTarget "$SMPROGRAMS\$R8"
3765 Pop $R5
3766 ${${_MOZFUNC_UN}GetLongPath} "$R5" $R5
3767 ${If} "$INSTDIR\${FileMainEXE}" == "$R5"
3768 Delete "$SMPROGRAMS\$R8"
3769 ${EndIf}
3770 ${EndIf}
3771 ${Loop}
3773 ; Delete Quick Launch shortcuts for this application
3774 StrCpy $R4 -1
3775 ${Do}
3776 IntOp $R4 $R4 + 1 ; Increment the counter
3777 ClearErrors
3778 ReadINIStr $R8 "$R9" "QUICKLAUNCH" "Shortcut$R4"
3779 ${If} ${Errors}
3780 ${ExitDo}
3781 ${EndIf}
3783 ${If} ${FileExists} "$QUICKLAUNCH\$R8"
3784 ShellLink::GetShortCutTarget "$QUICKLAUNCH\$R8"
3785 Pop $R5
3786 ${${_MOZFUNC_UN}GetLongPath} "$R5" $R5
3787 ${If} "$INSTDIR\${FileMainEXE}" == "$R5"
3788 Delete "$QUICKLAUNCH\$R8"
3789 ${EndIf}
3790 ${EndIf}
3791 ${Loop}
3793 ; Delete Desktop shortcuts for this application
3794 StrCpy $R4 -1
3795 ${Do}
3796 IntOp $R4 $R4 + 1 ; Increment the counter
3797 ClearErrors
3798 ReadINIStr $R8 "$R9" "DESKTOP" "Shortcut$R4"
3799 ${If} ${Errors}
3800 ${ExitDo}
3801 ${EndIf}
3803 ${If} ${FileExists} "$DESKTOP\$R8"
3804 ShellLink::GetShortCutTarget "$DESKTOP\$R8"
3805 Pop $R5
3806 ${${_MOZFUNC_UN}GetLongPath} "$R5" $R5
3807 ${If} "$INSTDIR\${FileMainEXE}" == "$R5"
3808 Delete "$DESKTOP\$R8"
3809 ${EndIf}
3810 ${EndIf}
3811 ${Loop}
3813 ${${_MOZFUNC_UN}GetLongPath} "$SMPROGRAMS" $R6
3815 ; Delete Start Menu Programs shortcuts for this application
3816 ClearErrors
3817 ReadINIStr $R7 "$R9" "SMPROGRAMS" "RelativePathToDir"
3818 ${${_MOZFUNC_UN}GetLongPath} "$R6\$R7" $R7
3819 ${Unless} "$R7" == ""
3820 StrCpy $R4 -1
3821 ${Do}
3822 IntOp $R4 $R4 + 1 ; Increment the counter
3823 ClearErrors
3824 ReadINIStr $R8 "$R9" "SMPROGRAMS" "Shortcut$R4"
3825 ${If} ${Errors}
3826 ${ExitDo}
3827 ${EndIf}
3829 ${If} ${FileExists} "$R7\$R8"
3830 ShellLink::GetShortCutTarget "$R7\$R8"
3831 Pop $R5
3832 ${${_MOZFUNC_UN}GetLongPath} "$R5" $R5
3833 ${If} "$INSTDIR\${FileMainEXE}" == "$R5"
3834 Delete "$R7\$R8"
3835 ${EndIf}
3836 ${EndIf}
3837 ${Loop}
3839 ; Delete Start Menu Programs directories for this application
3840 ${Do}
3841 ClearErrors
3842 ${If} "$R6" == "$R7"
3843 ${ExitDo}
3844 ${EndIf}
3845 RmDir "$R7"
3846 ${If} ${Errors}
3847 ${ExitDo}
3848 ${EndIf}
3849 ${${_MOZFUNC_UN}GetParent} "$R7" $R7
3850 ${Loop}
3851 ${EndUnless}
3852 ${EndIf}
3854 ClearErrors
3856 Pop $R4
3857 Pop $R5
3858 Pop $R6
3859 Pop $R7
3860 Pop $R8
3861 Pop $R9
3862 FunctionEnd
3864 !verbose pop
3865 !endif
3866 !macroend
3868 !macro DeleteShortcutsCall
3869 !verbose push
3870 !verbose ${_MOZFUNC_VERBOSE}
3871 Call DeleteShortcuts
3872 !verbose pop
3873 !macroend
3875 !macro un.DeleteShortcutsCall
3876 !verbose push
3877 !verbose ${_MOZFUNC_VERBOSE}
3878 Call un.DeleteShortcuts
3879 !verbose pop
3880 !macroend
3882 !macro un.DeleteShortcuts
3883 !ifndef un.DeleteShortcuts
3884 !verbose push
3885 !verbose ${_MOZFUNC_VERBOSE}
3886 !undef _MOZFUNC_UN
3887 !define _MOZFUNC_UN "un."
3889 !insertmacro DeleteShortcuts
3891 !undef _MOZFUNC_UN
3892 !define _MOZFUNC_UN
3893 !verbose pop
3894 !endif
3895 !macroend
3898 ################################################################################
3899 # Macros for parsing and updating the uninstall.log
3901 /**
3902 * Updates the uninstall.log with new files added by software update.
3903 *
3904 * When modifying this macro be aware that LineFind uses all registers except
3905 * $R0-$R3 and TextCompareNoDetails uses all registers except $R0-$R9 so be
3906 * cautious. Callers of this macro are not affected.
3907 */
3908 !macro UpdateUninstallLog
3910 !ifndef UpdateUninstallLog
3911 !insertmacro FileJoin
3912 !insertmacro LineFind
3913 !insertmacro TextCompareNoDetails
3914 !insertmacro TrimNewLines
3916 !verbose push
3917 !verbose ${_MOZFUNC_VERBOSE}
3918 !define UpdateUninstallLog "!insertmacro UpdateUninstallLogCall"
3920 Function UpdateUninstallLog
3921 Push $R3
3922 Push $R2
3923 Push $R1
3924 Push $R0
3926 ClearErrors
3928 GetFullPathName $R3 "$INSTDIR\uninstall"
3929 ${If} ${FileExists} "$R3\uninstall.update"
3930 ${LineFind} "$R3\uninstall.update" "" "1:-1" "CleanupUpdateLog"
3932 GetTempFileName $R2 "$R3"
3933 FileOpen $R1 "$R2" w
3934 ${TextCompareNoDetails} "$R3\uninstall.update" "$R3\uninstall.log" "SlowDiff" "CreateUpdateDiff"
3935 FileClose $R1
3937 IfErrors +2 0
3938 ${FileJoin} "$R3\uninstall.log" "$R2" "$R3\uninstall.log"
3940 ${DeleteFile} "$R2"
3941 ${EndIf}
3943 ClearErrors
3945 Pop $R0
3946 Pop $R1
3947 Pop $R2
3948 Pop $R3
3949 FunctionEnd
3951 ; This callback MUST use labels vs. relative line numbers.
3952 Function CleanupUpdateLog
3953 StrCpy $R2 "$R9" 12
3954 StrCmp "$R2" "EXECUTE ADD " +1 skip
3955 StrCpy $R9 "$R9" "" 12
3957 Push $R6
3958 Push $R5
3959 Push $R4
3960 StrCpy $R4 "" ; Initialize to an empty string.
3961 StrCpy $R6 -1 ; Set the counter to -1 so it will start at 0.
3963 loop:
3964 IntOp $R6 $R6 + 1 ; Increment the counter.
3965 StrCpy $R5 $R9 1 $R6 ; Starting from the counter copy the next char.
3966 StrCmp $R5 "" copy ; Are there no more chars?
3967 StrCmp $R5 "/" +1 +2 ; Is the char a /?
3968 StrCpy $R5 "\" ; Replace the char with a \.
3970 StrCpy $R4 "$R4$R5"
3971 GoTo loop
3973 copy:
3974 StrCpy $R9 "File: \$R4"
3975 Pop $R6
3976 Pop $R5
3977 Pop $R4
3978 GoTo end
3980 skip:
3981 StrCpy $0 "SkipWrite"
3983 end:
3984 Push $0
3985 FunctionEnd
3987 Function CreateUpdateDiff
3988 ${TrimNewLines} "$9" $9
3989 ${If} $9 != ""
3990 FileWrite $R1 "$9$\r$\n"
3991 ${EndIf}
3993 Push 0
3994 FunctionEnd
3996 !verbose pop
3997 !endif
3998 !macroend
4000 !macro UpdateUninstallLogCall
4001 !verbose push
4002 !verbose ${_MOZFUNC_VERBOSE}
4003 Call UpdateUninstallLog
4004 !verbose pop
4005 !macroend
4007 /**
4008 * Copies files from a source directory to a destination directory with logging
4009 * to the uninstall.log. If any destination files are in use a reboot will be
4010 * necessary to complete the installation and the reboot flag (see IfRebootFlag
4011 * in the NSIS documentation).
4012 *
4013 * @param _PATH_TO_SOURCE
4014 * Source path to copy the files from. This must not end with a \.
4015 *
4016 * @param _PATH_TO_DESTINATION
4017 * Destination path to copy the files to. This must not end with a \.
4018 *
4019 * @param _PREFIX_ERROR_CREATEDIR
4020 * Prefix for the directory creation error message. The directory path
4021 * will be inserted below this string.
4022 *
4023 * @param _SUFFIX_ERROR_CREATEDIR
4024 * Suffix for the directory creation error message. The directory path
4025 * will be inserted above this string.
4026 *
4027 * $0 = destination file's parent directory used in the create_dir label
4028 * $R0 = copied value from $R6 (e.g. _PATH_TO_SOURCE)
4029 * $R1 = copied value from $R7 (e.g. _PATH_TO_DESTINATION)
4030 * $R2 = string length of the path to source
4031 * $R3 = relative path from the path to source
4032 * $R4 = copied value from $R8 (e.g. _PREFIX_ERROR_CREATEDIR)
4033 * $R5 = copied value from $R9 (e.g. _SUFFIX_ERROR_CREATEDIR)
4034 * note: the LocateNoDetails macro uses these registers so we copy the values
4035 * to other registers.
4036 * $R6 = initially _PATH_TO_SOURCE and then set to "size" ($R6="" if directory,
4037 * $R6="0" if file with /S=)"path\name" in callback
4038 * $R7 = initially _PATH_TO_DESTINATION and then set to "name" in callback
4039 * $R8 = initially _PREFIX_ERROR_CREATEDIR and then set to "path" in callback
4040 * $R9 = initially _SUFFIX_ERROR_CREATEDIR and then set to "path\name" in
4041 * callback
4042 */
4043 !macro CopyFilesFromDir
4045 !ifndef CopyFilesFromDir
4046 !insertmacro LocateNoDetails
4047 !insertmacro OnEndCommon
4048 !insertmacro WordReplace
4050 !verbose push
4051 !verbose ${_MOZFUNC_VERBOSE}
4052 !define CopyFilesFromDir "!insertmacro CopyFilesFromDirCall"
4054 Function CopyFilesFromDir
4055 Exch $R9
4056 Exch 1
4057 Exch $R8
4058 Exch 2
4059 Exch $R7
4060 Exch 3
4061 Exch $R6
4062 Push $R5
4063 Push $R4
4064 Push $R3
4065 Push $R2
4066 Push $R1
4067 Push $R0
4068 Push $0
4070 StrCpy $R0 "$R6"
4071 StrCpy $R1 "$R7"
4072 StrCpy $R4 "$R8"
4073 StrCpy $R5 "$R9"
4075 StrLen $R2 "$R0"
4077 ${LocateNoDetails} "$R0" "/L=FD" "CopyFileCallback"
4079 Pop $0
4080 Pop $R0
4081 Pop $R1
4082 Pop $R2
4083 Pop $R3
4084 Pop $R4
4085 Pop $R5
4086 Exch $R6
4087 Exch 3
4088 Exch $R7
4089 Exch 2
4090 Exch $R8
4091 Exch 1
4092 Exch $R9
4093 FunctionEnd
4095 Function CopyFileCallback
4096 StrCpy $R3 $R8 "" $R2 ; $R3 always begins with a \.
4098 retry:
4099 ClearErrors
4100 StrCmp $R6 "" +1 copy_file
4101 IfFileExists "$R1$R3\$R7" end +1
4102 StrCpy $0 "$R1$R3\$R7"
4104 create_dir:
4105 ClearErrors
4106 CreateDirectory "$0"
4107 IfFileExists "$0" +1 err_create_dir ; protect against looping.
4108 ${LogMsg} "Created Directory: $0"
4109 StrCmp $R6 "" end copy_file
4111 err_create_dir:
4112 ${LogMsg} "** ERROR Creating Directory: $0 **"
4113 MessageBox MB_RETRYCANCEL|MB_ICONQUESTION "$R4$\r$\n$\r$\n$0$\r$\n$\r$\n$R5" IDRETRY retry
4114 ${OnEndCommon}
4115 Quit
4117 copy_file:
4118 StrCpy $0 "$R1$R3"
4119 StrCmp "$0" "$INSTDIR" +2 +1
4120 IfFileExists "$0" +1 create_dir
4122 ClearErrors
4123 ${DeleteFile} "$R1$R3\$R7"
4124 IfErrors +1 dest_clear
4125 ClearErrors
4126 Rename "$R1$R3\$R7" "$R1$R3\$R7.moz-delete"
4127 IfErrors +1 reboot_delete
4129 ; file will replace destination file on reboot
4130 Rename "$R9" "$R9.moz-upgrade"
4131 CopyFiles /SILENT "$R9.moz-upgrade" "$R1$R3"
4132 Rename /REBOOTOK "$R1$R3\$R7.moz-upgrade" "$R1$R3\$R7"
4133 ${LogMsg} "Copied File: $R1$R3\$R7.moz-upgrade"
4134 ${LogMsg} "Delayed Install File (Reboot Required): $R1$R3\$R7"
4135 GoTo log_uninstall
4137 ; file will be deleted on reboot
4138 reboot_delete:
4139 CopyFiles /SILENT $R9 "$R1$R3"
4140 Delete /REBOOTOK "$R1$R3\$R7.moz-delete"
4141 ${LogMsg} "Installed File: $R1$R3\$R7"
4142 ${LogMsg} "Delayed Delete File (Reboot Required): $R1$R3\$R7.moz-delete"
4143 GoTo log_uninstall
4145 ; destination file doesn't exist - coast is clear
4146 dest_clear:
4147 CopyFiles /SILENT $R9 "$R1$R3"
4148 ${LogMsg} "Installed File: $R1$R3\$R7"
4150 log_uninstall:
4151 ; If the file is installed into the installation directory remove the
4152 ; installation directory's path from the file path when writing to the
4153 ; uninstall.log so it will be a relative path. This allows the same
4154 ; helper.exe to be used with zip builds if we supply an uninstall.log.
4155 ${WordReplace} "$R1$R3\$R7" "$INSTDIR" "" "+" $R3
4156 ${LogUninstall} "File: $R3"
4158 end:
4159 Push 0
4160 FunctionEnd
4162 !verbose pop
4163 !endif
4164 !macroend
4166 !macro CopyFilesFromDirCall _PATH_TO_SOURCE _PATH_TO_DESTINATION \
4167 _PREFIX_ERROR_CREATEDIR _SUFFIX_ERROR_CREATEDIR
4168 !verbose push
4169 !verbose ${_MOZFUNC_VERBOSE}
4170 Push "${_PATH_TO_SOURCE}"
4171 Push "${_PATH_TO_DESTINATION}"
4172 Push "${_PREFIX_ERROR_CREATEDIR}"
4173 Push "${_SUFFIX_ERROR_CREATEDIR}"
4174 Call CopyFilesFromDir
4175 !verbose pop
4176 !macroend
4178 /**
4179 * Parses the uninstall.log on install to first remove a previous installation's
4180 * files and then their directories if empty prior to installing.
4181 *
4182 * When modifying this macro be aware that LineFind uses all registers except
4183 * $R0-$R3 so be cautious. Callers of this macro are not affected.
4184 */
4185 !macro OnInstallUninstall
4187 !ifndef OnInstallUninstall
4188 !insertmacro GetParent
4189 !insertmacro LineFind
4190 !insertmacro TrimNewLines
4192 !verbose push
4193 !verbose ${_MOZFUNC_VERBOSE}
4194 !define OnInstallUninstall "!insertmacro OnInstallUninstallCall"
4196 Function OnInstallUninstall
4197 Push $R9
4198 Push $R8
4199 Push $R7
4200 Push $R6
4201 Push $R5
4202 Push $R4
4203 Push $R3
4204 Push $R2
4205 Push $R1
4206 Push $R0
4207 Push $TmpVal
4209 IfFileExists "$INSTDIR\uninstall\uninstall.log" +1 end
4211 ${LogHeader} "Removing Previous Installation"
4213 ; Copy the uninstall log file to a temporary file
4214 GetTempFileName $TmpVal
4215 CopyFiles /SILENT /FILESONLY "$INSTDIR\uninstall\uninstall.log" "$TmpVal"
4217 ; Delete files
4218 ${LineFind} "$TmpVal" "/NUL" "1:-1" "RemoveFilesCallback"
4220 ; Remove empty directories
4221 ${LineFind} "$TmpVal" "/NUL" "1:-1" "RemoveDirsCallback"
4223 ; Delete the temporary uninstall log file
4224 Delete /REBOOTOK "$TmpVal"
4226 ; Delete the uninstall log file
4227 Delete "$INSTDIR\uninstall\uninstall.log"
4229 end:
4230 ClearErrors
4232 Pop $TmpVal
4233 Pop $R0
4234 Pop $R1
4235 Pop $R2
4236 Pop $R3
4237 Pop $R4
4238 Pop $R5
4239 Pop $R6
4240 Pop $R7
4241 Pop $R8
4242 Pop $R9
4243 FunctionEnd
4245 Function RemoveFilesCallback
4246 ${TrimNewLines} "$R9" $R9
4247 StrCpy $R1 "$R9" 5 ; Copy the first five chars
4249 StrCmp "$R1" "File:" +1 end
4250 StrCpy $R9 "$R9" "" 6 ; Copy string starting after the 6th char
4251 StrCpy $R0 "$R9" 1 ; Copy the first char
4253 StrCmp "$R0" "\" +1 end ; If this isn't a relative path goto end
4254 StrCmp "$R9" "\install.log" end +1 ; Skip the install.log
4255 StrCmp "$R9" "\MapiProxy_InUse.dll" end +1 ; Skip the MapiProxy_InUse.dll
4256 StrCmp "$R9" "\mozMapi32_InUse.dll" end +1 ; Skip the mozMapi32_InUse.dll
4258 StrCpy $R1 "$INSTDIR$R9" ; Copy the install dir path and suffix it with the string
4259 IfFileExists "$R1" +1 end
4261 ClearErrors
4262 Delete "$R1"
4263 ${Unless} ${Errors}
4264 ${LogMsg} "Deleted File: $R1"
4265 Goto end
4266 ${EndUnless}
4268 ClearErrors
4269 Rename "$R1" "$R1.moz-delete"
4270 ${Unless} ${Errors}
4271 Delete /REBOOTOK "$R1.moz-delete"
4272 ${LogMsg} "Delayed Delete File (Reboot Required): $R1.moz-delete"
4273 GoTo end
4274 ${EndUnless}
4276 ; Check if the file exists in the source. If it does the new file will
4277 ; replace the existing file when the system is rebooted. If it doesn't
4278 ; the file will be deleted when the system is rebooted.
4279 ${Unless} ${FileExists} "$EXEDIR\core$R9"
4280 ${AndUnless} ${FileExists} "$EXEDIR\optional$R9"
4281 Delete /REBOOTOK "$R1"
4282 ${LogMsg} "Delayed Delete File (Reboot Required): $R1"
4283 ${EndUnless}
4285 end:
4286 ClearErrors
4288 Push 0
4289 FunctionEnd
4291 ; Using locate will leave file handles open to some of the directories
4292 ; which will prevent the deletion of these directories. This parses the
4293 ; uninstall.log and uses the file entries to find / remove empty
4294 ; directories.
4295 Function RemoveDirsCallback
4296 ${TrimNewLines} "$R9" $R9
4297 StrCpy $R0 "$R9" 5 ; Copy the first five chars
4298 StrCmp "$R0" "File:" +1 end
4300 StrCpy $R9 "$R9" "" 6 ; Copy string starting after the 6th char
4301 StrCpy $R0 "$R9" 1 ; Copy the first char
4303 StrCpy $R1 "$INSTDIR$R9" ; Copy the install dir path and suffix it with the string
4304 StrCmp "$R0" "\" loop end ; If this isn't a relative path goto end
4306 loop:
4307 ${GetParent} "$R1" $R1 ; Get the parent directory for the path
4308 StrCmp "$R1" "$INSTDIR" end +1 ; If the directory is the install dir goto end
4310 IfFileExists "$R1" +1 loop ; Only try to remove the dir if it exists
4311 ClearErrors
4312 RmDir "$R1" ; Remove the dir
4313 IfErrors end +1 ; If we fail there is no use trying to remove its parent dir
4314 ${LogMsg} "Deleted Directory: $R1"
4315 GoTo loop
4317 end:
4318 ClearErrors
4320 Push 0
4321 FunctionEnd
4323 !verbose pop
4324 !endif
4325 !macroend
4327 !macro OnInstallUninstallCall
4328 !verbose push
4329 !verbose ${_MOZFUNC_VERBOSE}
4330 Call OnInstallUninstall
4331 !verbose pop
4332 !macroend
4334 /**
4335 * Parses the uninstall.log for the stub installer on install to first remove a
4336 * previous installation's files prior to installing.
4337 *
4338 * When modifying this macro be aware that LineFind uses all registers except
4339 * $R0-$R3 so be cautious. Callers of this macro are not affected.
4340 *
4341 * @param _PROGRESSBAR
4342 * The progress bar to update using PBM_STEPIT. Can also be "false" if
4343 * updating a progressbar isn't needed.
4344 * @param _INSTALL_STEP_COUNTER
4345 * The install step counter to increment. The variable specified in
4346 * this parameter is also updated. Can also be "false" if a counter
4347 * isn't needed.
4348 *
4349 * $R2 = _INSTALL_STEP_COUNTER
4350 * $R3 = _PROGRESSBAR
4351 */
4352 !macro OnStubInstallUninstall
4354 !ifndef OnStubInstallUninstall
4355 !insertmacro GetParent
4356 !insertmacro LineFind
4357 !insertmacro TrimNewLines
4359 !verbose push
4360 !verbose ${_MOZFUNC_VERBOSE}
4361 !define OnStubInstallUninstall "!insertmacro OnStubInstallUninstallCall"
4363 Function OnStubInstallUninstall
4364 Exch $R2
4365 Exch 1
4366 Exch $R3
4367 Push $R9
4368 Push $R8
4369 Push $R7
4370 Push $R6
4371 Push $R5
4372 Push $R4
4373 Push $R1
4374 Push $R0
4375 Push $TmpVal
4377 IfFileExists "$INSTDIR\uninstall\uninstall.log" +1 end
4379 ; Copy the uninstall log file to a temporary file
4380 GetTempFileName $TmpVal
4381 CopyFiles /SILENT /FILESONLY "$INSTDIR\uninstall\uninstall.log" "$TmpVal"
4383 CreateDirectory "$INSTDIR\${TO_BE_DELETED}"
4385 ; Delete files
4386 ${LineFind} "$TmpVal" "/NUL" "1:-1" "StubRemoveFilesCallback"
4388 ; Delete the temporary uninstall log file
4389 Delete /REBOOTOK "$TmpVal"
4391 RmDir /r /REBOOTOK "$INSTDIR\${TO_BE_DELETED}"
4393 end:
4394 ClearErrors
4396 Pop $TmpVal
4397 Pop $R0
4398 Pop $R1
4399 Pop $R4
4400 Pop $R5
4401 Pop $R6
4402 Pop $R7
4403 Pop $R8
4404 Pop $R9
4405 Exch $R3
4406 Exch 1
4407 Exch $R2
4408 FunctionEnd
4410 Function StubRemoveFilesCallback
4411 ${TrimNewLines} "$R9" $R9
4412 StrCpy $R1 "$R9" 5 ; Copy the first five chars
4414 StrCmp "$R1" "File:" +1 end
4415 StrCpy $R9 "$R9" "" 6 ; Copy string starting after the 6th char
4416 StrCpy $R0 "$R9" 1 ; Copy the first char
4418 StrCmp "$R0" "\" +1 end ; If this isn't a relative path goto end
4419 StrCmp "$R9" "\MapiProxy_InUse.dll" end +1 ; Skip the MapiProxy_InUse.dll
4420 StrCmp "$R9" "\mozMapi32_InUse.dll" end +1 ; Skip the mozMapi32_InUse.dll
4422 StrCpy $R1 "$INSTDIR$R9" ; Copy the install dir path and suffix it with the string
4423 IfFileExists "$R1" +1 end
4425 ${Unless} "$R2" == "false"
4426 IntOp $R2 $R2 + 2
4427 ${EndIf}
4428 ${Unless} "$R3" == "false"
4429 SendMessage $R3 ${PBM_STEPIT} 0 0
4430 SendMessage $R3 ${PBM_STEPIT} 0 0
4431 ${EndIf}
4433 ClearErrors
4434 Delete "$R1"
4435 ${Unless} ${Errors}
4436 Goto end
4437 ${EndUnless}
4439 GetTempFileName $R0 "$INSTDIR\${TO_BE_DELETED}"
4440 Delete "$R0"
4441 ClearErrors
4442 Rename "$R1" "$R0"
4443 ${If} ${Errors}
4444 Delete /REBOOTOK "$R1"
4445 ${EndUnless}
4447 end:
4448 ClearErrors
4450 Push 0
4451 FunctionEnd
4453 !verbose pop
4454 !endif
4455 !macroend
4457 !macro OnStubInstallUninstallCall _PROGRESSBAR _INSTALL_STEP_COUNTER
4458 !verbose push
4459 Push "${_PROGRESSBAR}"
4460 Push "${_INSTALL_STEP_COUNTER}"
4461 !verbose ${_MOZFUNC_VERBOSE}
4462 Call OnStubInstallUninstall
4463 Pop ${_INSTALL_STEP_COUNTER}
4464 !verbose pop
4465 !macroend
4467 /**
4468 * Parses the uninstall.log to unregister dll's, remove files, and remove
4469 * empty directories for this installation.
4470 *
4471 * When modifying this macro be aware that LineFind uses all registers except
4472 * $R0-$R3 so be cautious. Callers of this macro are not affected.
4473 */
4474 !macro un.ParseUninstallLog
4476 !ifndef un.ParseUninstallLog
4477 !insertmacro un.GetParent
4478 !insertmacro un.LineFind
4479 !insertmacro un.TrimNewLines
4481 !verbose push
4482 !verbose ${_MOZFUNC_VERBOSE}
4483 !define un.ParseUninstallLog "!insertmacro un.ParseUninstallLogCall"
4485 Function un.ParseUninstallLog
4486 Push $R9
4487 Push $R8
4488 Push $R7
4489 Push $R6
4490 Push $R5
4491 Push $R4
4492 Push $R3
4493 Push $R2
4494 Push $R1
4495 Push $R0
4496 Push $TmpVal
4498 IfFileExists "$INSTDIR\uninstall\uninstall.log" +1 end
4500 ; Copy the uninstall log file to a temporary file
4501 GetTempFileName $TmpVal
4502 CopyFiles /SILENT /FILESONLY "$INSTDIR\uninstall\uninstall.log" "$TmpVal"
4504 ; Unregister DLL's
4505 ${un.LineFind} "$TmpVal" "/NUL" "1:-1" "un.UnRegDLLsCallback"
4507 ; Delete files
4508 ${un.LineFind} "$TmpVal" "/NUL" "1:-1" "un.RemoveFilesCallback"
4510 ; Remove empty directories
4511 ${un.LineFind} "$TmpVal" "/NUL" "1:-1" "un.RemoveDirsCallback"
4513 ; Delete the temporary uninstall log file
4514 Delete /REBOOTOK "$TmpVal"
4516 end:
4518 Pop $TmpVal
4519 Pop $R0
4520 Pop $R1
4521 Pop $R2
4522 Pop $R3
4523 Pop $R4
4524 Pop $R5
4525 Pop $R6
4526 Pop $R7
4527 Pop $R8
4528 Pop $R9
4529 FunctionEnd
4531 Function un.RemoveFilesCallback
4532 ${un.TrimNewLines} "$R9" $R9
4533 StrCpy $R1 "$R9" 5
4535 StrCmp "$R1" "File:" +1 end
4536 StrCpy $R9 "$R9" "" 6
4537 StrCpy $R0 "$R9" 1
4539 StrCpy $R1 "$INSTDIR$R9"
4540 StrCmp "$R0" "\" +2 +1
4541 StrCpy $R1 "$R9"
4543 IfFileExists "$R1" +1 end
4544 Delete "$R1"
4545 IfErrors +1 end
4546 ClearErrors
4547 Rename "$R1" "$R1.moz-delete"
4548 IfErrors +1 +3
4549 Delete /REBOOTOK "$R1"
4550 GoTo end
4552 Delete /REBOOTOK "$R1.moz-delete"
4554 end:
4555 ClearErrors
4557 Push 0
4558 FunctionEnd
4560 Function un.UnRegDLLsCallback
4561 ${un.TrimNewLines} "$R9" $R9
4562 StrCpy $R1 "$R9" 7
4564 StrCmp $R1 "DLLReg:" +1 end
4565 StrCpy $R9 "$R9" "" 8
4566 StrCpy $R0 "$R9" 1
4568 StrCpy $R1 "$INSTDIR$R9"
4569 StrCmp $R0 "\" +2 +1
4570 StrCpy $R1 "$R9"
4572 ${UnregisterDLL} $R1
4574 end:
4575 ClearErrors
4577 Push 0
4578 FunctionEnd
4580 ; Using locate will leave file handles open to some of the directories
4581 ; which will prevent the deletion of these directories. This parses the
4582 ; uninstall.log and uses the file entries to find / remove empty
4583 ; directories.
4584 Function un.RemoveDirsCallback
4585 ${un.TrimNewLines} "$R9" $R9
4586 StrCpy $R0 "$R9" 5 ; Copy the first five chars
4587 StrCmp "$R0" "File:" +1 end
4589 StrCpy $R9 "$R9" "" 6 ; Copy string starting after the 6th char
4590 StrCpy $R0 "$R9" 1 ; Copy the first char
4592 StrCpy $R1 "$INSTDIR$R9" ; Copy the install dir path and suffix it with the string
4593 StrCmp "$R0" "\" loop ; If this is a relative path goto the loop
4594 StrCpy $R1 "$R9" ; Already a full path so copy the string
4596 loop:
4597 ${un.GetParent} "$R1" $R1 ; Get the parent directory for the path
4598 StrCmp "$R1" "$INSTDIR" end ; If the directory is the install dir goto end
4600 ; We only try to remove empty directories but the Desktop, StartMenu, and
4601 ; QuickLaunch directories can be empty so guard against removing them.
4602 SetShellVarContext all ; Set context to all users
4603 StrCmp "$R1" "$DESKTOP" end ; All users desktop
4604 StrCmp "$R1" "$STARTMENU" end ; All users start menu
4606 SetShellVarContext current ; Set context to all users
4607 StrCmp "$R1" "$DESKTOP" end ; Current user desktop
4608 StrCmp "$R1" "$STARTMENU" end ; Current user start menu
4609 StrCmp "$R1" "$QUICKLAUNCH" end ; Current user quick launch
4611 IfFileExists "$R1" +1 +3 ; Only try to remove the dir if it exists
4612 ClearErrors
4613 RmDir "$R1" ; Remove the dir
4614 IfErrors end ; If we fail there is no use trying to remove its parent dir
4616 StrCmp "$R0" "\" loop end ; Only loop when the path is relative to the install dir
4618 end:
4619 ClearErrors
4621 Push 0
4622 FunctionEnd
4624 !verbose pop
4625 !endif
4626 !macroend
4628 !macro un.ParseUninstallLogCall
4629 !verbose push
4630 !verbose ${_MOZFUNC_VERBOSE}
4631 Call un.ParseUninstallLog
4632 !verbose pop
4633 !macroend
4635 /**
4636 * Finds a valid Start Menu shortcut in the uninstall log and returns the
4637 * relative path from the Start Menu's Programs directory to the shortcut's
4638 * directory.
4639 *
4640 * When modifying this macro be aware that LineFind uses all registers except
4641 * $R0-$R3 so be cautious. Callers of this macro are not affected.
4642 *
4643 * @return _REL_PATH_TO_DIR
4644 * The relative path to the application's Start Menu directory from the
4645 * Start Menu's Programs directory.
4646 */
4647 !macro FindSMProgramsDir
4649 !ifndef FindSMProgramsDir
4650 !insertmacro GetParent
4651 !insertmacro LineFind
4652 !insertmacro TrimNewLines
4654 !verbose push
4655 !verbose ${_MOZFUNC_VERBOSE}
4656 !define FindSMProgramsDir "!insertmacro FindSMProgramsDirCall"
4658 Function FindSMProgramsDir
4659 Exch $R3
4660 Push $R2
4661 Push $R1
4662 Push $R0
4664 StrCpy $R3 ""
4665 ${If} ${FileExists} "$INSTDIR\uninstall\uninstall.log"
4666 ${LineFind} "$INSTDIR\uninstall\uninstall.log" "/NUL" "1:-1" "FindSMProgramsDirRelPath"
4667 ${EndIf}
4668 ClearErrors
4670 Pop $R0
4671 Pop $R1
4672 Pop $R2
4673 Exch $R3
4674 FunctionEnd
4676 ; This callback MUST use labels vs. relative line numbers.
4677 Function FindSMProgramsDirRelPath
4678 Push 0
4679 ${TrimNewLines} "$R9" $R9
4680 StrCpy $R4 "$R9" 5
4682 StrCmp "$R4" "File:" +1 end_FindSMProgramsDirRelPath
4683 StrCpy $R9 "$R9" "" 6
4684 StrCpy $R4 "$R9" 1
4686 StrCmp "$R4" "\" end_FindSMProgramsDirRelPath +1
4688 SetShellVarContext all
4689 ${GetLongPath} "$SMPROGRAMS" $R4
4690 StrLen $R2 "$R4"
4691 StrCpy $R1 "$R9" $R2
4692 StrCmp "$R1" "$R4" +1 end_FindSMProgramsDirRelPath
4693 IfFileExists "$R9" +1 end_FindSMProgramsDirRelPath
4694 ShellLink::GetShortCutTarget "$R9"
4695 Pop $R0
4696 StrCmp "$INSTDIR\${FileMainEXE}" "$R0" +1 end_FindSMProgramsDirRelPath
4697 ${GetParent} "$R9" $R3
4698 IntOp $R2 $R2 + 1
4699 StrCpy $R3 "$R3" "" $R2
4701 Pop $R4 ; Remove the previously pushed 0 from the stack and
4702 push "StopLineFind" ; push StopLineFind to stop finding more lines.
4704 end_FindSMProgramsDirRelPath:
4705 ClearErrors
4707 FunctionEnd
4709 !verbose pop
4710 !endif
4711 !macroend
4713 !macro FindSMProgramsDirCall _REL_PATH_TO_DIR
4714 !verbose push
4715 !verbose ${_MOZFUNC_VERBOSE}
4716 Call FindSMProgramsDir
4717 Pop ${_REL_PATH_TO_DIR}
4718 !verbose pop
4719 !macroend
4722 ################################################################################
4723 # Macros for custom branding
4725 /**
4726 * Sets BrandFullName and / or BrandShortName to values provided in the specified
4727 * ini file and defaults to BrandShortName and BrandFullName as defined in
4728 * branding.nsi when the associated ini file entry is not specified.
4729 *
4730 * ini file format:
4731 * [Branding]
4732 * BrandFullName=Custom Full Name
4733 * BrandShortName=Custom Short Name
4734 *
4735 * @param _PATH_TO_INI
4736 * Path to the ini file.
4737 *
4738 * $R6 = return value from ReadINIStr
4739 * $R7 = stores BrandShortName
4740 * $R8 = stores BrandFullName
4741 * $R9 = _PATH_TO_INI
4742 */
4743 !macro SetBrandNameVars
4745 !ifndef ${_MOZFUNC_UN}SetBrandNameVars
4746 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
4747 !insertmacro ${_MOZFUNC_UN_TMP}WordReplace
4748 !undef _MOZFUNC_UN
4749 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
4750 !undef _MOZFUNC_UN_TMP
4752 ; Prevent declaring vars twice when the SetBrandNameVars macro is
4753 ; inserted into both the installer and uninstaller.
4754 !ifndef SetBrandNameVars
4755 Var BrandFullName
4756 Var BrandFullNameDA
4757 Var BrandShortName
4758 !endif
4760 !verbose push
4761 !verbose ${_MOZFUNC_VERBOSE}
4762 !define ${_MOZFUNC_UN}SetBrandNameVars "!insertmacro ${_MOZFUNC_UN}SetBrandNameVarsCall"
4764 Function ${_MOZFUNC_UN}SetBrandNameVars
4765 Exch $R9
4766 Push $R8
4767 Push $R7
4768 Push $R6
4770 StrCpy $R8 "${BrandFullName}"
4771 StrCpy $R7 "${BrandShortName}"
4773 IfFileExists "$R9" +1 finish
4775 ClearErrors
4776 ReadINIStr $R6 $R9 "Branding" "BrandFullName"
4777 IfErrors +2 +1
4778 StrCpy $R8 "$R6"
4780 ClearErrors
4781 ReadINIStr $R6 $R9 "Branding" "BrandShortName"
4782 IfErrors +2 +1
4783 StrCpy $R7 "$R6"
4785 finish:
4786 StrCpy $BrandFullName "$R8"
4787 ${${_MOZFUNC_UN}WordReplace} "$R8" "&" "&&" "+" $R8
4788 StrCpy $BrandFullNameDA "$R8"
4789 StrCpy $BrandShortName "$R7"
4791 Pop $R6
4792 Pop $R7
4793 Pop $R8
4794 Exch $R9
4795 FunctionEnd
4797 !verbose pop
4798 !endif
4799 !macroend
4801 !macro SetBrandNameVarsCall _PATH_TO_INI
4802 !verbose push
4803 !verbose ${_MOZFUNC_VERBOSE}
4804 Push "${_PATH_TO_INI}"
4805 Call SetBrandNameVars
4806 !verbose pop
4807 !macroend
4809 !macro un.SetBrandNameVarsCall _PATH_TO_INI
4810 !verbose push
4811 !verbose ${_MOZFUNC_VERBOSE}
4812 Push "${_PATH_TO_INI}"
4813 Call un.SetBrandNameVars
4814 !verbose pop
4815 !macroend
4817 !macro un.SetBrandNameVars
4818 !ifndef un.SetBrandNameVars
4819 !verbose push
4820 !verbose ${_MOZFUNC_VERBOSE}
4821 !undef _MOZFUNC_UN
4822 !define _MOZFUNC_UN "un."
4824 !insertmacro SetBrandNameVars
4826 !undef _MOZFUNC_UN
4827 !define _MOZFUNC_UN
4828 !verbose pop
4829 !endif
4830 !macroend
4832 /**
4833 * Replaces the wizard's header image with the one specified.
4834 *
4835 * @param _PATH_TO_IMAGE
4836 * Fully qualified path to the bitmap to use for the header image.
4837 *
4838 * $R8 = hwnd for the control returned from GetDlgItem.
4839 * $R9 = _PATH_TO_IMAGE
4840 */
4841 !macro ChangeMUIHeaderImage
4843 !ifndef ${_MOZFUNC_UN}ChangeMUIHeaderImage
4844 Var hHeaderBitmap
4846 !verbose push
4847 !verbose ${_MOZFUNC_VERBOSE}
4848 !define ${_MOZFUNC_UN}ChangeMUIHeaderImage "!insertmacro ${_MOZFUNC_UN}ChangeMUIHeaderImageCall"
4850 Function ${_MOZFUNC_UN}ChangeMUIHeaderImage
4851 Exch $R9
4852 Push $R8
4854 GetDlgItem $R8 $HWNDPARENT 1046
4855 System::Call 'user32::LoadImageW(i 0, w "$R9", i 0, i 0, i 0, i 0x0010|0x2000) i.s'
4856 Pop $hHeaderBitmap
4857 SendMessage $R8 ${STM_SETIMAGE} 0 $hHeaderBitmap
4858 ; There is no way to specify a show function for a custom page so hide
4859 ; and then show the control to force the bitmap to redraw.
4860 ShowWindow $R8 ${SW_HIDE}
4861 ShowWindow $R8 ${SW_SHOW}
4863 Pop $R8
4864 Exch $R9
4865 FunctionEnd
4867 !verbose pop
4868 !endif
4869 !macroend
4871 !macro ChangeMUIHeaderImageCall _PATH_TO_IMAGE
4872 !verbose push
4873 !verbose ${_MOZFUNC_VERBOSE}
4874 Push "${_PATH_TO_IMAGE}"
4875 Call ChangeMUIHeaderImage
4876 !verbose pop
4877 !macroend
4879 !macro un.ChangeMUIHeaderImageCall _PATH_TO_IMAGE
4880 !verbose push
4881 !verbose ${_MOZFUNC_VERBOSE}
4882 Push "${_PATH_TO_IMAGE}"
4883 Call un.ChangeMUIHeaderImage
4884 !verbose pop
4885 !macroend
4887 !macro un.ChangeMUIHeaderImage
4888 !ifndef un.ChangeMUIHeaderImage
4889 !verbose push
4890 !verbose ${_MOZFUNC_VERBOSE}
4891 !undef _MOZFUNC_UN
4892 !define _MOZFUNC_UN "un."
4894 !insertmacro ChangeMUIHeaderImage
4896 !undef _MOZFUNC_UN
4897 !define _MOZFUNC_UN
4898 !verbose pop
4899 !endif
4900 !macroend
4903 ################################################################################
4904 # User interface callback helper defines and macros
4906 /* Install type defines */
4907 !ifndef INSTALLTYPE_BASIC
4908 !define INSTALLTYPE_BASIC 1
4909 !endif
4911 !ifndef INSTALLTYPE_CUSTOM
4912 !define INSTALLTYPE_CUSTOM 2
4913 !endif
4915 /**
4916 * Checks whether to display the current page (e.g. if not performing a custom
4917 * install don't display the custom pages).
4918 */
4919 !macro CheckCustomCommon
4921 !ifndef CheckCustomCommon
4922 !verbose push
4923 !verbose ${_MOZFUNC_VERBOSE}
4924 !define CheckCustomCommon "!insertmacro CheckCustomCommonCall"
4926 Function CheckCustomCommon
4928 ; Abort if not a custom install
4929 IntCmp $InstallType ${INSTALLTYPE_CUSTOM} +2 +1 +1
4930 Abort
4932 FunctionEnd
4934 !verbose pop
4935 !endif
4936 !macroend
4938 !macro CheckCustomCommonCall
4939 !verbose push
4940 !verbose ${_MOZFUNC_VERBOSE}
4941 Call CheckCustomCommon
4942 !verbose pop
4943 !macroend
4945 /**
4946 * Unloads dll's and releases references when the installer and uninstaller
4947 * exit.
4948 */
4949 !macro OnEndCommon
4951 !ifndef ${_MOZFUNC_UN}OnEndCommon
4952 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
4953 !insertmacro ${_MOZFUNC_UN_TMP}UnloadUAC
4954 !undef _MOZFUNC_UN
4955 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
4956 !undef _MOZFUNC_UN_TMP
4958 !verbose push
4959 !verbose ${_MOZFUNC_VERBOSE}
4960 !define ${_MOZFUNC_UN}OnEndCommon "!insertmacro ${_MOZFUNC_UN}OnEndCommonCall"
4962 Function ${_MOZFUNC_UN}OnEndCommon
4964 ${${_MOZFUNC_UN}UnloadUAC}
4965 StrCmp $hHeaderBitmap "" +3 +1
4966 System::Call "gdi32::DeleteObject(i s)" $hHeaderBitmap
4967 StrCpy $hHeaderBitmap ""
4969 System::Free 0
4971 FunctionEnd
4973 !verbose pop
4974 !endif
4975 !macroend
4977 !macro OnEndCommonCall
4978 !verbose push
4979 !verbose ${_MOZFUNC_VERBOSE}
4980 Call OnEndCommon
4981 !verbose pop
4982 !macroend
4984 !macro un.OnEndCommonCall
4985 !verbose push
4986 !verbose ${_MOZFUNC_VERBOSE}
4987 Call un.OnEndCommon
4988 !verbose pop
4989 !macroend
4991 !macro un.OnEndCommon
4992 !ifndef un.OnEndCommon
4993 !verbose push
4994 !verbose ${_MOZFUNC_VERBOSE}
4995 !undef _MOZFUNC_UN
4996 !define _MOZFUNC_UN "un."
4998 !insertmacro OnEndCommon
5000 !undef _MOZFUNC_UN
5001 !define _MOZFUNC_UN
5002 !verbose pop
5003 !endif
5004 !macroend
5006 /**
5007 * Called from the installer's .onInit function not to be confused with the
5008 * uninstaller's .onInit or the uninstaller's un.onInit functions.
5009 *
5010 * @param _WARN_UNSUPPORTED_MSG
5011 * Message displayed when the Windows version is not supported.
5012 *
5013 * $R5 = return value from the GetSize macro
5014 * $R6 = general string values, return value from GetTempFileName, return
5015 * value from the GetSize macro
5016 * $R7 = full path to the configuration ini file
5017 * $R8 = used for OS Version and Service Pack detection and the return value
5018 * from the GetParameters macro
5019 * $R9 = _WARN_UNSUPPORTED_MSG
5020 */
5021 !macro InstallOnInitCommon
5023 !ifndef InstallOnInitCommon
5024 !insertmacro ElevateUAC
5025 !insertmacro GetOptions
5026 !insertmacro GetParameters
5027 !insertmacro GetSize
5029 !verbose push
5030 !verbose ${_MOZFUNC_VERBOSE}
5031 !define InstallOnInitCommon "!insertmacro InstallOnInitCommonCall"
5033 Function InstallOnInitCommon
5034 Exch $R9
5035 Push $R8
5036 Push $R7
5037 Push $R6
5038 Push $R5
5040 !ifdef HAVE_64BIT_OS
5041 ${Unless} ${RunningX64}
5042 ${OrUnless} ${AtLeastWinVista}
5043 MessageBox MB_OK|MB_ICONSTOP "$R9" IDOK
5044 ; Nothing initialized so no need to call OnEndCommon
5045 Quit
5046 ${EndUnless}
5048 SetRegView 64
5049 !else
5050 StrCpy $R8 "0"
5051 ${If} ${AtMostWin2000}
5052 StrCpy $R8 "1"
5053 ${EndIf}
5055 ${If} ${IsWinXP}
5056 ${AndIf} ${AtMostServicePack} 1
5057 StrCpy $R8 "1"
5058 ${EndIf}
5060 ${If} $R8 == "1"
5061 ; XXX-rstrong - some systems failed the AtLeastWin2000 test that we
5062 ; used to use for an unknown reason and likely fail the AtMostWin2000
5063 ; and possibly the IsWinXP test as well. To work around this also
5064 ; check if the Windows NT registry Key exists and if it does if the
5065 ; first char in CurrentVersion is equal to 3 (Windows NT 3.5 and
5066 ; 3.5.1), to 4 (Windows NT 4) or 5 (Windows 2000 and Windows XP).
5067 StrCpy $R8 ""
5068 ClearErrors
5069 ReadRegStr $R8 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" "CurrentVersion"
5070 StrCpy $R8 "$R8" 1
5071 ${If} ${Errors}
5072 ${OrIf} "$R8" == "3"
5073 ${OrIf} "$R8" == "4"
5074 ${OrIf} "$R8" == "5"
5075 MessageBox MB_OK|MB_ICONSTOP "$R9" IDOK
5076 ; Nothing initialized so no need to call OnEndCommon
5077 Quit
5078 ${EndIf}
5079 ${EndUnless}
5080 !endif
5082 ${GetParameters} $R8
5084 ; Require elevation if the user can elevate
5085 ${ElevateUAC}
5087 ${If} $R8 != ""
5088 ; Default install type
5089 StrCpy $InstallType ${INSTALLTYPE_BASIC}
5091 ${Unless} ${Silent}
5092 ; Manually check for /S in the command line due to Bug 506867
5093 ClearErrors
5094 ${GetOptions} "$R8" "/S" $R7
5095 ${Unless} ${Errors}
5096 SetSilent silent
5097 ${Else}
5098 ; Support for the deprecated -ms command line argument. The new command
5099 ; line arguments are not supported when -ms is used.
5100 ClearErrors
5101 ${GetOptions} "$R8" "-ms" $R7
5102 ${Unless} ${Errors}
5103 SetSilent silent
5104 ${EndUnless}
5105 ${EndUnless}
5106 ${EndUnless}
5108 ; Support for specifying an installation configuration file.
5109 ClearErrors
5110 ${GetOptions} "$R8" "/INI=" $R7
5111 ${Unless} ${Errors}
5112 ; The configuration file must also exist
5113 ${If} ${FileExists} "$R7"
5114 SetSilent silent
5115 ReadINIStr $R8 $R7 "Install" "InstallDirectoryName"
5116 ${If} $R8 != ""
5117 !ifdef HAVE_64BIT_OS
5118 StrCpy $INSTDIR "$PROGRAMFILES64\$R8"
5119 !else
5120 StrCpy $INSTDIR "$PROGRAMFILES32\$R8"
5121 !endif
5122 ${Else}
5123 ReadINIStr $R8 $R7 "Install" "InstallDirectoryPath"
5124 ${If} $R8 != ""
5125 StrCpy $INSTDIR "$R8"
5126 ${EndIf}
5127 ${EndIf}
5129 ; Quit if we are unable to create the installation directory or we are
5130 ; unable to write to a file in the installation directory.
5131 ClearErrors
5132 ${If} ${FileExists} "$INSTDIR"
5133 GetTempFileName $R6 "$INSTDIR"
5134 FileOpen $R5 "$R6" w
5135 FileWrite $R5 "Write Access Test"
5136 FileClose $R5
5137 Delete $R6
5138 ${If} ${Errors}
5139 ; Nothing initialized so no need to call OnEndCommon
5140 Quit
5141 ${EndIf}
5142 ${Else}
5143 CreateDirectory "$INSTDIR"
5144 ${If} ${Errors}
5145 ; Nothing initialized so no need to call OnEndCommon
5146 Quit
5147 ${EndIf}
5148 ${EndIf}
5150 ReadINIStr $R8 $R7 "Install" "QuickLaunchShortcut"
5151 ${If} $R8 == "false"
5152 StrCpy $AddQuickLaunchSC "0"
5153 ${Else}
5154 StrCpy $AddQuickLaunchSC "1"
5155 ${EndIf}
5157 ReadINIStr $R8 $R7 "Install" "DesktopShortcut"
5158 ${If} $R8 == "false"
5159 StrCpy $AddDesktopSC "0"
5160 ${Else}
5161 StrCpy $AddDesktopSC "1"
5162 ${EndIf}
5164 ReadINIStr $R8 $R7 "Install" "StartMenuShortcuts"
5165 ${If} $R8 == "false"
5166 StrCpy $AddStartMenuSC "0"
5167 ${Else}
5168 StrCpy $AddStartMenuSC "1"
5169 ${EndIf}
5171 ReadINIStr $R8 $R7 "Install" "MaintenanceService"
5172 ${If} $R8 == "false"
5173 StrCpy $InstallMaintenanceService "0"
5174 ${EndIf}
5176 !ifndef NO_STARTMENU_DIR
5177 ReadINIStr $R8 $R7 "Install" "StartMenuDirectoryName"
5178 ${If} $R8 != ""
5179 StrCpy $StartMenuDir "$R8"
5180 ${EndIf}
5181 !endif
5182 ${EndIf}
5183 ${EndUnless}
5184 ${EndIf}
5185 ClearErrors
5187 Pop $R5
5188 Pop $R6
5189 Pop $R7
5190 Pop $R8
5191 Exch $R9
5192 FunctionEnd
5194 !verbose pop
5195 !endif
5196 !macroend
5198 !macro InstallOnInitCommonCall _WARN_UNSUPPORTED_MSG
5199 !verbose push
5200 !verbose ${_MOZFUNC_VERBOSE}
5201 Push "${_WARN_UNSUPPORTED_MSG}"
5202 Call InstallOnInitCommon
5203 !verbose pop
5204 !macroend
5206 /**
5207 * Called from the uninstaller's .onInit function not to be confused with the
5208 * installer's .onInit or the uninstaller's un.onInit functions.
5209 */
5210 !macro UninstallOnInitCommon
5212 !ifndef UninstallOnInitCommon
5213 !insertmacro ElevateUAC
5214 !insertmacro GetLongPath
5215 !insertmacro GetOptions
5216 !insertmacro GetParameters
5217 !insertmacro GetParent
5218 !insertmacro UnloadUAC
5219 !insertmacro UpdateShortcutAppModelIDs
5220 !insertmacro UpdateUninstallLog
5222 !verbose push
5223 !verbose ${_MOZFUNC_VERBOSE}
5224 !define UninstallOnInitCommon "!insertmacro UninstallOnInitCommonCall"
5226 Function UninstallOnInitCommon
5227 ; Prevents breaking apps that don't use SetBrandNameVars
5228 !ifdef SetBrandNameVars
5229 ${SetBrandNameVars} "$EXEDIR\distribution\setup.ini"
5230 !endif
5232 ; Prevent launching the application when a reboot is required and this
5233 ; executable is the main application executable
5234 IfFileExists "$EXEDIR\${FileMainEXE}.moz-upgrade" +1 +4
5235 MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(WARN_RESTART_REQUIRED_UPGRADE)" IDNO +2
5236 Reboot
5237 Quit ; Nothing initialized so no need to call OnEndCommon
5239 ${GetParent} "$EXEDIR" $INSTDIR
5240 ${GetLongPath} "$INSTDIR" $INSTDIR
5241 IfFileExists "$INSTDIR\${FileMainEXE}" +2 +1
5242 Quit ; Nothing initialized so no need to call OnEndCommon
5244 !ifmacrodef InitHashAppModelId
5245 ; setup the application model id registration value
5246 !ifdef AppName
5247 ${InitHashAppModelId} "$INSTDIR" "Software\Mozilla\${AppName}\TaskBarIDs"
5248 !endif
5249 !endif
5251 ; Prevents breaking apps that don't use SetBrandNameVars
5252 !ifdef SetBrandNameVars
5253 ${SetBrandNameVars} "$INSTDIR\distribution\setup.ini"
5254 !endif
5256 ; Application update uses a directory named tobedeleted in the $INSTDIR to
5257 ; delete files on OS reboot when they are in use. Try to delete this
5258 ; directory if it exists.
5259 ${If} ${FileExists} "$INSTDIR\${TO_BE_DELETED}"
5260 RmDir /r "$INSTDIR\${TO_BE_DELETED}"
5261 ${EndIf}
5263 ; Prevent all operations (e.g. set as default, postupdate, etc.) when a
5264 ; reboot is required and the executable launched is helper.exe
5265 IfFileExists "$INSTDIR\${FileMainEXE}.moz-upgrade" +1 +4
5266 MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(WARN_RESTART_REQUIRED_UPGRADE)" IDNO +2
5267 Reboot
5268 Quit ; Nothing initialized so no need to call OnEndCommon
5270 !ifdef HAVE_64BIT_OS
5271 SetRegView 64
5272 !endif
5274 ${GetParameters} $R0
5276 StrCmp "$R0" "" continue +1
5278 ; Update this user's shortcuts with the latest app user model id.
5279 ClearErrors
5280 ${GetOptions} "$R0" "/UpdateShortcutAppUserModelIds" $R2
5281 IfErrors hideshortcuts +1
5282 StrCpy $R2 ""
5283 !ifmacrodef InitHashAppModelId
5284 ${If} "$AppUserModelID" != ""
5285 ${UpdateShortcutAppModelIDs} "$INSTDIR\${FileMainEXE}" "$AppUserModelID" $R2
5286 ${EndIf}
5287 !endif
5288 StrCmp "$R2" "false" +1 finish ; true indicates that shortcuts have been updated
5289 Quit ; Nothing initialized so no need to call OnEndCommon
5291 ; Require elevation if the user can elevate
5292 hideshortcuts:
5293 ClearErrors
5294 ${GetOptions} "$R0" "/HideShortcuts" $R2
5295 IfErrors showshortcuts +1
5296 !ifndef NONADMIN_ELEVATE
5297 ${ElevateUAC}
5298 !endif
5299 ${HideShortcuts}
5300 GoTo finish
5302 ; Require elevation if the user can elevate
5303 showshortcuts:
5304 ClearErrors
5305 ${GetOptions} "$R0" "/ShowShortcuts" $R2
5306 IfErrors defaultappuser +1
5307 !ifndef NONADMIN_ELEVATE
5308 ${ElevateUAC}
5309 !endif
5310 ${ShowShortcuts}
5311 GoTo finish
5313 ; Require elevation if the the StartMenuInternet registry keys require
5314 ; updating and the user can elevate
5315 defaultappuser:
5316 ClearErrors
5317 ${GetOptions} "$R0" "/SetAsDefaultAppUser" $R2
5318 IfErrors defaultappglobal +1
5319 ${SetAsDefaultAppUser}
5320 GoTo finish
5322 ; Require elevation if the user can elevate
5323 defaultappglobal:
5324 ClearErrors
5325 ${GetOptions} "$R0" "/SetAsDefaultAppGlobal" $R2
5326 IfErrors postupdate +1
5327 ${ElevateUAC}
5328 ${SetAsDefaultAppGlobal}
5329 GoTo finish
5331 ; Do not attempt to elevate. The application launching this executable is
5332 ; responsible for elevation if it is required.
5333 postupdate:
5334 ${WordReplace} "$R0" "$\"" "" "+" $R0
5335 ClearErrors
5336 ${GetOptions} "$R0" "/PostUpdate" $R2
5337 IfErrors continue +1
5338 ; If the uninstall.log does not exist don't perform post update
5339 ; operations. This prevents updating the registry for zip builds.
5340 IfFileExists "$EXEDIR\uninstall.log" +2 +1
5341 Quit ; Nothing initialized so no need to call OnEndCommon
5342 ${PostUpdate}
5343 ClearErrors
5344 ${GetOptions} "$R0" "/UninstallLog=" $R2
5345 IfErrors updateuninstalllog +1
5346 StrCmp "$R2" "" finish +1
5347 GetFullPathName $R3 "$R2"
5348 IfFileExists "$R3" +1 finish
5349 Delete "$INSTDIR\uninstall\*wizard*"
5350 Delete "$INSTDIR\uninstall\uninstall.log"
5351 CopyFiles /SILENT /FILESONLY "$R3" "$INSTDIR\uninstall\"
5352 ${GetParent} "$R3" $R4
5353 Delete "$R3"
5354 RmDir "$R4"
5355 GoTo finish
5357 ; Do not attempt to elevate. The application launching this executable is
5358 ; responsible for elevation if it is required.
5359 updateuninstalllog:
5360 ${UpdateUninstallLog}
5362 finish:
5363 ${UnloadUAC}
5364 System::Call "shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i 0, i 0, i 0)"
5365 Quit ; Nothing initialized so no need to call OnEndCommon
5367 continue:
5369 ; If the uninstall.log does not exist don't perform uninstall
5370 ; operations. This prevents running the uninstaller for zip builds.
5371 IfFileExists "$INSTDIR\uninstall\uninstall.log" +2 +1
5372 Quit ; Nothing initialized so no need to call OnEndCommon
5374 ; Require elevation if the user can elevate
5375 ${ElevateUAC}
5377 ; If we made it this far then this installer is being used as an uninstaller.
5378 WriteUninstaller "$EXEDIR\uninstaller.exe"
5380 ${Unless} ${Silent}
5381 ; Manually check for /S in the command line due to Bug 506867
5382 ClearErrors
5383 ${GetOptions} "$R0" "/S" $R2
5384 ${Unless} ${Errors}
5385 SetSilent silent
5386 ${Else}
5387 ; Support for the deprecated -ms command line argument.
5388 ClearErrors
5389 ${GetOptions} "$R0" "-ms" $R2
5390 ${Unless} ${Errors}
5391 SetSilent silent
5392 ${EndUnless}
5393 ${EndUnless}
5394 ${EndUnless}
5396 ${If} ${Silent}
5397 StrCpy $R1 "$\"$EXEDIR\uninstaller.exe$\" /S"
5398 ${Else}
5399 StrCpy $R1 "$\"$EXEDIR\uninstaller.exe$\""
5400 ${EndIf}
5402 ; When the uninstaller is launched it copies itself to the temp directory
5403 ; so it won't be in use so it can delete itself.
5404 ExecWait $R1
5405 ${DeleteFile} "$EXEDIR\uninstaller.exe"
5406 ${UnloadUAC}
5407 SetErrorLevel 0
5408 Quit ; Nothing initialized so no need to call OnEndCommon
5410 FunctionEnd
5412 !verbose pop
5413 !endif
5414 !macroend
5416 !macro UninstallOnInitCommonCall
5417 !verbose push
5418 !verbose ${_MOZFUNC_VERBOSE}
5419 Call UninstallOnInitCommon
5420 !verbose pop
5421 !macroend
5423 /**
5424 * Called from the uninstaller's un.onInit function not to be confused with the
5425 * installer's .onInit or the uninstaller's .onInit functions.
5426 */
5427 !macro un.UninstallUnOnInitCommon
5429 !ifndef un.UninstallUnOnInitCommon
5430 !insertmacro un.GetLongPath
5431 !insertmacro un.GetParent
5432 !insertmacro un.SetBrandNameVars
5434 !verbose push
5435 !verbose ${_MOZFUNC_VERBOSE}
5436 !define un.UninstallUnOnInitCommon "!insertmacro un.UninstallUnOnInitCommonCall"
5438 Function un.UninstallUnOnInitCommon
5439 ${un.GetParent} "$INSTDIR" $INSTDIR
5440 ${un.GetLongPath} "$INSTDIR" $INSTDIR
5441 ${Unless} ${FileExists} "$INSTDIR\${FileMainEXE}"
5442 Abort
5443 ${EndUnless}
5445 !ifdef HAVE_64BIT_OS
5446 SetRegView 64
5447 !endif
5449 ; Prevents breaking apps that don't use SetBrandNameVars
5450 !ifdef un.SetBrandNameVars
5451 ${un.SetBrandNameVars} "$INSTDIR\distribution\setup.ini"
5452 !endif
5454 ; Initialize $hHeaderBitmap to prevent redundant changing of the bitmap if
5455 ; the user clicks the back button
5456 StrCpy $hHeaderBitmap ""
5457 FunctionEnd
5459 !verbose pop
5460 !endif
5461 !macroend
5463 !macro un.UninstallUnOnInitCommonCall
5464 !verbose push
5465 !verbose ${_MOZFUNC_VERBOSE}
5466 Call un.UninstallUnOnInitCommon
5467 !verbose pop
5468 !macroend
5470 /**
5471 * Called from the MUI leaveOptions function to set the value of $INSTDIR.
5472 */
5473 !macro LeaveOptionsCommon
5475 !ifndef LeaveOptionsCommon
5476 !insertmacro CanWriteToInstallDir
5477 !insertmacro GetLongPath
5479 !ifndef NO_INSTDIR_FROM_REG
5480 !insertmacro GetSingleInstallPath
5481 !endif
5483 !verbose push
5484 !verbose ${_MOZFUNC_VERBOSE}
5485 !define LeaveOptionsCommon "!insertmacro LeaveOptionsCommonCall"
5487 Function LeaveOptionsCommon
5488 Push $R9
5490 !ifndef NO_INSTDIR_FROM_REG
5491 SetShellVarContext all ; Set SHCTX to HKLM
5492 ${GetSingleInstallPath} "Software\Mozilla\${BrandFullNameInternal}" $R9
5494 StrCmp "$R9" "false" +1 finish_get_install_dir
5496 SetShellVarContext current ; Set SHCTX to HKCU
5497 ${GetSingleInstallPath} "Software\Mozilla\${BrandFullNameInternal}" $R9
5499 finish_get_install_dir:
5500 StrCmp "$R9" "false" +2 +1
5501 StrCpy $INSTDIR "$R9"
5502 !endif
5504 ; If the user doesn't have write access to the installation directory set
5505 ; the installation directory to a subdirectory of the All Users application
5506 ; directory and if the user can't write to that location set the installation
5507 ; directory to a subdirectory of the users local application directory
5508 ; (e.g. non-roaming).
5509 ${CanWriteToInstallDir} $R9
5510 StrCmp "$R9" "false" +1 finish_check_install_dir
5512 SetShellVarContext all ; Set SHCTX to All Users
5513 StrCpy $INSTDIR "$APPDATA\${BrandFullName}\"
5514 ${CanWriteToInstallDir} $R9
5515 StrCmp "$R9" "false" +2 +1
5516 StrCpy $INSTDIR "$LOCALAPPDATA\${BrandFullName}\"
5518 finish_check_install_dir:
5519 IfFileExists "$INSTDIR" +3 +1
5520 Pop $R9
5521 Return
5523 ; Always display the long path if the path already exists.
5524 ${GetLongPath} "$INSTDIR" $INSTDIR
5526 ; The call to GetLongPath returns a long path without a trailing
5527 ; back-slash. Append a \ to the path to prevent the directory
5528 ; name from being appended when using the NSIS create new folder.
5529 ; http://www.nullsoft.com/free/nsis/makensis.htm#InstallDir
5530 StrCpy $INSTDIR "$INSTDIR\"
5532 Pop $R9
5533 FunctionEnd
5535 !verbose pop
5536 !endif
5537 !macroend
5539 !macro LeaveOptionsCommonCall
5540 !verbose push
5541 !verbose ${_MOZFUNC_VERBOSE}
5542 Call LeaveOptionsCommon
5543 !verbose pop
5544 !macroend
5546 /**
5547 * Called from the MUI preDirectory function to verify there is enough disk
5548 * space for the installation and the installation directory is writable.
5549 *
5550 * $R9 = returned value from CheckDiskSpace and CanWriteToInstallDir macros
5551 */
5552 !macro PreDirectoryCommon
5554 !ifndef PreDirectoryCommon
5555 !insertmacro CanWriteToInstallDir
5556 !insertmacro CheckDiskSpace
5558 !verbose push
5559 !verbose ${_MOZFUNC_VERBOSE}
5560 !define PreDirectoryCommon "!insertmacro PreDirectoryCommonCall"
5562 Function PreDirectoryCommon
5563 Push $R9
5565 IntCmp $InstallType ${INSTALLTYPE_CUSTOM} end +1 +1
5566 ${CanWriteToInstallDir} $R9
5567 StrCmp "$R9" "false" end +1
5568 ${CheckDiskSpace} $R9
5569 StrCmp "$R9" "false" end +1
5570 Abort
5572 end:
5574 Pop $R9
5575 FunctionEnd
5577 !verbose pop
5578 !endif
5579 !macroend
5581 !macro PreDirectoryCommonCall
5582 !verbose push
5583 !verbose ${_MOZFUNC_VERBOSE}
5584 Call PreDirectoryCommon
5585 !verbose pop
5586 !macroend
5588 /**
5589 * Called from the MUI leaveDirectory function
5590 *
5591 * @param _WARN_DISK_SPACE
5592 * Message displayed when there isn't enough disk space to perform the
5593 * installation.
5594 * @param _WARN_WRITE_ACCESS
5595 * Message displayed when the installer does not have write access to
5596 * $INSTDIR.
5597 *
5598 * $R7 = returned value from CheckDiskSpace and CanWriteToInstallDir macros
5599 * $R8 = _WARN_DISK_SPACE
5600 * $R9 = _WARN_WRITE_ACCESS
5601 */
5602 !macro LeaveDirectoryCommon
5604 !ifndef LeaveDirectoryCommon
5605 !insertmacro CheckDiskSpace
5606 !insertmacro CanWriteToInstallDir
5608 !verbose push
5609 !verbose ${_MOZFUNC_VERBOSE}
5610 !define LeaveDirectoryCommon "!insertmacro LeaveDirectoryCommonCall"
5612 Function LeaveDirectoryCommon
5613 Exch $R9
5614 Exch 1
5615 Exch $R8
5616 Push $R7
5618 ${CanWriteToInstallDir} $R7
5619 ${If} $R7 == "false"
5620 MessageBox MB_OK|MB_ICONEXCLAMATION "$R9"
5621 Abort
5622 ${EndIf}
5624 ${CheckDiskSpace} $R7
5625 ${If} $R7 == "false"
5626 MessageBox MB_OK|MB_ICONEXCLAMATION "$R8"
5627 Abort
5628 ${EndIf}
5630 Pop $R7
5631 Exch $R8
5632 Exch 1
5633 Exch $R9
5634 FunctionEnd
5636 !verbose pop
5637 !endif
5638 !macroend
5640 !macro LeaveDirectoryCommonCall _WARN_DISK_SPACE _WARN_WRITE_ACCESS
5641 !verbose push
5642 Push "${_WARN_DISK_SPACE}"
5643 Push "${_WARN_WRITE_ACCESS}"
5644 !verbose ${_MOZFUNC_VERBOSE}
5645 Call LeaveDirectoryCommon
5646 !verbose pop
5647 !macroend
5650 ################################################################################
5651 # Install Section common macros.
5653 /**
5654 * Performs common cleanup operations prior to the actual installation.
5655 * This macro should be called first when installation starts.
5656 */
5657 !macro InstallStartCleanupCommon
5659 !ifndef InstallStartCleanupCommon
5660 !insertmacro CleanVirtualStore
5661 !insertmacro EndUninstallLog
5662 !insertmacro OnInstallUninstall
5664 !verbose push
5665 !verbose ${_MOZFUNC_VERBOSE}
5666 !define InstallStartCleanupCommon "!insertmacro InstallStartCleanupCommonCall"
5668 Function InstallStartCleanupCommon
5670 ; Remove files not removed by parsing the uninstall.log
5671 Delete "$INSTDIR\install_wizard.log"
5672 Delete "$INSTDIR\install_status.log"
5674 RmDir /r "$INSTDIR\updates"
5675 Delete "$INSTDIR\updates.xml"
5676 Delete "$INSTDIR\active-update.xml"
5678 RmDir /r "$INSTDIR\distribution"
5680 ; Remove files from the uninstall directory.
5681 ${If} ${FileExists} "$INSTDIR\uninstall"
5682 Delete "$INSTDIR\uninstall\*wizard*"
5683 Delete "$INSTDIR\uninstall\uninstall.ini"
5684 Delete "$INSTDIR\uninstall\cleanup.log"
5685 Delete "$INSTDIR\uninstall\uninstall.update"
5686 ${OnInstallUninstall}
5687 ${EndIf}
5689 ; Since we write to the uninstall.log in this directory during the
5690 ; installation create the directory if it doesn't already exist.
5691 IfFileExists "$INSTDIR\uninstall" +2 +1
5692 CreateDirectory "$INSTDIR\uninstall"
5694 ; Application update uses a directory named tobedeleted in the $INSTDIR to
5695 ; delete files on OS reboot when they are in use. Try to delete this
5696 ; directory if it exists.
5697 ${If} ${FileExists} "$INSTDIR\${TO_BE_DELETED}"
5698 RmDir /r "$INSTDIR\${TO_BE_DELETED}"
5699 ${EndIf}
5701 ; Remove files that may be left behind by the application in the
5702 ; VirtualStore directory.
5703 ${CleanVirtualStore}
5704 FunctionEnd
5706 !verbose pop
5707 !endif
5708 !macroend
5710 !macro InstallStartCleanupCommonCall
5711 !verbose push
5712 !verbose ${_MOZFUNC_VERBOSE}
5713 Call InstallStartCleanupCommon
5714 !verbose pop
5715 !macroend
5717 /**
5718 * Performs common cleanup operations after the actual installation.
5719 * This macro should be called last during the installation.
5720 */
5721 !macro InstallEndCleanupCommon
5723 !ifndef InstallEndCleanupCommon
5724 !insertmacro EndUninstallLog
5726 !verbose push
5727 !verbose ${_MOZFUNC_VERBOSE}
5728 !define InstallEndCleanupCommon "!insertmacro InstallEndCleanupCommonCall"
5730 Function InstallEndCleanupCommon
5732 ; Close the file handle to the uninstall.log
5733 ${EndUninstallLog}
5735 FunctionEnd
5737 !verbose pop
5738 !endif
5739 !macroend
5741 !macro InstallEndCleanupCommonCall
5742 !verbose push
5743 !verbose ${_MOZFUNC_VERBOSE}
5744 Call InstallEndCleanupCommon
5745 !verbose pop
5746 !macroend
5749 ################################################################################
5750 # UAC Related Macros
5752 /**
5753 * Provides UAC elevation support for Vista and above (requires the UAC plugin).
5754 *
5755 * $0 = return values from calls to the UAC plugin (always uses $0)
5756 * $R9 = return values from GetParameters and GetOptions macros
5757 */
5758 !macro ElevateUAC
5760 !ifndef ${_MOZFUNC_UN}ElevateUAC
5761 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
5762 !insertmacro ${_MOZFUNC_UN_TMP}GetOptions
5763 !insertmacro ${_MOZFUNC_UN_TMP}GetParameters
5764 !undef _MOZFUNC_UN
5765 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
5766 !undef _MOZFUNC_UN_TMP
5768 !verbose push
5769 !verbose ${_MOZFUNC_VERBOSE}
5770 !define ${_MOZFUNC_UN}ElevateUAC "!insertmacro ${_MOZFUNC_UN}ElevateUACCall"
5772 Function ${_MOZFUNC_UN}ElevateUAC
5773 Push $R9
5774 Push $0
5776 !ifndef NONADMIN_ELEVATE
5777 ${If} ${AtLeastWinVista}
5778 UAC::IsAdmin
5779 ; If the user is not an admin already
5780 ${If} "$0" != "1"
5781 UAC::SupportsUAC
5782 ; If the system supports UAC
5783 ${If} "$0" == "1"
5784 UAC::GetElevationType
5785 ; If the user account has a split token
5786 ${If} "$0" == "3"
5787 UAC::RunElevated
5788 UAC::Unload
5789 ; Nothing besides UAC initialized so no need to call OnEndCommon
5790 Quit
5791 ${EndIf}
5792 ${EndIf}
5793 ${Else}
5794 ${GetParameters} $R9
5795 ${If} $R9 != ""
5796 ClearErrors
5797 ${GetOptions} "$R9" "/UAC:" $0
5798 ; If the command line contains /UAC then we need to initialize
5799 ; the UAC plugin to use UAC::ExecCodeSegment to execute code in
5800 ; the non-elevated context.
5801 ${Unless} ${Errors}
5802 UAC::RunElevated
5803 ${EndUnless}
5804 ${EndIf}
5805 ${EndIf}
5806 ${EndIf}
5807 !else
5808 ${If} ${AtLeastWinVista}
5809 UAC::IsAdmin
5810 ; If the user is not an admin already
5811 ${If} "$0" != "1"
5812 UAC::SupportsUAC
5813 ; If the system supports UAC require that the user elevate
5814 ${If} "$0" == "1"
5815 UAC::GetElevationType
5816 ; If the user account has a split token
5817 ${If} "$0" == "3"
5818 UAC::RunElevated
5819 UAC::Unload
5820 ; Nothing besides UAC initialized so no need to call OnEndCommon
5821 Quit
5822 ${EndIf}
5823 ${Else}
5824 ; Check if UAC is enabled. If the user has turned UAC on or off
5825 ; without rebooting this value will be incorrect. This is an
5826 ; edgecase that we have to live with when trying to allow
5827 ; installing when the user doesn't have privileges such as a public
5828 ; computer while trying to also achieve UAC elevation. When this
5829 ; happens the user will be presented with the runas dialog if the
5830 ; value is 1 and won't be presented with the UAC dialog when the
5831 ; value is 0.
5832 ReadRegDWord $R9 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" "EnableLUA"
5833 ${If} "$R9" == "1"
5834 ; This will display the UAC version of the runas dialog which
5835 ; requires a password for an existing user account.
5836 UAC::RunElevated
5837 ${If} "$0" == "0" ; Was elevation successful
5838 UAC::Unload
5839 ; Nothing besides UAC initialized so no need to call OnEndCommon
5840 Quit
5841 ${EndIf}
5842 ; Unload UAC since the elevation request was not successful and
5843 ; install anyway.
5844 UAC::Unload
5845 ${EndIf}
5846 ${EndIf}
5847 ${Else}
5848 ClearErrors
5849 ${${_MOZFUNC_UN}GetParameters} $R9
5850 ${${_MOZFUNC_UN}GetOptions} "$R9" "/UAC:" $R9
5851 ; If the command line contains /UAC then we need to initialize the UAC
5852 ; plugin to use UAC::ExecCodeSegment to execute code in the
5853 ; non-elevated context.
5854 ${Unless} ${Errors}
5855 UAC::RunElevated
5856 ${EndUnless}
5857 ${EndIf}
5858 ${EndIf}
5859 !endif
5861 ClearErrors
5863 Pop $0
5864 Pop $R9
5865 FunctionEnd
5867 !verbose pop
5868 !endif
5869 !macroend
5871 !macro ElevateUACCall
5872 !verbose push
5873 !verbose ${_MOZFUNC_VERBOSE}
5874 Call ElevateUAC
5875 !verbose pop
5876 !macroend
5878 !macro un.ElevateUACCall
5879 !verbose push
5880 !verbose ${_MOZFUNC_VERBOSE}
5881 Call un.ElevateUAC
5882 !verbose pop
5883 !macroend
5885 !macro un.ElevateUAC
5886 !ifndef un.ElevateUAC
5887 !verbose push
5888 !verbose ${_MOZFUNC_VERBOSE}
5889 !undef _MOZFUNC_UN
5890 !define _MOZFUNC_UN "un."
5892 !insertmacro ElevateUAC
5894 !undef _MOZFUNC_UN
5895 !define _MOZFUNC_UN
5896 !verbose pop
5897 !endif
5898 !macroend
5900 /**
5901 * Unloads the UAC plugin so the NSIS plugins can be removed when the installer
5902 * and uninstaller exit.
5903 *
5904 * $R9 = return values from GetParameters and GetOptions macros
5905 */
5906 !macro UnloadUAC
5908 !ifndef ${_MOZFUNC_UN}UnloadUAC
5909 !define _MOZFUNC_UN_TMP_UnloadUAC ${_MOZFUNC_UN}
5910 !insertmacro ${_MOZFUNC_UN_TMP_UnloadUAC}GetOptions
5911 !insertmacro ${_MOZFUNC_UN_TMP_UnloadUAC}GetParameters
5912 !undef _MOZFUNC_UN
5913 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP_UnloadUAC}
5914 !undef _MOZFUNC_UN_TMP_UnloadUAC
5916 !verbose push
5917 !verbose ${_MOZFUNC_VERBOSE}
5918 !define ${_MOZFUNC_UN}UnloadUAC "!insertmacro ${_MOZFUNC_UN}UnloadUACCall"
5920 Function ${_MOZFUNC_UN}UnloadUAC
5921 ${Unless} ${AtLeastWinVista}
5922 Return
5923 ${EndUnless}
5925 Push $R9
5927 ClearErrors
5928 ${${_MOZFUNC_UN}GetParameters} $R9
5929 ${${_MOZFUNC_UN}GetOptions} "$R9" "/UAC:" $R9
5930 ; If the command line contains /UAC then we need to unload the UAC plugin
5931 IfErrors +2 +1
5932 UAC::Unload
5934 ClearErrors
5936 Pop $R9
5937 FunctionEnd
5939 !verbose pop
5940 !endif
5941 !macroend
5943 !macro UnloadUACCall
5944 !verbose push
5945 !verbose ${_MOZFUNC_VERBOSE}
5946 Call UnloadUAC
5947 !verbose pop
5948 !macroend
5950 !macro un.UnloadUACCall
5951 !verbose push
5952 !verbose ${_MOZFUNC_VERBOSE}
5953 Call un.UnloadUAC
5954 !verbose pop
5955 !macroend
5957 !macro un.UnloadUAC
5958 !ifndef un.UnloadUAC
5959 !verbose push
5960 !verbose ${_MOZFUNC_VERBOSE}
5961 !undef _MOZFUNC_UN
5962 !define _MOZFUNC_UN "un."
5964 !insertmacro UnloadUAC
5966 !undef _MOZFUNC_UN
5967 !define _MOZFUNC_UN
5968 !verbose pop
5969 !endif
5970 !macroend
5973 ################################################################################
5974 # Macros for uninstall.log and install.log logging
5975 #
5976 # Since these are used by other macros they should be inserted first. All of
5977 # these macros can be easily inserted using the _LoggingCommon macro.
5979 /**
5980 * Adds all logging macros in the correct order in one fell swoop as well as
5981 * the vars for the install.log and uninstall.log file handles.
5982 */
5983 !macro _LoggingCommon
5984 Var /GLOBAL fhInstallLog
5985 Var /GLOBAL fhUninstallLog
5986 !insertmacro StartInstallLog
5987 !insertmacro EndInstallLog
5988 !insertmacro StartUninstallLog
5989 !insertmacro EndUninstallLog
5990 !macroend
5991 !define _LoggingCommon "!insertmacro _LoggingCommon"
5993 /**
5994 * Creates a file named install.log in the install directory (e.g. $INSTDIR)
5995 * and adds the installation started message to the install.log for this
5996 * installation. This also adds the fhInstallLog and fhUninstallLog vars used
5997 * for logging.
5998 *
5999 * $fhInstallLog = filehandle for $INSTDIR\install.log
6000 *
6001 * @param _APP_NAME
6002 * Typically the BrandFullName
6003 * @param _AB_CD
6004 * The locale identifier
6005 * @param _APP_VERSION
6006 * The application version
6007 * @param _GRE_VERSION
6008 * The Gecko Runtime Engine version
6009 *
6010 * $R6 = _APP_NAME
6011 * $R7 = _AB_CD
6012 * $R8 = _APP_VERSION
6013 * $R9 = _GRE_VERSION
6014 */
6015 !macro StartInstallLog
6017 !ifndef StartInstallLog
6018 !insertmacro GetTime
6020 !verbose push
6021 !verbose ${_MOZFUNC_VERBOSE}
6022 !define StartInstallLog "!insertmacro StartInstallLogCall"
6024 Function StartInstallLog
6025 Exch $R9
6026 Exch 1
6027 Exch $R8
6028 Exch 2
6029 Exch $R7
6030 Exch 3
6031 Exch $R6
6032 Push $R5
6033 Push $R4
6034 Push $R3
6035 Push $R2
6036 Push $R1
6037 Push $R0
6038 Push $9
6040 ${DeleteFile} "$INSTDIR\install.log"
6041 FileOpen $fhInstallLog "$INSTDIR\install.log" w
6042 FileWriteWord $fhInstallLog "65279"
6044 ${GetTime} "" "L" $9 $R0 $R1 $R2 $R3 $R4 $R5
6045 FileWriteUTF16LE $fhInstallLog "$R6 Installation Started: $R1-$R0-$9 $R3:$R4:$R5"
6046 ${WriteLogSeparator}
6048 ${LogHeader} "Installation Details"
6049 ${LogMsg} "Install Dir: $INSTDIR"
6050 ${LogMsg} "Locale : $R7"
6051 ${LogMsg} "App Version: $R8"
6052 ${LogMsg} "GRE Version: $R9"
6054 ${If} ${IsWinXP}
6055 ${LogMsg} "OS Name : Windows XP"
6056 ${ElseIf} ${IsWin2003}
6057 ${LogMsg} "OS Name : Windows 2003"
6058 ${ElseIf} ${IsWinVista}
6059 ${LogMsg} "OS Name : Windows Vista"
6060 ${ElseIf} ${IsWin7}
6061 ${LogMsg} "OS Name : Windows 7"
6062 ${ElseIf} ${IsWin8}
6063 ${LogMsg} "OS Name : Windows 8"
6064 ${ElseIf} ${AtLeastWin8}
6065 ${LogMsg} "OS Name : Above Windows 8"
6066 ${Else}
6067 ${LogMsg} "OS Name : Unable to detect"
6068 ${EndIf}
6070 !ifdef HAVE_64BIT_OS
6071 ${LogMsg} "Target CPU : x64"
6072 !else
6073 ${LogMsg} "Target CPU : x86"
6074 !endif
6076 Pop $9
6077 Pop $R0
6078 Pop $R1
6079 Pop $R2
6080 Pop $R3
6081 Pop $R4
6082 Pop $R5
6083 Exch $R6
6084 Exch 3
6085 Exch $R7
6086 Exch 2
6087 Exch $R8
6088 Exch 1
6089 Exch $R9
6090 FunctionEnd
6092 !verbose pop
6093 !endif
6094 !macroend
6096 !macro StartInstallLogCall _APP_NAME _AB_CD _APP_VERSION _GRE_VERSION
6097 !verbose push
6098 !verbose ${_MOZFUNC_VERBOSE}
6099 Push "${_APP_NAME}"
6100 Push "${_AB_CD}"
6101 Push "${_APP_VERSION}"
6102 Push "${_GRE_VERSION}"
6103 Call StartInstallLog
6104 !verbose pop
6105 !macroend
6107 /**
6108 * Writes the installation finished message to the install.log and closes the
6109 * file handles to the install.log and uninstall.log
6110 *
6111 * @param _APP_NAME
6112 *
6113 * $R9 = _APP_NAME
6114 */
6115 !macro EndInstallLog
6117 !ifndef EndInstallLog
6118 !insertmacro GetTime
6120 !verbose push
6121 !verbose ${_MOZFUNC_VERBOSE}
6122 !define EndInstallLog "!insertmacro EndInstallLogCall"
6124 Function EndInstallLog
6125 Exch $R9
6126 Push $R8
6127 Push $R7
6128 Push $R6
6129 Push $R5
6130 Push $R4
6131 Push $R3
6132 Push $R2
6134 ${WriteLogSeparator}
6135 ${GetTime} "" "L" $R2 $R3 $R4 $R5 $R6 $R7 $R8
6136 FileWriteUTF16LE $fhInstallLog "$R9 Installation Finished: $R4-$R3-$R2 $R6:$R7:$R8$\r$\n"
6137 FileClose $fhInstallLog
6139 Pop $R2
6140 Pop $R3
6141 Pop $R4
6142 Pop $R5
6143 Pop $R6
6144 Pop $R7
6145 Pop $R8
6146 Exch $R9
6147 FunctionEnd
6149 !verbose pop
6150 !endif
6151 !macroend
6153 !macro EndInstallLogCall _APP_NAME
6154 !verbose push
6155 !verbose ${_MOZFUNC_VERBOSE}
6156 Push "${_APP_NAME}"
6157 Call EndInstallLog
6158 !verbose pop
6159 !macroend
6161 /**
6162 * Opens the file handle to the uninstall.log.
6163 *
6164 * $fhUninstallLog = filehandle for $INSTDIR\uninstall\uninstall.log
6165 */
6166 !macro StartUninstallLog
6168 !ifndef StartUninstallLog
6169 !verbose push
6170 !verbose ${_MOZFUNC_VERBOSE}
6171 !define StartUninstallLog "!insertmacro StartUninstallLogCall"
6173 Function StartUninstallLog
6174 FileOpen $fhUninstallLog "$INSTDIR\uninstall\uninstall.log" w
6175 FunctionEnd
6177 !verbose pop
6178 !endif
6179 !macroend
6181 !macro StartUninstallLogCall
6182 !verbose push
6183 !verbose ${_MOZFUNC_VERBOSE}
6184 Call StartUninstallLog
6185 !verbose pop
6186 !macroend
6188 /**
6189 * Closes the file handle to the uninstall.log.
6190 */
6191 !macro EndUninstallLog
6193 !ifndef EndUninstallLog
6195 !verbose push
6196 !verbose ${_MOZFUNC_VERBOSE}
6197 !define EndUninstallLog "!insertmacro EndUninstallLogCall"
6199 Function EndUninstallLog
6200 FileClose $fhUninstallLog
6201 FunctionEnd
6203 !verbose pop
6204 !endif
6205 !macroend
6207 !macro EndUninstallLogCall
6208 !verbose push
6209 !verbose ${_MOZFUNC_VERBOSE}
6210 Call EndUninstallLog
6211 !verbose pop
6212 !macroend
6214 /**
6215 * Adds a section header to the human readable log.
6216 *
6217 * @param _HEADER
6218 * The header text to write to the log.
6219 */
6220 !macro LogHeader _HEADER
6221 ${WriteLogSeparator}
6222 FileWriteUTF16LE $fhInstallLog "${_HEADER}"
6223 ${WriteLogSeparator}
6224 !macroend
6225 !define LogHeader "!insertmacro LogHeader"
6227 /**
6228 * Adds a section message to the human readable log.
6229 *
6230 * @param _MSG
6231 * The message text to write to the log.
6232 */
6233 !macro LogMsg _MSG
6234 FileWriteUTF16LE $fhInstallLog " ${_MSG}$\r$\n"
6235 !macroend
6236 !define LogMsg "!insertmacro LogMsg"
6238 /**
6239 * Adds an uninstall entry to the uninstall log.
6240 *
6241 * @param _MSG
6242 * The message text to write to the log.
6243 */
6244 !macro LogUninstall _MSG
6245 FileWrite $fhUninstallLog "${_MSG}$\r$\n"
6246 !macroend
6247 !define LogUninstall "!insertmacro LogUninstall"
6249 /**
6250 * Adds a section divider to the human readable log.
6251 */
6252 !macro WriteLogSeparator
6253 FileWriteUTF16LE $fhInstallLog "$\r$\n----------------------------------------\
6254 ---------------------------------------$\r$\n"
6255 !macroend
6256 !define WriteLogSeparator "!insertmacro WriteLogSeparator"
6259 ################################################################################
6260 # Macros for managing the shortcuts log ini file
6262 /**
6263 * Adds the most commonly used shortcut logging macros for the installer in one
6264 * fell swoop.
6265 */
6266 !macro _LoggingShortcutsCommon
6267 !insertmacro LogDesktopShortcut
6268 !insertmacro LogQuickLaunchShortcut
6269 !insertmacro LogSMProgramsShortcut
6270 !macroend
6271 !define _LoggingShortcutsCommon "!insertmacro _LoggingShortcutsCommon"
6273 /**
6274 * Creates the shortcuts log ini file with a UTF-16LE BOM if it doesn't exist.
6275 */
6276 !macro initShortcutsLog
6277 Push $R9
6279 IfFileExists "$INSTDIR\uninstall\${SHORTCUTS_LOG}" +4 +1
6280 FileOpen $R9 "$INSTDIR\uninstall\${SHORTCUTS_LOG}" w
6281 FileWriteWord $R9 "65279"
6282 FileClose $R9
6284 Pop $R9
6285 !macroend
6286 !define initShortcutsLog "!insertmacro initShortcutsLog"
6288 /**
6289 * Adds shortcut entries to the shortcuts log ini file. This macro is primarily
6290 * a helper used by the LogDesktopShortcut, LogQuickLaunchShortcut, and
6291 * LogSMProgramsShortcut macros but it can be used by other code if desired. If
6292 * the value already exists the the value is not written to the file.
6293 *
6294 * @param _SECTION_NAME
6295 * The section name to write to in the shortcut log ini file
6296 * @param _FILE_NAME
6297 * The shortcut's file name
6298 *
6299 * $R6 = return value from ReadIniStr for the shortcut file name
6300 * $R7 = counter for supporting multiple shortcuts in the same location
6301 * $R8 = _SECTION_NAME
6302 * $R9 = _FILE_NAME
6303 */
6304 !macro LogShortcut
6306 !ifndef LogShortcut
6307 !verbose push
6308 !verbose ${_MOZFUNC_VERBOSE}
6309 !define LogShortcut "!insertmacro LogShortcutCall"
6311 Function LogShortcut
6312 Exch $R9
6313 Exch 1
6314 Exch $R8
6315 Push $R7
6316 Push $R6
6318 ClearErrors
6320 !insertmacro initShortcutsLog
6322 StrCpy $R6 ""
6323 StrCpy $R7 -1
6325 StrCmp "$R6" "$R9" +5 +1 ; if the shortcut already exists don't add it
6326 IntOp $R7 $R7 + 1 ; increment the counter
6327 ReadIniStr $R6 "$INSTDIR\uninstall\${SHORTCUTS_LOG}" "$R8" "Shortcut$R7"
6328 IfErrors +1 -3
6329 WriteINIStr "$INSTDIR\uninstall\${SHORTCUTS_LOG}" "$R8" "Shortcut$R7" "$R9"
6331 ClearErrors
6333 Pop $R6
6334 Pop $R7
6335 Exch $R8
6336 Exch 1
6337 Exch $R9
6338 FunctionEnd
6340 !verbose pop
6341 !endif
6342 !macroend
6344 !macro LogShortcutCall _SECTION_NAME _FILE_NAME
6345 !verbose push
6346 !verbose ${_MOZFUNC_VERBOSE}
6347 Push "${_SECTION_NAME}"
6348 Push "${_FILE_NAME}"
6349 Call LogShortcut
6350 !verbose pop
6351 !macroend
6353 /**
6354 * Adds a Desktop shortcut entry to the shortcuts log ini file.
6355 *
6356 * @param _FILE_NAME
6357 * The shortcut file name (e.g. shortcut.lnk)
6358 */
6359 !macro LogDesktopShortcut
6361 !ifndef LogDesktopShortcut
6362 !insertmacro LogShortcut
6364 !verbose push
6365 !verbose ${_MOZFUNC_VERBOSE}
6366 !define LogDesktopShortcut "!insertmacro LogDesktopShortcutCall"
6368 Function LogDesktopShortcut
6369 Call LogShortcut
6370 FunctionEnd
6372 !verbose pop
6373 !endif
6374 !macroend
6376 !macro LogDesktopShortcutCall _FILE_NAME
6377 !verbose push
6378 !verbose ${_MOZFUNC_VERBOSE}
6379 Push "DESKTOP"
6380 Push "${_FILE_NAME}"
6381 Call LogDesktopShortcut
6382 !verbose pop
6383 !macroend
6385 /**
6386 * Adds a QuickLaunch shortcut entry to the shortcuts log ini file.
6387 *
6388 * @param _FILE_NAME
6389 * The shortcut file name (e.g. shortcut.lnk)
6390 */
6391 !macro LogQuickLaunchShortcut
6393 !ifndef LogQuickLaunchShortcut
6394 !insertmacro LogShortcut
6396 !verbose push
6397 !verbose ${_MOZFUNC_VERBOSE}
6398 !define LogQuickLaunchShortcut "!insertmacro LogQuickLaunchShortcutCall"
6400 Function LogQuickLaunchShortcut
6401 Call LogShortcut
6402 FunctionEnd
6404 !verbose pop
6405 !endif
6406 !macroend
6408 !macro LogQuickLaunchShortcutCall _FILE_NAME
6409 !verbose push
6410 !verbose ${_MOZFUNC_VERBOSE}
6411 Push "QUICKLAUNCH"
6412 Push "${_FILE_NAME}"
6413 Call LogQuickLaunchShortcut
6414 !verbose pop
6415 !macroend
6417 /**
6418 * Adds a Start Menu shortcut entry to the shortcuts log ini file.
6419 *
6420 * @param _FILE_NAME
6421 * The shortcut file name (e.g. shortcut.lnk)
6422 */
6423 !macro LogStartMenuShortcut
6425 !ifndef LogStartMenuShortcut
6426 !insertmacro LogShortcut
6428 !verbose push
6429 !verbose ${_MOZFUNC_VERBOSE}
6430 !define LogStartMenuShortcut "!insertmacro LogStartMenuShortcutCall"
6432 Function LogStartMenuShortcut
6433 Call LogShortcut
6434 FunctionEnd
6436 !verbose pop
6437 !endif
6438 !macroend
6440 !macro LogStartMenuShortcutCall _FILE_NAME
6441 !verbose push
6442 !verbose ${_MOZFUNC_VERBOSE}
6443 Push "STARTMENU"
6444 Push "${_FILE_NAME}"
6445 Call LogStartMenuShortcut
6446 !verbose pop
6447 !macroend
6449 /**
6450 * Adds a Start Menu Programs shortcut entry to the shortcuts log ini file.
6451 *
6452 * @param _FILE_NAME
6453 * The shortcut file name (e.g. shortcut.lnk)
6454 */
6455 !macro LogSMProgramsShortcut
6457 !ifndef LogSMProgramsShortcut
6458 !insertmacro LogShortcut
6460 !verbose push
6461 !verbose ${_MOZFUNC_VERBOSE}
6462 !define LogSMProgramsShortcut "!insertmacro LogSMProgramsShortcutCall"
6464 Function LogSMProgramsShortcut
6465 Call LogShortcut
6466 FunctionEnd
6468 !verbose pop
6469 !endif
6470 !macroend
6472 !macro LogSMProgramsShortcutCall _FILE_NAME
6473 !verbose push
6474 !verbose ${_MOZFUNC_VERBOSE}
6475 Push "SMPROGRAMS"
6476 Push "${_FILE_NAME}"
6477 Call LogSMProgramsShortcut
6478 !verbose pop
6479 !macroend
6481 /**
6482 * Adds the relative path from the Start Menu Programs directory for the
6483 * application's Start Menu directory if it is different from the existing value
6484 * to the shortcuts log ini file.
6485 *
6486 * @param _REL_PATH_TO_DIR
6487 * The relative path from the Start Menu Programs directory to the
6488 * program's directory.
6489 *
6490 * $R9 = _REL_PATH_TO_DIR
6491 */
6492 !macro LogSMProgramsDirRelPath _REL_PATH_TO_DIR
6493 Push $R9
6495 !insertmacro initShortcutsLog
6497 ReadINIStr $R9 "$INSTDIR\uninstall\${SHORTCUTS_LOG}" "SMPROGRAMS" "RelativePathToDir"
6498 StrCmp "$R9" "${_REL_PATH_TO_DIR}" +2 +1
6499 WriteINIStr "$INSTDIR\uninstall\${SHORTCUTS_LOG}" "SMPROGRAMS" "RelativePathToDir" "${_REL_PATH_TO_DIR}"
6501 Pop $R9
6502 !macroend
6503 !define LogSMProgramsDirRelPath "!insertmacro LogSMProgramsDirRelPath"
6505 /**
6506 * Copies the value for the relative path from the Start Menu programs directory
6507 * (e.g. $SMPROGRAMS) to the Start Menu directory as it is stored in the
6508 * shortcuts log ini file to the variable specified in the first parameter.
6509 */
6510 !macro GetSMProgramsDirRelPath _VAR
6511 ReadINIStr ${_VAR} "$INSTDIR\uninstall\${SHORTCUTS_LOG}" "SMPROGRAMS" \
6512 "RelativePathToDir"
6513 !macroend
6514 !define GetSMProgramsDirRelPath "!insertmacro GetSMProgramsDirRelPath"
6516 /**
6517 * Copies the shortcuts log ini file path to the variable specified in the
6518 * first parameter.
6519 */
6520 !macro GetShortcutsLogPath _VAR
6521 StrCpy ${_VAR} "$INSTDIR\uninstall\${SHORTCUTS_LOG}"
6522 !macroend
6523 !define GetShortcutsLogPath "!insertmacro GetShortcutsLogPath"
6525 /**
6526 * Deletes the shortcuts log ini file.
6527 */
6528 !macro DeleteShortcutsLogFile
6529 ${DeleteFile} "$INSTDIR\uninstall\${SHORTCUTS_LOG}"
6530 !macroend
6531 !define DeleteShortcutsLogFile "!insertmacro DeleteShortcutsLogFile"
6534 ################################################################################
6535 # Macros for managing specific Windows version features
6537 /**
6538 * Sets the permitted layered service provider (LSP) categories on Windows
6539 * Vista and above for the application. Consumers should call this after an
6540 * installation log section has completed since this macro will log the results
6541 * to the installation log along with a header.
6542 *
6543 * !IMPORTANT - When calling this macro from an uninstaller do not specify a
6544 * parameter. The paramter is hardcoded with 0x00000000 to remove
6545 * the LSP category for the application when performing an
6546 * uninstall.
6547 *
6548 * @param _LSP_CATEGORIES
6549 * The permitted LSP categories for the application. When called by an
6550 * uninstaller this will always be 0x00000000.
6551 *
6552 * $R5 = error code popped from the stack for the WSCSetApplicationCategory call
6553 * $R6 = return value from the WSCSetApplicationCategory call
6554 * $R7 = string length for the long path to the main application executable
6555 * $R8 = long path to the main application executable
6556 * $R9 = _LSP_CATEGORIES
6557 */
6558 !macro SetAppLSPCategories
6560 !ifndef ${_MOZFUNC_UN}SetAppLSPCategories
6561 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
6562 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
6563 !undef _MOZFUNC_UN
6564 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
6565 !undef _MOZFUNC_UN_TMP
6567 !verbose push
6568 !verbose ${_MOZFUNC_VERBOSE}
6569 !define ${_MOZFUNC_UN}SetAppLSPCategories "!insertmacro ${_MOZFUNC_UN}SetAppLSPCategoriesCall"
6571 Function ${_MOZFUNC_UN}SetAppLSPCategories
6572 ${Unless} ${AtLeastWinVista}
6573 Return
6574 ${EndUnless}
6576 Exch $R9
6577 Push $R8
6578 Push $R7
6579 Push $R6
6580 Push $R5
6582 ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR\${FileMainEXE}" $R8
6583 StrLen $R7 "$R8"
6585 ; Remove existing categories by setting the permitted categories to
6586 ; 0x00000000 since new categories are ANDed with existing categories. If
6587 ; the param value stored in $R9 is 0x00000000 then skip the removal since
6588 ; the categories will be removed by the second call to
6589 ; WSCSetApplicationCategory.
6590 StrCmp "$R9" "0x00000000" +2 +1
6591 System::Call "Ws2_32::WSCSetApplicationCategory(w R8, i R7, w n, i 0,\
6592 i 0x00000000, i n, *i) i"
6594 ; Set the permitted LSP categories
6595 System::Call "Ws2_32::WSCSetApplicationCategory(w R8, i R7, w n, i 0,\
6596 i R9, i n, *i .s) i.R6"
6597 Pop $R5
6599 !ifndef NO_LOG
6600 ${LogHeader} "Setting Permitted LSP Categories"
6601 StrCmp "$R6" 0 +3 +1
6602 ${LogMsg} "** ERROR Setting LSP Categories: $R5 **"
6603 GoTo +2
6604 ${LogMsg} "Permitted LSP Categories: $R9"
6605 !endif
6607 ClearErrors
6609 Pop $R5
6610 Pop $R6
6611 Pop $R7
6612 Pop $R8
6613 Exch $R9
6614 FunctionEnd
6616 !verbose pop
6617 !endif
6618 !macroend
6620 !macro SetAppLSPCategoriesCall _LSP_CATEGORIES
6621 !verbose push
6622 !verbose ${_MOZFUNC_VERBOSE}
6623 Push "${_LSP_CATEGORIES}"
6624 Call SetAppLSPCategories
6625 !verbose pop
6626 !macroend
6628 !macro un.SetAppLSPCategoriesCall
6629 !verbose push
6630 !verbose ${_MOZFUNC_VERBOSE}
6631 Push "0x00000000"
6632 Call un.SetAppLSPCategories
6633 !verbose pop
6634 !macroend
6636 !macro un.SetAppLSPCategories
6637 !ifndef un.SetAppLSPCategories
6638 !verbose push
6639 !verbose ${_MOZFUNC_VERBOSE}
6640 !undef _MOZFUNC_UN
6641 !define _MOZFUNC_UN "un."
6643 !insertmacro SetAppLSPCategories
6645 !undef _MOZFUNC_UN
6646 !define _MOZFUNC_UN
6647 !verbose pop
6648 !endif
6649 !macroend
6651 /**
6652 * Checks if any pinned TaskBar lnk files point to the executable's path passed
6653 * to the macro.
6654 *
6655 * @param _EXE_PATH
6656 * The executable path
6657 * @return _RESULT
6658 * false if no pinned shotcuts were found for this install location.
6659 * true if pinned shotcuts were found for this install location.
6660 *
6661 * $R5 = stores whether a TaskBar lnk file has been found for the executable
6662 * $R6 = long path returned from GetShortCutTarget and GetLongPath
6663 * $R7 = file name returned from FindFirst and FindNext
6664 * $R8 = find handle for FindFirst and FindNext
6665 * $R9 = _EXE_PATH and _RESULT
6666 */
6667 !macro IsPinnedToTaskBar
6669 !ifndef IsPinnedToTaskBar
6670 !insertmacro GetLongPath
6672 !verbose push
6673 !verbose ${_MOZFUNC_VERBOSE}
6674 !define IsPinnedToTaskBar "!insertmacro IsPinnedToTaskBarCall"
6676 Function IsPinnedToTaskBar
6677 Exch $R9
6678 Push $R8
6679 Push $R7
6680 Push $R6
6681 Push $R5
6683 StrCpy $R5 "false"
6685 ${If} ${AtLeastWin7}
6686 ${AndIf} ${FileExists} "$QUICKLAUNCH\User Pinned\TaskBar"
6687 FindFirst $R8 $R7 "$QUICKLAUNCH\User Pinned\TaskBar\*.lnk"
6688 ${Do}
6689 ${If} ${FileExists} "$QUICKLAUNCH\User Pinned\TaskBar\$R7"
6690 ShellLink::GetShortCutTarget "$QUICKLAUNCH\User Pinned\TaskBar\$R7"
6691 Pop $R6
6692 ${GetLongPath} "$R6" $R6
6693 ${If} "$R6" == "$R9"
6694 StrCpy $R5 "true"
6695 ${ExitDo}
6696 ${EndIf}
6697 ${EndIf}
6698 ClearErrors
6699 FindNext $R8 $R7
6700 ${If} ${Errors}
6701 ${ExitDo}
6702 ${EndIf}
6703 ${Loop}
6704 FindClose $R8
6705 ${EndIf}
6707 ClearErrors
6709 StrCpy $R9 $R5
6711 Pop $R5
6712 Pop $R6
6713 Pop $R7
6714 Pop $R8
6715 Exch $R9
6716 FunctionEnd
6718 !verbose pop
6719 !endif
6720 !macroend
6722 !macro IsPinnedToTaskBarCall _EXE_PATH _RESULT
6723 !verbose push
6724 !verbose ${_MOZFUNC_VERBOSE}
6725 Push "${_EXE_PATH}"
6726 Call IsPinnedToTaskBar
6727 Pop ${_RESULT}
6728 !verbose pop
6729 !macroend
6731 /**
6732 * Checks if any pinned Start Menu lnk files point to the executable's path
6733 * passed to the macro.
6734 *
6735 * @param _EXE_PATH
6736 * The executable path
6737 * @return _RESULT
6738 * false if no pinned shotcuts were found for this install location.
6739 * true if pinned shotcuts were found for this install location.
6740 *
6741 * $R5 = stores whether a Start Menu lnk file has been found for the executable
6742 * $R6 = long path returned from GetShortCutTarget and GetLongPath
6743 * $R7 = file name returned from FindFirst and FindNext
6744 * $R8 = find handle for FindFirst and FindNext
6745 * $R9 = _EXE_PATH and _RESULT
6746 */
6747 !macro IsPinnedToStartMenu
6749 !ifndef IsPinnedToStartMenu
6750 !insertmacro GetLongPath
6752 !verbose push
6753 !verbose ${_MOZFUNC_VERBOSE}
6754 !define IsPinnedToStartMenu "!insertmacro IsPinnedToStartMenuCall"
6756 Function IsPinnedToStartMenu
6757 Exch $R9
6758 Push $R8
6759 Push $R7
6760 Push $R6
6761 Push $R5
6763 StrCpy $R5 "false"
6765 ${If} ${AtLeastWin7}
6766 ${AndIf} ${FileExists} "$QUICKLAUNCH\User Pinned\StartMenu"
6767 FindFirst $R8 $R7 "$QUICKLAUNCH\User Pinned\StartMenu\*.lnk"
6768 ${Do}
6769 ${If} ${FileExists} "$QUICKLAUNCH\User Pinned\StartMenu\$R7"
6770 ShellLink::GetShortCutTarget "$QUICKLAUNCH\User Pinned\StartMenu\$R7"
6771 Pop $R6
6772 ${GetLongPath} "$R6" $R6
6773 ${If} "$R6" == "$R9"
6774 StrCpy $R5 "true"
6775 ${ExitDo}
6776 ${EndIf}
6777 ${EndIf}
6778 ClearErrors
6779 FindNext $R8 $R7
6780 ${If} ${Errors}
6781 ${ExitDo}
6782 ${EndIf}
6783 ${Loop}
6784 FindClose $R8
6785 ${EndIf}
6787 ClearErrors
6789 StrCpy $R9 $R5
6791 Pop $R5
6792 Pop $R6
6793 Pop $R7
6794 Pop $R8
6795 Exch $R9
6796 FunctionEnd
6798 !verbose pop
6799 !endif
6800 !macroend
6802 !macro IsPinnedToStartMenuCall _EXE_PATH _RESULT
6803 !verbose push
6804 !verbose ${_MOZFUNC_VERBOSE}
6805 Push "${_EXE_PATH}"
6806 Call IsPinnedToStartMenu
6807 Pop ${_RESULT}
6808 !verbose pop
6809 !macroend
6811 /**
6812 * Gets the number of pinned shortcut lnk files pinned to the Task Bar.
6813 *
6814 * @return _RESULT
6815 * number of pinned shortcut lnk files.
6816 *
6817 * $R7 = file name returned from FindFirst and FindNext
6818 * $R8 = find handle for FindFirst and FindNext
6819 * $R9 = _RESULT
6820 */
6821 !macro PinnedToTaskBarLnkCount
6823 !ifndef PinnedToTaskBarLnkCount
6824 !insertmacro GetLongPath
6826 !verbose push
6827 !verbose ${_MOZFUNC_VERBOSE}
6828 !define PinnedToTaskBarLnkCount "!insertmacro PinnedToTaskBarLnkCountCall"
6830 Function PinnedToTaskBarLnkCount
6831 Push $R9
6832 Push $R8
6833 Push $R7
6835 StrCpy $R9 0
6837 ${If} ${AtLeastWin7}
6838 ${AndIf} ${FileExists} "$QUICKLAUNCH\User Pinned\TaskBar"
6839 FindFirst $R8 $R7 "$QUICKLAUNCH\User Pinned\TaskBar\*.lnk"
6840 ${Do}
6841 ${If} ${FileExists} "$QUICKLAUNCH\User Pinned\TaskBar\$R7"
6842 IntOp $R9 $R9 + 1
6843 ${EndIf}
6844 ClearErrors
6845 FindNext $R8 $R7
6846 ${If} ${Errors}
6847 ${ExitDo}
6848 ${EndIf}
6849 ${Loop}
6850 FindClose $R8
6851 ${EndIf}
6853 ClearErrors
6855 Pop $R7
6856 Pop $R8
6857 Exch $R9
6858 FunctionEnd
6860 !verbose pop
6861 !endif
6862 !macroend
6864 !macro PinnedToTaskBarLnkCountCall _RESULT
6865 !verbose push
6866 !verbose ${_MOZFUNC_VERBOSE}
6867 Call PinnedToTaskBarLnkCount
6868 Pop ${_RESULT}
6869 !verbose pop
6870 !macroend
6872 /**
6873 * Gets the number of pinned shortcut lnk files pinned to the Start Menu.
6874 *
6875 * @return _RESULT
6876 * number of pinned shortcut lnk files.
6877 *
6878 * $R7 = file name returned from FindFirst and FindNext
6879 * $R8 = find handle for FindFirst and FindNext
6880 * $R9 = _RESULT
6881 */
6882 !macro PinnedToStartMenuLnkCount
6884 !ifndef PinnedToStartMenuLnkCount
6885 !insertmacro GetLongPath
6887 !verbose push
6888 !verbose ${_MOZFUNC_VERBOSE}
6889 !define PinnedToStartMenuLnkCount "!insertmacro PinnedToStartMenuLnkCountCall"
6891 Function PinnedToStartMenuLnkCount
6892 Push $R9
6893 Push $R8
6894 Push $R7
6896 StrCpy $R9 0
6898 ${If} ${AtLeastWin7}
6899 ${AndIf} ${FileExists} "$QUICKLAUNCH\User Pinned\StartMenu"
6900 FindFirst $R8 $R7 "$QUICKLAUNCH\User Pinned\StartMenu\*.lnk"
6901 ${Do}
6902 ${If} ${FileExists} "$QUICKLAUNCH\User Pinned\StartMenu\$R7"
6903 IntOp $R9 $R9 + 1
6904 ${EndIf}
6905 ClearErrors
6906 FindNext $R8 $R7
6907 ${If} ${Errors}
6908 ${ExitDo}
6909 ${EndIf}
6910 ${Loop}
6911 FindClose $R8
6912 ${EndIf}
6914 ClearErrors
6916 Pop $R7
6917 Pop $R8
6918 Exch $R9
6919 FunctionEnd
6921 !verbose pop
6922 !endif
6923 !macroend
6925 !macro PinnedToStartMenuLnkCountCall _RESULT
6926 !verbose push
6927 !verbose ${_MOZFUNC_VERBOSE}
6928 Call PinnedToStartMenuLnkCount
6929 Pop ${_RESULT}
6930 !verbose pop
6931 !macroend
6933 /**
6934 * Update Start Menu / TaskBar lnk files that point to the executable's path
6935 * passed to the macro and all other shortcuts installed by the application with
6936 * the current application user model ID. Requires ApplicationID.
6937 *
6938 * NOTE: this does not update Desktop shortcut application user model ID due to
6939 * bug 633728.
6940 *
6941 * @param _EXE_PATH
6942 * The main application executable path
6943 * @param _APP_ID
6944 * The application user model ID for the current install
6945 * @return _RESULT
6946 * false if no pinned shotcuts were found for this install location.
6947 * true if pinned shotcuts were found for this install location.
6948 */
6949 !macro UpdateShortcutAppModelIDs
6951 !ifndef UpdateShortcutAppModelIDs
6952 !insertmacro GetLongPath
6954 !verbose push
6955 !verbose ${_MOZFUNC_VERBOSE}
6956 !define UpdateShortcutAppModelIDs "!insertmacro UpdateShortcutAppModelIDsCall"
6958 Function UpdateShortcutAppModelIDs
6959 ; stack: path, appid
6960 Exch $R9 ; stack: $R9, appid | $R9 = path
6961 Exch 1 ; stack: appid, $R9
6962 Exch $R8 ; stack: $R8, $R9 | $R8 = appid
6963 Push $R7 ; stack: $R7, $R8, $R9
6964 Push $R6
6965 Push $R5
6966 Push $R4
6967 Push $R3 ; stack: $R3, $R5, $R6, $R7, $R8, $R9
6968 Push $R2
6970 ; $R9 = main application executable path
6971 ; $R8 = appid
6972 ; $R7 = path to the application's start menu programs directory
6973 ; $R6 = path to the shortcut log ini file
6974 ; $R5 = shortcut filename
6975 ; $R4 = GetShortCutTarget result
6977 StrCpy $R3 "false"
6979 ${If} ${AtLeastWin7}
6980 ; installed shortcuts
6981 ${${_MOZFUNC_UN}GetLongPath} "$INSTDIR\uninstall\${SHORTCUTS_LOG}" $R6
6982 ${If} ${FileExists} "$R6"
6983 ; Update the Start Menu shortcuts' App ID for this application
6984 StrCpy $R2 -1
6985 ${Do}
6986 IntOp $R2 $R2 + 1 ; Increment the counter
6987 ClearErrors
6988 ReadINIStr $R5 "$R6" "STARTMENU" "Shortcut$R2"
6989 ${If} ${Errors}
6990 ${ExitDo}
6991 ${EndIf}
6993 ${If} ${FileExists} "$SMPROGRAMS\$R5"
6994 ShellLink::GetShortCutTarget "$SMPROGRAMS\$$R5"
6995 Pop $R4
6996 ${GetLongPath} "$R4" $R4
6997 ${If} "$R4" == "$R9" ; link path == install path
6998 ApplicationID::Set "$SMPROGRAMS\$R5" "$R8"
6999 Pop $R4
7000 ${EndIf}
7001 ${EndIf}
7002 ${Loop}
7004 ; Update the Quick Launch shortcuts' App ID for this application
7005 StrCpy $R2 -1
7006 ${Do}
7007 IntOp $R2 $R2 + 1 ; Increment the counter
7008 ClearErrors
7009 ReadINIStr $R5 "$R6" "QUICKLAUNCH" "Shortcut$R2"
7010 ${If} ${Errors}
7011 ${ExitDo}
7012 ${EndIf}
7014 ${If} ${FileExists} "$QUICKLAUNCH\$R5"
7015 ShellLink::GetShortCutTarget "$QUICKLAUNCH\$R5"
7016 Pop $R4
7017 ${GetLongPath} "$R4" $R4
7018 ${If} "$R4" == "$R9" ; link path == install path
7019 ApplicationID::Set "$QUICKLAUNCH\$R5" "$R8"
7020 Pop $R4
7021 ${EndIf}
7022 ${EndIf}
7023 ${Loop}
7025 ; Update the Start Menu Programs shortcuts' App ID for this application
7026 ClearErrors
7027 ReadINIStr $R7 "$R6" "SMPROGRAMS" "RelativePathToDir"
7028 ${Unless} ${Errors}
7029 ${${_MOZFUNC_UN}GetLongPath} "$SMPROGRAMS\$R7" $R7
7030 ${Unless} "$R7" == ""
7031 StrCpy $R2 -1
7032 ${Do}
7033 IntOp $R2 $R2 + 1 ; Increment the counter
7034 ClearErrors
7035 ReadINIStr $R5 "$R6" "SMPROGRAMS" "Shortcut$R2"
7036 ${If} ${Errors}
7037 ${ExitDo}
7038 ${EndIf}
7040 ${If} ${FileExists} "$R7\$R5"
7041 ShellLink::GetShortCutTarget "$R7\$R5"
7042 Pop $R4
7043 ${GetLongPath} "$R4" $R4
7044 ${If} "$R4" == "$R9" ; link path == install path
7045 ApplicationID::Set "$R7\$R5" "$R8"
7046 Pop $R4
7047 ${EndIf}
7048 ${EndIf}
7049 ${Loop}
7050 ${EndUnless}
7051 ${EndUnless}
7052 ${EndIf}
7054 StrCpy $R7 "$QUICKLAUNCH\User Pinned"
7055 StrCpy $R3 "false"
7057 ; $R9 = main application executable path
7058 ; $R8 = appid
7059 ; $R7 = user pinned path
7060 ; $R6 = find handle
7061 ; $R5 = found filename
7062 ; $R4 = GetShortCutTarget result
7064 ; TaskBar links
7065 FindFirst $R6 $R5 "$R7\TaskBar\*.lnk"
7066 ${Do}
7067 ${If} ${FileExists} "$R7\TaskBar\$R5"
7068 ShellLink::GetShortCutTarget "$R7\TaskBar\$R5"
7069 Pop $R4
7070 ${If} "$R4" == "$R9" ; link path == install path
7071 ApplicationID::Set "$R7\TaskBar\$R5" "$R8"
7072 Pop $R4 ; pop Set result off the stack
7073 StrCpy $R3 "true"
7074 ${EndIf}
7075 ${EndIf}
7076 ClearErrors
7077 FindNext $R6 $R5
7078 ${If} ${Errors}
7079 ${ExitDo}
7080 ${EndIf}
7081 ${Loop}
7082 FindClose $R6
7084 ; Start menu links
7085 FindFirst $R6 $R5 "$R7\StartMenu\*.lnk"
7086 ${Do}
7087 ${If} ${FileExists} "$R7\StartMenu\$R5"
7088 ShellLink::GetShortCutTarget "$R7\StartMenu\$R5"
7089 Pop $R4
7090 ${If} "$R4" == "$R9" ; link path == install path
7091 ApplicationID::Set "$R7\StartMenu\$R5" "$R8"
7092 Pop $R4 ; pop Set result off the stack
7093 StrCpy $R3 "true"
7094 ${EndIf}
7095 ${EndIf}
7096 ClearErrors
7097 FindNext $R6 $R5
7098 ${If} ${Errors}
7099 ${ExitDo}
7100 ${EndIf}
7101 ${Loop}
7102 FindClose $R6
7103 ${EndIf}
7105 ClearErrors
7107 StrCpy $R9 $R3
7109 Pop $R2
7110 Pop $R3 ; stack: $R4, $R5, $R6, $R7, $R8, $R9
7111 Pop $R4 ; stack: $R5, $R6, $R7, $R8, $R9
7112 Pop $R5 ; stack: $R6, $R7, $R8, $R9
7113 Pop $R6 ; stack: $R7, $R8, $R9
7114 Pop $R7 ; stack: $R8, $R9
7115 Exch $R8 ; stack: appid, $R9 | $R8 = old $R8
7116 Exch 1 ; stack: $R9, appid
7117 Exch $R9 ; stack: path, appid | $R9 = old $R9
7118 FunctionEnd
7120 !verbose pop
7121 !endif
7122 !macroend
7124 !macro UpdateShortcutAppModelIDsCall _EXE_PATH _APP_ID _RESULT
7125 !verbose push
7126 !verbose ${_MOZFUNC_VERBOSE}
7127 Push "${_APP_ID}"
7128 Push "${_EXE_PATH}"
7129 Call UpdateShortcutAppModelIDs
7130 Pop ${_RESULT}
7131 !verbose pop
7132 !macroend
7134 !macro IsUserAdmin
7135 ; Copied from: http://nsis.sourceforge.net/IsUserAdmin
7136 Function IsUserAdmin
7137 Push $R0
7138 Push $R1
7139 Push $R2
7141 ClearErrors
7142 UserInfo::GetName
7143 IfErrors Win9x
7144 Pop $R1
7145 UserInfo::GetAccountType
7146 Pop $R2
7148 StrCmp $R2 "Admin" 0 Continue
7149 StrCpy $R0 "true"
7150 Goto Done
7152 Continue:
7154 StrCmp $R2 "" Win9x
7155 StrCpy $R0 "false"
7156 Goto Done
7158 Win9x:
7159 StrCpy $R0 "true"
7161 Done:
7162 Pop $R2
7163 Pop $R1
7164 Exch $R0
7165 FunctionEnd
7166 !macroend
7168 /**
7169 * Retrieve if present or generate and store a 64 bit hash of an install path
7170 * using the City Hash algorithm. On return the resulting id is saved in the
7171 * $AppUserModelID variable declared by inserting this macro. InitHashAppModelId
7172 * will attempt to load from HKLM/_REG_PATH first, then HKCU/_REG_PATH. If found
7173 * in either it will return the hash it finds. If not found it will generate a
7174 * new hash and attempt to store the hash in HKLM/_REG_PATH, then HKCU/_REG_PATH.
7175 * Subsequent calls will then retreive the stored hash value. On any failure,
7176 * $AppUserModelID will be set to an empty string.
7177 *
7178 * Registry format: root/_REG_PATH/"_EXE_PATH" = "hash"
7179 *
7180 * @param _EXE_PATH
7181 * The main application executable path
7182 * @param _REG_PATH
7183 * The HKLM/HKCU agnostic registry path where the key hash should
7184 * be stored. ex: "Software\Mozilla\Firefox\TaskBarIDs"
7185 * @result (Var) $AppUserModelID contains the app model id.
7186 */
7187 !macro InitHashAppModelId
7188 !ifndef ${_MOZFUNC_UN}InitHashAppModelId
7189 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
7190 !insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
7191 !undef _MOZFUNC_UN
7192 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
7193 !undef _MOZFUNC_UN_TMP
7195 !ifndef InitHashAppModelId
7196 Var AppUserModelID
7197 !endif
7199 !verbose push
7200 !verbose ${_MOZFUNC_VERBOSE}
7201 !define ${_MOZFUNC_UN}InitHashAppModelId "!insertmacro ${_MOZFUNC_UN}InitHashAppModelIdCall"
7203 Function ${_MOZFUNC_UN}InitHashAppModelId
7204 ; stack: apppath, regpath
7205 Exch $R9 ; stack: $R9, regpath | $R9 = apppath
7206 Exch 1 ; stack: regpath, $R9
7207 Exch $R8 ; stack: $R8, $R9 | $R8 = regpath
7208 Push $R7
7210 ${If} ${AtLeastWin7}
7211 ${${_MOZFUNC_UN}GetLongPath} "$R9" $R9
7212 ; Always create a new AppUserModelID and overwrite the existing one
7213 ; for the current installation path.
7214 CityHash::GetCityHash64 "$R9"
7215 Pop $AppUserModelID
7216 ${If} $AppUserModelID == "error"
7217 GoTo end
7218 ${EndIf}
7219 ClearErrors
7220 WriteRegStr HKLM "$R8" "$R9" "$AppUserModelID"
7221 ${If} ${Errors}
7222 ClearErrors
7223 WriteRegStr HKCU "$R8" "$R9" "$AppUserModelID"
7224 ${If} ${Errors}
7225 StrCpy $AppUserModelID "error"
7226 ${EndIf}
7227 ${EndIf}
7228 ${EndIf}
7230 end:
7231 ${If} "$AppUserModelID" == "error"
7232 StrCpy $AppUserModelID ""
7233 ${EndIf}
7235 ClearErrors
7236 Pop $R7
7237 Exch $R8
7238 Exch 1
7239 Exch $R9
7240 FunctionEnd
7242 !verbose pop
7243 !endif
7244 !macroend
7246 !macro InitHashAppModelIdCall _EXE_PATH _REG_PATH
7247 !verbose push
7248 !verbose ${_MOZFUNC_VERBOSE}
7249 Push "${_REG_PATH}"
7250 Push "${_EXE_PATH}"
7251 Call InitHashAppModelId
7252 !verbose pop
7253 !macroend
7255 !macro un.InitHashAppModelIdCall _EXE_PATH _REG_PATH
7256 !verbose push
7257 !verbose ${_MOZFUNC_VERBOSE}
7258 Push "${_REG_PATH}"
7259 Push "${_EXE_PATH}"
7260 Call un.InitHashAppModelId
7261 !verbose pop
7262 !macroend
7264 !macro un.InitHashAppModelId
7265 !ifndef un.InitHashAppModelId
7266 !verbose push
7267 !verbose ${_MOZFUNC_VERBOSE}
7268 !undef _MOZFUNC_UN
7269 !define _MOZFUNC_UN "un."
7271 !insertmacro InitHashAppModelId
7273 !undef _MOZFUNC_UN
7274 !define _MOZFUNC_UN
7275 !verbose pop
7276 !endif
7277 !macroend
7280 ################################################################################
7281 # Helpers for the new user interface
7283 !ifndef MAXDWORD
7284 !define MAXDWORD 0xffffffff
7285 !endif
7287 !ifndef DT_WORDBREAK
7288 !define DT_WORDBREAK 0x0010
7289 !endif
7290 !ifndef DT_SINGLELINE
7291 !define DT_SINGLELINE 0x0020
7292 !endif
7293 !ifndef DT_NOCLIP
7294 !define DT_NOCLIP 0x0100
7295 !endif
7296 !ifndef DT_CALCRECT
7297 !define DT_CALCRECT 0x0400
7298 !endif
7299 !ifndef DT_EDITCONTROL
7300 !define DT_EDITCONTROL 0x2000
7301 !endif
7302 !ifndef DT_RTLREADING
7303 !define DT_RTLREADING 0x00020000
7304 !endif
7305 !ifndef DT_NOFULLWIDTHCHARBREAK
7306 !define DT_NOFULLWIDTHCHARBREAK 0x00080000
7307 !endif
7309 !ifndef WS_EX_NOINHERITLAYOUT
7310 !define WS_EX_NOINHERITLAYOUT 0x00100000
7311 !endif
7312 !ifndef WS_EX_LAYOUTRTL
7313 !define WS_EX_LAYOUTRTL 0x00400000
7314 !endif
7316 !ifndef PBS_MARQUEE
7317 !define PBS_MARQUEE 0x08
7318 !endif
7320 !ifndef PBM_SETRANGE32
7321 !define PBM_SETRANGE32 0x406
7322 !endif
7323 !ifndef PBM_GETRANGE
7324 !define PBM_GETRANGE 0x407
7325 !endif
7327 !ifndef SHACF_FILESYSTEM
7328 !define SHACF_FILESYSTEM 1
7329 !endif
7331 !define MOZ_LOADTRANSPARENT ${LR_LOADFROMFILE}|${LR_LOADTRANSPARENT}|${LR_LOADMAP3DCOLORS}
7333 ; Extend nsDialogs.nsh to support creating centered labels if it is already
7334 ; included
7335 !ifmacrodef __NSD_DefineControl
7336 !insertmacro __NSD_DefineControl LabelCenter
7337 !define __NSD_LabelCenter_CLASS STATIC
7338 !define __NSD_LabelCenter_STYLE ${DEFAULT_STYLES}|${SS_NOTIFY}|${SS_CENTER}
7339 !define __NSD_LabelCenter_EXSTYLE ${WS_EX_TRANSPARENT}
7340 !endif
7342 /**
7343 * Modified version of the __NSD_SetStretchedImage macro from nsDialogs.nsh that
7344 * supports transparency. See nsDialogs documentation for additional info.
7345 */
7346 !macro __SetStretchedTransparentImage CONTROL IMAGE HANDLE
7347 Push $0
7348 Push $1
7349 Push $2
7350 Push $R0
7352 StrCpy $R0 ${CONTROL} ; in case ${CONTROL} is $0
7353 StrCpy $1 ""
7354 StrCpy $2 ""
7356 System::Call '*(i, i, i, i) i.s'
7357 Pop $0
7359 ${If} $0 <> 0
7360 System::Call 'user32::GetClientRect(i R0, i r0)'
7361 System::Call '*$0(i, i, i .s, i .s)'
7362 System::Free $0
7363 Pop $1
7364 Pop $2
7365 ${EndIf}
7367 System::Call 'user32::LoadImageW(i 0, t s, i ${IMAGE_BITMAP}, i r1, i r2, \
7368 i ${MOZ_LOADTRANSPARENT}) i .s' "${IMAGE}"
7369 Pop $0
7370 SendMessage $R0 ${STM_SETIMAGE} ${IMAGE_BITMAP} $0
7372 SetCtlColors $R0 "" transparent
7373 ${NSD_AddExStyle} $R0 ${WS_EX_TRANSPARENT}|${WS_EX_TOPMOST}
7375 Pop $R0
7376 Pop $2
7377 Pop $1
7378 Exch $0
7379 Pop ${HANDLE}
7380 !macroend
7381 !define SetStretchedTransparentImage `!insertmacro __SetStretchedTransparentImage`
7383 /**
7384 * Removes a single style from a control.
7385 *
7386 * _HANDLE the handle of the control
7387 * _STYLE the style to remove
7388 */
7389 !macro _RemoveStyle _HANDLE _STYLE
7390 Push $0
7392 System::Call 'user32::GetWindowLongW(i ${_HANDLE}, i ${GWL_STYLE}) i .r0'
7393 IntOp $0 $0 | ${_STYLE}
7394 IntOp $0 $0 - ${_STYLE}
7395 System::Call 'user32::SetWindowLongW(i ${_HANDLE}, i ${GWL_STYLE}, i r0)'
7397 Pop $0
7398 !macroend
7399 !define RemoveStyle "!insertmacro _RemoveStyle"
7401 /**
7402 * Removes a single extended style from a control.
7403 *
7404 * _HANDLE the handle of the control
7405 * _EXSTYLE the extended style to remove
7406 */
7407 !macro _RemoveExStyle _HANDLE _EXSTYLE
7408 Push $0
7410 System::Call 'user32::GetWindowLongW(i ${_HANDLE}, i ${GWL_EXSTYLE}) i .r0'
7411 IntOp $0 $0 | ${_EXSTYLE}
7412 IntOp $0 $0 - ${_EXSTYLE}
7413 System::Call 'user32::SetWindowLongW(i ${_HANDLE}, i ${GWL_EXSTYLE}, i r0)'
7415 Pop $0
7416 !macroend
7417 !define RemoveExStyle "!insertmacro _RemoveExStyle"
7419 /**
7420 * Gets the extent of the specified text in pixels for sizing a control.
7421 *
7422 * _TEXT the text to get the text extent for
7423 * _FONT the font to use when getting the text extent
7424 * _RES_WIDTH return value - control width for the text
7425 * _RES_HEIGHT return value - control height for the text
7426 */
7427 !macro GetTextExtentCall _TEXT _FONT _RES_WIDTH _RES_HEIGHT
7428 Push "${_TEXT}"
7429 Push "${_FONT}"
7430 ${CallArtificialFunction} GetTextExtent_
7431 Pop ${_RES_WIDTH}
7432 Pop ${_RES_HEIGHT}
7433 !macroend
7435 !define GetTextExtent "!insertmacro GetTextExtentCall"
7436 !define un.GetTextExtent "!insertmacro GetTextExtentCall"
7438 !macro GetTextExtent_
7439 Exch $0 ; font
7440 Exch 1
7441 Exch $1 ; text
7442 Push $2
7443 Push $3
7444 Push $4
7445 Push $5
7446 Push $6
7447 Push $7
7449 ; Reuse the existing NSIS control which is used for BrandingText instead of
7450 ; creating a new control.
7451 GetDlgItem $2 $HWNDPARENT 1028
7453 System::Call 'user32::GetDC(i r2) i .r3'
7454 System::Call 'gdi32::SelectObject(i r3, i r0)'
7456 StrLen $4 "$1"
7458 System::Call '*(i, i) i .r5'
7459 System::Call 'gdi32::GetTextExtentPoint32W(i r3, t$\"$1$\", i r4, i r5)'
7460 System::Call '*$5(i .r6, i .r7)'
7461 System::Free $5
7463 System::Call 'user32::ReleaseDC(i r2, i r3)'
7465 StrCpy $1 $7
7466 StrCpy $0 $6
7468 Pop $7
7469 Pop $6
7470 Pop $5
7471 Pop $4
7472 Pop $3
7473 Pop $2
7474 Exch $1 ; return height
7475 Exch 1
7476 Exch $0 ; return width
7477 !macroend
7479 /**
7480 * Gets the width and the height of a control in pixels.
7481 *
7482 * _HANDLE the handle of the control
7483 * _RES_WIDTH return value - control width for the text
7484 * _RES_HEIGHT return value - control height for the text
7485 */
7486 !macro GetDlgItemWidthHeightCall _HANDLE _RES_WIDTH _RES_HEIGHT
7487 Push "${_HANDLE}"
7488 ${CallArtificialFunction} GetDlgItemWidthHeight_
7489 Pop ${_RES_WIDTH}
7490 Pop ${_RES_HEIGHT}
7491 !macroend
7493 !define GetDlgItemWidthHeight "!insertmacro GetDlgItemWidthHeightCall"
7494 !define un.GetDlgItemWidthHeight "!insertmacro GetDlgItemWidthHeightCall"
7496 !macro GetDlgItemWidthHeight_
7497 Exch $0 ; handle for the control
7498 Push $1
7499 Push $2
7501 System::Call '*(i, i, i, i) i .r2'
7502 ; The left and top values will always be 0 so the right and bottom values
7503 ; will be the width and height.
7504 System::Call 'user32::GetClientRect(i r0, i r2)'
7505 System::Call '*$2(i, i, i .r0, i .r1)'
7506 System::Free $2
7508 Pop $2
7509 Exch $1 ; return height
7510 Exch 1
7511 Exch $0 ; return width
7512 !macroend
7514 /**
7515 * Gets the number of pixels from the beginning of the dialog to the end of a
7516 * control in a RTL friendly manner.
7517 *
7518 * _HANDLE the handle of the control
7519 * _RES_PX return value - pixels from the beginning of the dialog to the end of
7520 * the control
7521 */
7522 !macro GetDlgItemEndPXCall _HANDLE _RES_PX
7523 Push "${_HANDLE}"
7524 ${CallArtificialFunction} GetDlgItemEndPX_
7525 Pop ${_RES_PX}
7526 !macroend
7528 !define GetDlgItemEndPX "!insertmacro GetDlgItemEndPXCall"
7529 !define un.GetDlgItemEndPX "!insertmacro GetDlgItemEndPXCall"
7531 !macro GetDlgItemEndPX_
7532 Exch $0 ; handle of the control
7533 Push $1
7534 Push $2
7536 ; #32770 is the dialog class
7537 FindWindow $1 "#32770" "" $HWNDPARENT
7538 System::Call '*(i, i, i, i) i .r2'
7539 System::Call 'user32::GetWindowRect(i r0, i r2)'
7540 System::Call 'user32::MapWindowPoints(i 0, i r1,i r2, i 2)'
7541 System::Call '*$2(i, i, i .r0, i)'
7542 System::Free $2
7544 Pop $2
7545 Pop $1
7546 Exch $0 ; pixels from the beginning of the dialog to the end of the control
7547 !macroend
7549 /**
7550 * Gets the width and height for sizing a control that has the specified text.
7551 * If the text has embedded newlines then the width and height will be
7552 * determined without trying to optimize the control's width and height. If the
7553 * text doesn't contain newlines the control's height and width will be
7554 * dynamically determined using a minimum of 3 lines (incrementing the
7555 * number of lines if necessary) for the height and the maximum width specified.
7556 *
7557 * _TEXT the text
7558 * _FONT the font to use when getting the width and height
7559 * _MAX_WIDTH the maximum width for the control
7560 * _RES_WIDTH return value - control width for the text
7561 * _RES_HEIGHT return value - control height for the text
7562 */
7563 !macro GetTextWidthHeight
7565 !ifndef ${_MOZFUNC_UN}GetTextWidthHeight
7566 !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
7567 !insertmacro ${_MOZFUNC_UN_TMP}WordFind
7568 !undef _MOZFUNC_UN
7569 !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
7570 !undef _MOZFUNC_UN_TMP
7572 !verbose push
7573 !verbose ${_MOZFUNC_VERBOSE}
7574 !define ${_MOZFUNC_UN}GetTextWidthHeight "!insertmacro ${_MOZFUNC_UN}GetTextWidthHeightCall"
7576 Function ${_MOZFUNC_UN}GetTextWidthHeight
7577 Exch $0 ; maximum width use to calculate the control's width and height
7578 Exch 1
7579 Exch $1 ; font
7580 Exch 2
7581 Exch $2 ; text
7582 Push $3
7583 Push $4
7584 Push $5
7585 Push $6
7586 Push $7
7587 Push $8
7588 Push $9
7589 Push $R0
7590 Push $R1
7591 Push $R2
7593 StrCpy $R2 "${DT_NOCLIP}|${DT_CALCRECT}"
7594 !ifdef ${AB_CD}_rtl
7595 StrCpy $R2 "$R2|${DT_RTLREADING}"
7596 !endif
7598 ; Reuse the existing NSIS control which is used for BrandingText instead
7599 ; of creating a new control.
7600 GetDlgItem $3 $HWNDPARENT 1028
7602 System::Call 'user32::GetDC(i r3) i .r4'
7603 System::Call 'gdi32::SelectObject(i r4, i r1)'
7605 StrLen $5 "$2" ; text length
7606 System::Call '*(i, i, i, i) i .r6'
7608 ClearErrors
7609 ${${_MOZFUNC_UN}WordFind} "$2" "$\n" "E#" $R0
7610 ${If} ${Errors}
7611 ; When there aren't newlines in the text calculate the size of the
7612 ; rectangle needed for the text with a minimum of three lines of text.
7613 ClearErrors
7614 System::Call 'user32::DrawTextW(i r4, t $\"$2$\", i r5, i r6, \
7615 i $R2|${DT_SINGLELINE})'
7616 System::Call '*$6(i, i, i .r8, i .r7)'
7617 System::Free $6
7619 ; Get the approximate number height needed to display the text starting
7620 ; with a minimum of 3 lines of text.
7621 StrCpy $9 $8
7622 StrCpy $R1 2 ; set the number of lines initially to 2
7623 ${Do}
7624 IntOp $R1 $R1 + 1 ; increment the number of lines
7625 IntOp $9 $8 / $R1
7626 ${LoopUntil} $9 < $0
7627 IntOp $7 $7 * $R1
7629 StrCpy $R0 $9
7630 ${Do}
7631 IntOp $R0 $R0 + 20
7632 System::Call '*(i, i, i R0, i r7) i .r6'
7633 System::Call 'user32::DrawTextW(i r4, t $\"$2$\", i r5, i r6, \
7634 i $R2|${DT_WORDBREAK}) i .R1'
7635 System::Call '*$6(i, i, i .r8, i .r9)'
7636 System::Free $6
7637 ${LoopUntil} $7 >= $R1
7638 ${Else}
7639 ; When there are newlines in the text just return the size of the
7640 ; rectangle for the text.
7641 System::Call 'user32::DrawTextW(i r4, t $\"$2$\", i r5, i r6, i $R2)'
7642 System::Call '*$6(i, i, i .r8, i .r9)'
7643 System::Free $6
7644 ${EndIf}
7646 ; Reselect the original DC
7647 System::Call 'gdi32::SelectObject(i r4, i r1)'
7648 System::Call 'user32::ReleaseDC(i r3, i r4)'
7650 StrCpy $1 $9
7651 StrCpy $0 $8
7653 Pop $R2
7654 Pop $R1
7655 Pop $R0
7656 Pop $9
7657 Pop $8
7658 Pop $7
7659 Pop $6
7660 Pop $5
7661 Pop $4
7662 Pop $3
7663 Exch $2
7664 Exch 2
7665 Exch $1 ; return height
7666 Exch 1
7667 Exch $0 ; return width
7668 FunctionEnd
7670 !verbose pop
7671 !endif
7672 !macroend
7674 !macro GetTextWidthHeightCall _TEXT _FONT _MAX_WIDTH _RES_WIDTH _RES_HEIGHT
7675 !verbose push
7676 !verbose ${_MOZFUNC_VERBOSE}
7677 Push "${_TEXT}"
7678 Push "${_FONT}"
7679 Push "${_MAX_WIDTH}"
7680 Call GetTextWidthHeight
7681 Pop ${_RES_WIDTH}
7682 Pop ${_RES_HEIGHT}
7683 !verbose pop
7684 !macroend
7686 !macro un.GetTextWidthHeightCall _TEXT _FONT _MAX_WIDTH _RES_WIDTH _RES_HEIGHT
7687 !verbose push
7688 !verbose ${_MOZFUNC_VERBOSE}
7689 Push "${_TEXT}"
7690 Push "${_FONT}"
7691 Push "${_MAX_WIDTH}"
7692 Call un.GetTextWidthHeight
7693 Pop ${_RES_WIDTH}
7694 Pop ${_RES_HEIGHT}
7695 !verbose pop
7696 !macroend
7698 !macro un.GetTextWidthHeight
7699 !ifndef un.GetTextWidthHeight
7700 !verbose push
7701 !verbose ${_MOZFUNC_VERBOSE}
7702 !undef _MOZFUNC_UN
7703 !define _MOZFUNC_UN "un."
7705 !insertmacro GetTextWidthHeight
7707 !undef _MOZFUNC_UN
7708 !define _MOZFUNC_UN
7709 !verbose pop
7710 !endif
7711 !macroend
7713 /**
7714 * Gets the elapsed time in seconds between two values in milliseconds stored as
7715 * an int64. The caller will typically get the millisecond values using
7716 * GetTickCount with a long return value as follows.
7717 * System::Call "kernel32::GetTickCount()l .s"
7718 * Pop $varname
7719 *
7720 * _START_TICK_COUNT
7721 * _FINISH_TICK_COUNT
7722 * _RES_ELAPSED_SECONDS return value - elapsed time between _START_TICK_COUNT
7723 * and _FINISH_TICK_COUNT in seconds.
7724 */
7725 !macro GetSecondsElapsedCall _START_TICK_COUNT _FINISH_TICK_COUNT _RES_ELAPSED_SECONDS
7726 Push "${_START_TICK_COUNT}"
7727 Push "${_FINISH_TICK_COUNT}"
7728 ${CallArtificialFunction} GetSecondsElapsed_
7729 Pop ${_RES_ELAPSED_SECONDS}
7730 !macroend
7732 !define GetSecondsElapsed "!insertmacro GetSecondsElapsedCall"
7733 !define un.GetSecondsElapsed "!insertmacro GetSecondsElapsedCall"
7735 !macro GetSecondsElapsed_
7736 Exch $0 ; finish tick count
7737 Exch 1
7738 Exch $1 ; start tick count
7740 System::Int64Op $0 - $1
7741 Pop $0
7742 ; Discard the top bits of the int64 by bitmasking with MAXDWORD
7743 System::Int64Op $0 & ${MAXDWORD}
7744 Pop $0
7746 ; Convert from milliseconds to seconds
7747 System::Int64Op $0 / 1000
7748 Pop $0
7750 Pop $1
7751 Exch $0 ; return elapsed seconds
7752 !macroend
7754 !ifdef MOZ_METRO
7755 ; Removes the CEH registration if it's set to our installation directory.
7756 ; If it's set to some other installation directory, then it should be removed
7757 ; by that installation.
7758 !macro RemoveDEHRegistrationIfMatchingCall un
7760 Function ${un}RemoveDEHRegistrationIfMatchingCall
7761 ; Retrieve DEH ID from the stack into $R9
7762 Exch $R9
7763 Exch 1
7765 ; Retrieve Protocol Activation ID from stack into $R8
7766 Exch $R8
7767 Exch 2
7769 ; Retrieve File Activation ID from stack into $R7
7770 Exch $R7
7772 ; Backup the old values of R6 and R5 on the stack
7773 Push $R6
7774 Push $R5
7776 ; Conditionally remove the DEH as long as we are the default (HKCU)
7777 ReadRegStr $R6 HKCU "Software\Classes\CLSID\$R9\LocalServer32" ""
7778 ${${un}GetLongPath} "$INSTDIR" $R5
7779 StrCmp "$R6" "" next +1
7780 IfFileExists "$R6" +1 clearHKCU
7781 ${${un}GetParent} "$R6" $R6
7782 ${${un}GetLongPath} "$R6" $R6
7783 StrCmp "$R5" "$R6" clearHKCU next
7784 clearHKCU:
7785 DeleteRegKey HKCU "Software\Classes\CLSID\$R9"
7786 DeleteRegValue HKCU "Software\Classes\$R8\shell\open\command" "DelegateExecute"
7787 DeleteRegValue HKCU "Software\Classes\$R7\shell\open\command" "DelegateExecute"
7788 next:
7790 ; Conditionally remove the DEH as long as we are the default (HKLM)
7791 ReadRegStr $R6 HKLM "Software\Classes\CLSID\$R9\LocalServer32" ""
7792 ${${un}GetLongPath} "$INSTDIR" $R5
7793 StrCmp "$R6" "" done +1
7794 IfFileExists "$R6" +1 clearHKLM
7795 ${${un}GetParent} "$R6" $R6
7796 ${${un}GetLongPath} "$R6" $R6
7797 StrCmp "$R5" "$R6" clearHKLM done
7798 clearHKLM:
7799 DeleteRegKey HKLM "Software\Classes\CLSID\$R9"
7800 DeleteRegValue HKLM "Software\Classes\$R8\shell\open\command" "DelegateExecute"
7801 DeleteRegValue HKLM "Software\Classes\$R7\shell\open\command" "DelegateExecute"
7802 done:
7804 ; Always remove the AppUserModelID keys for this installation
7805 DeleteRegKey HKCU "Software\Classes\$AppUserModelID"
7806 DeleteRegKey HKLM "Software\Classes\$AppUserModelID"
7808 ; Restore the registers back to their original state
7809 Pop $R5
7810 Pop $R6
7811 Exch $R7
7812 Exch 2
7813 Exch $R8
7814 Exch 1
7815 Exch $R9
7816 FunctionEnd
7817 !macroend
7819 !macro RemoveDEHRegistrationIfMatching
7820 !insertmacro RemoveDEHRegistrationIfMatchingCall ""
7821 !macroend
7823 !macro un.RemoveDEHRegistrationIfMatching
7824 !insertmacro RemoveDEHRegistrationIfMatchingCall "un."
7825 !macroend
7827 !macro CleanupMetroBrowserHandlerValues un DELEGATE_EXECUTE_HANDLER_ID \
7828 PROTOCOL_ACTIVATION_ID \
7829 FILE_ACTIVATION_ID
7830 Push ${FILE_ACTIVATION_ID}
7831 Push ${PROTOCOL_ACTIVATION_ID}
7832 Push ${DELEGATE_EXECUTE_HANDLER_ID}
7833 Call ${un}RemoveDEHRegistrationIfMatchingCall
7834 !macroend
7835 !define CleanupMetroBrowserHandlerValues '!insertmacro CleanupMetroBrowserHandlerValues ""'
7836 !define un.CleanupMetroBrowserHandlerValues '!insertmacro CleanupMetroBrowserHandlerValues "un."'
7838 !macro AddMetroBrowserHandlerValues DELEGATE_EXECUTE_HANDLER_ID \
7839 DELEGATE_EXECUTE_HANDLER_PATH \
7840 APP_USER_MODEL_ID \
7841 PROTOCOL_ACTIVATION_ID \
7842 FILE_ACTIVATION_ID
7843 ; Win8 doesn't use conventional progid command data to launch anymore.
7844 ; Instead it uses a delegate execute handler which is a light weight COM
7845 ; server for choosing the metro or desktop browser to launch depending
7846 ; on the current environment (metro/desktop) it was activated in.
7847 WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}" "" ""
7848 WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}\.exe" "" ""
7849 WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}\.exe\shell" "" "open"
7850 WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}\.exe\shell\open" "CommandId" "open"
7851 WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}\.exe\shell\open\command" "" "$2"
7852 WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}\.exe\shell\open\command" "DelegateExecute" "${DELEGATE_EXECUTE_HANDLER_ID}"
7854 ; Augment the url handler registrations with additional data needed for Metro
7855 WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}" "AppUserModelID" "${APP_USER_MODEL_ID}"
7856 WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\Application" "AppUserModelID" "${APP_USER_MODEL_ID}"
7857 WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\Application" "ApplicationName" "$BrandShortName"
7858 WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\Application" "ApplicationIcon" "$INSTDIR\${FileMainEXE},0"
7859 WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\Application" "ApplicationCompany" "${CompanyName}"
7860 WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\Application" "ApplicationDescription" "$(REG_APP_DESC)"
7861 WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\shell" "" "open"
7862 WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\shell\open" "CommandId" "open"
7863 WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\shell\open\command" "DelegateExecute" "${DELEGATE_EXECUTE_HANDLER_ID}"
7865 ; Augment the file handler registrations with additional data needed for Metro
7866 WriteRegStr SHCTX "Software\Classes\${FILE_ACTIVATION_ID}" "AppUserModelID" "${APP_USER_MODEL_ID}"
7867 WriteRegStr SHCTX "Software\Classes\${FILE_ACTIVATION_ID}\shell" "" "open"
7868 WriteRegStr SHCTX "Software\Classes\${FILE_ACTIVATION_ID}\shell\open" "CommandId" "open"
7869 WriteRegStr SHCTX "Software\Classes\${FILE_ACTIVATION_ID}\shell\open\command" "DelegateExecute" "${DELEGATE_EXECUTE_HANDLER_ID}"
7871 ; Win8 Metro delegate execute handler registration
7872 WriteRegStr SHCTX "Software\Classes\CLSID\${DELEGATE_EXECUTE_HANDLER_ID}" "" "$BrandShortName CommandExecuteHandler"
7873 WriteRegStr SHCTX "Software\Classes\CLSID\${DELEGATE_EXECUTE_HANDLER_ID}" "AppId" "${DELEGATE_EXECUTE_HANDLER_ID}"
7874 WriteRegStr SHCTX "Software\Classes\CLSID\${DELEGATE_EXECUTE_HANDLER_ID}\LocalServer32" "" "${DELEGATE_EXECUTE_HANDLER_PATH}"
7875 !macroend
7876 !define AddMetroBrowserHandlerValues "!insertmacro AddMetroBrowserHandlerValues"
7877 !endif ;end MOZ_METRO