VirtualBox

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

最後變更 在這個檔案從96775是 96775,由 vboxsync 提交於 3 年 前

Add/Nt/Installer: Removed iexplore.ico as it's not needed, except perhaps on NT4.

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

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