VirtualBox

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

Last change on this file since 96692 was 96687, checked in by vboxsync, 21 months ago

Add/Nt/Installer: Changed the 2nd parameter of ${CmdExecute} from a 'true/false' to a more explicit 'non-zero-exitcode=log/abort' to make it explicitly clear what's going to happen on failure. Always save the install_ui.log. bugref:10261

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

© 2023 Oracle
ContactPrivacy policyTerms of Use