VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditionsCommon.nsh@ 83531

Last change on this file since 83531 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 24.4 KB
Line 
1; $Id: VBoxGuestAdditionsCommon.nsh 82968 2020-02-04 10:35:17Z vboxsync $
2;; @file
3; VBoxGuestAdditionsCommon.nsh - Common / shared utility functions.
4;
5
6;
7; Copyright (C) 2006-2020 Oracle Corporation
8;
9; This file is part of VirtualBox Open Source Edition (OSE), as
10; available from http://www.virtualbox.org. This file is free software;
11; you can redistribute it and/or modify it under the terms of the GNU
12; General Public License (GPL) as published by the Free Software
13; Foundation, in version 2 as it comes in the "COPYING" file of the
14; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16;
17
18Function Common_CopyFiles
19
20 SetOutPath "$INSTDIR"
21 SetOverwrite on
22
23!ifdef VBOX_WITH_LICENSE_INSTALL_RTF
24 ; Copy license file (if any) into the installation directory
25 FILE "/oname=${LICENSE_FILE_RTF}" "$%VBOX_BRAND_LICENSE_RTF%"
26!endif
27
28 FILE "$%VBOX_PATH_DIFX%\DIFxAPI.dll"
29 FILE "$%PATH_OUT%\bin\additions\VBoxDrvInst.exe"
30
31 FILE "$%PATH_OUT%\bin\additions\VBoxVideo.inf"
32!ifdef VBOX_SIGN_ADDITIONS
33 FILE "$%PATH_OUT%\bin\additions\VBoxVideo.cat"
34!endif
35
36 FILE "iexplore.ico"
37
38FunctionEnd
39
40!ifndef UNINSTALLER_ONLY
41Function ExtractFiles
42
43 ; @todo: Use a define for all the file specs to group the files per module
44 ; and keep the redundancy low
45
46 Push $0
47 StrCpy "$0" "$INSTDIR\$%BUILD_TARGET_ARCH%"
48
49 ; Root files
50 SetOutPath "$0"
51!if $%VBOX_WITH_LICENSE_INSTALL_RTF% == "1"
52 FILE "/oname=${LICENSE_FILE_RTF}" "$%VBOX_BRAND_LICENSE_RTF%"
53!endif
54
55 ; Video driver
56 SetOutPath "$0\VBoxVideo"
57 FILE "$%PATH_OUT%\bin\additions\VBoxVideo.sys"
58 FILE "$%PATH_OUT%\bin\additions\VBoxVideo.inf"
59!ifdef VBOX_SIGN_ADDITIONS
60 FILE "$%PATH_OUT%\bin\additions\VBoxVideo.cat"
61!endif
62 FILE "$%PATH_OUT%\bin\additions\VBoxDisp.dll"
63
64!if $%VBOX_WITH_WDDM% == "1"
65 ; WDDM Video driver
66 SetOutPath "$0\VBoxWddm"
67
68 !ifdef VBOX_SIGN_ADDITIONS
69 FILE "$%PATH_OUT%\bin\additions\VBoxWddm.cat"
70 !endif
71 FILE "$%PATH_OUT%\bin\additions\VBoxWddm.sys"
72 FILE "$%PATH_OUT%\bin\additions\VBoxWddm.inf"
73 FILE "$%PATH_OUT%\bin\additions\VBoxDispD3D.dll"
74 !if $%VBOX_WITH_MESA3D% == "1"
75 FILE "$%PATH_OUT%\bin\additions\VBoxNine.dll"
76 FILE "$%PATH_OUT%\bin\additions\VBoxSVGA.dll"
77 FILE "$%PATH_OUT%\bin\additions\VBoxICD.dll"
78 FILE "$%PATH_OUT%\bin\additions\VBoxGL.dll"
79 !endif
80
81 !if $%BUILD_TARGET_ARCH% == "amd64"
82 FILE "$%PATH_OUT%\bin\additions\VBoxDispD3D-x86.dll"
83 !if $%VBOX_WITH_MESA3D% == "1"
84 FILE "$%PATH_OUT%\bin\additions\VBoxNine-x86.dll"
85 FILE "$%PATH_OUT%\bin\additions\VBoxSVGA-x86.dll"
86 FILE "$%PATH_OUT%\bin\additions\VBoxICD-x86.dll"
87 FILE "$%PATH_OUT%\bin\additions\VBoxGL-x86.dll"
88 !endif
89
90 !endif ; $%BUILD_TARGET_ARCH% == "amd64"
91!endif ; $%VBOX_WITH_WDDM% == "1"
92
93 ; Mouse driver
94 SetOutPath "$0\VBoxMouse"
95 FILE "$%PATH_OUT%\bin\additions\VBoxMouse.sys"
96 FILE "$%PATH_OUT%\bin\additions\VBoxMouse.inf"
97!ifdef VBOX_SIGN_ADDITIONS
98 FILE "$%PATH_OUT%\bin\additions\VBoxMouse.cat"
99!endif
100
101!if $%BUILD_TARGET_ARCH% == "x86"
102 SetOutPath "$0\VBoxMouse\NT4"
103 FILE "$%PATH_OUT%\bin\additions\VBoxMouseNT.sys"
104!endif
105
106 ; Guest driver
107 SetOutPath "$0\VBoxGuest"
108 FILE "$%PATH_OUT%\bin\additions\VBoxGuest.sys"
109 FILE "$%PATH_OUT%\bin\additions\VBoxGuest.inf"
110!ifdef VBOX_SIGN_ADDITIONS
111 FILE "$%PATH_OUT%\bin\additions\VBoxGuest.cat"
112!endif
113 FILE "$%PATH_OUT%\bin\additions\VBoxTray.exe"
114 FILE "$%PATH_OUT%\bin\additions\VBoxHook.dll"
115 FILE "$%PATH_OUT%\bin\additions\VBoxControl.exe"
116
117 ; VBoxService
118 SetOutPath "$0\Bin"
119 FILE "$%PATH_OUT%\bin\additions\VBoxService.exe"
120
121 ; Shared Folders
122 SetOutPath "$0\VBoxSF"
123 FILE "$%PATH_OUT%\bin\additions\VBoxSF.sys"
124 FILE "$%PATH_OUT%\bin\additions\VBoxMRXNP.dll"
125 !if $%BUILD_TARGET_ARCH% == "amd64"
126 ; Only 64-bit installer: Also copy 32-bit DLLs on 64-bit target
127 FILE "$%PATH_OUT%\bin\additions\VBoxMRXNP-x86.dll"
128 !endif
129
130 ; Auto-Logon
131 SetOutPath "$0\AutoLogon"
132 FILE "$%PATH_OUT%\bin\additions\VBoxGINA.dll"
133 FILE "$%PATH_OUT%\bin\additions\VBoxCredProv.dll"
134
135 ; Misc tools
136 SetOutPath "$0\Tools"
137 FILE "$%PATH_OUT%\bin\additions\VBoxDrvInst.exe"
138 FILE "$%VBOX_PATH_DIFX%\DIFxAPI.dll"
139
140!if $%BUILD_TARGET_ARCH% == "x86"
141 SetOutPath "$0\Tools\NT4"
142 FILE "$%PATH_OUT%\bin\additions\VBoxGuestDrvInst.exe"
143 FILE "$%PATH_OUT%\bin\additions\RegCleanup.exe"
144!endif
145
146 Pop $0
147
148FunctionEnd
149!endif ; UNINSTALLER_ONLY
150
151!macro CheckArchitecture un
152Function ${un}CheckArchitecture
153
154 Push $0
155
156 System::Call "kernel32::GetCurrentProcess() i .s"
157 System::Call "kernel32::IsWow64Process(i s, *i .r0)"
158 ; R0 now contains 1 if we're a 64-bit process, or 0 if not
159
160!if $%BUILD_TARGET_ARCH% == "amd64"
161 IntCmp $0 0 wrong_platform
162!else ; 32-bit
163 IntCmp $0 1 wrong_platform
164!endif
165
166 Push 0
167 Goto exit
168
169wrong_platform:
170
171 Push 1
172 Goto exit
173
174exit:
175
176FunctionEnd
177!macroend
178!insertmacro CheckArchitecture ""
179!insertmacro CheckArchitecture "un."
180
181;
182; Macro for retrieving the Windows version this installer is running on.
183;
184; @return Stack: Windows version string. Empty on error /
185; if not able to identify.
186;
187!macro GetWindowsVersionEx un
188Function ${un}GetWindowsVersionEx
189
190 Push $0
191 Push $1
192
193 ; Check if we are running on Windows 2000 or above
194 ; For other windows versions (> XP) it may be necessary to change winver.nsh
195 Call ${un}GetWindowsVersion
196 Pop $0 ; Windows Version
197
198 Push $0 ; The windows version string
199 Push "NT" ; String to search for. W2K+ returns no string containing "NT"
200 Call ${un}StrStr
201 Pop $1
202
203 ${If} $1 == "" ; If empty -> not NT 3.XX or 4.XX
204 ; $0 contains the original version string
205 ${Else}
206 ; Ok we know it is NT. Must be a string like NT X.XX
207 Push $0 ; The windows version string
208 Push "4." ; String to search for
209 Call ${un}StrStr
210 Pop $1
211 ${If} $1 == "" ; If empty -> not NT 4
212 ;; @todo NT <= 3.x ?
213 ; $0 contains the original version string
214 ${Else}
215 StrCpy $0 "NT4"
216 ${EndIf}
217 ${EndIf}
218
219 Pop $1
220 Exch $0
221
222FunctionEnd
223!macroend
224!insertmacro GetWindowsVersionEx ""
225!insertmacro GetWindowsVersionEx "un."
226
227!macro GetAdditionsVersion un
228Function ${un}GetAdditionsVersion
229
230 Push $0
231 Push $1
232
233 ; Get additions version
234 ReadRegStr $0 HKLM "SOFTWARE\$%VBOX_VENDOR_SHORT%\VirtualBox Guest Additions" "Version"
235
236 ; Get revision
237 ReadRegStr $g_strAddVerRev HKLM "SOFTWARE\$%VBOX_VENDOR_SHORT%\VirtualBox Guest Additions" "Revision"
238
239 ; Extract major version
240 Push "$0" ; String
241 Push "." ; SubString
242 Push ">" ; SearchDirection
243 Push "<" ; StrInclusionDirection
244 Push "0" ; IncludeSubString
245 Push "0" ; Loops
246 Push "0" ; CaseSensitive
247 Call ${un}StrStrAdv
248 Pop $g_strAddVerMaj
249
250 ; Extract minor version
251 Push "$0" ; String
252 Push "." ; SubString
253 Push ">" ; SearchDirection
254 Push ">" ; StrInclusionDirection
255 Push "0" ; IncludeSubString
256 Push "0" ; Loops
257 Push "0" ; CaseSensitive
258 Call ${un}StrStrAdv
259 Pop $1 ; Got first part (e.g. "1.5")
260
261 Push "$1" ; String
262 Push "." ; SubString
263 Push ">" ; SearchDirection
264 Push "<" ; StrInclusionDirection
265 Push "0" ; IncludeSubString
266 Push "0" ; Loops
267 Push "0" ; CaseSensitive
268 Call ${un}StrStrAdv
269 Pop $g_strAddVerMin ; Extracted second part (e.g. "5" from "1.5")
270
271 ; Extract build number
272 Push "$0" ; String
273 Push "." ; SubString
274 Push "<" ; SearchDirection
275 Push ">" ; StrInclusionDirection
276 Push "0" ; IncludeSubString
277 Push "0" ; Loops
278 Push "0" ; CaseSensitive
279 Call ${un}StrStrAdv
280 Pop $g_strAddVerBuild
281
282exit:
283
284 Pop $1
285 Pop $0
286
287FunctionEnd
288!macroend
289!insertmacro GetAdditionsVersion ""
290!insertmacro GetAdditionsVersion "un."
291
292!macro StopVBoxService un
293Function ${un}StopVBoxService
294
295 Push $0 ; Temp results
296 Push $1
297 Push $2 ; Image name of VBoxService
298 Push $3 ; Safety counter
299
300 StrCpy $3 "0" ; Init counter
301 ${LogVerbose} "Stopping VBoxService ..."
302
303svc_stop:
304
305 ${LogVerbose} "Stopping VBoxService via SCM ..."
306 ${If} $g_strWinVersion == "NT4"
307 nsExec::Exec '"$SYSDIR\net.exe" stop VBoxService'
308 ${Else}
309 nsExec::Exec '"$SYSDIR\SC.exe" stop VBoxService'
310 ${EndIf}
311 Sleep "1000" ; Wait a bit
312
313exe_stop:
314
315!ifdef _DEBUG
316 ${LogVerbose} "Stopping VBoxService (as exe) ..."
317!endif
318
319exe_stop_loop:
320
321 IntCmp $3 10 exit ; Only try this loop 10 times max
322 IntOp $3 $3 + 1 ; Increment
323
324!ifdef _DEBUG
325 ${LogVerbose} "Stopping attempt #$3"
326!endif
327
328 StrCpy $2 "VBoxService.exe"
329
330 ${nsProcess::FindProcess} $2 $0
331 StrCmp $0 0 0 exit
332
333 ${nsProcess::KillProcess} $2 $0
334 Sleep "1000" ; Wait a bit
335 Goto exe_stop_loop
336
337exit:
338
339 ${LogVerbose} "Stopping VBoxService done"
340
341 Pop $3
342 Pop $2
343 Pop $1
344 Pop $0
345
346FunctionEnd
347!macroend
348!insertmacro StopVBoxService ""
349!insertmacro StopVBoxService "un."
350
351!macro StopVBoxTray un
352Function ${un}StopVBoxTray
353
354 Push $0 ; Temp results
355 Push $1 ; Safety counter
356
357 StrCpy $1 "0" ; Init counter
358 ${LogVerbose} "Stopping VBoxTray ..."
359
360exe_stop:
361
362 IntCmp $1 10 exit ; Only try this loop 10 times max
363 IntOp $1 $1 + 1 ; Increment
364
365 ${nsProcess::FindProcess} "VBoxTray.exe" $0
366 StrCmp $0 0 0 exit
367
368 ${nsProcess::KillProcess} "VBoxTray.exe" $0
369 Sleep "1000" ; Wait a bit
370 Goto exe_stop
371
372exit:
373
374 ${LogVerbose} "Stopping VBoxTray done"
375
376 Pop $1
377 Pop $0
378
379FunctionEnd
380!macroend
381!insertmacro StopVBoxTray ""
382!insertmacro StopVBoxTray "un."
383
384!macro StopVBoxMMR un
385Function ${un}StopVBoxMMR
386
387 Push $0 ; Temp results
388 Push $1 ; Safety counter
389
390 StrCpy $1 "0" ; Init counter
391 DetailPrint "Stopping VBoxMMR ..."
392
393exe_stop:
394
395 IntCmp $1 10 exit ; Only try this loop 10 times max
396 IntOp $1 $1 + 1 ; Increment
397
398 ${nsProcess::FindProcess} "VBoxMMR.exe" $0
399 StrCmp $0 0 0 exit
400
401 ${nsProcess::KillProcess} "VBoxMMR.exe" $0
402 Sleep "1000" ; Wait a bit
403 Goto exe_stop
404
405exit:
406
407 DetailPrint "Stopping VBoxMMR done."
408
409 Pop $1
410 Pop $0
411
412FunctionEnd
413!macroend
414!insertmacro StopVBoxMMR ""
415!insertmacro StopVBoxMMR "un."
416
417!macro WriteRegBinR ROOT KEY NAME VALUE
418 WriteRegBin "${ROOT}" "${KEY}" "${NAME}" "${VALUE}"
419!macroend
420
421!macro AbortShutdown un
422Function ${un}AbortShutdown
423
424 ${If} ${FileExists} "$g_strSystemDir\shutdown.exe"
425 ; Try to abort the shutdown
426 ${CmdExecute} "$\"$g_strSystemDir\shutdown.exe$\" -a" "true"
427 ${Else}
428 ${LogVerbose} "Shutting down not supported: Binary $\"$g_strSystemDir\shutdown.exe$\" not found"
429 ${EndIf}
430
431FunctionEnd
432!macroend
433!insertmacro AbortShutdown ""
434!insertmacro AbortShutdown "un."
435
436!macro CheckForWDDMCapability un
437Function ${un}CheckForWDDMCapability
438
439!if $%VBOX_WITH_WDDM% == "1"
440 ; If we're on a 32-bit Windows Vista / 7 / 8 we can use the WDDM driver
441 ${If} $g_strWinVersion == "Vista"
442 ${OrIf} $g_strWinVersion == "7"
443 ${OrIf} $g_strWinVersion == "8"
444 ${OrIf} $g_strWinVersion == "8_1"
445 ${OrIf} $g_strWinVersion == "10"
446 StrCpy $g_bCapWDDM "true"
447 ${LogVerbose} "OS is WDDM driver capable"
448 ${EndIf}
449 ; If we're on Windows 8 we *have* to use the WDDM driver, so select it
450 ; by default
451 ${If} $g_strWinVersion == "8"
452 ${OrIf} $g_strWinVersion == "8_1"
453 ${OrIf} $g_strWinVersion == "10"
454 StrCpy $g_bWithWDDM "true"
455 ${LogVerbose} "OS needs WDDM driver by default"
456 ${EndIf}
457!endif
458
459FunctionEnd
460!macroend
461!insertmacro CheckForWDDMCapability ""
462!insertmacro CheckForWDDMCapability "un."
463
464!macro CheckForCapabilities un
465Function ${un}CheckForCapabilities
466
467 Push $0
468
469 ; Retrieve system mode and store result in
470 System::Call 'user32::GetSystemMetrics(i ${SM_CLEANBOOT}) i .r0'
471 StrCpy $g_iSystemMode $0
472
473 ; Does the guest have a DLL cache?
474 ${If} $g_strWinVersion == "NT4"
475 ${OrIf} $g_strWinVersion == "2000"
476 ${OrIf} $g_strWinVersion == "XP"
477 StrCpy $g_bCapDllCache "true"
478 ${LogVerbose} "OS has a DLL cache"
479 ${EndIf}
480
481 ; Check whether this OS is capable of handling WDDM drivers
482 Call ${un}CheckForWDDMCapability
483
484 Pop $0
485
486FunctionEnd
487!macroend
488!insertmacro CheckForCapabilities ""
489!insertmacro CheckForCapabilities "un."
490
491; Switches (back) the path + registry view to
492; 32-bit mode (SysWOW64) on 64-bit guests
493!macro SetAppMode32 un
494Function ${un}SetAppMode32
495 !if $%BUILD_TARGET_ARCH% == "amd64"
496 ${EnableX64FSRedirection}
497 SetRegView 32
498 !endif
499FunctionEnd
500!macroend
501!insertmacro SetAppMode32 ""
502!insertmacro SetAppMode32 "un."
503
504; Because this NSIS installer is always built in 32-bit mode, we have to
505; do some tricks for the Windows paths + registry on 64-bit guests
506!macro SetAppMode64 un
507Function ${un}SetAppMode64
508 !if $%BUILD_TARGET_ARCH% == "amd64"
509 ${DisableX64FSRedirection}
510 SetRegView 64
511 !endif
512FunctionEnd
513!macroend
514!insertmacro SetAppMode64 ""
515!insertmacro SetAppMode64 "un."
516
517;
518; Retrieves the vendor ("CompanyName" of FILEINFO structure)
519; of a given file.
520; @return Stack: Company name, or "" on error/if not found.
521; @param Stack: File name to retrieve vendor for.
522;
523!macro GetFileVendor un
524Function ${un}GetFileVendor
525
526 ; Preserve values
527 Exch $0 ; Stack: $0 <filename> (Get file name into $0)
528 Push $1
529
530 IfFileExists "$0" found
531 Goto not_found
532
533found:
534
535 VBoxGuestInstallHelper::FileGetVendor "$0"
536 ; Stack: <vendor> $1 $0
537 Pop $0 ; Get vendor
538 Pop $1 ; Restore $1
539 Exch $0 ; Restore $0, push vendor on top of stack
540 Goto end
541
542not_found:
543
544 Pop $1
545 Pop $0
546 Push "File not found"
547 Goto end
548
549end:
550
551FunctionEnd
552!macroend
553!insertmacro GetFileVendor ""
554!insertmacro GetFileVendor "un."
555
556;
557; Retrieves the architecture of a given file.
558; @return Stack: Architecture ("x86", "amd64") or error message.
559; @param Stack: File name to retrieve architecture for.
560;
561!macro GetFileArchitecture un
562Function ${un}GetFileArchitecture
563
564 ; Preserve values
565 Exch $0 ; Stack: $0 <filename> (Get file name into $0)
566 Push $1
567
568 IfFileExists "$0" found
569 Goto not_found
570
571found:
572
573 ${LogVerbose} "Getting architecture of file $\"$0$\" ..."
574
575 VBoxGuestInstallHelper::FileGetArchitecture "$0"
576
577 ; Stack: <architecture> $1 $0
578 Pop $0 ; Get architecture string
579
580 ${LogVerbose} "Architecture is: $0"
581
582 Pop $1 ; Restore $1
583 Exch $0 ; Restore $0, push vendor on top of stack
584 Goto end
585
586not_found:
587
588 Pop $1
589 Pop $0
590 Push "File not found"
591 Goto end
592
593end:
594
595FunctionEnd
596!macroend
597!insertmacro GetFileArchitecture ""
598!insertmacro GetFileArchitecture "un."
599
600;
601; Verifies a given file by checking its file vendor and target
602; architecture.
603; @return Stack: "0" if valid, "1" if not, "2" on error / not found.
604; @param Stack: Architecture ("x86" or "amd64").
605; @param Stack: Vendor.
606; @param Stack: File name to verify.
607;
608!macro VerifyFile un
609Function ${un}VerifyFile
610
611 ; Preserve values
612 Exch $0 ; File; S: old$0 vendor arch
613 Exch ; S: vendor old$0 arch
614 Exch $1 ; Vendor; S: old$1 old$0 arch
615 Exch ; S: old$0 old$1 arch
616 Exch 2 ; S: arch old$1 old$0
617 Exch $2 ; Architecture; S: old$2 old$1 old$0
618 Push $3 ; S: old$3 old$2 old$1 old$0
619
620 ${LogVerbose} "Verifying file $\"$0$\" (vendor: $1, arch: $2) ..."
621
622 IfFileExists "$0" check_arch
623 Goto not_found
624
625check_arch:
626
627 ${LogVerbose} "File $\"$0$\" found"
628
629 Push $0
630 Call ${un}GetFileArchitecture
631 Pop $3
632
633 ${LogVerbose} "Architecture is: $3"
634
635 ${If} $3 == $2
636 Goto check_vendor
637 ${EndIf}
638 Goto invalid
639
640check_vendor:
641
642 Push $0
643 Call ${un}GetFileVendor
644 Pop $3
645
646 ${LogVerbose} "Vendor is: $3"
647
648 ${If} $3 == $1
649 Goto valid
650 ${EndIf}
651
652invalid:
653
654 ${LogVerbose} "File $\"$0$\" is invalid"
655
656 StrCpy $3 "1" ; Invalid
657 Goto end
658
659valid:
660
661 ${LogVerbose} "File $\"$0$\" is valid"
662
663 StrCpy $3 "0" ; Valid
664 Goto end
665
666not_found:
667
668 ${LogVerbose} "File $\"$0$\" was not found"
669
670 StrCpy $3 "2" ; Not found
671 Goto end
672
673end:
674
675 ; S: old$3 old$2 old$1 old$0
676 Exch $3 ; S: $3 old$2 old$1 old$0
677 Exch ; S: old$2 $3 old$1
678 Pop $2 ; S: $3 old$1 old$0
679 Exch ; S: old$1 $3 old$0
680 Pop $1 ; S: $3 old$0
681 Exch ; S: old$0 $3
682 Pop $0 ; S: $3
683
684FunctionEnd
685!macroend
686!insertmacro VerifyFile ""
687!insertmacro VerifyFile "un."
688
689;
690; Macro for accessing VerifyFile in a more convenient way by using
691; a parameter list.
692; @return Stack: "0" if valid, "1" if not, "2" on error / not found.
693; @param Un/Installer prefix; either "" or "un".
694; @param Name of file to verify.
695; @param Vendor to check for.
696; @param Architecture ("x86" or "amd64") to check for.
697;
698!macro VerifyFileEx un File Vendor Architecture
699 Push $0
700 Push "${Architecture}"
701 Push "${Vendor}"
702 Push "${File}"
703 Call ${un}VerifyFile
704 Pop $0
705 ${If} $0 == "0"
706 ${LogVerbose} "Verification of file $\"${File}$\" successful (Vendor: ${Vendor}, Architecture: ${Architecture})"
707 ${ElseIf} $0 == "1"
708 ${LogVerbose} "Verification of file $\"${File}$\" failed (not Vendor: ${Vendor}, and/or not Architecture: ${Architecture})"
709 ${Else}
710 ${LogVerbose} "Skipping to file $\"${File}$\"; not found"
711 ${EndIf}
712 ; Push result popped off the stack to stack again
713 Push $0
714!macroend
715!define VerifyFileEx "!insertmacro VerifyFileEx"
716
717;
718; Macro for copying a file only if the source file is verified
719; to be from a certain vendor and architecture.
720; @return Stack: "0" if copied, "1" if not, "2" on error / not found.
721; @param Un/Installer prefix; either "" or "un".
722; @param Name of file to verify and copy to destination.
723; @param Destination name to copy verified file to.
724; @param Vendor to check for.
725; @param Architecture ("x86" or "amd64") to check for.
726;
727!macro CopyFileEx un FileSrc FileDest Vendor Architecture
728 Push $0
729 Push "${Architecture}"
730 Push "${Vendor}"
731 Push "${FileSrc}"
732 Call ${un}VerifyFile
733 Pop $0
734 ${If} $0 == "0"
735 ${LogVerbose} "Copying verified file $\"${FileSrc}$\" to $\"${FileDest}$\" ..."
736 ClearErrors
737 SetOverwrite on
738 CopyFiles /SILENT "${FileSrc}" "${FileDest}"
739 ${If} ${Errors}
740 CreateDirectory "$TEMP\${PRODUCT_NAME}"
741 ${GetFileName} "${FileSrc}" $0 ; Get the base name
742 CopyFiles /SILENT "${FileSrc}" "$TEMP\${PRODUCT_NAME}\$0"
743 ${LogVerbose} "Immediate installation failed, postponing to next reboot (temporary location is: $\"$TEMP\${PRODUCT_NAME}\$0$\") ..."
744 ;${InstallFileEx} "${un}" "${FileSrc}" "${FileDest}" "$TEMP" ; Only works with compile time files!
745 System::Call "kernel32::MoveFileEx(t '$TEMP\${PRODUCT_NAME}\$0', t '${FileDest}', i 5)"
746 ${EndIf}
747 ${Else}
748 ${LogVerbose} "Skipping to copy file $\"${FileSrc}$\" to $\"${FileDest}$\" (not Vendor: ${Vendor}, Architecture: ${Architecture})"
749 ${EndIf}
750 ; Push result popped off the stack to stack again
751 Push $0
752!macroend
753!define CopyFileEx "!insertmacro CopyFileEx"
754
755;
756; Macro for installing a library/DLL.
757; @return Stack: "0" if copied, "1" if not, "2" on error / not found.
758; @param Un/Installer prefix; either "" or "un".
759; @param Name of lib/DLL to copy to destination.
760; @param Destination name to copy the source file to.
761; @param Temporary folder used for exchanging the (locked) lib/DLL after a reboot.
762;
763!macro InstallFileEx un FileSrc FileDest DirTemp
764 ${LogVerbose} "Installing library $\"${FileSrc}$\" to $\"${FileDest}$\" ..."
765 ; Try the gentle way and replace the file instantly
766 !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "${FileSrc}" "${FileDest}" "${DirTemp}"
767 ; If the above call didn't help, use a (later) reboot to replace the file
768 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "${FileSrc}" "${FileDest}" "${DirTemp}"
769!macroend
770!define InstallFileEx "!insertmacro InstallFileEx"
771
772;
773; Macro for installing a library/DLL.
774; @return Stack: "0" if copied, "1" if not, "2" on error / not found.
775; @param Un/Installer prefix; either "" or "un".
776; @param Name of lib/DLL to verify and copy to destination.
777; @param Destination name to copy verified file to.
778; @param Temporary folder used for exchanging the (locked) lib/DLL after a reboot.
779; @param Vendor to check for.
780; @param Architecture ("x86" or "amd64") to check for.
781;
782!macro InstallFileVerify un FileSrc FileDest DirTemp Vendor Architecture
783 Push $0
784 Push "${Architecture}"
785 Push "${Vendor}"
786 Push "${FileSrc}"
787 ${LogVerbose} "Verifying library $\"${FileSrc}$\" ..."
788 Call ${un}VerifyFile
789 Pop $0
790 ${If} $0 == "0"
791 ${InstallFileEx} ${un} ${FileSrc} ${FileDest} ${DirTemp}
792 ${Else}
793 ${LogVerbose} "File $\"${FileSrc}$\" did not pass verification (Vendor: ${Vendor}, Architecture: ${Architecture})"
794 ${EndIf}
795 ; Push result popped off the stack to stack again.
796 Push $0
797!macroend
798!define InstallFileVerify "!insertmacro InstallFileVerify"
799
800; Prepares the access rights for replacing
801; a WRP (Windows Resource Protection) protected file
802!macro PrepareWRPFile un
803Function ${un}PrepareWRPFile
804
805 Pop $0
806 Push $1
807
808 ${IfNot} ${FileExists} "$0"
809 ${LogVerbose} "WRP: File $\"$0$\" does not exist, skipping"
810 Return
811 ${EndIf}
812
813 ${Switch} $g_strWinVersion
814 ${Case} "NT4"
815 ${Case} "2000"
816 ${Case} "XP"
817 ${LogVerbose} "WRP: changing ownership or permissions is not required on NT4, 2000, XP."
818 ${Break}
819 ${Default}
820 ${CmdExecute} "$\"$g_strSystemDir\takeown.exe$\" /A /F $\"$0$\"" "true"
821 Pop $1
822 ${LogVerbose} "WRP: Changing ownership for $\"$0$\" returned: $1"
823
824 ${CmdExecute} "icacls.exe $\"$0$\" /grant *S-1-5-32-544:F" "true"
825 Pop $1
826 ${LogVerbose} "WRP: Changing DACL for $\"$0$\" returned: $1"
827
828 Sleep 1000 ; TrustedInstaller needs some time to forget about the file
829 ${EndSwitch}
830
831!if $%VBOX_WITH_GUEST_INSTALL_HELPER% == "1"
832 !ifdef WFP_FILE_EXCEPTION
833 VBoxGuestInstallHelper::DisableWFP "$0"
834 Pop $1 ; Get return value (ignored for now)
835 ${LogVerbose} "WRP: Setting WFP exception for $\"$0$\" returned: $1"
836 !endif
837!endif
838
839 Pop $1
840
841FunctionEnd
842!macroend
843!insertmacro PrepareWRPFile ""
844!insertmacro PrepareWRPFile "un."
845
846;
847; Macro for preparing the access rights for replacing
848; a WRP (Windows Resource Protection) protected file.
849; @return None.
850; @param Path of file to prepare.
851;
852!macro PrepareWRPFileEx un FileSrc
853 Push $0
854 Push "${FileSrc}"
855 Call ${un}PrepareWRPFile
856 Pop $0
857!macroend
858!define PrepareWRPFileEx "!insertmacro PrepareWRPFileEx"
859
860; Note: We don't ship modified Direct3D files anymore, but we need to (try to)
861; restore the original (backed up) DLLs when upgrading from an old(er)
862; installation.
863;
864; Restores formerly backed up Direct3D original files, which were replaced by
865; a VBox XPDM driver installation before. This might be necessary for upgrading a
866; XPDM installation to a WDDM one.
867; @return Stack: "0" if files were restored successfully; otherwise "1".
868;
869!macro RestoreFilesDirect3D un
870Function ${un}RestoreFilesDirect3D
871
872 Push $0
873
874 ; We need to switch to 64-bit app mode to handle the "real" 64-bit files in
875 ; "system32" on a 64-bit guest
876 Call ${un}SetAppMode64
877
878 ; Note: Not finding a file (like *d3d8.dll) on Windows Vista/7 is fine;
879 ; it simply is not present there.
880
881 ; Note 2: On 64-bit systems there are no 64-bit *d3d8 DLLs, only 32-bit ones
882 ; in SysWOW64 (or in system32 on 32-bit systems).
883
884 ${LogVerbose} "Restoring original D3D files ..."
885!if $%BUILD_TARGET_ARCH% == "x86"
886 ${PrepareWRPFileEx} "${un}" "$SYSDIR\d3d8.dll"
887 ${CopyFileEx} "${un}" "$SYSDIR\msd3d8.dll" "$SYSDIR\d3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
888!endif
889 ${PrepareWRPFileEx} "${un}" "$SYSDIR\d3d9.dll"
890 ${CopyFileEx} "${un}" "$SYSDIR\msd3d9.dll" "$SYSDIR\d3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
891
892 ${If} $g_bCapDllCache == "true"
893!if $%BUILD_TARGET_ARCH% == "x86"
894 ${PrepareWRPFileEx} "${un}" "$SYSDIR\dllcache\d3d8.dll"
895 ${CopyFileEx} "${un}" "$SYSDIR\dllcache\msd3d8.dll" "$SYSDIR\dllcache\d3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
896!endif
897 ${PrepareWRPFileEx} "${un}" "$SYSDIR\dllcache\d3d9.dll"
898 ${CopyFileEx} "${un}" "$SYSDIR\dllcache\msd3d9.dll" "$SYSDIR\dllcache\d3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
899 ${EndIf}
900
901!if $%BUILD_TARGET_ARCH% == "amd64"
902 ${PrepareWRPFileEx} "${un}" "$g_strSysWow64\d3d8.dll"
903 ${CopyFileEx} "${un}" "$g_strSysWow64\msd3d8.dll" "$g_strSysWow64\d3d8.dll" "Microsoft Corporation" "x86"
904 ${PrepareWRPFileEx} "${un}" "$g_strSysWow64\d3d9.dll"
905 ${CopyFileEx} "${un}" "$g_strSysWow64\msd3d9.dll" "$g_strSysWow64\d3d9.dll" "Microsoft Corporation" "x86"
906
907 ${If} $g_bCapDllCache == "true"
908 ${PrepareWRPFileEx} "${un}" "$g_strSysWow64\dllcache\d3d8.dll"
909 ${CopyFileEx} "${un}" "$g_strSysWow64\dllcache\msd3d8.dll" "$g_strSysWow64\dllcache\d3d8.dll" "Microsoft Corporation" "x86"
910 ${PrepareWRPFileEx} "${un}" "$g_strSysWow64\dllcache\d3d9.dll"
911 ${CopyFileEx} "${un}" "$g_strSysWow64\dllcache\msd3d9.dll" "$g_strSysWow64\dllcache\d3d9.dll" "Microsoft Corporation" "x86"
912 ${EndIf}
913!endif
914
915 Pop $0
916
917FunctionEnd
918!macroend
919!insertmacro RestoreFilesDirect3D ""
920!insertmacro RestoreFilesDirect3D "un."
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette