VirtualBox

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

Last change on this file since 85800 was 85006, checked in by vboxsync, 4 years ago

GA/Installer/WinNT: Prevent a repeated recovery of d3d9.dll, bugref:9725

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 22.0 KB
Line 
1; $Id: VBoxGuestAdditionsCommon.nsh 85006 2020-06-30 11:15:18Z 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\$%KBUILD_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 $%KBUILD_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 ; $%KBUILD_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 $%KBUILD_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 $%KBUILD_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 $%KBUILD_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 $%KBUILD_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 CheckForCapabilities un
437Function ${un}CheckForCapabilities
438
439 Push $0
440
441 ; Retrieve system mode and store result in
442 System::Call 'user32::GetSystemMetrics(i ${SM_CLEANBOOT}) i .r0'
443 StrCpy $g_iSystemMode $0
444
445 ; Does the guest have a DLL cache?
446 ${If} $g_strWinVersion == "NT4"
447 ${OrIf} $g_strWinVersion == "2000"
448 ${OrIf} $g_strWinVersion == "XP"
449 StrCpy $g_bCapDllCache "true"
450 ${LogVerbose} "OS has a DLL cache"
451 ${EndIf}
452
453 ${If} $g_strWinVersion == "2000"
454 ${OrIf} $g_strWinVersion == "XP"
455 ${OrIf} $g_strWinVersion == "2003"
456 ${OrIf} $g_strWinVersion == "Vista"
457 ${OrIf} $g_strWinVersion == "7"
458 StrCpy $g_bCapXPDM "true"
459 ${LogVerbose} "OS is XPDM driver capable"
460 ${EndIf}
461
462!if $%VBOX_WITH_WDDM% == "1"
463 ; By default use the WDDM driver on Vista+
464 ${If} $g_strWinVersion == "Vista"
465 ${OrIf} $g_strWinVersion == "7"
466 ${OrIf} $g_strWinVersion == "8"
467 ${OrIf} $g_strWinVersion == "8_1"
468 ${OrIf} $g_strWinVersion == "10"
469 StrCpy $g_bWithWDDM "true"
470 StrCpy $g_bCapWDDM "true"
471 ${LogVerbose} "OS is WDDM driver capable"
472 ${EndIf}
473!endif
474
475 Pop $0
476
477FunctionEnd
478!macroend
479!insertmacro CheckForCapabilities ""
480!insertmacro CheckForCapabilities "un."
481
482; Switches (back) the path + registry view to
483; 32-bit mode (SysWOW64) on 64-bit guests
484!macro SetAppMode32 un
485Function ${un}SetAppMode32
486 !if $%KBUILD_TARGET_ARCH% == "amd64"
487 ${EnableX64FSRedirection}
488 SetRegView 32
489 !endif
490FunctionEnd
491!macroend
492!insertmacro SetAppMode32 ""
493!insertmacro SetAppMode32 "un."
494
495; Because this NSIS installer is always built in 32-bit mode, we have to
496; do some tricks for the Windows paths + registry on 64-bit guests
497!macro SetAppMode64 un
498Function ${un}SetAppMode64
499 !if $%KBUILD_TARGET_ARCH% == "amd64"
500 ${DisableX64FSRedirection}
501 SetRegView 64
502 !endif
503FunctionEnd
504!macroend
505!insertmacro SetAppMode64 ""
506!insertmacro SetAppMode64 "un."
507
508;
509; Retrieves the vendor ("CompanyName" of FILEINFO structure)
510; of a given file.
511; @return Stack: Company name, or "" on error/if not found.
512; @param Stack: File name to retrieve vendor for.
513;
514!macro GetFileVendor un
515Function ${un}GetFileVendor
516
517 ; Preserve values
518 Exch $0 ; Stack: $0 <filename> (Get file name into $0)
519 Push $1
520
521 IfFileExists "$0" found
522 Goto not_found
523
524found:
525
526 VBoxGuestInstallHelper::FileGetVendor "$0"
527 ; Stack: <vendor> $1 $0
528 Pop $0 ; Get vendor
529 Pop $1 ; Restore $1
530 Exch $0 ; Restore $0, push vendor on top of stack
531 Goto end
532
533not_found:
534
535 Pop $1
536 Pop $0
537 Push "File not found"
538 Goto end
539
540end:
541
542FunctionEnd
543!macroend
544!insertmacro GetFileVendor ""
545!insertmacro GetFileVendor "un."
546
547;
548; Retrieves the architecture of a given file.
549; @return Stack: Architecture ("x86", "amd64") or error message.
550; @param Stack: File name to retrieve architecture for.
551;
552!macro GetFileArchitecture un
553Function ${un}GetFileArchitecture
554
555 ; Preserve values
556 Exch $0 ; Stack: $0 <filename> (Get file name into $0)
557 Push $1
558
559 IfFileExists "$0" found
560 Goto not_found
561
562found:
563
564 ${LogVerbose} "Getting architecture of file $\"$0$\" ..."
565
566 VBoxGuestInstallHelper::FileGetArchitecture "$0"
567
568 ; Stack: <architecture> $1 $0
569 Pop $0 ; Get architecture string
570
571 ${LogVerbose} "Architecture is: $0"
572
573 Pop $1 ; Restore $1
574 Exch $0 ; Restore $0, push vendor on top of stack
575 Goto end
576
577not_found:
578
579 Pop $1
580 Pop $0
581 Push "File not found"
582 Goto end
583
584end:
585
586FunctionEnd
587!macroend
588!insertmacro GetFileArchitecture ""
589!insertmacro GetFileArchitecture "un."
590
591;
592; Verifies a given file by checking its file vendor and target
593; architecture.
594; @return Stack: "0" if valid, "1" if not, "2" on error / not found.
595; @param Stack: Architecture ("x86" or "amd64").
596; @param Stack: Vendor.
597; @param Stack: File name to verify.
598;
599!macro VerifyFile un
600Function ${un}VerifyFile
601
602 ; Preserve values
603 Exch $0 ; File; S: old$0 vendor arch
604 Exch ; S: vendor old$0 arch
605 Exch $1 ; Vendor; S: old$1 old$0 arch
606 Exch ; S: old$0 old$1 arch
607 Exch 2 ; S: arch old$1 old$0
608 Exch $2 ; Architecture; S: old$2 old$1 old$0
609 Push $3 ; S: old$3 old$2 old$1 old$0
610
611 ${LogVerbose} "Verifying file $\"$0$\" (vendor: $1, arch: $2) ..."
612
613 IfFileExists "$0" check_arch
614 Goto not_found
615
616check_arch:
617
618 ${LogVerbose} "File $\"$0$\" found"
619
620 Push $0
621 Call ${un}GetFileArchitecture
622 Pop $3
623
624 ${LogVerbose} "Architecture is: $3"
625
626 ${If} $3 == $2
627 Goto check_vendor
628 ${EndIf}
629 Goto invalid
630
631check_vendor:
632
633 Push $0
634 Call ${un}GetFileVendor
635 Pop $3
636
637 ${LogVerbose} "Vendor is: $3"
638
639 ${If} $3 == $1
640 Goto valid
641 ${EndIf}
642
643invalid:
644
645 ${LogVerbose} "File $\"$0$\" is invalid"
646
647 StrCpy $3 "1" ; Invalid
648 Goto end
649
650valid:
651
652 ${LogVerbose} "File $\"$0$\" is valid"
653
654 StrCpy $3 "0" ; Valid
655 Goto end
656
657not_found:
658
659 ${LogVerbose} "File $\"$0$\" was not found"
660
661 StrCpy $3 "2" ; Not found
662 Goto end
663
664end:
665
666 ; S: old$3 old$2 old$1 old$0
667 Exch $3 ; S: $3 old$2 old$1 old$0
668 Exch ; S: old$2 $3 old$1
669 Pop $2 ; S: $3 old$1 old$0
670 Exch ; S: old$1 $3 old$0
671 Pop $1 ; S: $3 old$0
672 Exch ; S: old$0 $3
673 Pop $0 ; S: $3
674
675FunctionEnd
676!macroend
677!insertmacro VerifyFile ""
678!insertmacro VerifyFile "un."
679
680;
681; Macro for accessing VerifyFile in a more convenient way by using
682; a parameter list.
683; @return Stack: "0" if valid, "1" if not, "2" on error / not found.
684; @param Un/Installer prefix; either "" or "un".
685; @param Name of file to verify.
686; @param Vendor to check for.
687; @param Architecture ("x86" or "amd64") to check for.
688;
689!macro VerifyFileEx un File Vendor Architecture
690 Push $0
691 Push "${Architecture}"
692 Push "${Vendor}"
693 Push "${File}"
694 Call ${un}VerifyFile
695 Pop $0
696 ${If} $0 == "0"
697 ${LogVerbose} "Verification of file $\"${File}$\" successful (Vendor: ${Vendor}, Architecture: ${Architecture})"
698 ${ElseIf} $0 == "1"
699 ${LogVerbose} "Verification of file $\"${File}$\" failed (not Vendor: ${Vendor}, and/or not Architecture: ${Architecture})"
700 ${Else}
701 ${LogVerbose} "Skipping to file $\"${File}$\"; not found"
702 ${EndIf}
703 ; Push result popped off the stack to stack again
704 Push $0
705!macroend
706!define VerifyFileEx "!insertmacro VerifyFileEx"
707
708;
709; Macro for copying a file only if the source file is verified
710; to be from a certain vendor and architecture.
711; @return Stack: "0" if copied, "1" if not, "2" on error / not found.
712; @param Un/Installer prefix; either "" or "un".
713; @param Name of file to verify and copy to destination.
714; @param Destination name to copy verified file to.
715; @param Vendor to check for.
716; @param Architecture ("x86" or "amd64") to check for.
717;
718!macro CopyFileEx un FileSrc FileDest Vendor Architecture
719 Push $0
720 Push "${Architecture}"
721 Push "${Vendor}"
722 Push "${FileSrc}"
723 Call ${un}VerifyFile
724 Pop $0
725
726 Push "${Architecture}"
727 Push "Oracle Corporation"
728 Push "${FileDest}"
729 Call ${un}VerifyFile
730 Pop $0
731
732 ${If} $0 == "0"
733 ${LogVerbose} "Copying verified file $\"${FileSrc}$\" to $\"${FileDest}$\" ..."
734 ClearErrors
735 SetOverwrite on
736 CopyFiles /SILENT "${FileSrc}" "${FileDest}"
737 ${If} ${Errors}
738 CreateDirectory "$TEMP\${PRODUCT_NAME}"
739 ${GetFileName} "${FileSrc}" $0 ; Get the base name
740 CopyFiles /SILENT "${FileSrc}" "$TEMP\${PRODUCT_NAME}\$0"
741 ${LogVerbose} "Immediate installation failed, postponing to next reboot (temporary location is: $\"$TEMP\${PRODUCT_NAME}\$0$\") ..."
742 ;${InstallFileEx} "${un}" "${FileSrc}" "${FileDest}" "$TEMP" ; Only works with compile time files!
743 System::Call "kernel32::MoveFileEx(t '$TEMP\${PRODUCT_NAME}\$0', t '${FileDest}', i 5)"
744 ${EndIf}
745 ${Else}
746 ${LogVerbose} "Skipping to copy file $\"${FileSrc}$\" to $\"${FileDest}$\" (not Vendor: ${Vendor}, Architecture: ${Architecture})"
747 ${EndIf}
748 ; Push result popped off the stack to stack again
749 Push $0
750!macroend
751!define CopyFileEx "!insertmacro CopyFileEx"
752
753;
754; Macro for installing a library/DLL.
755; @return Stack: "0" if copied, "1" if not, "2" on error / not found.
756; @param Un/Installer prefix; either "" or "un".
757; @param Name of lib/DLL to copy to destination.
758; @param Destination name to copy the source file to.
759; @param Temporary folder used for exchanging the (locked) lib/DLL after a reboot.
760;
761!macro InstallFileEx un FileSrc FileDest DirTemp
762 ${LogVerbose} "Installing library $\"${FileSrc}$\" to $\"${FileDest}$\" ..."
763 ; Try the gentle way and replace the file instantly
764 !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "${FileSrc}" "${FileDest}" "${DirTemp}"
765 ; If the above call didn't help, use a (later) reboot to replace the file
766 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "${FileSrc}" "${FileDest}" "${DirTemp}"
767!macroend
768!define InstallFileEx "!insertmacro InstallFileEx"
769
770;
771; Macro for installing a library/DLL.
772; @return Stack: "0" if copied, "1" if not, "2" on error / not found.
773; @param Un/Installer prefix; either "" or "un".
774; @param Name of lib/DLL to verify and copy to destination.
775; @param Destination name to copy verified file to.
776; @param Temporary folder used for exchanging the (locked) lib/DLL after a reboot.
777; @param Vendor to check for.
778; @param Architecture ("x86" or "amd64") to check for.
779;
780!macro InstallFileVerify un FileSrc FileDest DirTemp Vendor Architecture
781 Push $0
782 Push "${Architecture}"
783 Push "${Vendor}"
784 Push "${FileSrc}"
785 ${LogVerbose} "Verifying library $\"${FileSrc}$\" ..."
786 Call ${un}VerifyFile
787 Pop $0
788 ${If} $0 == "0"
789 ${InstallFileEx} ${un} ${FileSrc} ${FileDest} ${DirTemp}
790 ${Else}
791 ${LogVerbose} "File $\"${FileSrc}$\" did not pass verification (Vendor: ${Vendor}, Architecture: ${Architecture})"
792 ${EndIf}
793 ; Push result popped off the stack to stack again.
794 Push $0
795!macroend
796!define InstallFileVerify "!insertmacro InstallFileVerify"
797
798
799; Note: We don't ship modified Direct3D files anymore, but we need to (try to)
800; restore the original (backed up) DLLs when upgrading from an old(er)
801; installation.
802;
803; Restores formerly backed up Direct3D original files, which were replaced by
804; a VBox XPDM driver installation before. This might be necessary for upgrading a
805; XPDM installation to a WDDM one.
806; @return Stack: "0" if files were restored successfully; otherwise "1".
807;
808!macro RestoreFilesDirect3D un
809Function ${un}RestoreFilesDirect3D
810 ${If} $g_bCapXPDM != "true"
811 ${LogVerbose} "RestoreFilesDirect3D: XPDM is not supported"
812 Return
813 ${EndIf}
814
815 Push $0
816
817 ; We need to switch to 64-bit app mode to handle the "real" 64-bit files in
818 ; "system32" on a 64-bit guest
819 Call ${un}SetAppMode64
820
821 ${LogVerbose} "Restoring original D3D files ..."
822 ${CopyFileEx} "${un}" "$SYSDIR\msd3d8.dll" "$SYSDIR\d3d8.dll" "Microsoft Corporation" "$%KBUILD_TARGET_ARCH%"
823 ${CopyFileEx} "${un}" "$SYSDIR\msd3d9.dll" "$SYSDIR\d3d9.dll" "Microsoft Corporation" "$%KBUILD_TARGET_ARCH%"
824
825 ${If} $g_bCapDllCache == "true"
826 ${CopyFileEx} "${un}" "$SYSDIR\dllcache\msd3d8.dll" "$SYSDIR\dllcache\d3d8.dll" "Microsoft Corporation" "$%KBUILD_TARGET_ARCH%"
827 ${CopyFileEx} "${un}" "$SYSDIR\dllcache\msd3d9.dll" "$SYSDIR\dllcache\d3d9.dll" "Microsoft Corporation" "$%KBUILD_TARGET_ARCH%"
828 ${EndIf}
829
830!if $%KBUILD_TARGET_ARCH% == "amd64"
831 ${CopyFileEx} "${un}" "$g_strSysWow64\msd3d8.dll" "$g_strSysWow64\d3d8.dll" "Microsoft Corporation" "x86"
832 ${CopyFileEx} "${un}" "$g_strSysWow64\msd3d9.dll" "$g_strSysWow64\d3d9.dll" "Microsoft Corporation" "x86"
833
834 ${If} $g_bCapDllCache == "true"
835 ${CopyFileEx} "${un}" "$g_strSysWow64\dllcache\msd3d8.dll" "$g_strSysWow64\dllcache\d3d8.dll" "Microsoft Corporation" "x86"
836 ${CopyFileEx} "${un}" "$g_strSysWow64\dllcache\msd3d9.dll" "$g_strSysWow64\dllcache\d3d9.dll" "Microsoft Corporation" "x86"
837 ${EndIf}
838!endif
839
840 Pop $0
841
842FunctionEnd
843!macroend
844!insertmacro RestoreFilesDirect3D ""
845!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