Source code

Revision control

Other Tools

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/.
4
5
6
################################################################################
7
# Helper defines and macros for toolkit applications
8
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
*/
52
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
58
59
!ifmacrondef FILEFUNC_VERBOSE
60
!include FileFunc.nsh
61
!endif
62
63
!ifmacrondef LOGICLIB_VERBOSITY
64
!include LogicLib.nsh
65
!endif
66
67
!ifndef WINMESSAGES_INCLUDED
68
!include WinMessages.nsh
69
!endif
70
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
76
77
; When including x64.nsh check if ___X64__NSH___ is defined to prevent
78
; loading the file a second time.
79
!ifndef ___X64__NSH___
80
!include x64.nsh
81
!endif
82
83
; NSIS provided macros that we have overridden.
84
!include overrides.nsh
85
86
!define SHORTCUTS_LOG "shortcuts_log.ini"
87
!define TO_BE_DELETED "tobedeleted"
88
89
; !define SHCNF_DWORD 0x0003
90
; !define SHCNF_FLUSH 0x1000
91
!ifndef SHCNF_DWORDFLUSH
92
!define SHCNF_DWORDFLUSH 0x1003
93
!endif
94
!ifndef SHCNE_ASSOCCHANGED
95
!define SHCNE_ASSOCCHANGED 0x08000000
96
!endif
97
98
################################################################################
99
# Macros for debugging
100
101
/**
102
* The following two macros assist with verifying that a macro doesn't
103
* overwrite any registers.
104
*
105
* Usage:
106
* ${debugSetRegisters}
107
* <do stuff>
108
* ${debugDisplayRegisters}
109
*/
110
111
/**
112
* Sets all register values to their name to assist with verifying that a macro
113
* doesn't overwrite any registers.
114
*/
115
!macro debugSetRegisters
116
StrCpy $0 "$$0"
117
StrCpy $1 "$$1"
118
StrCpy $2 "$$2"
119
StrCpy $3 "$$3"
120
StrCpy $4 "$$4"
121
StrCpy $5 "$$5"
122
StrCpy $6 "$$6"
123
StrCpy $7 "$$7"
124
StrCpy $8 "$$8"
125
StrCpy $9 "$$9"
126
StrCpy $R0 "$$R0"
127
StrCpy $R1 "$$R1"
128
StrCpy $R2 "$$R2"
129
StrCpy $R3 "$$R3"
130
StrCpy $R4 "$$R4"
131
StrCpy $R5 "$$R5"
132
StrCpy $R6 "$$R6"
133
StrCpy $R7 "$$R7"
134
StrCpy $R8 "$$R8"
135
StrCpy $R9 "$$R9"
136
!macroend
137
!define debugSetRegisters "!insertmacro debugSetRegisters"
138
139
/**
140
* Displays all register values to assist with verifying that a macro doesn't
141
* overwrite any registers.
142
*/
143
!macro debugDisplayRegisters
144
MessageBox MB_OK \
145
"Register Values:$\n\
146
$$0 = $0$\n$$1 = $1$\n$$2 = $2$\n$$3 = $3$\n$$4 = $4$\n\
147
$$5 = $5$\n$$6 = $6$\n$$7 = $7$\n$$8 = $8$\n$$9 = $9$\n\
148
$$R0 = $R0$\n$$R1 = $R1$\n$$R2 = $R2$\n$$R3 = $R3$\n$$R4 = $R4$\n\
149
$$R5 = $R5$\n$$R6 = $R6$\n$$R7 = $R7$\n$$R8 = $R8$\n$$R9 = $R9"
150
!macroend
151
!define debugDisplayRegisters "!insertmacro debugDisplayRegisters"
152
153
154
################################################################################
155
# Modern User Interface (MUI) override macros
156
157
; Removed macros in nsis 2.33u (ported from nsis 2.22)
158
; MUI_LANGUAGEFILE_DEFINE
159
; MUI_LANGUAGEFILE_LANGSTRING_PAGE
160
; MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE
161
; MUI_LANGUAGEFILE_LANGSTRING_DEFINE
162
; MUI_LANGUAGEFILE_UNLANGSTRING_PAGE
163
164
!macro MOZ_MUI_LANGUAGEFILE_DEFINE DEFINE NAME
165
166
!ifndef "${DEFINE}"
167
!define "${DEFINE}" "${${NAME}}"
168
!endif
169
!undef "${NAME}"
170
171
!macroend
172
173
!macro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE PAGE NAME
174
175
!ifdef MUI_${PAGE}PAGE
176
LangString "${NAME}" 0 "${${NAME}}"
177
!undef "${NAME}"
178
!else
179
!undef "${NAME}"
180
!endif
181
182
!macroend
183
184
!macro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE PAGE NAME
185
186
!ifdef MUI_${PAGE}PAGE | MUI_UN${PAGE}PAGE
187
LangString "${NAME}" 0 "${${NAME}}"
188
!undef "${NAME}"
189
!else
190
!undef "${NAME}"
191
!endif
192
193
!macroend
194
195
!macro MOZ_MUI_LANGUAGEFILE_LANGSTRING_DEFINE DEFINE NAME
196
197
!ifdef "${DEFINE}"
198
LangString "${NAME}" 0 "${${NAME}}"
199
!endif
200
!undef "${NAME}"
201
202
!macroend
203
204
!macro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE PAGE NAME
205
206
!ifdef MUI_UNINSTALLER
207
!ifdef MUI_UN${PAGE}PAGE
208
LangString "${NAME}" 0 "${${NAME}}"
209
!undef "${NAME}"
210
!else
211
!undef "${NAME}"
212
!endif
213
!else
214
!undef "${NAME}"
215
!endif
216
217
!macroend
218
219
; Modified version of the following MUI macros to support Mozilla localization.
220
; MUI_LANGUAGE
221
; MUI_LANGUAGEFILE_BEGIN
222
; MOZ_MUI_LANGUAGEFILE_END
223
; See <NSIS App Dir>/Contrib/Modern UI/System.nsh for more information
224
!define MUI_INSTALLOPTIONS_READ "!insertmacro MUI_INSTALLOPTIONS_READ"
225
226
!macro MOZ_MUI_LANGUAGE LANGUAGE
227
!verbose push
228
!verbose ${MUI_VERBOSE}
229
!include "${LANGUAGE}.nsh"
230
!verbose pop
231
!macroend
232
233
!macro MOZ_MUI_LANGUAGEFILE_BEGIN LANGUAGE
234
!insertmacro MUI_INSERT
235
!ifndef "MUI_LANGUAGEFILE_${LANGUAGE}_USED"
236
!define "MUI_LANGUAGEFILE_${LANGUAGE}_USED"
237
LoadLanguageFile "${LANGUAGE}.nlf"
238
!else
239
!error "Modern UI language file ${LANGUAGE} included twice!"
240
!endif
241
!macroend
242
243
; Custom version of MUI_LANGUAGEFILE_END. The macro to add the default MUI
244
; strings and the macros for several strings that are part of the NSIS MUI and
245
; not in our locale files have been commented out.
246
!macro MOZ_MUI_LANGUAGEFILE_END
247
248
# !include "${NSISDIR}\Contrib\Modern UI\Language files\Default.nsh"
249
!ifdef MUI_LANGUAGEFILE_DEFAULT_USED
250
!undef MUI_LANGUAGEFILE_DEFAULT_USED
251
!warning "${LANGUAGE} Modern UI language file version doesn't match. Using default English texts for missing strings."
252
!endif
253
254
!insertmacro MOZ_MUI_LANGUAGEFILE_DEFINE "MUI_${LANGUAGE}_LANGNAME" "MUI_LANGNAME"
255
256
!ifndef MUI_LANGDLL_PUSHLIST
257
!define MUI_LANGDLL_PUSHLIST "'${MUI_${LANGUAGE}_LANGNAME}' ${LANG_${LANGUAGE}} "
258
!else
259
!ifdef MUI_LANGDLL_PUSHLIST_TEMP
260
!undef MUI_LANGDLL_PUSHLIST_TEMP
261
!endif
262
!define MUI_LANGDLL_PUSHLIST_TEMP "${MUI_LANGDLL_PUSHLIST}"
263
!undef MUI_LANGDLL_PUSHLIST
264
!define MUI_LANGDLL_PUSHLIST "'${MUI_${LANGUAGE}_LANGNAME}' ${LANG_${LANGUAGE}} ${MUI_LANGDLL_PUSHLIST_TEMP}"
265
!endif
266
267
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE WELCOME "MUI_TEXT_WELCOME_INFO_TITLE"
268
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE WELCOME "MUI_TEXT_WELCOME_INFO_TEXT"
269
270
!ifdef MUI_TEXT_LICENSE_TITLE
271
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE LICENSE "MUI_TEXT_LICENSE_TITLE"
272
!endif
273
!ifdef MUI_TEXT_LICENSE_SUBTITLE
274
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE LICENSE "MUI_TEXT_LICENSE_SUBTITLE"
275
!endif
276
!ifdef MUI_INNERTEXT_LICENSE_TOP
277
!insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE LICENSE "MUI_INNERTEXT_LICENSE_TOP"
278
!endif
279
280
# !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE LICENSE "MUI_INNERTEXT_LICENSE_BOTTOM"
281
282
!ifdef MUI_INNERTEXT_LICENSE_BOTTOM_CHECKBOX
283
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE LICENSE "MUI_INNERTEXT_LICENSE_BOTTOM_CHECKBOX"
284
!endif
285
286
!ifdef MUI_INNERTEXT_LICENSE_BOTTOM_RADIOBUTTONS
287
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE LICENSE "MUI_INNERTEXT_LICENSE_BOTTOM_RADIOBUTTONS"
288
!endif
289
290
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE COMPONENTS "MUI_TEXT_COMPONENTS_TITLE"
291
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE COMPONENTS "MUI_TEXT_COMPONENTS_SUBTITLE"
292
!insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE COMPONENTS "MUI_INNERTEXT_COMPONENTS_DESCRIPTION_TITLE"
293
!insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE COMPONENTS "MUI_INNERTEXT_COMPONENTS_DESCRIPTION_INFO"
294
295
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE DIRECTORY "MUI_TEXT_DIRECTORY_TITLE"
296
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE DIRECTORY "MUI_TEXT_DIRECTORY_SUBTITLE"
297
298
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE STARTMENU "MUI_TEXT_STARTMENU_TITLE"
299
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE STARTMENU "MUI_TEXT_STARTMENU_SUBTITLE"
300
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE STARTMENU "MUI_INNERTEXT_STARTMENU_TOP"
301
# !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE STARTMENU "MUI_INNERTEXT_STARTMENU_CHECKBOX"
302
303
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_INSTALLING_TITLE"
304
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_INSTALLING_SUBTITLE"
305
306
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_FINISH_TITLE"
307
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_FINISH_SUBTITLE"
308
309
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_ABORT_TITLE"
310
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_ABORT_SUBTITLE"
311
312
!insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE FINISH "MUI_BUTTONTEXT_FINISH"
313
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_INFO_TITLE"
314
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_INFO_TEXT"
315
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_INFO_REBOOT"
316
!insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_REBOOTNOW"
317
!insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_REBOOTLATER"
318
# !insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_RUN"
319
# !insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_SHOWREADME"
320
321
; Support for using the existing MUI_TEXT_ABORTWARNING string
322
!ifdef MOZ_MUI_CUSTOM_ABORT
323
LangString MOZ_MUI_TEXT_ABORTWARNING 0 "${MUI_TEXT_ABORTWARNING}"
324
!endif
325
326
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_DEFINE MUI_ABORTWARNING "MUI_TEXT_ABORTWARNING"
327
328
329
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE WELCOME "MUI_UNTEXT_WELCOME_INFO_TITLE"
330
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE WELCOME "MUI_UNTEXT_WELCOME_INFO_TEXT"
331
332
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE CONFIRM "MUI_UNTEXT_CONFIRM_TITLE"
333
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE CONFIRM "MUI_UNTEXT_CONFIRM_SUBTITLE"
334
335
# !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE LICENSE "MUI_UNTEXT_LICENSE_TITLE"
336
# !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE LICENSE "MUI_UNTEXT_LICENSE_SUBTITLE"
337
338
# !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE LICENSE "MUI_UNINNERTEXT_LICENSE_BOTTOM"
339
# !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE LICENSE "MUI_UNINNERTEXT_LICENSE_BOTTOM_CHECKBOX"
340
# !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE LICENSE "MUI_UNINNERTEXT_LICENSE_BOTTOM_RADIOBUTTONS"
341
342
# !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE COMPONENTS "MUI_UNTEXT_COMPONENTS_TITLE"
343
# !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE COMPONENTS "MUI_UNTEXT_COMPONENTS_SUBTITLE"
344
345
# !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE DIRECTORY "MUI_UNTEXT_DIRECTORY_TITLE"
346
# !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE DIRECTORY "MUI_UNTEXT_DIRECTORY_SUBTITLE"
347
348
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_UNINSTALLING_TITLE"
349
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_UNINSTALLING_SUBTITLE"
350
351
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_FINISH_TITLE"
352
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_FINISH_SUBTITLE"
353
354
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_ABORT_TITLE"
355
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_ABORT_SUBTITLE"
356
357
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE FINISH "MUI_UNTEXT_FINISH_INFO_TITLE"
358
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE FINISH "MUI_UNTEXT_FINISH_INFO_TEXT"
359
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE FINISH "MUI_UNTEXT_FINISH_INFO_REBOOT"
360
361
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_DEFINE MUI_UNABORTWARNING "MUI_UNTEXT_ABORTWARNING"
362
363
!ifndef MUI_LANGDLL_LANGUAGES
364
!define MUI_LANGDLL_LANGUAGES "'${LANGFILE_${LANGUAGE}_NAME}' '${LANG_${LANGUAGE}}' "
365
!define MUI_LANGDLL_LANGUAGES_CP "'${LANGFILE_${LANGUAGE}_NAME}' '${LANG_${LANGUAGE}}' '${LANG_${LANGUAGE}_CP}' "
366
!else
367
!ifdef MUI_LANGDLL_LANGUAGES_TEMP
368
!undef MUI_LANGDLL_LANGUAGES_TEMP
369
!endif
370
!define MUI_LANGDLL_LANGUAGES_TEMP "${MUI_LANGDLL_LANGUAGES}"
371
!undef MUI_LANGDLL_LANGUAGES
372
373
!ifdef MUI_LANGDLL_LANGUAGES_CP_TEMP
374
!undef MUI_LANGDLL_LANGUAGES_CP_TEMP
375
!endif
376
!define MUI_LANGDLL_LANGUAGES_CP_TEMP "${MUI_LANGDLL_LANGUAGES_CP}"
377
!undef MUI_LANGDLL_LANGUAGES_CP
378
379
!define MUI_LANGDLL_LANGUAGES "'${LANGFILE_${LANGUAGE}_NAME}' '${LANG_${LANGUAGE}}' ${MUI_LANGDLL_LANGUAGES_TEMP}"
380
!define MUI_LANGDLL_LANGUAGES_CP "'${LANGFILE_${LANGUAGE}_NAME}' '${LANG_${LANGUAGE}}' '${LANG_${LANGUAGE}_CP}' ${MUI_LANGDLL_LANGUAGES_CP_TEMP}"
381
!endif
382
383
!macroend
384
385
/**
386
* Creates an InstallOptions file with a UTF-16LE BOM and adds the RTL value
387
* to the Settings section.
388
*
389
* @param _FILE
390
* The name of the file to be created in $PLUGINSDIR.
391
*/
392
!macro InitInstallOptionsFile _FILE
393
Push $R9
394
395
FileOpen $R9 "$PLUGINSDIR\${_FILE}" w
396
FileWriteWord $R9 "65279"
397
FileClose $R9
398
WriteIniStr "$PLUGINSDIR\${_FILE}" "Settings" "RTL" "$(^RTL)"
399
400
Pop $R9
401
!macroend
402
403
404
################################################################################
405
# Macros for handling files in use
406
407
/**
408
* Checks for files in use in the $INSTDIR directory. To check files in
409
* sub-directories this macro would need to be rewritten to create
410
* sub-directories in the temporary directory used to backup the files that are
411
* checked.
412
*
413
* Example usage:
414
*
415
* ; The first string to be pushed onto the stack MUST be "end" to indicate
416
* ; that there are no more files in the $INSTDIR directory to check.
417
* Push "end"
418
* Push "freebl3.dll"
419
* ; The last file pushed should be the app's main exe so if it is in use this
420
* ; macro will return after the first check.
421
* Push "${FileMainEXE}"
422
* ${CheckForFilesInUse} $R9
423
*
424
* !IMPORTANT - this macro uses the $R7, $R8, and $R9 registers and makes no
425
* attempt to restore their original values.
426
*
427
* @return _RESULT
428
* false if all of the files popped from the stack are not in use.
429
* True if any of the files popped from the stack are in use.
430
* $R7 = Temporary backup directory where the files will be copied to.
431
* $R8 = value popped from the stack. This will either be a file name for a file
432
* in the $INSTDIR directory or "end" to indicate that there are no
433
* additional files to check.
434
* $R9 = _RESULT
435
*/
436
!macro CheckForFilesInUse
437
438
!ifndef ${_MOZFUNC_UN}CheckForFilesInUse
439
!verbose push
440
!verbose ${_MOZFUNC_VERBOSE}
441
!define ${_MOZFUNC_UN}CheckForFilesInUse "!insertmacro ${_MOZFUNC_UN}CheckForFilesInUseCall"
442
443
Function ${_MOZFUNC_UN}CheckForFilesInUse
444
; Create a temporary backup directory.
445
GetTempFileName $R7 "$INSTDIR"
446
Delete "$R7"
447
SetOutPath "$R7"
448
StrCpy $R9 "false"
449
450
Pop $R8
451
${While} $R8 != "end"
452
${Unless} ${FileExists} "$INSTDIR\$R8"
453
Pop $R8 ; get next file to check before continuing
454
${Continue}
455
${EndUnless}
456
457
ClearErrors
458
CopyFiles /SILENT "$INSTDIR\$R8" "$R7\$R8" ; try to copy
459
${If} ${Errors}
460
; File is in use
461
StrCpy $R9 "true"
462
${Break}
463
${EndIf}
464
465
Delete "$INSTDIR\$R8" ; delete original
466
${If} ${Errors}
467
; File is in use
468
StrCpy $R9 "true"
469
Delete "$R7\$R8" ; delete temp copy
470
${Break}
471
${EndIf}
472
473
Pop $R8 ; get next file to check
474
${EndWhile}
475
476
; clear stack
477
${While} $R8 != "end"
478
Pop $R8
479
${EndWhile}
480
481
; restore everything
482
SetOutPath "$INSTDIR"
483
CopyFiles /SILENT "$R7\*" "$INSTDIR\"
484
RmDir /r "$R7"
485
SetOutPath "$EXEDIR"
486
ClearErrors
487
488
Push $R9
489
FunctionEnd
490
491
!verbose pop
492
!endif
493
!macroend
494
495
!macro CheckForFilesInUseCall _RESULT
496
!verbose push
497
!verbose ${_MOZFUNC_VERBOSE}
498
Call CheckForFilesInUse
499
Pop ${_RESULT}
500
!verbose pop
501
!macroend
502
503
!macro un.CheckForFilesInUseCall _RESULT
504
!verbose push
505
!verbose ${_MOZFUNC_VERBOSE}
506
Call un.CheckForFilesInUse
507
Pop ${_RESULT}
508
!verbose pop
509
!macroend
510
511
!macro un.CheckForFilesInUse
512
!ifndef un.CheckForFilesInUse
513
!verbose push
514
!verbose ${_MOZFUNC_VERBOSE}
515
!undef _MOZFUNC_UN
516
!define _MOZFUNC_UN "un."
517
518
!insertmacro CheckForFilesInUse
519
520
!undef _MOZFUNC_UN
521
!define _MOZFUNC_UN
522
!verbose pop
523
!endif
524
!macroend
525
526
/**
527
* The macros below will automatically prepend un. to the function names when
528
* they are defined (e.g. !define un.RegCleanMain).
529
*/
530
!verbose push
531
!verbose 3
532
!ifndef _MOZFUNC_VERBOSE
533
!define _MOZFUNC_VERBOSE 3
534
!endif
535
!verbose ${_MOZFUNC_VERBOSE}
536
!define MOZFUNC_VERBOSE "!insertmacro MOZFUNC_VERBOSE"
537
!define _MOZFUNC_UN
538
!define _MOZFUNC_S
539
!verbose pop
540
541
!macro MOZFUNC_VERBOSE _VERBOSE
542
!verbose push
543
!verbose 3
544
!undef _MOZFUNC_VERBOSE
545
!define _MOZFUNC_VERBOSE ${_VERBOSE}
546
!verbose pop
547
!macroend
548
549
/**
550
* Displays a MessageBox and then calls abort to prevent continuing to the
551
* next page when the specified Window Class is found.
552
*
553
* @param _WINDOW_CLASS
554
* The Window Class to search for with FindWindow.
555
* @param _MSG
556
* The message text to display in the message box.
557
*
558
* $R7 = return value from FindWindow
559
* $R8 = _WINDOW_CLASS
560
* $R9 = _MSG
561
*/
562
!macro ManualCloseAppPrompt
563
564
!ifndef ${_MOZFUNC_UN}ManualCloseAppPrompt
565
!verbose push
566
!verbose ${_MOZFUNC_VERBOSE}
567
!define ${_MOZFUNC_UN}ManualCloseAppPrompt "!insertmacro ${_MOZFUNC_UN}ManualCloseAppPromptCall"
568
569
Function ${_MOZFUNC_UN}ManualCloseAppPrompt
570
Exch $R9
571
Exch 1
572
Exch $R8
573
Push $R7
574
575
FindWindow $R7 "$R8"
576
${If} $R7 <> 0 ; integer comparison
577
MessageBox MB_OK|MB_ICONQUESTION "$R9"
578
Abort
579
${EndIf}
580
581
Pop $R7
582
Exch $R8
583
Exch 1
584
Exch $R9
585
FunctionEnd
586
587
!verbose pop
588
!endif
589
!macroend
590
591
!macro ManualCloseAppPromptCall _WINDOW_CLASS _MSG
592
!verbose push
593
!verbose ${_MOZFUNC_VERBOSE}
594
Push "${_WINDOW_CLASS}"
595
Push "${_MSG}"
596
Call ManualCloseAppPrompt
597
!verbose pop
598
!macroend
599
600
!macro un.ManualCloseAppPromptCall _WINDOW_CLASS _MSG
601
!verbose push
602
!verbose ${_MOZFUNC_VERBOSE}
603
Push "${_WINDOW_CLASS}"
604
Push "${_MSG}"
605
Call un.ManualCloseAppPrompt
606
!verbose pop
607
!macroend
608
609
!macro un.ManualCloseAppPrompt
610
!ifndef un.ManualCloseAppPrompt
611
!verbose push
612
!verbose ${_MOZFUNC_VERBOSE}
613
!undef _MOZFUNC_UN
614
!define _MOZFUNC_UN "un."
615
616
!insertmacro ManualCloseAppPrompt
617
618
!undef _MOZFUNC_UN
619
!define _MOZFUNC_UN
620
!verbose pop
621
!endif
622
!macroend
623
624
625
################################################################################
626
# Macros for working with the registry
627
628
/**
629
* Writes a registry string using SHCTX and the supplied params and logs the
630
* action to the install log and the uninstall log if _LOG_UNINSTALL equals 1.
631
*
632
* Define NO_LOG to prevent all logging when calling this from the uninstaller.
633
*
634
* @param _ROOT
635
* The registry key root as defined by NSIS (e.g. HKLM, HKCU, etc.).
636
* This will only be used for logging.
637
* @param _KEY
638
* The subkey in relation to the key root.
639
* @param _NAME
640
* The key value name to write to.
641
* @param _STR
642
* The string to write to the key value name.
643
* @param _LOG_UNINSTALL
644
* 0 = don't add to uninstall log, 1 = add to uninstall log.
645
*
646
* $R5 = _ROOT
647
* $R6 = _KEY
648
* $R7 = _NAME
649
* $R8 = _STR
650
* $R9 = _LOG_UNINSTALL
651
*/
652
!macro WriteRegStr2
653
654
!ifndef ${_MOZFUNC_UN}WriteRegStr2
655
!verbose push
656
!verbose ${_MOZFUNC_VERBOSE}
657
!define ${_MOZFUNC_UN}WriteRegStr2 "!insertmacro ${_MOZFUNC_UN}WriteRegStr2Call"
658
659
Function ${_MOZFUNC_UN}WriteRegStr2
660
Exch $R9
661
Exch 1
662
Exch $R8
663
Exch 2
664
Exch $R7
665
Exch 3
666
Exch $R6
667
Exch 4
668
Exch $R5
669
670
ClearErrors
671
WriteRegStr SHCTX "$R6" "$R7" "$R8"
672
673
!ifndef NO_LOG
674
${If} ${Errors}
675
${LogMsg} "** ERROR Adding Registry String: $R5 | $R6 | $R7 | $R8 **"
676
${Else}
677
${If} $R9 == 1 ; add to the uninstall log?
678
${LogUninstall} "RegVal: $R5 | $R6 | $R7"
679
${EndIf}
680
${LogMsg} "Added Registry String: $R5 | $R6 | $R7 | $R8"
681
${EndIf}
682
!endif
683
684
Exch $R5
685
Exch 4
686
Exch $R6
687
Exch 3
688
Exch $R7
689
Exch 2
690
Exch $R8
691
Exch 1
692
Exch $R9
693
FunctionEnd
694
695
!verbose pop
696
!endif
697
!macroend
698
699
!macro WriteRegStr2Call _ROOT _KEY _NAME _STR _LOG_UNINSTALL
700
!verbose push
701
!verbose ${_MOZFUNC_VERBOSE}
702
Push "${_ROOT}"
703
Push "${_KEY}"
704
Push "${_NAME}"
705
Push "${_STR}"
706
Push "${_LOG_UNINSTALL}"
707
Call WriteRegStr2
708
!verbose pop
709
!macroend
710
711
!macro un.WriteRegStr2Call _ROOT _KEY _NAME _STR _LOG_UNINSTALL
712
!verbose push
713
!verbose ${_MOZFUNC_VERBOSE}
714
Push "${_ROOT}"
715
Push "${_KEY}"
716
Push "${_NAME}"
717
Push "${_STR}"
718
Push "${_LOG_UNINSTALL}"
719
Call un.WriteRegStr2
720
!verbose pop
721
!macroend
722
723
!macro un.WriteRegStr2
724
!ifndef un.WriteRegStr2
725
!verbose push
726
!verbose ${_MOZFUNC_VERBOSE}
727
!undef _MOZFUNC_UN
728
!define _MOZFUNC_UN "un."
729
730
!insertmacro WriteRegStr2
731
732
!undef _MOZFUNC_UN
733
!define _MOZFUNC_UN
734
!verbose pop
735
!endif
736
!macroend
737
738
/**
739
* Writes a registry dword using SHCTX and the supplied params and logs the
740
* action to the install log and the uninstall log if _LOG_UNINSTALL equals 1.
741
*
742
* Define NO_LOG to prevent all logging when calling this from the uninstaller.
743
*
744
* @param _ROOT
745
* The registry key root as defined by NSIS (e.g. HKLM, HKCU, etc.).
746
* This will only be used for logging.
747
* @param _KEY
748
* The subkey in relation to the key root.
749
* @param _NAME
750
* The key value name to write to.
751
* @param _DWORD
752
* The dword to write to the key value name.
753
* @param _LOG_UNINSTALL
754
* 0 = don't add to uninstall log, 1 = add to uninstall log.
755
*
756
* $R5 = _ROOT
757
* $R6 = _KEY
758
* $R7 = _NAME
759
* $R8 = _DWORD
760
* $R9 = _LOG_UNINSTALL
761
*/
762
!macro WriteRegDWORD2
763
764
!ifndef ${_MOZFUNC_UN}WriteRegDWORD2
765
!verbose push
766
!verbose ${_MOZFUNC_VERBOSE}
767
!define ${_MOZFUNC_UN}WriteRegDWORD2 "!insertmacro ${_MOZFUNC_UN}WriteRegDWORD2Call"
768
769
Function ${_MOZFUNC_UN}WriteRegDWORD2
770
Exch $R9
771
Exch 1
772
Exch $R8
773
Exch 2
774
Exch $R7
775
Exch 3
776
Exch $R6
777
Exch 4
778
Exch $R5
779
780
ClearErrors
781
WriteRegDWORD SHCTX "$R6" "$R7" "$R8"
782
783
!ifndef NO_LOG
784
${If} ${Errors}
785
${LogMsg} "** ERROR Adding Registry DWord: $R5 | $R6 | $R7 | $R8 **"
786
${Else}
787
${If} $R9 == 1 ; add to the uninstall log?
788
${LogUninstall} "RegVal: $R5 | $R6 | $R7"
789
${EndIf}
790
${LogMsg} "Added Registry DWord: $R5 | $R6 | $R7 | $R8"
791
${EndIf}
792
!endif
793
794
Exch $R5
795
Exch 4
796
Exch $R6
797
Exch 3
798
Exch $R7
799
Exch 2
800
Exch $R8
801
Exch 1
802
Exch $R9
803
FunctionEnd
804
805
!verbose pop
806
!endif
807
!macroend
808
809
!macro WriteRegDWORD2Call _ROOT _KEY _NAME _DWORD _LOG_UNINSTALL
810
!verbose push
811
!verbose ${_MOZFUNC_VERBOSE}
812
Push "${_ROOT}"
813
Push "${_KEY}"
814
Push "${_NAME}"
815
Push "${_DWORD}"
816
Push "${_LOG_UNINSTALL}"
817
Call WriteRegDWORD2
818
!verbose pop
819
!macroend
820
821
!macro un.WriteRegDWORD2Call _ROOT _KEY _NAME _DWORD _LOG_UNINSTALL
822
!verbose push
823
!verbose ${_MOZFUNC_VERBOSE}
824
Push "${_ROOT}"
825
Push "${_KEY}"
826
Push "${_NAME}"
827
Push "${_DWORD}"
828
Push "${_LOG_UNINSTALL}"
829
Call un.WriteRegDWORD2
830
!verbose pop
831
!macroend
832
833
!macro un.WriteRegDWORD2
834
!ifndef un.WriteRegDWORD2
835
!verbose push
836
!verbose ${_MOZFUNC_VERBOSE}
837
!undef _MOZFUNC_UN
838
!define _MOZFUNC_UN "un."
839
840
!insertmacro WriteRegDWORD2
841
842
!undef _MOZFUNC_UN
843
!define _MOZFUNC_UN
844
!verbose pop
845
!endif
846
!macroend
847
848
/**
849
* Writes a registry string to HKCR using the supplied params and logs the
850
* action to the install log and the uninstall log if _LOG_UNINSTALL equals 1.
851
*
852
* Define NO_LOG to prevent all logging when calling this from the uninstaller.
853
*
854
* @param _ROOT
855
* The registry key root as defined by NSIS (e.g. HKLM, HKCU, etc.).
856
* This will only be used for logging.
857
* @param _KEY
858
* The subkey in relation to the key root.
859
* @param _NAME
860
* The key value name to write to.
861
* @param _STR
862
* The string to write to the key value name.
863
* @param _LOG_UNINSTALL
864
* 0 = don't add to uninstall log, 1 = add to uninstall log.
865
*
866
* $R5 = _ROOT
867
* $R6 = _KEY
868
* $R7 = _NAME
869
* $R8 = _STR
870
* $R9 = _LOG_UNINSTALL
871
*/
872
!macro WriteRegStrHKCR
873
874
!ifndef ${_MOZFUNC_UN}WriteRegStrHKCR
875
!verbose push
876
!verbose ${_MOZFUNC_VERBOSE}
877
!define ${_MOZFUNC_UN}WriteRegStrHKCR "!insertmacro ${_MOZFUNC_UN}WriteRegStrHKCRCall"
878
879
Function ${_MOZFUNC_UN}WriteRegStrHKCR
880
Exch $R9
881
Exch 1
882
Exch $R8
883
Exch 2
884
Exch $R7
885
Exch 3
886
Exch $R6
887
Exch 4
888
Exch $R5
889
890
ClearErrors
891
WriteRegStr HKCR "$R6" "$R7" "$R8"
892
893
!ifndef NO_LOG
894
${If} ${Errors}
895
${LogMsg} "** ERROR Adding Registry String: $R5 | $R6 | $R7 | $R8 **"
896
${Else}
897
${If} $R9 == 1 ; add to the uninstall log?
898
${LogUninstall} "RegVal: $R5 | $R6 | $R7"
899
${EndIf}
900
${LogMsg} "Added Registry String: $R5 | $R6 | $R7 | $R8"
901
${EndIf}
902
!endif
903
904
Exch $R5
905
Exch 4
906
Exch $R6
907
Exch 3
908
Exch $R7
909
Exch 2
910
Exch $R8
911
Exch 1
912
Exch $R9
913
FunctionEnd
914
915
!verbose pop
916
!endif
917
!macroend
918
919
!macro WriteRegStrHKCRCall _ROOT _KEY _NAME _STR _LOG_UNINSTALL
920
!verbose push
921
!verbose ${_MOZFUNC_VERBOSE}
922
Push "${_ROOT}"
923
Push "${_KEY}"
924
Push "${_NAME}"
925
Push "${_STR}"
926
Push "${_LOG_UNINSTALL}"
927
Call WriteRegStrHKCR
928
!verbose pop
929
!macroend
930
931
!macro un.WriteRegStrHKCRCall _ROOT _KEY _NAME _STR _LOG_UNINSTALL
932
!verbose push
933
!verbose ${_MOZFUNC_VERBOSE}
934
Push "${_ROOT}"
935
Push "${_KEY}"
936
Push "${_NAME}"
937
Push "${_STR}"
938
Push "${_LOG_UNINSTALL}"
939
Call un.WriteRegStrHKCR
940
!verbose pop
941
!macroend
942
943
!macro un.WriteRegStrHKCR
944
!ifndef un.WriteRegStrHKCR
945
!verbose push
946
!verbose ${_MOZFUNC_VERBOSE}
947
!undef _MOZFUNC_UN
948
!define _MOZFUNC_UN "un."
949
950
!insertmacro WriteRegStrHKCR
951
952
!undef _MOZFUNC_UN
953
!define _MOZFUNC_UN
954
!verbose pop
955
!endif
956
!macroend
957
958
!ifndef KEY_SET_VALUE
959
!define KEY_SET_VALUE 0x0002
960
!endif
961
!ifndef KEY_WOW64_64KEY
962
!define KEY_WOW64_64KEY 0x0100
963
!endif
964
!ifndef HAVE_64BIT_BUILD
965
!define CREATE_KEY_SAM ${KEY_SET_VALUE}
966
!else
967
!define CREATE_KEY_SAM ${KEY_SET_VALUE}|${KEY_WOW64_64KEY}
968
!endif
969
970
/**
971
* Creates a registry key. This will log the actions to the install and
972
* uninstall logs. Alternatively you can set a registry value to create the key
973
* and then delete the value.
974
*
975
* Define NO_LOG to prevent all logging when calling this from the uninstaller.
976
*
977
* @param _ROOT
978
* The registry key root as defined by NSIS (e.g. HKLM, HKCU, etc.).
979
* @param _KEY
980
* The subkey in relation to the key root.
981
* @param _LOG_UNINSTALL
982
* 0 = don't add to uninstall log, 1 = add to uninstall log.
983
*
984
* $R4 = [out] handle to newly created registry key. If this is not a key
985
* located in one of the predefined registry keys this must be closed
986
* with RegCloseKey (this should not be needed unless someone decides to
987
* do something extremely squirrelly with NSIS).
988
* $R5 = return value from RegCreateKeyExW (represented by R5 in the system call).
989
* $R6 = [in] hKey passed to RegCreateKeyExW.
990
* $R7 = _ROOT
991
* $R8 = _KEY
992
* $R9 = _LOG_UNINSTALL
993
*/
994
!macro CreateRegKey
995
996
!ifndef ${_MOZFUNC_UN}CreateRegKey
997
!verbose push
998
!verbose ${_MOZFUNC_VERBOSE}
999
!define ${_MOZFUNC_UN}CreateRegKey "!insertmacro ${_MOZFUNC_UN}CreateRegKeyCall"
1000
1001
Function ${_MOZFUNC_UN}CreateRegKey
1002
Exch $R9
1003
Exch 1
1004
Exch $R8
1005
Exch 2
1006
Exch $R7
1007
Push $R6
1008
Push $R5
1009
Push $R4
1010
1011
StrCmp $R7 "HKCR" +1 +2
1012
StrCpy $R6 "0x80000000"
1013
StrCmp $R7 "HKCU" +1 +2
1014
StrCpy $R6 "0x80000001"
1015
StrCmp $R7 "HKLM" +1 +2
1016
StrCpy $R6 "0x80000002"
1017
1018
; see definition of RegCreateKey
1019
System::Call "Advapi32::RegCreateKeyExW(i R6, w R8, i 0, i 0, i 0,\
1020
i ${CREATE_KEY_SAM}, i 0, *i .R4,\
1021
i 0) i .R5"
1022
1023
!ifndef NO_LOG
1024
; if $R5 is not 0 then there was an error creating the registry key.
1025
${If} $R5 <> 0
1026
${LogMsg} "** ERROR Adding Registry Key: $R7 | $R8 **"
1027
${Else}
1028
${If} $R9 == 1 ; add to the uninstall log?
1029
${LogUninstall} "RegKey: $R7 | $R8"
1030
${EndIf}
1031
${LogMsg} "Added Registry Key: $R7 | $R8"
1032
${EndIf}
1033
!endif
1034
1035
StrCmp $R5 0 +1 +2
1036
System::Call "Advapi32::RegCloseKey(iR4)"
1037
1038
Pop $R4
1039
Pop $R5
1040
Pop $R6
1041
Exch $R7
1042
Exch 2
1043
Exch $R8
1044
Exch 1
1045
Exch $R9
1046
FunctionEnd
1047
1048
!verbose pop
1049
!endif
1050
!macroend
1051
1052
!macro CreateRegKeyCall _ROOT _KEY _LOG_UNINSTALL
1053
!verbose push
1054
!verbose ${_MOZFUNC_VERBOSE}
1055
Push "${_ROOT}"
1056
Push "${_KEY}"
1057
Push "${_LOG_UNINSTALL}"
1058
Call CreateRegKey
1059
!verbose pop
1060
!macroend
1061
1062
!macro un.CreateRegKeyCall _ROOT _KEY _LOG_UNINSTALL
1063
!verbose push
1064
!verbose ${_MOZFUNC_VERBOSE}
1065
Push "${_ROOT}"
1066
Push "${_KEY}"
1067
Push "${_LOG_UNINSTALL}"
1068
Call un.CreateRegKey
1069
!verbose pop
1070
!macroend
1071
1072
!macro un.CreateRegKey
1073
!ifndef un.CreateRegKey
1074
!verbose push
1075
!verbose ${_MOZFUNC_VERBOSE}
1076
!undef _MOZFUNC_UN
1077
!define _MOZFUNC_UN "un."
1078
1079
!insertmacro CreateRegKey
1080
1081
!undef _MOZFUNC_UN
1082
!define _MOZFUNC_UN
1083
!verbose pop
1084
!endif
1085
!macroend
1086
1087
/**
1088
* Helper for checking for the existence of a registry key.
1089
* SHCTX is the root key to search.
1090
*
1091
* @param _MAIN_KEY
1092
* Sub key to iterate for the key in question
1093
* @param _KEY
1094
* Key name to search for
1095
* @return _RESULT
1096
* 'true' / 'false' result
1097
*/
1098
!macro CheckIfRegistryKeyExists
1099
!ifndef CheckIfRegistryKeyExists
1100
!verbose push
1101
!verbose ${_MOZFUNC_VERBOSE}
1102
!define CheckIfRegistryKeyExists "!insertmacro CheckIfRegistryKeyExistsCall"
1103
1104
Function CheckIfRegistryKeyExists
1105
; stack: main key, key
1106
Exch $R9 ; main key, stack: old R9, key
1107
Exch 1 ; stack: key, old R9
1108
Exch $R8 ; key, stack: old R8, old R9
1109
Push $R7
1110
Push $R6
1111
Push $R5
1112
1113
StrCpy $R5 "false"
1114
StrCpy $R7 "0" # loop index
1115
${Do}
1116
EnumRegKey $R6 SHCTX "$R9" "$R7"
1117
${If} "$R6" == "$R8"
1118
StrCpy $R5 "true"
1119
${Break}
1120
${EndIf}
1121
IntOp $R7 $R7 + 1
1122
${LoopWhile} $R6 != ""
1123
ClearErrors
1124
1125
StrCpy $R9 $R5
1126
1127
Pop $R5
1128
Pop $R6
1129
Pop $R7 ; stack: old R8, old R9
1130
Pop $R8 ; stack: old R9
1131
Exch $R9 ; stack: result
1132
FunctionEnd
1133
1134
!verbose pop
1135
!endif
1136
!macroend
1137
1138
!macro CheckIfRegistryKeyExistsCall _MAIN_KEY _KEY _RESULT
1139
!verbose push
1140
!verbose ${_MOZFUNC_VERBOSE}
1141
Push "${_KEY}"
1142
Push "${_MAIN_KEY}"
1143
Call CheckIfRegistryKeyExists
1144
Pop ${_RESULT}
1145
!verbose pop
1146
!macroend
1147
1148
/**
1149
* Read the value of an installer pref that's been set by the product.
1150
*
1151
* @param _KEY ($R1)
1152
* Sub key containing all the installer prefs
1153
* Usually "Software\Mozilla\${AppName}"
1154
* @param _PREF ($R2)
1155
* Name of the pref to look up
1156
* @return _RESULT ($R3)
1157
* 'true' or 'false' (only boolean prefs are supported)
1158
* If no value exists for the requested pref, the result is 'false'
1159
*/
1160
!macro GetInstallerRegistryPref
1161
!ifndef ${_MOZFUNC_UN}GetInstallerRegistryPref
1162
!verbose push
1163
!verbose ${_MOZFUNC_VERBOSE}
1164
!define ${_MOZFUNC_UN}GetInstallerRegistryPref "!insertmacro GetInstallerRegistryPrefCall"
1165
1166
Function ${_MOZFUNC_UN}GetInstallerRegistryPref
1167
; stack: key, pref
1168
Exch $R1 ; key, stack: old R1, pref
1169
Exch 1 ; stack: pref, old R1
1170
Exch $R2 ; pref, stack: old R2, old R1
1171
Push $R3
1172
1173
StrCpy $R3 0
1174
1175
; These prefs are always stored in the native registry.
1176
SetRegView 64
1177
1178
ClearErrors
1179
ReadRegDWORD $R3 HKCU "$R1\Installer\$AppUserModelID" "$R2"
1180
1181
SetRegView lastused
1182
1183
${IfNot} ${Errors}
1184
${AndIf} $R3 != 0
1185
StrCpy $R1 "true"
1186
${Else}
1187
StrCpy $R1 "false"
1188
${EndIf}
1189
1190
; stack: old R3, old R2, old R1
1191
Pop $R3 ; stack: old R2, old R1
1192
Pop $R2 ; stack: old R1
1193
Exch $R1 ; stack: result
1194
FunctionEnd
1195
1196
!verbose pop
1197
!endif
1198
!macroend
1199
1200
!macro GetInstallerRegistryPrefCall _KEY _PREF _RESULT
1201
!verbose push
1202
!verbose ${_MOZFUNC_VERBOSE}
1203
Push "${_PREF}"
1204
Push "${_KEY}"
1205
Call GetInstallerRegistryPref
1206
Pop ${_RESULT}
1207
!verbose pop
1208
!macroend
1209
1210
!macro un.GetInstallerRegistryPrefCall _KEY _PREF _RESULT
1211
!verbose push
1212
!verbose ${_MOZFUNC_VERBOSE}
1213
Push "${_PREF}"
1214
Push "${_KEY}"
1215
Call un.GetInstallerRegistryPref
1216
Pop ${_RESULT}
1217
!verbose pop
1218
!macroend
1219
1220
!macro un.GetInstallerRegistryPref
1221
!ifndef un.GetInstallerRegistryPref
1222
!verbose push
1223
!verbose ${_MOZFUNC_VERBOSE}
1224
!undef _MOZFUNC_UN
1225
!define _MOZFUNC_UN "un."
1226
1227
!insertmacro GetInstallerRegistryPref
1228
1229
!undef _MOZFUNC_UN
1230
!define _MOZFUNC_UN
1231
!verbose pop
1232
!endif
1233
!macroend
1234
1235
################################################################################
1236
# Macros for adding file and protocol handlers
1237
1238
/**
1239
* Writes common registry values for a handler using SHCTX.
1240
*
1241
* @param _KEY
1242
* The subkey in relation to the key root.
1243
* @param _VALOPEN
1244
* The path and args to launch the application.
1245
* @param _VALICON
1246
* The path to the binary that contains the icon group for the default icon
1247
* followed by a comma and either the icon group's resource index or the icon
1248
* group's resource id prefixed with a minus sign
1249
* @param _DISPNAME
1250
* The display name for the handler. If emtpy no value will be set.
1251
* @param _ISPROTOCOL
1252
* Sets protocol handler specific registry values when "true".
1253
* Deletes protocol handler specific registry values when "delete".
1254
* Otherwise doesn't touch handler specific registry values.
1255
* @param _ISDDE
1256
* Sets DDE specific registry values when "true".
1257
*
1258
* $R3 = string value of the current registry key path.
1259
* $R4 = _KEY
1260
* $R5 = _VALOPEN
1261
* $R6 = _VALICON
1262
* $R7 = _DISPNAME
1263
* $R8 = _ISPROTOCOL
1264
* $R9 = _ISDDE
1265
*/
1266
!macro AddHandlerValues
1267
1268
!ifndef ${_MOZFUNC_UN}AddHandlerValues
1269
!verbose push
1270
!verbose ${_MOZFUNC_VERBOSE}
1271
!define ${_MOZFUNC_UN}AddHandlerValues "!insertmacro ${_MOZFUNC_UN}AddHandlerValuesCall"
1272
1273
Function ${_MOZFUNC_UN}AddHandlerValues
1274
Exch $R9
1275
Exch 1
1276
Exch $R8
1277
Exch 2
1278
Exch $R7
1279
Exch 3
1280
Exch $R6
1281
Exch 4
1282
Exch $R5
1283
Exch 5
1284
Exch $R4
1285
Push $R3
1286
1287
StrCmp "$R7" "" +6 +1
1288
ReadRegStr $R3 SHCTX "$R4" "FriendlyTypeName"
1289
1290
StrCmp "$R3" "" +1 +3
1291
WriteRegStr SHCTX "$R4" "" "$R7"
1292
WriteRegStr SHCTX "$R4" "FriendlyTypeName" "$R7"
1293
1294
StrCmp "$R8" "true" +1 +2
1295
WriteRegStr SHCTX "$R4" "URL Protocol" ""
1296
StrCmp "$R8" "delete" +1 +2
1297
DeleteRegValue SHCTX "$R4" "URL Protocol"
1298
StrCpy $R3 ""
1299
ReadRegDWord $R3 SHCTX "$R4" "EditFlags"
1300
StrCmp $R3 "" +1 +3 ; Only add EditFlags if a value doesn't exist
1301
DeleteRegValue SHCTX "$R4" "EditFlags"
1302
WriteRegDWord SHCTX "$R4" "EditFlags" 0x00000002
1303
1304
StrCmp "$R6" "" +2 +1
1305
WriteRegStr SHCTX "$R4\DefaultIcon" "" "$R6"
1306
1307
StrCmp "$R5" "" +2 +1
1308
WriteRegStr SHCTX "$R4\shell\open\command" "" "$R5"
1309
1310
!ifdef DDEApplication
1311
StrCmp "$R9" "true" +1 +11
1312
WriteRegStr SHCTX "$R4\shell\open\ddeexec" "" "$\"%1$\",,0,0,,,,"
1313
WriteRegStr SHCTX "$R4\shell\open\ddeexec" "NoActivateHandler" ""
1314
WriteRegStr SHCTX "$R4\shell\open\ddeexec\Application" "" "${DDEApplication}"
1315
WriteRegStr SHCTX "$R4\shell\open\ddeexec\Topic" "" "WWW_OpenURL"
1316
; The ifexec key may have been added by another application so try to
1317
; delete it to prevent it from breaking this app's shell integration.
1318
; Also, IE 6 and below doesn't remove this key when it sets itself as the
1319
; default handler and if this key exists IE's shell integration breaks.
1320
DeleteRegKey HKLM "$R4\shell\open\ddeexec\ifexec"
1321
DeleteRegKey HKCU "$R4\shell\open\ddeexec\ifexec"
1322
!endif
1323
1324
ClearErrors
1325
1326
Pop $R3
1327
Exch $R4
1328
Exch 5
1329
Exch $R5
1330
Exch 4
1331
Exch $R6
1332
Exch 3
1333
Exch $R7
1334
Exch 2
1335
Exch $R8
1336
Exch 1
1337
Exch $R9
1338
FunctionEnd
1339
1340
!verbose pop
1341
!endif
1342
!macroend
1343
1344
!macro AddHandlerValuesCall _KEY _VALOPEN _VALICON _DISPNAME _ISPROTOCOL _ISDDE
1345
!verbose push
1346
!verbose ${_MOZFUNC_VERBOSE}
1347
Push "${_KEY}"
1348
Push "${_VALOPEN}"
1349
Push "${_VALICON}"
1350
Push "${_DISPNAME}"
1351
Push "${_ISPROTOCOL}"
1352
Push "${_ISDDE}"
1353
Call AddHandlerValues
1354
!verbose pop
1355
!macroend
1356
1357
!macro un.AddHandlerValuesCall _KEY _VALOPEN _VALICON _DISPNAME _ISPROTOCOL _ISDDE
1358
!verbose push
1359
!verbose ${_MOZFUNC_VERBOSE}
1360
Push "${_KEY}"
1361
Push "${_VALOPEN}"
1362
Push "${_VALICON}"
1363
Push "${_DISPNAME}"
1364
Push "${_ISPROTOCOL}"
1365
Push "${_ISDDE}"
1366
Call un.AddHandlerValues
1367
!verbose pop
1368
!macroend
1369
1370
!macro un.AddHandlerValues
1371
!ifndef un.AddHandlerValues
1372
!verbose push
1373
!verbose ${_MOZFUNC_VERBOSE}
1374
!undef _MOZFUNC_UN
1375
!define _MOZFUNC_UN "un."
1376
1377
!insertmacro AddHandlerValues
1378
1379
!undef _MOZFUNC_UN
1380
!define _MOZFUNC_UN
1381
!verbose pop
1382
!endif
1383
!macroend
1384
1385
/**
1386
* Writes common registry values for a handler that DOES NOT use DDE using SHCTX.
1387
*
1388
* @param _KEY
1389
* The key name in relation to the HKCR root. SOFTWARE\Classes is
1390
* prefixed to this value when using SHCTX.
1391
* @param _VALOPEN
1392
* The path and args to launch the application.
1393
* @param _VALICON
1394
* The path to the binary that contains the icon group for the default icon
1395
* followed by a comma and either the icon group's resource index or the icon
1396
* group's resource id prefixed with a minus sign
1397
* @param _DISPNAME
1398
* The display name for the handler. If emtpy no value will be set.
1399
* @param _ISPROTOCOL
1400
* Sets protocol handler specific registry values when "true".
1401
* Deletes protocol handler specific registry values when "delete".
1402
* Otherwise doesn't touch handler specific registry values.
1403
*
1404
* $R3 = storage for SOFTWARE\Classes
1405
* $R4 = string value of the current registry key path.
1406
* $R5 = _KEY
1407
* $R6 = _VALOPEN
1408
* $R7 = _VALICON
1409
* $R8 = _DISPNAME
1410
* $R9 = _ISPROTOCOL
1411
*/
1412
!macro AddDisabledDDEHandlerValues
1413
1414
!ifndef ${_MOZFUNC_UN}AddDisabledDDEHandlerValues
1415
!verbose push
1416
!verbose ${_MOZFUNC_VERBOSE}
1417
!define ${_MOZFUNC_UN}AddDisabledDDEHandlerValues "!insertmacro ${_MOZFUNC_UN}AddDisabledDDEHandlerValuesCall"
1418
1419
Function ${_MOZFUNC_UN}AddDisabledDDEHandlerValues
1420
Exch $R9 ; _ISPROTOCOL
1421
Exch 1
1422
Exch $R8 ; FriendlyTypeName
1423
Exch 2
1424
Exch $R7 ; icon index
1425
Exch 3
1426
Exch $R6 ; shell\open\command
1427
Exch 4
1428
Exch $R5 ; reg key
1429
Push $R4 ;
1430
Push $R3 ; base reg class
1431
1432
StrCpy $R3 "SOFTWARE\Classes"
1433
StrCmp "$R8" "" +6 +1
1434
ReadRegStr $R4 SHCTX "$R5" "FriendlyTypeName"
1435
1436
StrCmp "$R4" "" +1 +3
1437
WriteRegStr SHCTX "$R3\$R5" "" "$R8"
1438
WriteRegStr SHCTX "$R3\$R5" "FriendlyTypeName" "$R8"
1439
1440
StrCmp "$R9" "true" +1 +2
1441
WriteRegStr SHCTX "$R3\$R5" "URL Protocol" ""
1442
StrCmp "$R9" "delete" +1 +2
1443
DeleteRegValue SHCTX "$R3\$R5" "URL Protocol"
1444
StrCpy $R4 ""
1445
ReadRegDWord $R4 SHCTX "$R3\$R5" "EditFlags"
1446
StrCmp $R4 "" +1 +3 ; Only add EditFlags if a value doesn't exist
1447
DeleteRegValue SHCTX "$R3\$R5" "EditFlags"
1448
WriteRegDWord SHCTX "$R3\$R5" "EditFlags" 0x00000002
1449
1450
StrCmp "$R7" "" +2 +1
1451
WriteRegStr SHCTX "$R3\$R5\DefaultIcon" "" "$R7"
1452
1453
; Main command handler for the app
1454
WriteRegStr SHCTX "$R3\$R5\shell" "" "open"
1455
WriteRegStr SHCTX "$R3\$R5\shell\open\command" "" "$R6"
1456
1457
; Drop support for DDE (bug 491947), and remove old dde entries if
1458
; they exist.
1459
;
1460
; Note, changes in SHCTX should propegate to hkey classes root when
1461
; current user or local machine entries are written. Windows will also
1462
; attempt to propegate entries when a handler is used. CR entries are a
1463
; combination of LM and CU, with CU taking priority.
1464
;
1465
; To disable dde, an empty shell/ddeexec key must be created in current
1466
; user or local machine. Unfortunately, settings have various different
1467
; behaviors depending on the windows version. The following code attempts
1468
; to address these differences.
1469
;
1470
; IE does not configure ddeexec, so issues with left over ddeexec keys
1471
; in LM are reduced. We configure an empty ddeexec key with an empty default
1472
; string in CU to be sure.
1473
;
1474
DeleteRegKey SHCTX "SOFTWARE\Classes\$R5\shell\open\ddeexec"
1475
WriteRegStr SHCTX "SOFTWARE\Classes\$R5\shell\open\ddeexec" "" ""
1476
1477
ClearErrors
1478
1479
Pop $R3
1480
Pop $R4
1481
Exch $R5
1482
Exch 4
1483
Exch $R6
1484
Exch 3
1485
Exch $R7
1486
Exch 2
1487
Exch $R8
1488
Exch 1
1489
Exch $R9
1490
FunctionEnd
1491
1492
!verbose pop
1493
!endif
1494
!macroend
1495
1496
!macro AddDisabledDDEHandlerValuesCall _KEY _VALOPEN _VALICON _DISPNAME _ISPROTOCOL
1497
!verbose push
1498
!verbose ${_MOZFUNC_VERBOSE}
1499
Push "${_KEY}"
1500
Push "${_VALOPEN}"
1501
Push "${_VALICON}"
1502
Push "${_DISPNAME}"
1503
Push "${_ISPROTOCOL}"
1504
Call AddDisabledDDEHandlerValues
1505
!verbose pop
1506
!macroend
1507
1508
!macro un.AddDisabledDDEHandlerValuesCall _KEY _VALOPEN _VALICON _DISPNAME _ISPROTOCOL
1509
!verbose push
1510
!verbose ${_MOZFUNC_VERBOSE}
1511
Push "${_KEY}"
1512
Push "${_VALOPEN}"
1513
Push "${_VALICON}"
1514
Push "${_DISPNAME}"
1515
Push "${_ISPROTOCOL}"
1516
Call un.AddDisabledDDEHandlerValues
1517
!verbose pop
1518
!macroend
1519
1520
!macro un.AddDisabledDDEHandlerValues
1521
!ifndef un.AddDisabledDDEHandlerValues
1522
!verbose push
1523
!verbose ${_MOZFUNC_VERBOSE}
1524
!undef _MOZFUNC_UN
1525
!define _MOZFUNC_UN "un."
1526
1527
!insertmacro AddDisabledDDEHandlerValues
1528
1529
!undef _MOZFUNC_UN
1530
!define _MOZFUNC_UN
1531
!verbose pop
1532
!endif
1533
!macroend
1534
1535
1536
################################################################################
1537
# Macros for handling DLL registration
1538
1539
!macro RegisterDLL DLL
1540
1541
; The x64 regsvr32.exe registers x86 DLL's properly so just use it
1542
; when installing on an x64 systems even when installing an x86 application.
1543
${If} ${RunningX64}
1544
${OrIf} ${IsNativeARM64}
1545
${DisableX64FSRedirection}
1546
ExecWait '"$SYSDIR\regsvr32.exe" /s "${DLL}"'
1547
${EnableX64FSRedirection}
1548
${Else}
1549
RegDLL "${DLL}"
1550
${EndIf}
1551
1552
!macroend
1553
1554
!macro UnregisterDLL DLL
1555
1556
; The x64 regsvr32.exe registers x86 DLL's properly so just use it
1557
; when installing on an x64 systems even when installing an x86 application.
1558
${If} ${RunningX64}
1559
${OrIf} ${IsNativeARM64}
1560
${DisableX64FSRedirection}
1561
ExecWait '"$SYSDIR\regsvr32.exe" /s /u "${DLL}"'
1562
${EnableX64FSRedirection}
1563
${Else}
1564
UnRegDLL "${DLL}"
1565
${EndIf}
1566
1567
!macroend
1568
1569
!define RegisterDLL "!insertmacro RegisterDLL"
1570
!define UnregisterDLL "!insertmacro UnregisterDLL"
1571
1572
1573
################################################################################
1574
# Macros for retrieving existing install paths
1575
1576
/**
1577
* Finds a second installation of the application so we can make informed
1578
* decisions about registry operations. This uses SHCTX to determine the
1579
* registry hive so you must call SetShellVarContext first.
1580
*
1581
* @param _KEY
1582
* The registry subkey (typically this will be Software\Mozilla).
1583
* @return _RESULT
1584
* false if a second install isn't found, path to the main exe if a
1585
* second install is found.
1586
*
1587
* $R3 = stores the long path to $INSTDIR
1588
* $R4 = counter for the outer loop's EnumRegKey
1589
* $R5 = return value from ReadRegStr and RemoveQuotesFromPath
1590
* $R6 = return value from GetParent
1591
* $R7 = return value from the loop's EnumRegKey
1592
* $R8 = storage for _KEY
1593
* $R9 = _KEY and _RESULT
1594
*/
1595
!macro GetSecondInstallPath
1596
1597
!ifndef ${_MOZFUNC_UN}GetSecondInstallPath
1598
!define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
1599
!insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
1600
!insertmacro ${_MOZFUNC_UN_TMP}GetParent
1601
!insertmacro ${_MOZFUNC_UN_TMP}RemoveQuotesFromPath
1602
!undef _MOZFUNC_UN
1603
!define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
1604
!undef _MOZFUNC_UN_TMP
1605
1606
!verbose push
1607
!verbose ${_MOZFUNC_VERBOSE}
1608
!define ${_MOZFUNC_UN}GetSecondInstallPath "!insertmacro ${_MOZFUNC_UN}GetSecondInstallPathCall"
1609
1610
Function ${_MOZFUNC_UN}GetSecondInstallPath
1611
Exch $R9
1612
Push $R8
1613
Push $R7
1614
Push $R6
1615
Push $R5
1616
Push $R4
1617
Push $R3
1618
1619
${${_MOZFUNC_UN}GetLongPath} "$INSTDIR" $R3
1620
1621
StrCpy $R4 0 ; set the counter for the loop to 0
1622
StrCpy $R8 "$R9" ; Registry key path to search
1623
StrCpy $R9 "false" ; default return value
1624
1625
loop:
1626
EnumRegKey $R7 SHCTX $R8 $R4
1627
StrCmp $R7 "" end +1 ; if empty there are no more keys to enumerate
1628
IntOp $R4 $R4 + 1 ; increment the loop's counter
1629
ClearErrors
1630
ReadRegStr $R5 SHCTX "$R8\$R7\bin" "PathToExe"
1631
IfErrors loop
1632
1633
${${_MOZFUNC_UN}RemoveQuotesFromPath} "$R5" $R5
1634
1635
IfFileExists "$R5" +1 loop
1636
${${_MOZFUNC_UN}GetLongPath} "$R5" $R5
1637
${${_MOZFUNC_UN}GetParent} "$R5" $R6
1638
StrCmp "$R6" "$R3" loop +1
1639
StrCmp "$R6\${FileMainEXE}" "$R5" +1 loop
1640
StrCpy $R9 "$R5"
1641
1642
end:
1643
ClearErrors
1644
1645
Pop $R3
1646
Pop $R4
1647
Pop $R5
1648
Pop $R6
1649
Pop $R7
1650
Pop $R8
1651
Exch $R9
1652
FunctionEnd
1653
1654
!verbose pop
1655
!endif
1656
!macroend
1657
1658
!macro GetSecondInstallPathCall _KEY _RESULT
1659
!verbose push
1660
!verbose ${_MOZFUNC_VERBOSE}
1661
Push "${_KEY}"
1662
Call GetSecondInstallPath
1663
Pop ${_RESULT}
1664
!verbose pop
1665
!macroend
1666
1667
!macro un.GetSecondInstallPathCall _KEY _RESULT
1668
!verbose push
1669
!verbose ${_MOZFUNC_VERBOSE}
1670
Push "${_KEY}"
1671
Call un.GetSecondInstallPath
1672
Pop ${_RESULT}
1673
!verbose pop
1674
!macroend
1675
1676
!macro un.GetSecondInstallPath
1677
!ifndef un.GetSecondInstallPath
1678
!verbose push
1679
!verbose ${_MOZFUNC_VERBOSE}
1680
!undef _MOZFUNC_UN
1681
!define _MOZFUNC_UN "un."
1682
1683
!insertmacro GetSecondInstallPath
1684
1685
!undef _MOZFUNC_UN
1686
!define _MOZFUNC_UN
1687
!verbose pop
1688
!endif
1689
!macroend
1690
1691
/**
1692
* Finds an existing installation path for the application based on the
1693
* application's executable name so we can default to using this path for the
1694
* install. If there is zero or more than one installation of the application
1695
* then we default to the default installation path. This uses SHCTX to
1696
* determine the registry hive to read from so you must call SetShellVarContext
1697
* first.
1698
*
1699
* @param _KEY
1700
* The registry subkey (typically this will be Software\Mozilla\App Name).
1701
* @return _RESULT
1702
* false if a single install location for this app name isn't found,
1703
* path to the install directory if a single install location is found.
1704
*
1705
* $R5 = counter for the loop's EnumRegKey
1706
* $R6 = return value from EnumRegKey
1707
* $R7 = return value from ReadRegStr
1708
* $R8 = storage for _KEY
1709
* $R9 = _KEY and _RESULT
1710
*/
1711
!macro GetSingleInstallPath
1712
1713
!ifndef ${_MOZFUNC_UN}GetSingleInstallPath
1714
!define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
1715
!insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
1716
!insertmacro ${_MOZFUNC_UN_TMP}GetParent
1717
!insertmacro ${_MOZFUNC_UN_TMP}RemoveQuotesFromPath
1718
!undef _MOZFUNC_UN
1719
!define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
1720
!undef _MOZFUNC_UN_TMP
1721
1722
!verbose push
1723
!verbose ${_MOZFUNC_VERBOSE}
1724
!define ${_MOZFUNC_UN}GetSingleInstallPath "!insertmacro ${_MOZFUNC_UN}GetSingleInstallPathCall"
1725
1726
Function ${_MOZFUNC_UN}GetSingleInstallPath
1727
Exch $R9
1728
Push $R8
1729
Push $R7
1730
Push $R6
1731
Push $R5
1732
1733
StrCpy $R8 $R9
1734
StrCpy $R9 "false"
1735
StrCpy $R5 0 ; set the counter for the loop to 0
1736
1737
loop:
1738
ClearErrors
1739
EnumRegKey $R6 SHCTX $R8 $R5
1740
IfErrors cleanup
1741
StrCmp $R6 "" cleanup +1 ; if empty there are no more keys to enumerate
1742
IntOp $R5 $R5 + 1 ; increment the loop's counter
1743
ClearErrors
1744
ReadRegStr $R7 SHCTX "$R8\$R6\Main" "PathToExe"
1745
IfErrors loop
1746
${${_MOZFUNC_UN}RemoveQuotesFromPath} "$R7" $R7
1747
GetFullPathName $R7 "$R7"
1748
IfErrors loop
1749
1750
StrCmp "$R9" "false" +1 +3
1751
StrCpy $R9 "$R7"
1752
GoTo Loop
1753
1754
StrCpy $R9 "false"
1755
1756
cleanup:
1757
StrCmp $R9 "false" end +1
1758
${${_MOZFUNC_UN}GetLongPath} "$R9" $R9
1759
${${_MOZFUNC_UN}GetParent} "$R9" $R9
1760
1761
end:
1762
ClearErrors
1763
1764
Pop $R5
1765
Pop $R6
1766
Pop $R7
1767
Pop $R8
1768
Exch $R9
1769
FunctionEnd
1770
1771
!verbose pop
1772
!endif
1773
!macroend
1774
1775
!macro GetSingleInstallPathCall _KEY _RESULT
1776
!verbose push
1777
!verbose ${_MOZFUNC_VERBOSE}
1778
Push "${_KEY}"
1779
Call GetSingleInstallPath
1780
Pop ${_RESULT}
1781
!verbose pop
1782
!macroend
1783
1784
!macro un.GetSingleInstallPathCall _KEY _RESULT
1785
!verbose push
1786
!verbose ${_MOZFUNC_VERBOSE}
1787
Push "${_KEY}"
1788
Call un.GetSingleInstallPath
1789
Pop ${_RESULT}
1790
!verbose pop
1791
!macroend
1792
1793
!macro un.GetSingleInstallPath
1794
!ifndef un.GetSingleInstallPath
1795
!verbose push
1796
!verbose ${_MOZFUNC_VERBOSE}
1797
!undef _MOZFUNC_UN
1798
!define _MOZFUNC_UN "un."
1799
1800
!insertmacro GetSingleInstallPath
1801
1802
!undef _MOZFUNC_UN
1803
!define _MOZFUNC_UN
1804
!verbose pop
1805
!endif
1806
!macroend
1807
1808
/**
1809
* Find the first existing installation for the application.
1810
* This is similar to GetSingleInstallPath, except that it always returns the
1811
* first path it finds, instead of an error when more than one path exists.
1812
*
1813
* The shell context and the registry view should already have been set.
1814
*
1815
* @param _KEY
1816
* The registry subkey (typically Software\Mozilla\App Name).
1817
* @return _RESULT
1818
* path to the install directory of the first location found, or
1819
* the string "false" if no existing installation was found.
1820
*
1821
* $R5 = counter for the loop's EnumRegKey
1822
* $R6 = return value from EnumRegKey
1823
* $R7 = return value from ReadRegStr
1824
* $R8 = storage for _KEY
1825
* $R9 = _KEY and _RESULT
1826
*/
1827
!macro GetFirstInstallPath
1828
!ifndef ${_MOZFUNC_UN}GetFirstInstallPath
1829
!define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
1830
!insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
1831
!insertmacro ${_MOZFUNC_UN_TMP}GetParent
1832
!insertmacro ${_MOZFUNC_UN_TMP}RemoveQuotesFromPath
1833
!undef _MOZFUNC_UN
1834
!define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
1835
!undef _MOZFUNC_UN_TMP
1836
1837
!verbose push
1838
!verbose ${_MOZFUNC_VERBOSE}
1839
!define ${_MOZFUNC_UN}GetFirstInstallPath "!insertmacro ${_MOZFUNC_UN}__GetFirstInstallPathCall"
1840
1841
Function ${_MOZFUNC_UN}__GetFirstInstallPath
1842
Exch $R9
1843
Push $R8
1844
Push $R7
1845
Push $R6
1846
Push $R5
1847
1848
StrCpy $R8 $R9
1849
StrCpy $R9 "false"
1850
StrCpy $R5 0
1851
1852
${Do}
1853
ClearErrors
1854
EnumRegKey $R6 SHCTX $R8 $R5
1855
${If} ${Errors}
1856
${OrIf} $R6 == ""
1857
${Break}
1858
${EndIf}
1859
1860
IntOp $R5 $R5 + 1
1861
1862
ReadRegStr $R7 SHCTX "$R8\$R6\Main" "PathToExe"
1863
${If} ${Errors}
1864
${Continue}
1865
${EndIf}
1866
1867
${${_MOZFUNC_UN}RemoveQuotesFromPath} "$R7" $R7
1868
GetFullPathName $R7 "$R7"
1869
${If} ${Errors}
1870
${Continue}
1871
${EndIf}
1872
1873
StrCpy $R9 "$R7"
1874
${Break}
1875
${Loop}
1876
1877
${If} $R9 != "false"
1878
${${_MOZFUNC_UN}GetLongPath} "$R9" $R9
1879
${${_MOZFUNC_UN}GetParent} "$R9" $R9
1880
${EndIf}
1881
1882
Pop $R5
1883
Pop $R6
1884
Pop $R7
1885
Pop $R8
1886
Exch $R9
1887
FunctionEnd
1888
1889
!verbose pop
1890
!endif
1891
!macroend
1892
1893
!macro __GetFirstInstallPathCall _KEY _RESULT
1894
!verbose push
1895
!verbose ${_MOZFUNC_VERBOSE}
1896
Push "${_KEY}"
1897
Call __GetFirstInstallPath
1898
Pop ${_RESULT}
1899
!verbose pop
1900
!macroend
1901
1902
!macro un.__GetFirstInstallPathCall _KEY _RESULT
1903
!verbose push
1904
!verbose ${_MOZFUNC_VERBOSE}
1905
Push "${_KEY}"
1906
Call un.__GetFirstInstallPath
1907
Pop ${_RESULT}
1908
!verbose pop
1909
!macroend
1910
1911
!macro un.__GetFirstInstallPath
1912
!ifndef un.__GetFirstInstallPath
1913
!verbose push
1914
!verbose ${_MOZFUNC_VERBOSE}
1915
!undef _MOZFUNC_UN
1916
!define _MOZFUNC_UN "un."
1917
1918
!insertmacro __GetFirstInstallPath
1919
1920
!undef _MOZFUNC_UN
1921
!define _MOZFUNC_UN
1922
!verbose pop
1923
!endif
1924
!macroend
1925
1926
1927
################################################################################
1928
# Macros for working with the file system
1929
1930
/**
1931
* Attempts to delete a file if it exists. This will fail if the file is in use.
1932
*
1933
* @param _FILE
1934
* The path to the file that is to be deleted.
1935
*/
1936
!macro DeleteFile _FILE
1937
${If} ${FileExists} "${_FILE}"
1938
Delete "${_FILE}"
1939
${EndIf}
1940
!macroend
1941
!define DeleteFile "!insertmacro DeleteFile"
1942
1943
/**
1944
* Removes a directory if it exists and is empty.
1945
*
1946
* @param _DIR
1947
* The path to the directory that is to be removed.
1948
*/
1949
!macro RemoveDir _DIR
1950
${If} ${FileExists} "${_DIR}"
1951
RmDir "${_DIR}"
1952
${EndIf}
1953
!macroend
1954
!define RemoveDir "!insertmacro RemoveDir"
1955
1956
/**
1957
* Checks whether it is possible to create and delete a directory and a file in
1958
* the install directory. Creation and deletion of files and directories are
1959
* checked since a user may have rights for one and not the other. If creation
1960
* and deletion of a file and a directory are successful this macro will return
1961
* true... if not, this it return false.
1962
*
1963
* @return _RESULT
1964
* true if files and directories can be created and deleted in the
1965
* install directory otherwise false.
1966
*
1967
* $R8 = temporary filename in the installation directory returned from
1968
* GetTempFileName.
1969
* $R9 = _RESULT
1970
*/
1971
!macro CanWriteToInstallDir
1972
1973
!ifndef ${_MOZFUNC_UN}CanWriteToInstallDir
1974
!verbose push
1975
!verbose ${_MOZFUNC_VERBOSE}
1976
!define ${_MOZFUNC_UN}CanWriteToInstallDir "!insertmacro ${_MOZFUNC_UN}CanWriteToInstallDirCall"
1977
1978
Function ${_MOZFUNC_UN}CanWriteToInstallDir
1979
Push $R9
1980
Push $R8
1981
1982
StrCpy $R9 "true"
1983
1984
; IfFileExists returns false for $INSTDIR when $INSTDIR is the root of a
1985
; UNC path so always try to create $INSTDIR
1986
CreateDirectory "$INSTDIR\"
1987
GetTempFileName $R8 "$INSTDIR\"
1988
1989
${Unless} ${FileExists} $R8 ; Can files be created?
1990
StrCpy $R9 "false"
1991
Goto done
1992
${EndUnless}
1993
1994
Delete $R8
1995
${If} ${FileExists} $R8 ; Can files be deleted?
1996
StrCpy $R9 "false"
1997
Goto done
1998
${EndIf}
1999
2000
CreateDirectory $R8
2001
${Unless} ${FileExists} $R8 ; Can directories be created?
2002
StrCpy $R9 "false"
2003
Goto done
2004
${EndUnless}
2005
2006
RmDir $R8
2007
${If} ${FileExists} $R8 ; Can directories be deleted?
2008
StrCpy $R9 "false"
2009
Goto done
2010
${EndIf}
2011
2012
done:
2013
2014
RmDir "$INSTDIR\" ; Only remove $INSTDIR if it is empty
2015
ClearErrors
2016
2017
Pop $R8
2018
Exch $R9
2019
FunctionEnd
2020
2021
!verbose pop
2022
!endif
2023
!macroend
2024
2025
!macro CanWriteToInstallDirCall _RESULT
2026
!verbose push
2027
!verbose ${_MOZFUNC_VERBOSE}
2028
Call CanWriteToInstallDir
2029
Pop ${_RESULT}
2030
!verbose pop
2031
!macroend
2032
2033
!macro un.CanWriteToInstallDirCall _RESULT
2034
!verbose push
2035
!verbose ${_MOZFUNC_VERBOSE}
2036
Call un.CanWriteToInstallDir
2037
Pop ${_RESULT}
2038
!verbose pop
2039
!macroend
2040
2041
!macro un.CanWriteToInstallDir
2042
!ifndef un.CanWriteToInstallDir
2043
!verbose push
2044
!verbose ${_MOZFUNC_VERBOSE}
2045
!undef _MOZFUNC_UN
2046
!define _MOZFUNC_UN "un."
2047
2048
!insertmacro CanWriteToInstallDir
2049
2050
!undef _MOZFUNC_UN
2051
!define _MOZFUNC_UN
2052
!verbose pop
2053
!endif
2054
!macroend
2055
2056
/**
2057
* Checks whether there is sufficient free space available for the installation
2058
* directory using GetDiskFreeSpaceExW which respects disk quotas. This macro
2059
* will calculate the size of all sections that are selected, compare that with
2060
* the free space available, and if there is sufficient free space it will
2061
* return true... if not, it will return false.
2062
*
2063
* @return _RESULT
2064
* "true" if there is sufficient free space otherwise "false".
2065
*
2066
* $R5 = return value from SectionGetSize
2067
* $R6 = return value from SectionGetFlags
2068
* return value from an 'and' comparison of SectionGetFlags (1=selected)
2069
* return value for lpFreeBytesAvailable from GetDiskFreeSpaceExW
2070
* return value for System::Int64Op $R6 / 1024
2071
* return value for System::Int64Op $R6 > $R8
2072
* $R7 = the counter for enumerating the sections
2073
* the temporary file name for the directory created under $INSTDIR passed
2074
* to GetDiskFreeSpaceExW.
2075
* $R8 = sum in KB of all selected sections
2076
* $R9 = _RESULT
2077
*/
2078
!macro CheckDiskSpace
2079
2080
!ifndef ${_MOZFUNC_UN}CheckDiskSpace
2081
!verbose push
2082
!verbose ${_MOZFUNC_VERBOSE}
2083
!define ${_MOZFUNC_UN}CheckDiskSpace "!insertmacro ${_MOZFUNC_UN}CheckDiskSpaceCall"
2084
2085
Function ${_MOZFUNC_UN}CheckDiskSpace
2086
Push $R9
2087
Push $R8
2088
Push $R7
2089
Push $R6
2090
Push $R5
2091
2092
ClearErrors
2093
2094
StrCpy $R9 "true" ; default return value
2095
StrCpy $R8 "0" ; sum in KB of all selected sections
2096
StrCpy $R7 "0" ; counter for enumerating sections
2097
2098
; Enumerate the sections and sum up the sizes of the sections that are
2099
; selected.
2100
SectionGetFlags $R7 $R6
2101
IfErrors +7 +1
2102
IntOp $R6 ${SF_SELECTED} & $R6
2103
IntCmp $R6 0 +3 +1 +1
2104
SectionGetSize $R7 $R5
2105
IntOp $R8 $R8 + $R5
2106
IntOp $R7 $R7 + 1
2107
GoTo -7
2108
2109
; The directory passed to GetDiskFreeSpaceExW must exist for the call to
2110
; succeed. Since the CanWriteToInstallDir macro is called prior to this
2111
; macro the call to CreateDirectory will always succeed.
2112
2113
; IfFileExists returns false for $INSTDIR when $INSTDIR is the root of a
2114
; UNC path so always try to create $INSTDIR
2115
CreateDirectory "$INSTDIR\"
2116
GetTempFileName $R7 "$INSTDIR\"
2117
Delete "$R7"
2118
CreateDirectory "$R7"
2119
2120
System::Call 'kernel32::GetDiskFreeSpaceExW(w, *l, *l, *l) i(R7, .R6, ., .) .'
2121
2122
; Convert to KB for comparison with $R8 which is in KB
2123
System::Int64Op $R6 / 1024
2124
Pop $R6
2125
2126
System::Int64Op $R6 > $R8
2127
Pop $R6
2128
2129
IntCmp $R6 1 end +1 +1
2130
StrCpy $R9 "false"
2131
2132
end:
2133
RmDir "$R7"
2134
RmDir "$INSTDIR\" ; Only remove $INSTDIR if it is empty
2135
2136
ClearErrors
2137
2138
Pop $R5
2139
Pop $R6
2140
Pop $R7
2141
Pop $R8
2142
Exch $R9
2143
FunctionEnd
2144
2145
!verbose pop
2146
!endif
2147
!macroend
2148
2149
!macro CheckDiskSpaceCall _RESULT
2150
!verbose push
2151
!verbose ${_MOZFUNC_VERBOSE}
2152
Call CheckDiskSpace
2153
Pop ${_RESULT}
2154
!verbose pop
2155
!macroend
2156
2157
!macro un.CheckDiskSpaceCall _RESULT
2158
!verbose push
2159
!verbose ${_MOZFUNC_VERBOSE}
2160
Call un.CheckDiskSpace
2161
Pop ${_RESULT}
2162
!verbose pop
2163
!macroend
2164
2165
!macro un.CheckDiskSpace
2166
!ifndef un.CheckDiskSpace
2167
!verbose push
2168
!verbose ${_MOZFUNC_VERBOSE}
2169
!undef _MOZFUNC_UN
2170
!define _MOZFUNC_UN "un."
2171
2172
!insertmacro CheckDiskSpace
2173
2174
!undef _MOZFUNC_UN
2175
!define _MOZFUNC_UN
2176
!verbose pop
2177
!endif
2178
!macroend
2179
2180
/**
2181
* Returns the path found within a passed in string. The path is quoted or not
2182
* with the exception of an unquoted non 8dot3 path without arguments that is
2183
* also not a DefaultIcon path, is a 8dot3 path or not, has command line
2184
* arguments, or is a registry DefaultIcon path (e.g. <path to binary>,# where #
2185
* is the icon's resuorce id). The string does not need to be a valid path or
2186
* exist. It is up to the caller to pass in a string of one of the forms noted
2187
* above and to verify existence if necessary.
2188
*
2189
* Examples:
2190
* In: C:\PROGRA~1\MOZILL~1\FIREFOX.EXE -flag "%1"
2191
* In: C:\PROGRA~1\MOZILL~1\FIREFOX.EXE,0
2192
* In: C:\PROGRA~1\MOZILL~1\FIREFOX.EXE
2193
* In: "C:\PROGRA~1\MOZILL~1\FIREFOX.EXE"
2194
* In: "C:\PROGRA~1\MOZILL~1\FIREFOX.EXE" -flag "%1"
2195
* Out: C:\PROGRA~1\MOZILL~1\FIREFOX.EXE
2196
*
2197
* In: "C:\Program Files\Mozilla Firefox\firefox.exe" -flag "%1"
2198
* In: C:\Program Files\Mozilla Firefox\firefox.exe,0
2199
* In: "C:\Program Files\Mozilla Firefox\firefox.exe"
2200
* Out: C:\Program Files\Mozilla Firefox\firefox.exe
2201
*
2202
* @param _IN_PATH
2203
* The string containing the path.
2204
* @param _OUT_PATH
2205
* The register to store the path to.
2206
*
2207
* $R7 = counter for the outer loop's EnumRegKey
2208
* $R8 = return value from ReadRegStr
2209
* $R9 = _IN_PATH and _OUT_PATH
2210
*/
2211
!macro GetPathFromString
2212
2213
!ifndef ${_MOZFUNC_UN}GetPathFromString
2214
!verbose push
2215
!verbose ${_MOZFUNC_VERBOSE}
2216
!define ${_MOZFUNC_UN}GetPathFromString "!insertmacro ${_MOZFUNC_UN}GetPathFromStringCall"
2217
2218
Function ${_MOZFUNC_UN}GetPathFromString
2219
Exch $R9
2220
Push $R8
2221
Push $R7
2222
2223
StrCpy $R7 0 ; Set the counter to 0.
2224
2225
; Handle quoted paths with arguments.
2226
StrCpy $R8 $R9 1 ; Copy the first char.
2227
StrCmp $R8 '"' +2 +1 ; Is it a "?
2228
StrCmp $R8 "'" +1 +9 ; Is it a '?
2229
StrCpy $R9 $R9 "" 1 ; Remove the first char.
2230
IntOp $R7 $R7 + 1 ; Increment the counter.
2231
StrCpy $R8 $R9 1 $R7 ; Starting from the counter copy the next char.
2232
StrCmp $R8 "" end +1 ; Are there no more chars?
2233
StrCmp $R8 '"' +2 +1 ; Is it a " char?
2234
StrCmp $R8 "'" +1 -4 ; Is it a ' char?
2235
StrCpy $R9 $R9 $R7 ; Copy chars up to the counter.
2236
GoTo end
2237
2238
; Handle DefaultIcon paths. DefaultIcon paths are not quoted and end with
2239
; a , and a number.
2240
IntOp $R7 $R7 - 1 ; Decrement the counter.
2241
StrCpy $R8 $R9 1 $R7 ; Copy one char from the end minus the counter.
2242
StrCmp $R8 '' +4 +1 ; Are there no more chars?
2243
StrCmp $R8 ',' +1 -3 ; Is it a , char?
2244
StrCpy $R9 $R9 $R7 ; Copy chars up to the end minus the counter.
2245
GoTo end
2246
2247
; Handle unquoted paths with arguments. An unquoted path with arguments
2248
; must be an 8dot3 path.
2249
StrCpy $R7 -1 ; Set the counter to -1 so it will start at 0.
2250
IntOp $R7 $R7 + 1 ; Increment the counter.
2251
StrCpy $R8 $R9 1 $R7 ; Starting from the counter copy the next char.
2252
StrCmp $R8 "" end +1 ; Are there no more chars?
2253
StrCmp $R8 " " +1 -3 ; Is it a space char?
2254
StrCpy $R9 $R9 $R7 ; Copy chars up to the counter.
2255
2256
end:
2257
ClearErrors
2258
2259
Pop $R7
2260
Pop $R8
2261
Exch $R9
2262
FunctionEnd
2263
2264
!verbose pop
2265
!endif
2266
!macroend
2267
2268
!macro GetPathFromStringCall _IN_PATH _OUT_PATH
2269
!verbose push
2270
!verbose ${_MOZFUNC_VERBOSE}
2271
Push "${_IN_PATH}"
2272
Call GetPathFromString
2273
Pop ${_OUT_PATH}
2274
!verbose pop
2275
!macroend
2276
2277
!macro un.GetPathFromStringCall _IN_PATH _OUT_PATH
2278
!verbose push
2279
!verbose ${_MOZFUNC_VERBOSE}
2280
Push "${_IN_PATH}"
2281
Call un.GetPathFromString
2282
Pop ${_OUT_PATH}
2283
!verbose pop
2284
!macroend
2285
2286
!macro un.GetPathFromString
2287
!ifndef un.GetPathFromString
2288
!verbose push
2289
!verbose ${_MOZFUNC_VERBOSE}
2290
!undef _MOZFUNC_UN
2291
!define _MOZFUNC_UN "un."
2292
2293
!insertmacro GetPathFromString
2294
2295
!undef _MOZFUNC_UN
2296
!define _MOZFUNC_UN
2297
!verbose pop
2298
!endif
2299
!macroend
2300
2301
/**
2302
* Removes the quotes from each end of a string if present.
2303
*
2304
* @param _IN_PATH
2305
* The string containing the path.
2306
* @param _OUT_PATH
2307
* The register to store the long path.
2308
*
2309
* $R7 = storage for single character comparison
2310
* $R8 = storage for _IN_PATH
2311
* $R9 = _IN_PATH and _OUT_PATH
2312
*/
2313
!macro RemoveQuotesFromPath
2314
2315
!ifndef ${_MOZFUNC_UN}RemoveQuotesFromPath
2316
!verbose push
2317
!verbose ${_MOZFUNC_VERBOSE}
2318
!define ${_MOZFUNC_UN}RemoveQuotesFromPath "!insertmacro ${_MOZFUNC_UN}RemoveQuotesFromPathCall"
2319
2320
Function ${_MOZFUNC_UN}RemoveQuotesFromPath
2321
Exch $R9
2322
Push $R8
2323
Push $R7
2324
2325
StrCpy $R7 "$R9" 1
2326
StrCmp $R7 "$\"" +1 +2
2327
StrCpy $R9 "$R9" "" 1
2328
2329
StrCpy $R7 "$R9" "" -1
2330
StrCmp $R7 "$\"" +1 +2
2331
StrCpy $R9 "$R9" -1
2332
2333
Pop $R7
2334
Pop $R8
2335
Exch $R9
2336
FunctionEnd
2337
2338
!verbose pop
2339
!endif
2340
!macroend
2341
2342
!macro RemoveQuotesFromPathCall _IN_PATH _OUT_PATH
2343
!verbose push
2344
!verbose ${_MOZFUNC_VERBOSE}
2345
Push "${_IN_PATH}"
2346
Call RemoveQuotesFromPath
2347
Pop ${_OUT_PATH}
2348
!verbose pop
2349
!macroend
2350
2351
!macro un.RemoveQuotesFromPathCall _IN_PATH _OUT_PATH
2352
!verbose push
2353
!verbose ${_MOZFUNC_VERBOSE}
2354
Push "${_IN_PATH}"
2355
Call un.RemoveQuotesFromPath
2356
Pop ${_OUT_PATH}
2357
!verbose pop
2358
!macroend
2359
2360
!macro un.RemoveQuotesFromPath
2361
!ifndef un.RemoveQuotesFromPath
2362
!verbose push
2363
!verbose ${_MOZFUNC_VERBOSE}
2364
!undef _MOZFUNC_UN
2365
!define _MOZFUNC_UN "un."
2366
2367
!insertmacro RemoveQuotesFromPath
2368
2369
!undef _MOZFUNC_UN
2370
!define _MOZFUNC_UN
2371
!verbose pop
2372
!endif
2373
!macroend
2374
2375
/**
2376
* Returns the long path for an existing file or directory. GetLongPathNameW
2377
* may not be available on Win95 if Microsoft Layer for Unicode is not
2378
* installed and GetFullPathName only returns a long path for the last file or
2379
* directory that doesn't end with a \ in the path that it is passed. If the
2380
* path does not exist on the file system this will return an empty string. To
2381
* provide a consistent result trailing back-slashes are always removed.
2382
*
2383
* Note: 1024 used by GetLongPathNameW is the maximum NSIS string length.
2384
*
2385
* @param _IN_PATH
2386
* The string containing the path.
2387
* @param _OUT_PATH
2388
* The register to store the long path.
2389
*
2390
* $R4 = counter value when the previous \ was found
2391
* $R5 = directory or file name found during loop
2392
* $R6 = return value from GetLongPathNameW and loop counter
2393
* $R7 = long path from GetLongPathNameW and single char from path for comparison
2394
* $R8 = storage for _IN_PATH
2395
* $R9 = _IN_PATH _OUT_PATH
2396
*/
2397
!macro GetLongPath
2398
2399
!ifndef ${_MOZFUNC_UN}GetLongPath
2400
!verbose push
2401
!verbose ${_MOZFUNC_VERBOSE}
2402
!define ${_MOZFUNC_UN}GetLongPath "!insertmacro ${_MOZFUNC_UN}GetLongPathCall"
2403
2404
Function ${_MOZFUNC_UN}GetLongPath
2405
Exch $R9
2406
Push $R8
2407
Push $R7
2408
Push $R6
2409
Push $R5
2410
Push $R4
2411
2412
ClearErrors
2413
2414
GetFullPathName $R8 "$R9"
2415
IfErrors end_GetLongPath +1 ; If the path doesn't exist return an empty string.
2416
2417
; Make the drive letter uppercase.
2418
StrCpy $R9 "$R8" 1 ; Copy the first char.
2419
StrCpy $R8 "$R8" "" 1 ; Copy everything after the first char.
2420
; Convert the first char to uppercase.
2421
System::Call "User32::CharUpper(w R9 R9)i"
2422
StrCpy $R8 "$R9$R8" ; Copy the uppercase char and the rest of the chars.
2423
2424
; Do it the hard way.
2425
StrCpy $R4 0 ; Stores the position in the string of the last \ found.
2426
StrCpy $R6 -1 ; Set the counter to -1 so it will start at 0.
2427
2428
loop_GetLongPath:
2429
IntOp $R6 $R6 + 1 ; Increment the counter.
2430
StrCpy $R7 $R8 1 $R6 ; Starting from the counter copy the next char.
2431
StrCmp $R7 "" +2 +1 ; Are there no more chars?
2432
StrCmp $R7 "\" +1 -3 ; Is it a \?
2433
2434
; Copy chars starting from the previously found \ to the counter.
2435
StrCpy $R5 $R8 $R6 $R4
2436
2437
; If this is the first \ found we want to swap R9 with R5 so a \ will
2438
; be appended to the drive letter and colon (e.g. C: will become C:\).
2439
StrCmp $R4 0 +1 +3
2440
StrCpy $R9 $R5
2441
StrCpy $R5 ""
2442
2443
GetFullPathName $R9 "$R9\$R5"
2444
2445
StrCmp $R7 "" end_GetLongPath +1 ; Are there no more chars?
2446
2447
; Store the counter for the current \ and prefix it for StrCpy operations.
2448
StrCpy $R4 "+$R6"
2449
IntOp $R6 $R6 + 1 ; Increment the counter so we skip over the \.
2450
StrCpy $R8 $R8 "" $R6 ; Copy chars starting from the counter to the end.
2451
StrCpy $R6 -1 ; Reset the counter to -1 so it will start over at 0.
2452
GoTo loop_GetLongPath
2453
2454
end_GetLongPath:
2455
; If there is a trailing slash remove it
2456
StrCmp $R9 "" +4 +1
2457
StrCpy $R8 "$R9" "" -1
2458
StrCmp $R8 "\" +1 +2
2459
StrCpy $R9 "$R9" -1
2460
2461
ClearErrors
2462
2463
Pop $R4
2464
Pop $R5
2465
Pop $R6
2466
Pop $R7
2467
Pop $R8
2468
Exch $R9
2469
FunctionEnd
2470
2471
!verbose pop
2472
!endif
2473
!macroend
2474
2475
!macro GetLongPathCall _IN_PATH _OUT_PATH
2476
!verbose push
2477
!verbose ${_MOZFUNC_VERBOSE}
2478
Push "${_IN_PATH}"
2479
Call GetLongPath
2480
Pop ${_OUT_PATH}
2481
!verbose pop
2482
!macroend
2483
2484
!macro un.GetLongPathCall _IN_PATH _OUT_PATH
2485
!verbose push
2486
!verbose ${_MOZFUNC_VERBOSE}
2487
Push "${_IN_PATH}"
2488
Call un.GetLongPath
2489
Pop ${_OUT_PATH}
2490
!verbose pop
2491
!macroend
2492
2493
!macro un.GetLongPath
2494
!ifndef un.GetLongPath
2495
!verbose push
2496
!verbose ${_MOZFUNC_VERBOSE}
2497
!undef _MOZFUNC_UN
2498
!define _MOZFUNC_UN "un."
2499
2500
!insertmacro GetLongPath
2501
2502
!undef _MOZFUNC_UN
2503
!define _MOZFUNC_UN
2504
!verbose pop
2505
!endif
2506
!macroend
2507
2508
2509
################################################################################
2510
# Macros for cleaning up the registry and file system
2511
2512
/**
2513
* Removes registry keys that reference this install location and for paths that
2514
* no longer exist. This uses SHCTX to determine the registry hive so you must
2515
* call SetShellVarContext first.
2516
*
2517
* @param _KEY
2518
* The registry subkey (typically this will be Software\Mozilla).
2519
*
2520
* $0 = loop counter
2521
* $1 = temporary value used for string searches
2522
* $R0 = on x64 systems set to 'false' at the beginning of the macro when
2523
* enumerating the x86 registry view and set to 'true' when enumerating
2524
* the x64 registry view.
2525
* $R1 = stores the long path to $INSTDIR
2526
* $R2 = return value from the stack from the GetParent and GetLongPath macros
2527
* $R3 = return value from the outer loop's EnumRegKey and ESR string
2528
* $R4 = return value from the inner loop's EnumRegKey
2529
* $R5 = return value from ReadRegStr
2530
* $R6 = counter for the outer loop's EnumRegKey
2531
* $R7 = counter for the inner loop's EnumRegKey
2532
* $R8 = return value from the stack from the RemoveQuotesFromPath macro
2533
* $R9 = _KEY
2534
*/
2535
!macro RegCleanMain
2536
2537
!ifndef ${_MOZFUNC_UN}RegCleanMain
2538
!define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
2539
!insertmacro ${_MOZFUNC_UN_TMP}GetParent
2540
!insertmacro ${_MOZFUNC_UN_TMP}GetLongPath
2541
!insertmacro ${_MOZFUNC_UN_TMP}RemoveQuotesFromPath
2542
!undef _MOZFUNC_UN
2543
!define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
2544
!undef _MOZFUNC_UN_TMP
2545
2546
!verbose push
2547
!verbose ${_MOZFUNC_VERBOSE}
2548
!define ${_MOZFUNC_UN}RegCleanMain "!insertmacro ${_MOZFUNC_UN}RegCleanMainCall"
2549
2550
Function ${_MOZFUNC_UN}RegCleanMain
2551
Exch $R9
2552
Push $R8
2553
Push $R7
2554
Push $R6
2555
Push $R5
2556
Push $R4
2557
Push $R3
2558
Push $R2
2559
Push $R1
2560
Push $R0
2561
Push $0
2562
Push $1
2563
2564
${${_MOZFUNC_UN}GetLongPath} "$INSTDIR" $R1