VirtualBox

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

Last change on this file since 95009 was 94485, checked in by vboxsync, 3 years ago

WDDM: added VBOX_WITH_WDDM_DX (not enabled yet) to include the new driver into the additions installer. bugref:9845

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

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