-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathcommon.nsh
executable file
·8894 lines (7607 loc) · 245 KB
/
common.nsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
################################################################################
# Helper defines and macros for toolkit applications
/**
* Avoid creating macros / functions that overwrite registers (see the
* GetLongPath macro for one way to avoid this)!
*
* Before using the registers exchange the passed in params and save existing
* register values to the stack.
*
* Exch $R9 ; exhange the original $R9 with the top of the stack
* Exch 1 ; exchange the top of the stack with 1 below the top of the stack
* Exch $R8 ; exchange the original $R8 with the top of the stack
* Exch 2 ; exchange the top of the stack with 2 below the top of the stack
* Exch $R7 ; exchange the original $R7 with the top of the stack
* Push $R6 ; push the original $R6 onto the top of the stack
* Push $R5 ; push the original $R5 onto the top of the stack
* Push $R4 ; push the original $R4 onto the top of the stack
*
* <do stuff>
*
* ; Restore the values.
* Pop $R4 ; restore the value for $R4 from the top of the stack
* Pop $R5 ; restore the value for $R5 from the top of the stack
* Pop $R6 ; restore the value for $R6 from the top of the stack
* Exch $R7 ; exchange the new $R7 value with the top of the stack
* Exch 2 ; exchange the top of the stack with 2 below the top of the stack
* Exch $R8 ; exchange the new $R8 value with the top of the stack
* Exch 1 ; exchange the top of the stack with 2 below the top of the stack
* Exch $R9 ; exchange the new $R9 value with the top of the stack
*
*
* When inserting macros in common.nsh from another macro in common.nsh that
* can be used from the uninstaller _MOZFUNC_UN will be undefined when it is
* inserted. Use the following to redefine _MOZFUNC_UN with its original value
* (see the RegCleanMain macro for an example).
*
* !define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
* !insertmacro ${_MOZFUNC_UN_TMP}FileJoin
* !insertmacro ${_MOZFUNC_UN_TMP}LineFind
* !insertmacro ${_MOZFUNC_UN_TMP}TextCompareNoDetails
* !insertmacro ${_MOZFUNC_UN_TMP}TrimNewLines
* !undef _MOZFUNC_UN
* !define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
* !undef _MOZFUNC_UN_TMP
*/
; When including a file provided by NSIS check if its verbose macro is defined
; to prevent loading the file a second time.
!ifmacrondef TEXTFUNC_VERBOSE
!include TextFunc.nsh
!endif
!ifmacrondef FILEFUNC_VERBOSE
!include FileFunc.nsh
!endif
!ifmacrondef LOGICLIB_VERBOSITY
!include LogicLib.nsh
!endif
!ifndef WINMESSAGES_INCLUDED
!include WinMessages.nsh
!endif
; When including WinVer.nsh check if ___WINVER__NSH___ is defined to prevent
; loading the file a second time.
!ifndef ___WINVER__NSH___
!include WinVer.nsh
!endif
; When including x64.nsh check if ___X64__NSH___ is defined to prevent
; loading the file a second time.
!ifndef ___X64__NSH___
!include x64.nsh
!endif
; NSIS provided macros that we have overridden.
!include overrides.nsh
!define SHORTCUTS_LOG "shortcuts_log.ini"
!define TO_BE_DELETED "tobedeleted"
; !define SHCNF_DWORD 0x0003
; !define SHCNF_FLUSH 0x1000
!ifndef SHCNF_DWORDFLUSH
!define SHCNF_DWORDFLUSH 0x1003
!endif
!ifndef SHCNE_ASSOCCHANGED
!define SHCNE_ASSOCCHANGED 0x08000000
!endif
################################################################################
# Macros for debugging
/**
* The following two macros assist with verifying that a macro doesn't
* overwrite any registers.
*
* Usage:
* ${debugSetRegisters}
* <do stuff>
* ${debugDisplayRegisters}
*/
/**
* Sets all register values to their name to assist with verifying that a macro
* doesn't overwrite any registers.
*/
!macro debugSetRegisters
StrCpy $0 "$$0"
StrCpy $1 "$$1"
StrCpy $2 "$$2"
StrCpy $3 "$$3"
StrCpy $4 "$$4"
StrCpy $5 "$$5"
StrCpy $6 "$$6"
StrCpy $7 "$$7"
StrCpy $8 "$$8"
StrCpy $9 "$$9"
StrCpy $R0 "$$R0"
StrCpy $R1 "$$R1"
StrCpy $R2 "$$R2"
StrCpy $R3 "$$R3"
StrCpy $R4 "$$R4"
StrCpy $R5 "$$R5"
StrCpy $R6 "$$R6"
StrCpy $R7 "$$R7"
StrCpy $R8 "$$R8"
StrCpy $R9 "$$R9"
!macroend
!define debugSetRegisters "!insertmacro debugSetRegisters"
/**
* Displays all register values to assist with verifying that a macro doesn't
* overwrite any registers.
*/
!macro debugDisplayRegisters
MessageBox MB_OK \
"Register Values:$\n\
$$0 = $0$\n$$1 = $1$\n$$2 = $2$\n$$3 = $3$\n$$4 = $4$\n\
$$5 = $5$\n$$6 = $6$\n$$7 = $7$\n$$8 = $8$\n$$9 = $9$\n\
$$R0 = $R0$\n$$R1 = $R1$\n$$R2 = $R2$\n$$R3 = $R3$\n$$R4 = $R4$\n\
$$R5 = $R5$\n$$R6 = $R6$\n$$R7 = $R7$\n$$R8 = $R8$\n$$R9 = $R9"
!macroend
!define debugDisplayRegisters "!insertmacro debugDisplayRegisters"
################################################################################
# Modern User Interface (MUI) override macros
; Removed macros in nsis 2.33u (ported from nsis 2.22)
; MUI_LANGUAGEFILE_DEFINE
; MUI_LANGUAGEFILE_LANGSTRING_PAGE
; MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE
; MUI_LANGUAGEFILE_LANGSTRING_DEFINE
; MUI_LANGUAGEFILE_UNLANGSTRING_PAGE
!macro MOZ_MUI_LANGUAGEFILE_DEFINE DEFINE NAME
!ifndef "${DEFINE}"
!define "${DEFINE}" "${${NAME}}"
!endif
!undef "${NAME}"
!macroend
!macro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE PAGE NAME
!ifdef MUI_${PAGE}PAGE
LangString "${NAME}" 0 "${${NAME}}"
!undef "${NAME}"
!else
!undef "${NAME}"
!endif
!macroend
!macro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE PAGE NAME
!ifdef MUI_${PAGE}PAGE | MUI_UN${PAGE}PAGE
LangString "${NAME}" 0 "${${NAME}}"
!undef "${NAME}"
!else
!undef "${NAME}"
!endif
!macroend
!macro MOZ_MUI_LANGUAGEFILE_LANGSTRING_DEFINE DEFINE NAME
!ifdef "${DEFINE}"
LangString "${NAME}" 0 "${${NAME}}"
!endif
!undef "${NAME}"
!macroend
!macro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE PAGE NAME
!ifdef MUI_UNINSTALLER
!ifdef MUI_UN${PAGE}PAGE
LangString "${NAME}" 0 "${${NAME}}"
!undef "${NAME}"
!else
!undef "${NAME}"
!endif
!else
!undef "${NAME}"
!endif
!macroend
; Modified version of the following MUI macros to support Mozilla localization.
; MUI_LANGUAGE
; MUI_LANGUAGEFILE_BEGIN
; MOZ_MUI_LANGUAGEFILE_END
; See <NSIS App Dir>/Contrib/Modern UI/System.nsh for more information
!define MUI_INSTALLOPTIONS_READ "!insertmacro MUI_INSTALLOPTIONS_READ"
!macro MOZ_MUI_LANGUAGE LANGUAGE
!verbose push
!verbose ${MUI_VERBOSE}
!include "${LANGUAGE}.nsh"
!verbose pop
!macroend
!macro MOZ_MUI_LANGUAGEFILE_BEGIN LANGUAGE
!insertmacro MUI_INSERT
!ifndef "MUI_LANGUAGEFILE_${LANGUAGE}_USED"
!define "MUI_LANGUAGEFILE_${LANGUAGE}_USED"
LoadLanguageFile "${LANGUAGE}.nlf"
!else
!error "Modern UI language file ${LANGUAGE} included twice!"
!endif
!macroend
; Custom version of MUI_LANGUAGEFILE_END. The macro to add the default MUI
; strings and the macros for several strings that are part of the NSIS MUI and
; not in our locale files have been commented out.
!macro MOZ_MUI_LANGUAGEFILE_END
# !include "${NSISDIR}\Contrib\Modern UI\Language files\Default.nsh"
!ifdef MUI_LANGUAGEFILE_DEFAULT_USED
!undef MUI_LANGUAGEFILE_DEFAULT_USED
!warning "${LANGUAGE} Modern UI language file version doesn't match. Using default English texts for missing strings."
!endif
!insertmacro MOZ_MUI_LANGUAGEFILE_DEFINE "MUI_${LANGUAGE}_LANGNAME" "MUI_LANGNAME"
!ifndef MUI_LANGDLL_PUSHLIST
!define MUI_LANGDLL_PUSHLIST "'${MUI_${LANGUAGE}_LANGNAME}' ${LANG_${LANGUAGE}} "
!else
!ifdef MUI_LANGDLL_PUSHLIST_TEMP
!undef MUI_LANGDLL_PUSHLIST_TEMP
!endif
!define MUI_LANGDLL_PUSHLIST_TEMP "${MUI_LANGDLL_PUSHLIST}"
!undef MUI_LANGDLL_PUSHLIST
!define MUI_LANGDLL_PUSHLIST "'${MUI_${LANGUAGE}_LANGNAME}' ${LANG_${LANGUAGE}} ${MUI_LANGDLL_PUSHLIST_TEMP}"
!endif
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE WELCOME "MUI_TEXT_WELCOME_INFO_TITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE WELCOME "MUI_TEXT_WELCOME_INFO_TEXT"
!ifdef MUI_TEXT_LICENSE_TITLE
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE LICENSE "MUI_TEXT_LICENSE_TITLE"
!endif
!ifdef MUI_TEXT_LICENSE_SUBTITLE
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE LICENSE "MUI_TEXT_LICENSE_SUBTITLE"
!endif
!ifdef MUI_INNERTEXT_LICENSE_TOP
!insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE LICENSE "MUI_INNERTEXT_LICENSE_TOP"
!endif
# !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE LICENSE "MUI_INNERTEXT_LICENSE_BOTTOM"
!ifdef MUI_INNERTEXT_LICENSE_BOTTOM_CHECKBOX
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE LICENSE "MUI_INNERTEXT_LICENSE_BOTTOM_CHECKBOX"
!endif
!ifdef MUI_INNERTEXT_LICENSE_BOTTOM_RADIOBUTTONS
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE LICENSE "MUI_INNERTEXT_LICENSE_BOTTOM_RADIOBUTTONS"
!endif
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE COMPONENTS "MUI_TEXT_COMPONENTS_TITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE COMPONENTS "MUI_TEXT_COMPONENTS_SUBTITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE COMPONENTS "MUI_INNERTEXT_COMPONENTS_DESCRIPTION_TITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE COMPONENTS "MUI_INNERTEXT_COMPONENTS_DESCRIPTION_INFO"
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE DIRECTORY "MUI_TEXT_DIRECTORY_TITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE DIRECTORY "MUI_TEXT_DIRECTORY_SUBTITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE STARTMENU "MUI_TEXT_STARTMENU_TITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE STARTMENU "MUI_TEXT_STARTMENU_SUBTITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE STARTMENU "MUI_INNERTEXT_STARTMENU_TOP"
# !insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE STARTMENU "MUI_INNERTEXT_STARTMENU_CHECKBOX"
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_INSTALLING_TITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_INSTALLING_SUBTITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_FINISH_TITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_FINISH_SUBTITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_ABORT_TITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE INSTFILES "MUI_TEXT_ABORT_SUBTITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE FINISH "MUI_BUTTONTEXT_FINISH"
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_INFO_TITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_INFO_TEXT"
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_INFO_REBOOT"
!insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_REBOOTNOW"
!insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_REBOOTLATER"
# !insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_RUN"
# !insertmacro MOZ_MUI_LANGUAGEFILE_MULTILANGSTRING_PAGE FINISH "MUI_TEXT_FINISH_SHOWREADME"
; Support for using the existing MUI_TEXT_ABORTWARNING string
!ifdef MOZ_MUI_CUSTOM_ABORT
LangString MOZ_MUI_TEXT_ABORTWARNING 0 "${MUI_TEXT_ABORTWARNING}"
!endif
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_DEFINE MUI_ABORTWARNING "MUI_TEXT_ABORTWARNING"
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE WELCOME "MUI_UNTEXT_WELCOME_INFO_TITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE WELCOME "MUI_UNTEXT_WELCOME_INFO_TEXT"
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE CONFIRM "MUI_UNTEXT_CONFIRM_TITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE CONFIRM "MUI_UNTEXT_CONFIRM_SUBTITLE"
# !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE LICENSE "MUI_UNTEXT_LICENSE_TITLE"
# !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE LICENSE "MUI_UNTEXT_LICENSE_SUBTITLE"
# !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE LICENSE "MUI_UNINNERTEXT_LICENSE_BOTTOM"
# !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE LICENSE "MUI_UNINNERTEXT_LICENSE_BOTTOM_CHECKBOX"
# !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE LICENSE "MUI_UNINNERTEXT_LICENSE_BOTTOM_RADIOBUTTONS"
# !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE COMPONENTS "MUI_UNTEXT_COMPONENTS_TITLE"
# !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE COMPONENTS "MUI_UNTEXT_COMPONENTS_SUBTITLE"
# !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE DIRECTORY "MUI_UNTEXT_DIRECTORY_TITLE"
# !insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE DIRECTORY "MUI_UNTEXT_DIRECTORY_SUBTITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_UNINSTALLING_TITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_UNINSTALLING_SUBTITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_FINISH_TITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_FINISH_SUBTITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_ABORT_TITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE INSTFILES "MUI_UNTEXT_ABORT_SUBTITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE FINISH "MUI_UNTEXT_FINISH_INFO_TITLE"
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE FINISH "MUI_UNTEXT_FINISH_INFO_TEXT"
!insertmacro MOZ_MUI_LANGUAGEFILE_UNLANGSTRING_PAGE FINISH "MUI_UNTEXT_FINISH_INFO_REBOOT"
!insertmacro MOZ_MUI_LANGUAGEFILE_LANGSTRING_DEFINE MUI_UNABORTWARNING "MUI_UNTEXT_ABORTWARNING"
!ifndef MUI_LANGDLL_LANGUAGES
!define MUI_LANGDLL_LANGUAGES "'${LANGFILE_${LANGUAGE}_NAME}' '${LANG_${LANGUAGE}}' "
!define MUI_LANGDLL_LANGUAGES_CP "'${LANGFILE_${LANGUAGE}_NAME}' '${LANG_${LANGUAGE}}' '${LANG_${LANGUAGE}_CP}' "
!else
!ifdef MUI_LANGDLL_LANGUAGES_TEMP
!undef MUI_LANGDLL_LANGUAGES_TEMP
!endif
!define MUI_LANGDLL_LANGUAGES_TEMP "${MUI_LANGDLL_LANGUAGES}"
!undef MUI_LANGDLL_LANGUAGES
!ifdef MUI_LANGDLL_LANGUAGES_CP_TEMP
!undef MUI_LANGDLL_LANGUAGES_CP_TEMP
!endif
!define MUI_LANGDLL_LANGUAGES_CP_TEMP "${MUI_LANGDLL_LANGUAGES_CP}"
!undef MUI_LANGDLL_LANGUAGES_CP
!define MUI_LANGDLL_LANGUAGES "'${LANGFILE_${LANGUAGE}_NAME}' '${LANG_${LANGUAGE}}' ${MUI_LANGDLL_LANGUAGES_TEMP}"
!define MUI_LANGDLL_LANGUAGES_CP "'${LANGFILE_${LANGUAGE}_NAME}' '${LANG_${LANGUAGE}}' '${LANG_${LANGUAGE}_CP}' ${MUI_LANGDLL_LANGUAGES_CP_TEMP}"
!endif
!macroend
/**
* Creates an InstallOptions file with a UTF-16LE BOM and adds the RTL value
* to the Settings section.
*
* @param _FILE
* The name of the file to be created in $PLUGINSDIR.
*/
!macro InitInstallOptionsFile _FILE
Push $R9
FileOpen $R9 "$PLUGINSDIR\${_FILE}" w
FileWriteWord $R9 "65279"
FileClose $R9
WriteIniStr "$PLUGINSDIR\${_FILE}" "Settings" "RTL" "$(^RTL)"
Pop $R9
!macroend
################################################################################
# Macros for handling files in use
/**
* Checks for files in use in the $INSTDIR directory. To check files in
* sub-directories this macro would need to be rewritten to create
* sub-directories in the temporary directory used to backup the files that are
* checked.
*
* Example usage:
*
* ; The first string to be pushed onto the stack MUST be "end" to indicate
* ; that there are no more files in the $INSTDIR directory to check.
* Push "end"
* Push "freebl3.dll"
* ; The last file pushed should be the app's main exe so if it is in use this
* ; macro will return after the first check.
* Push "${FileMainEXE}"
* ${CheckForFilesInUse} $R9
*
* !IMPORTANT - this macro uses the $R7, $R8, and $R9 registers and makes no
* attempt to restore their original values.
*
* @return _RESULT
* false if all of the files popped from the stack are not in use.
* True if any of the files popped from the stack are in use.
* $R7 = Temporary backup directory where the files will be copied to.
* $R8 = value popped from the stack. This will either be a file name for a file
* in the $INSTDIR directory or "end" to indicate that there are no
* additional files to check.
* $R9 = _RESULT
*/
!macro CheckForFilesInUse
!ifndef ${_MOZFUNC_UN}CheckForFilesInUse
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
!define ${_MOZFUNC_UN}CheckForFilesInUse "!insertmacro ${_MOZFUNC_UN}CheckForFilesInUseCall"
Function ${_MOZFUNC_UN}CheckForFilesInUse
; Create a temporary backup directory.
GetTempFileName $R7 "$INSTDIR"
Delete "$R7"
SetOutPath "$R7"
StrCpy $R9 "false"
Pop $R8
${While} $R8 != "end"
${Unless} ${FileExists} "$INSTDIR\$R8"
Pop $R8 ; get next file to check before continuing
${Continue}
${EndUnless}
ClearErrors
CopyFiles /SILENT "$INSTDIR\$R8" "$R7\$R8" ; try to copy
${If} ${Errors}
; File is in use
StrCpy $R9 "true"
${Break}
${EndIf}
Delete "$INSTDIR\$R8" ; delete original
${If} ${Errors}
; File is in use
StrCpy $R9 "true"
Delete "$R7\$R8" ; delete temp copy
${Break}
${EndIf}
Pop $R8 ; get next file to check
${EndWhile}
; clear stack
${While} $R8 != "end"
Pop $R8
${EndWhile}
; restore everything
SetOutPath "$INSTDIR"
CopyFiles /SILENT "$R7\*" "$INSTDIR\"
RmDir /r "$R7"
SetOutPath "$EXEDIR"
ClearErrors
Push $R9
FunctionEnd
!verbose pop
!endif
!macroend
!macro CheckForFilesInUseCall _RESULT
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
Call CheckForFilesInUse
Pop ${_RESULT}
!verbose pop
!macroend
!macro un.CheckForFilesInUseCall _RESULT
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
Call un.CheckForFilesInUse
Pop ${_RESULT}
!verbose pop
!macroend
!macro un.CheckForFilesInUse
!ifndef un.CheckForFilesInUse
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
!undef _MOZFUNC_UN
!define _MOZFUNC_UN "un."
!insertmacro CheckForFilesInUse
!undef _MOZFUNC_UN
!define _MOZFUNC_UN
!verbose pop
!endif
!macroend
/**
* The macros below will automatically prepend un. to the function names when
* they are defined (e.g. !define un.RegCleanMain).
*/
!verbose push
!verbose 3
!ifndef _MOZFUNC_VERBOSE
!define _MOZFUNC_VERBOSE 3
!endif
!verbose ${_MOZFUNC_VERBOSE}
!define MOZFUNC_VERBOSE "!insertmacro MOZFUNC_VERBOSE"
!define _MOZFUNC_UN
!define _MOZFUNC_S
!verbose pop
!macro MOZFUNC_VERBOSE _VERBOSE
!verbose push
!verbose 3
!undef _MOZFUNC_VERBOSE
!define _MOZFUNC_VERBOSE ${_VERBOSE}
!verbose pop
!macroend
/**
* Displays a MessageBox and then calls abort to prevent continuing to the
* next page when the specified Window Class is found.
*
* @param _WINDOW_CLASS
* The Window Class to search for with FindWindow.
* @param _MSG
* The message text to display in the message box.
*
* $R7 = return value from FindWindow
* $R8 = _WINDOW_CLASS
* $R9 = _MSG
*/
!macro ManualCloseAppPrompt
!ifndef ${_MOZFUNC_UN}ManualCloseAppPrompt
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
!define ${_MOZFUNC_UN}ManualCloseAppPrompt "!insertmacro ${_MOZFUNC_UN}ManualCloseAppPromptCall"
Function ${_MOZFUNC_UN}ManualCloseAppPrompt
Exch $R9
Exch 1
Exch $R8
Push $R7
FindWindow $R7 "$R8"
${If} $R7 <> 0 ; integer comparison
MessageBox MB_OK|MB_ICONQUESTION "$R9"
Abort
${EndIf}
Pop $R7
Exch $R8
Exch 1
Exch $R9
FunctionEnd
!verbose pop
!endif
!macroend
!macro ManualCloseAppPromptCall _WINDOW_CLASS _MSG
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
Push "${_WINDOW_CLASS}"
Push "${_MSG}"
Call ManualCloseAppPrompt
!verbose pop
!macroend
!macro un.ManualCloseAppPromptCall _WINDOW_CLASS _MSG
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
Push "${_WINDOW_CLASS}"
Push "${_MSG}"
Call un.ManualCloseAppPrompt
!verbose pop
!macroend
!macro un.ManualCloseAppPrompt
!ifndef un.ManualCloseAppPrompt
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
!undef _MOZFUNC_UN
!define _MOZFUNC_UN "un."
!insertmacro ManualCloseAppPrompt
!undef _MOZFUNC_UN
!define _MOZFUNC_UN
!verbose pop
!endif
!macroend
################################################################################
# Macros for working with the registry
/**
* Writes a registry string using SHCTX and the supplied params and logs the
* action to the install log and the uninstall log if _LOG_UNINSTALL equals 1.
*
* Define NO_LOG to prevent all logging when calling this from the uninstaller.
*
* @param _ROOT
* The registry key root as defined by NSIS (e.g. HKLM, HKCU, etc.).
* This will only be used for logging.
* @param _KEY
* The subkey in relation to the key root.
* @param _NAME
* The key value name to write to.
* @param _STR
* The string to write to the key value name.
* @param _LOG_UNINSTALL
* 0 = don't add to uninstall log, 1 = add to uninstall log.
*
* $R5 = _ROOT
* $R6 = _KEY
* $R7 = _NAME
* $R8 = _STR
* $R9 = _LOG_UNINSTALL
*/
!macro WriteRegStr2
!ifndef ${_MOZFUNC_UN}WriteRegStr2
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
!define ${_MOZFUNC_UN}WriteRegStr2 "!insertmacro ${_MOZFUNC_UN}WriteRegStr2Call"
Function ${_MOZFUNC_UN}WriteRegStr2
Exch $R9
Exch 1
Exch $R8
Exch 2
Exch $R7
Exch 3
Exch $R6
Exch 4
Exch $R5
ClearErrors
WriteRegStr SHCTX "$R6" "$R7" "$R8"
!ifndef NO_LOG
${If} ${Errors}
${LogMsg} "** ERROR Adding Registry String: $R5 | $R6 | $R7 | $R8 **"
${Else}
${If} $R9 == 1 ; add to the uninstall log?
${LogUninstall} "RegVal: $R5 | $R6 | $R7"
${EndIf}
${LogMsg} "Added Registry String: $R5 | $R6 | $R7 | $R8"
${EndIf}
!endif
Exch $R5
Exch 4
Exch $R6
Exch 3
Exch $R7
Exch 2
Exch $R8
Exch 1
Exch $R9
FunctionEnd
!verbose pop
!endif
!macroend
!macro WriteRegStr2Call _ROOT _KEY _NAME _STR _LOG_UNINSTALL
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
Push "${_ROOT}"
Push "${_KEY}"
Push "${_NAME}"
Push "${_STR}"
Push "${_LOG_UNINSTALL}"
Call WriteRegStr2
!verbose pop
!macroend
!macro un.WriteRegStr2Call _ROOT _KEY _NAME _STR _LOG_UNINSTALL
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
Push "${_ROOT}"
Push "${_KEY}"
Push "${_NAME}"
Push "${_STR}"
Push "${_LOG_UNINSTALL}"
Call un.WriteRegStr2
!verbose pop
!macroend
!macro un.WriteRegStr2
!ifndef un.WriteRegStr2
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
!undef _MOZFUNC_UN
!define _MOZFUNC_UN "un."
!insertmacro WriteRegStr2
!undef _MOZFUNC_UN
!define _MOZFUNC_UN
!verbose pop
!endif
!macroend
/**
* Writes a registry dword using SHCTX and the supplied params and logs the
* action to the install log and the uninstall log if _LOG_UNINSTALL equals 1.
*
* Define NO_LOG to prevent all logging when calling this from the uninstaller.
*
* @param _ROOT
* The registry key root as defined by NSIS (e.g. HKLM, HKCU, etc.).
* This will only be used for logging.
* @param _KEY
* The subkey in relation to the key root.
* @param _NAME
* The key value name to write to.
* @param _DWORD
* The dword to write to the key value name.
* @param _LOG_UNINSTALL
* 0 = don't add to uninstall log, 1 = add to uninstall log.
*
* $R5 = _ROOT
* $R6 = _KEY
* $R7 = _NAME
* $R8 = _DWORD
* $R9 = _LOG_UNINSTALL
*/
!macro WriteRegDWORD2
!ifndef ${_MOZFUNC_UN}WriteRegDWORD2
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
!define ${_MOZFUNC_UN}WriteRegDWORD2 "!insertmacro ${_MOZFUNC_UN}WriteRegDWORD2Call"
Function ${_MOZFUNC_UN}WriteRegDWORD2
Exch $R9
Exch 1
Exch $R8
Exch 2
Exch $R7
Exch 3
Exch $R6
Exch 4
Exch $R5
ClearErrors
WriteRegDWORD SHCTX "$R6" "$R7" "$R8"
!ifndef NO_LOG
${If} ${Errors}
${LogMsg} "** ERROR Adding Registry DWord: $R5 | $R6 | $R7 | $R8 **"
${Else}
${If} $R9 == 1 ; add to the uninstall log?
${LogUninstall} "RegVal: $R5 | $R6 | $R7"
${EndIf}
${LogMsg} "Added Registry DWord: $R5 | $R6 | $R7 | $R8"
${EndIf}
!endif
Exch $R5
Exch 4
Exch $R6
Exch 3
Exch $R7
Exch 2
Exch $R8
Exch 1
Exch $R9
FunctionEnd
!verbose pop
!endif
!macroend
!macro WriteRegDWORD2Call _ROOT _KEY _NAME _DWORD _LOG_UNINSTALL
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
Push "${_ROOT}"
Push "${_KEY}"
Push "${_NAME}"
Push "${_DWORD}"
Push "${_LOG_UNINSTALL}"
Call WriteRegDWORD2
!verbose pop
!macroend
!macro un.WriteRegDWORD2Call _ROOT _KEY _NAME _DWORD _LOG_UNINSTALL
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
Push "${_ROOT}"
Push "${_KEY}"
Push "${_NAME}"
Push "${_DWORD}"
Push "${_LOG_UNINSTALL}"
Call un.WriteRegDWORD2
!verbose pop
!macroend
!macro un.WriteRegDWORD2
!ifndef un.WriteRegDWORD2
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
!undef _MOZFUNC_UN
!define _MOZFUNC_UN "un."
!insertmacro WriteRegDWORD2
!undef _MOZFUNC_UN
!define _MOZFUNC_UN
!verbose pop
!endif
!macroend
/**
* Writes a registry string to HKCR using the supplied params and logs the
* action to the install log and the uninstall log if _LOG_UNINSTALL equals 1.
*
* Define NO_LOG to prevent all logging when calling this from the uninstaller.
*
* @param _ROOT
* The registry key root as defined by NSIS (e.g. HKLM, HKCU, etc.).
* This will only be used for logging.
* @param _KEY
* The subkey in relation to the key root.
* @param _NAME
* The key value name to write to.
* @param _STR
* The string to write to the key value name.
* @param _LOG_UNINSTALL
* 0 = don't add to uninstall log, 1 = add to uninstall log.
*
* $R5 = _ROOT
* $R6 = _KEY
* $R7 = _NAME
* $R8 = _STR
* $R9 = _LOG_UNINSTALL
*/
!macro WriteRegStrHKCR
!ifndef ${_MOZFUNC_UN}WriteRegStrHKCR
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
!define ${_MOZFUNC_UN}WriteRegStrHKCR "!insertmacro ${_MOZFUNC_UN}WriteRegStrHKCRCall"
Function ${_MOZFUNC_UN}WriteRegStrHKCR
Exch $R9
Exch 1
Exch $R8
Exch 2
Exch $R7
Exch 3
Exch $R6
Exch 4
Exch $R5
ClearErrors
WriteRegStr HKCR "$R6" "$R7" "$R8"
!ifndef NO_LOG
${If} ${Errors}
${LogMsg} "** ERROR Adding Registry String: $R5 | $R6 | $R7 | $R8 **"
${Else}
${If} $R9 == 1 ; add to the uninstall log?
${LogUninstall} "RegVal: $R5 | $R6 | $R7"
${EndIf}
${LogMsg} "Added Registry String: $R5 | $R6 | $R7 | $R8"
${EndIf}
!endif
Exch $R5
Exch 4
Exch $R6
Exch 3
Exch $R7
Exch 2
Exch $R8
Exch 1
Exch $R9
FunctionEnd
!verbose pop
!endif
!macroend
!macro WriteRegStrHKCRCall _ROOT _KEY _NAME _STR _LOG_UNINSTALL
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
Push "${_ROOT}"
Push "${_KEY}"
Push "${_NAME}"
Push "${_STR}"
Push "${_LOG_UNINSTALL}"
Call WriteRegStrHKCR
!verbose pop
!macroend
!macro un.WriteRegStrHKCRCall _ROOT _KEY _NAME _STR _LOG_UNINSTALL
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
Push "${_ROOT}"
Push "${_KEY}"
Push "${_NAME}"
Push "${_STR}"
Push "${_LOG_UNINSTALL}"
Call un.WriteRegStrHKCR
!verbose pop
!macroend
!macro un.WriteRegStrHKCR
!ifndef un.WriteRegStrHKCR
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
!undef _MOZFUNC_UN
!define _MOZFUNC_UN "un."
!insertmacro WriteRegStrHKCR
!undef _MOZFUNC_UN
!define _MOZFUNC_UN
!verbose pop
!endif
!macroend
!ifndef KEY_SET_VALUE
!define KEY_SET_VALUE 0x0002
!endif
!ifndef KEY_WOW64_64KEY
!define KEY_WOW64_64KEY 0x0100
!endif
!ifndef HAVE_64BIT_BUILD
!define CREATE_KEY_SAM ${KEY_SET_VALUE}
!else
!define CREATE_KEY_SAM ${KEY_SET_VALUE}|${KEY_WOW64_64KEY}
!endif
/**
* Creates a registry key. This will log the actions to the install and
* uninstall logs. Alternatively you can set a registry value to create the key
* and then delete the value.
*
* Define NO_LOG to prevent all logging when calling this from the uninstaller.
*
* @param _ROOT
* The registry key root as defined by NSIS (e.g. HKLM, HKCU, etc.).
* @param _KEY
* The subkey in relation to the key root.
* @param _LOG_UNINSTALL
* 0 = don't add to uninstall log, 1 = add to uninstall log.
*
* $R4 = [out] handle to newly created registry key. If this is not a key
* located in one of the predefined registry keys this must be closed
* with RegCloseKey (this should not be needed unless someone decides to
* do something extremely squirrelly with NSIS).
* $R5 = return value from RegCreateKeyExW (represented by R5 in the system call).
* $R6 = [in] hKey passed to RegCreateKeyExW.
* $R7 = _ROOT
* $R8 = _KEY
* $R9 = _LOG_UNINSTALL
*/
!macro CreateRegKey
!ifndef ${_MOZFUNC_UN}CreateRegKey
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
!define ${_MOZFUNC_UN}CreateRegKey "!insertmacro ${_MOZFUNC_UN}CreateRegKeyCall"