VirtualBox

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

Last change on this file since 96697 was 96695, checked in by vboxsync, 21 months ago

Add/Nt/Installer: Reduce the number of warnings to almost none. [fix]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 23.8 KB
Line 
1; $Id: VBoxGuestAdditionsCommon.nsh 96695 2022-09-12 09:54:31Z 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!ifndef UNINSTALLER_ONLY
223 !insertmacro CheckArchitecture ""
224 !insertmacro CheckArchitecture "un."
225!endif
226
227;
228; Macro for retrieving the Windows version this installer is running on.
229;
230; @return Stack: Windows version string. Empty on error /
231; if not able to identify.
232;
233!macro GetWindowsVersionEx un
234Function ${un}GetWindowsVersionEx
235
236 Push $0
237 Push $1
238
239 ; Check if we are running on Windows 2000 or above
240 ; For other windows versions (> XP) it may be necessary to change winver.nsh
241 Call ${un}GetWindowsVersion
242 Pop $0 ; Windows Version
243
244 Push $0 ; The windows version string
245 Push "NT" ; String to search for. W2K+ returns no string containing "NT"
246 Call ${un}StrStr
247 Pop $1
248
249 ${If} $1 == "" ; If empty -> not NT 3.XX or 4.XX
250 ; $0 contains the original version string
251 ${Else}
252 ; Ok we know it is NT. Must be a string like NT X.XX
253 Push $0 ; The windows version string
254 Push "4." ; String to search for
255 Call ${un}StrStr
256 Pop $1
257 ${If} $1 == "" ; If empty -> not NT 4
258 ;; @todo NT <= 3.x ?
259 ; $0 contains the original version string
260 ${Else}
261 StrCpy $0 "NT4"
262 ${EndIf}
263 ${EndIf}
264
265 Pop $1
266 Exch $0
267
268FunctionEnd
269!macroend
270!ifndef UNINSTALLER_ONLY
271 !insertmacro GetWindowsVersionEx ""
272!endif
273!insertmacro GetWindowsVersionEx "un."
274
275!ifndef UNINSTALLER_ONLY
276!macro GetAdditionsVersion un
277Function ${un}GetAdditionsVersion
278
279 Push $0
280 Push $1
281
282 ; Get additions version
283 ReadRegStr $0 HKLM "SOFTWARE\$%VBOX_VENDOR_SHORT%\VirtualBox Guest Additions" "Version"
284
285 ; Get revision
286 ReadRegStr $g_strAddVerRev HKLM "SOFTWARE\$%VBOX_VENDOR_SHORT%\VirtualBox Guest Additions" "Revision"
287
288 ; Extract major version
289 Push "$0" ; String
290 Push "." ; SubString
291 Push ">" ; SearchDirection
292 Push "<" ; StrInclusionDirection
293 Push "0" ; IncludeSubString
294 Push "0" ; Loops
295 Push "0" ; CaseSensitive
296 Call ${un}StrStrAdv
297 Pop $g_strAddVerMaj
298
299 ; Extract minor version
300 Push "$0" ; String
301 Push "." ; SubString
302 Push ">" ; SearchDirection
303 Push ">" ; StrInclusionDirection
304 Push "0" ; IncludeSubString
305 Push "0" ; Loops
306 Push "0" ; CaseSensitive
307 Call ${un}StrStrAdv
308 Pop $1 ; Got first part (e.g. "1.5")
309
310 Push "$1" ; String
311 Push "." ; SubString
312 Push ">" ; SearchDirection
313 Push "<" ; StrInclusionDirection
314 Push "0" ; IncludeSubString
315 Push "0" ; Loops
316 Push "0" ; CaseSensitive
317 Call ${un}StrStrAdv
318 Pop $g_strAddVerMin ; Extracted second part (e.g. "5" from "1.5")
319
320 ; Extract build number
321 Push "$0" ; String
322 Push "." ; SubString
323 Push "<" ; SearchDirection
324 Push ">" ; StrInclusionDirection
325 Push "0" ; IncludeSubString
326 Push "0" ; Loops
327 Push "0" ; CaseSensitive
328 Call ${un}StrStrAdv
329 Pop $g_strAddVerBuild
330
331 Pop $1
332 Pop $0
333
334FunctionEnd
335!macroend
336!insertmacro GetAdditionsVersion ""
337; !insertmacro GetAdditionsVersion "un." - not used.
338!endif ; UNINSTALLER_ONLY
339
340!macro StopVBoxService un
341Function ${un}StopVBoxService
342
343 Push $0 ; Temp results
344 Push $1
345 Push $2 ; Image name of VBoxService
346 Push $3 ; Safety counter
347
348 StrCpy $3 "0" ; Init counter
349 ${LogVerbose} "Stopping VBoxService ..."
350
351 ${LogVerbose} "Stopping VBoxService via SCM ..."
352 ${If} $g_strWinVersion == "NT4"
353 nsExec::Exec '"$SYSDIR\net.exe" stop VBoxService'
354 ${Else}
355 nsExec::Exec '"$SYSDIR\sc.exe" stop VBoxService'
356 ${EndIf}
357 Sleep "1000" ; Wait a bit
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!ifdef UNUSED_CODE ; Only used by unused Uninstall_RunExtUnInstaller function in VBoxguestAdditionsUninstallOld.nsh.
466!macro AbortShutdown un
467Function ${un}AbortShutdown
468
469 ${If} ${FileExists} "$g_strSystemDir\shutdown.exe"
470 ; Try to abort the shutdown
471 ${CmdExecute} "$\"$g_strSystemDir\shutdown.exe$\" -a" 'non-zero-exitcode=log'
472 ${Else}
473 ${LogVerbose} "Shutting down not supported: Binary $\"$g_strSystemDir\shutdown.exe$\" not found"
474 ${EndIf}
475
476FunctionEnd
477!macroend
478!insertmacro AbortShutdown ""
479!insertmacro AbortShutdown "un."
480!endif ; UNUSED_CODE
481
482;;
483; Sets $g_bCapDllCache, $g_bCapXPDM, $g_bWithWDDM and $g_bCapWDDM.
484;
485!macro CheckForCapabilities un
486Function ${un}CheckForCapabilities
487
488 Push $0
489
490 ; Retrieve system mode and store result in
491 System::Call 'user32::GetSystemMetrics(i ${SM_CLEANBOOT}) i .r0'
492 StrCpy $g_iSystemMode $0
493
494 ; Does the guest have a DLL cache?
495 ${If} $g_strWinVersion == "NT4" ; bird: NT4 doesn't have a DLL cache, WTP is 5.0 <= NtVersion < 6.0.
496 ${OrIf} $g_strWinVersion == "2000"
497 ${OrIf} $g_strWinVersion == "XP"
498 StrCpy $g_bCapDllCache "true"
499 ${LogVerbose} "OS has a DLL cache"
500 ${EndIf}
501
502 ${If} $g_strWinVersion == "2000"
503 ${OrIf} $g_strWinVersion == "XP"
504 ${OrIf} $g_strWinVersion == "2003"
505 ${OrIf} $g_strWinVersion == "Vista"
506 ${OrIf} $g_strWinVersion == "7"
507 StrCpy $g_bCapXPDM "true"
508 ${LogVerbose} "OS is XPDM driver capable"
509 ${EndIf}
510
511!if $%VBOX_WITH_WDDM% == "1"
512 ; By default use the WDDM driver on Vista+
513 ${If} $g_strWinVersion == "Vista"
514 ${OrIf} $g_strWinVersion == "7"
515 ${OrIf} $g_strWinVersion == "8"
516 ${OrIf} $g_strWinVersion == "8_1"
517 ${OrIf} $g_strWinVersion == "10"
518 StrCpy $g_bWithWDDM "true"
519 StrCpy $g_bCapWDDM "true"
520 ${LogVerbose} "OS is WDDM driver capable"
521 ${EndIf}
522!endif
523
524 Pop $0
525
526FunctionEnd
527!macroend
528!ifndef UNINSTALLER_ONLY
529 !insertmacro CheckForCapabilities ""
530!endif
531!insertmacro CheckForCapabilities "un."
532
533; Switches (back) the path + registry view to
534; 32-bit mode (SysWOW64) on 64-bit guests
535!macro SetAppMode32 un
536Function ${un}SetAppMode32
537 !if $%KBUILD_TARGET_ARCH% == "amd64"
538 ${EnableX64FSRedirection}
539 SetRegView 32
540 !endif
541FunctionEnd
542!macroend
543!ifndef UNINSTALLER_ONLY
544 !insertmacro SetAppMode32 ""
545 !insertmacro SetAppMode32 "un."
546!endif
547
548; Because this NSIS installer is always built in 32-bit mode, we have to
549; do some tricks for the Windows paths + registry on 64-bit guests
550!macro SetAppMode64 un
551Function ${un}SetAppMode64
552 !if $%KBUILD_TARGET_ARCH% == "amd64"
553 ${DisableX64FSRedirection}
554 SetRegView 64
555 !endif
556FunctionEnd
557!macroend
558!insertmacro SetAppMode64 ""
559!insertmacro SetAppMode64 "un."
560
561;
562; Retrieves the vendor ("CompanyName" of FILEINFO structure)
563; of a given file.
564; @return Stack: Company name, or "" on error/if not found.
565; @param Stack: File name to retrieve vendor for.
566;
567!macro GetFileVendor un
568Function ${un}GetFileVendor
569
570 ; Preserve values
571 Exch $0 ; Stack: $0 <filename> (Get file name into $0)
572 Push $1
573
574 IfFileExists "$0" found
575 Goto not_found
576
577found:
578
579 VBoxGuestInstallHelper::FileGetVendor "$0"
580 ; Stack: <vendor> $1 $0
581 Pop $0 ; Get vendor
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 GetFileVendor ""
598!insertmacro GetFileVendor "un."
599
600;
601; Retrieves the architecture of a given file.
602; @return Stack: Architecture ("x86", "amd64") or error message.
603; @param Stack: File name to retrieve architecture for.
604;
605!macro GetFileArchitecture un
606Function ${un}GetFileArchitecture
607
608 ; Preserve values
609 Exch $0 ; Stack: $0 <filename> (Get file name into $0)
610 Push $1
611
612 IfFileExists "$0" found
613 Goto not_found
614
615found:
616
617 ${LogVerbose} "Getting architecture of file $\"$0$\" ..."
618
619 VBoxGuestInstallHelper::FileGetArchitecture "$0"
620
621 ; Stack: <architecture> $1 $0
622 Pop $0 ; Get architecture string
623
624 ${LogVerbose} "Architecture is: $0"
625
626 Pop $1 ; Restore $1
627 Exch $0 ; Restore $0, push vendor on top of stack
628 Goto end
629
630not_found:
631
632 Pop $1
633 Pop $0
634 Push "File not found"
635 Goto end
636
637end:
638
639FunctionEnd
640!macroend
641!insertmacro GetFileArchitecture ""
642!insertmacro GetFileArchitecture "un."
643
644;
645; Verifies a given file by checking its file vendor and target
646; architecture.
647; @return Stack: "0" if valid, "1" if not, "2" on error / not found.
648; @param Stack: Architecture ("x86" or "amd64").
649; @param Stack: Vendor.
650; @param Stack: File name to verify.
651;
652!macro VerifyFile un
653Function ${un}VerifyFile
654
655 ; Preserve values
656 Exch $0 ; File; S: old$0 vendor arch
657 Exch ; S: vendor old$0 arch
658 Exch $1 ; Vendor; S: old$1 old$0 arch
659 Exch ; S: old$0 old$1 arch
660 Exch 2 ; S: arch old$1 old$0
661 Exch $2 ; Architecture; S: old$2 old$1 old$0
662 Push $3 ; S: old$3 old$2 old$1 old$0
663
664 ${LogVerbose} "Verifying file $\"$0$\" (vendor: $1, arch: $2) ..."
665
666 IfFileExists "$0" check_arch
667 Goto not_found
668
669check_arch:
670
671 ${LogVerbose} "File $\"$0$\" found"
672
673 Push $0
674 Call ${un}GetFileArchitecture
675 Pop $3
676
677 ${LogVerbose} "Architecture is: $3"
678
679 ${If} $3 == $2
680 Goto check_vendor
681 ${EndIf}
682 Goto invalid
683
684check_vendor:
685
686 Push $0
687 Call ${un}GetFileVendor
688 Pop $3
689
690 ${LogVerbose} "Vendor is: $3"
691
692 ${If} $3 == $1
693 Goto valid
694 ${EndIf}
695
696invalid:
697
698 ${LogVerbose} "File $\"$0$\" is invalid"
699
700 StrCpy $3 "1" ; Invalid
701 Goto end
702
703valid:
704
705 ${LogVerbose} "File $\"$0$\" is valid"
706
707 StrCpy $3 "0" ; Valid
708 Goto end
709
710not_found:
711
712 ${LogVerbose} "File $\"$0$\" was not found"
713
714 StrCpy $3 "2" ; Not found
715 Goto end
716
717end:
718
719 ; S: old$3 old$2 old$1 old$0
720 Exch $3 ; S: $3 old$2 old$1 old$0
721 Exch ; S: old$2 $3 old$1
722 Pop $2 ; S: $3 old$1 old$0
723 Exch ; S: old$1 $3 old$0
724 Pop $1 ; S: $3 old$0
725 Exch ; S: old$0 $3
726 Pop $0 ; S: $3
727
728FunctionEnd
729!macroend
730!insertmacro VerifyFile ""
731!insertmacro VerifyFile "un."
732
733;
734; Macro for accessing VerifyFile in a more convenient way by using
735; a parameter list.
736; @return Stack: "0" if valid, "1" if not, "2" on error / not found.
737; @param Un/Installer prefix; either "" or "un".
738; @param Name of file to verify.
739; @param Vendor to check for.
740; @param Architecture ("x86" or "amd64") to check for.
741;
742!macro VerifyFileEx un File Vendor Architecture
743 Push $0
744 Push "${Architecture}"
745 Push "${Vendor}"
746 Push "${File}"
747 Call ${un}VerifyFile
748 Pop $0
749 ${If} $0 == "0"
750 ${LogVerbose} "Verification of file $\"${File}$\" successful (Vendor: ${Vendor}, Architecture: ${Architecture})"
751 ${ElseIf} $0 == "1"
752 ${LogVerbose} "Verification of file $\"${File}$\" failed (not Vendor: ${Vendor}, and/or not Architecture: ${Architecture})"
753 ${Else}
754 ${LogVerbose} "Skipping to file $\"${File}$\"; not found"
755 ${EndIf}
756 ; Push result popped off the stack to stack again
757 Push $0
758!macroend
759!define VerifyFileEx "!insertmacro VerifyFileEx"
760
761;
762; Macro for copying a file only if the source file is verified
763; to be from a certain vendor and architecture.
764; @return Stack: "0" if copied, "1" if not, "2" on error / not found.
765; @param Un/Installer prefix; either "" or "un".
766; @param Name of file to verify and copy to destination.
767; @param Destination name to copy verified file to.
768; @param Vendor to check for.
769; @param Architecture ("x86" or "amd64") to check for.
770;
771!macro CopyFileEx un FileSrc FileDest Vendor Architecture
772 Push $0
773 Push "${Architecture}"
774 Push "${Vendor}"
775 Push "${FileSrc}"
776 Call ${un}VerifyFile
777 Pop $0
778
779 Push "${Architecture}"
780 Push "Oracle Corporation"
781 Push "${FileDest}"
782 Call ${un}VerifyFile
783 Pop $0
784
785 ${If} $0 == "0"
786 ${LogVerbose} "Copying verified file $\"${FileSrc}$\" to $\"${FileDest}$\" ..."
787 ClearErrors
788 SetOverwrite on
789 CopyFiles /SILENT "${FileSrc}" "${FileDest}"
790 ${If} ${Errors}
791 CreateDirectory "$TEMP\${PRODUCT_NAME}"
792 ${GetFileName} "${FileSrc}" $0 ; Get the base name
793 CopyFiles /SILENT "${FileSrc}" "$TEMP\${PRODUCT_NAME}\$0"
794 ${LogVerbose} "Immediate installation failed, postponing to next reboot (temporary location is: $\"$TEMP\${PRODUCT_NAME}\$0$\") ..."
795 ;${InstallFileEx} "${un}" "${FileSrc}" "${FileDest}" "$TEMP" ; Only works with compile time files!
796 System::Call "kernel32::MoveFileEx(t '$TEMP\${PRODUCT_NAME}\$0', t '${FileDest}', i 5)"
797 ${EndIf}
798 ${Else}
799 ${LogVerbose} "Skipping to copy file $\"${FileSrc}$\" to $\"${FileDest}$\" (not Vendor: ${Vendor}, Architecture: ${Architecture})"
800 ${EndIf}
801 ; Push result popped off the stack to stack again
802 Push $0
803!macroend
804!define CopyFileEx "!insertmacro CopyFileEx"
805
806;
807; Macro for installing a library/DLL.
808; @return Stack: "0" if copied, "1" if not, "2" on error / not found.
809; @param Un/Installer prefix; either "" or "un".
810; @param Name of lib/DLL to copy to destination.
811; @param Destination name to copy the source file to.
812; @param Temporary folder used for exchanging the (locked) lib/DLL after a reboot.
813;
814!macro InstallFileEx un FileSrc FileDest DirTemp
815 ${LogVerbose} "Installing library $\"${FileSrc}$\" to $\"${FileDest}$\" ..."
816 ; Try the gentle way and replace the file instantly
817 !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "${FileSrc}" "${FileDest}" "${DirTemp}"
818 ; If the above call didn't help, use a (later) reboot to replace the file
819 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "${FileSrc}" "${FileDest}" "${DirTemp}"
820!macroend
821!define InstallFileEx "!insertmacro InstallFileEx"
822
823;
824; Macro for installing a library/DLL.
825; @return Stack: "0" if copied, "1" if not, "2" on error / not found.
826; @param Un/Installer prefix; either "" or "un".
827; @param Name of lib/DLL to verify and copy to destination.
828; @param Destination name to copy verified file to.
829; @param Temporary folder used for exchanging the (locked) lib/DLL after a reboot.
830; @param Vendor to check for.
831; @param Architecture ("x86" or "amd64") to check for.
832;
833!macro InstallFileVerify un FileSrc FileDest DirTemp Vendor Architecture
834 Push $0
835 Push "${Architecture}"
836 Push "${Vendor}"
837 Push "${FileSrc}"
838 ${LogVerbose} "Verifying library $\"${FileSrc}$\" ..."
839 Call ${un}VerifyFile
840 Pop $0
841 ${If} $0 == "0"
842 ${InstallFileEx} ${un} ${FileSrc} ${FileDest} ${DirTemp}
843 ${Else}
844 ${LogVerbose} "File $\"${FileSrc}$\" did not pass verification (Vendor: ${Vendor}, Architecture: ${Architecture})"
845 ${EndIf}
846 ; Push result popped off the stack to stack again.
847 Push $0
848!macroend
849!define InstallFileVerify "!insertmacro InstallFileVerify"
850
851
852; Note: We don't ship modified Direct3D files anymore, but we need to (try to)
853; restore the original (backed up) DLLs when upgrading from an old(er)
854; installation.
855;
856; Restores formerly backed up Direct3D original files, which were replaced by
857; a VBox XPDM driver installation before. This might be necessary for upgrading a
858; XPDM installation to a WDDM one.
859; @return Stack: "0" if files were restored successfully; otherwise "1".
860;
861!macro RestoreFilesDirect3D un
862Function ${un}RestoreFilesDirect3D
863 ${If} $g_bCapXPDM != "true"
864 ${LogVerbose} "RestoreFilesDirect3D: XPDM is not supported"
865 Return
866 ${EndIf}
867
868 Push $0
869
870 ; We need to switch to 64-bit app mode to handle the "real" 64-bit files in
871 ; "system32" on a 64-bit guest
872 Call ${un}SetAppMode64
873
874 ${LogVerbose} "Restoring original D3D files ..."
875 ${CopyFileEx} "${un}" "$SYSDIR\msd3d8.dll" "$SYSDIR\d3d8.dll" "Microsoft Corporation" "$%KBUILD_TARGET_ARCH%"
876 ${CopyFileEx} "${un}" "$SYSDIR\msd3d9.dll" "$SYSDIR\d3d9.dll" "Microsoft Corporation" "$%KBUILD_TARGET_ARCH%"
877
878 ${If} $g_bCapDllCache == "true"
879 ${CopyFileEx} "${un}" "$SYSDIR\dllcache\msd3d8.dll" "$SYSDIR\dllcache\d3d8.dll" "Microsoft Corporation" "$%KBUILD_TARGET_ARCH%"
880 ${CopyFileEx} "${un}" "$SYSDIR\dllcache\msd3d9.dll" "$SYSDIR\dllcache\d3d9.dll" "Microsoft Corporation" "$%KBUILD_TARGET_ARCH%"
881 ${EndIf}
882
883!if $%KBUILD_TARGET_ARCH% == "amd64"
884 ${CopyFileEx} "${un}" "$g_strSysWow64\msd3d8.dll" "$g_strSysWow64\d3d8.dll" "Microsoft Corporation" "x86"
885 ${CopyFileEx} "${un}" "$g_strSysWow64\msd3d9.dll" "$g_strSysWow64\d3d9.dll" "Microsoft Corporation" "x86"
886
887 ${If} $g_bCapDllCache == "true"
888 ${CopyFileEx} "${un}" "$g_strSysWow64\dllcache\msd3d8.dll" "$g_strSysWow64\dllcache\d3d8.dll" "Microsoft Corporation" "x86"
889 ${CopyFileEx} "${un}" "$g_strSysWow64\dllcache\msd3d9.dll" "$g_strSysWow64\dllcache\d3d9.dll" "Microsoft Corporation" "x86"
890 ${EndIf}
891!endif
892
893 Pop $0
894
895FunctionEnd
896!macroend
897!insertmacro RestoreFilesDirect3D ""
898!insertmacro RestoreFilesDirect3D "un."
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use