VirtualBox

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

Last change on this file since 75445 was 75445, checked in by vboxsync, 7 years ago

WDDM: Gallium driver (disabled)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 30.5 KB
Line 
1; $Id: VBoxGuestAdditionsCommon.nsh 75445 2018-11-14 12:19:32Z vboxsync $
2;; @file
3; VBoxGuestAdditionsCommon.nsh - Common / shared utility functions.
4;
5
6;
7; Copyright (C) 2006-2017 Oracle Corporation
8;
9; This file is part of VirtualBox Open Source Edition (OSE), as
10; available from http://www.virtualbox.org. This file is free software;
11; you can redistribute it and/or modify it under the terms of the GNU
12; General Public License (GPL) as published by the Free Software
13; Foundation, in version 2 as it comes in the "COPYING" file of the
14; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16;
17
18Function Common_CopyFiles
19
20 SetOutPath "$INSTDIR"
21 SetOverwrite on
22
23!ifdef VBOX_WITH_LICENSE_INSTALL_RTF
24 ; Copy license file (if any) into the installation directory
25 FILE "/oname=${LICENSE_FILE_RTF}" "$%VBOX_BRAND_LICENSE_RTF%"
26!endif
27
28 FILE "$%VBOX_PATH_DIFX%\DIFxAPI.dll"
29 FILE "$%PATH_OUT%\bin\additions\VBoxDrvInst.exe"
30
31 FILE "$%PATH_OUT%\bin\additions\VBoxVideo.inf"
32!ifdef VBOX_SIGN_ADDITIONS
33 FILE "$%PATH_OUT%\bin\additions\VBoxVideo.cat"
34!endif
35
36 FILE "iexplore.ico"
37
38FunctionEnd
39
40!ifndef UNINSTALLER_ONLY
41Function ExtractFiles
42
43 ; @todo: Use a define for all the file specs to group the files per module
44 ; and keep the redundancy low
45
46 Push $0
47 StrCpy "$0" "$INSTDIR\$%BUILD_TARGET_ARCH%"
48
49 ; Root files
50 SetOutPath "$0"
51!if $%VBOX_WITH_LICENSE_INSTALL_RTF% == "1"
52 FILE "/oname=${LICENSE_FILE_RTF}" "$%VBOX_BRAND_LICENSE_RTF%"
53!endif
54
55 ; Video driver
56 SetOutPath "$0\VBoxVideo"
57 FILE "$%PATH_OUT%\bin\additions\VBoxVideo.sys"
58 FILE "$%PATH_OUT%\bin\additions\VBoxVideo.inf"
59!ifdef VBOX_SIGN_ADDITIONS
60 FILE "$%PATH_OUT%\bin\additions\VBoxVideo.cat"
61!endif
62 FILE "$%PATH_OUT%\bin\additions\VBoxDisp.dll"
63
64!if $%VBOX_WITH_CROGL% == "1"
65 ; crOpenGL
66 FILE "$%PATH_OUT%\bin\additions\VBoxOGLarrayspu.dll"
67 FILE "$%PATH_OUT%\bin\additions\VBoxOGLcrutil.dll"
68 FILE "$%PATH_OUT%\bin\additions\VBoxOGLerrorspu.dll"
69 FILE "$%PATH_OUT%\bin\additions\VBoxOGLpackspu.dll"
70 FILE "$%PATH_OUT%\bin\additions\VBoxOGLpassthroughspu.dll"
71 FILE "$%PATH_OUT%\bin\additions\VBoxOGLfeedbackspu.dll"
72 FILE "$%PATH_OUT%\bin\additions\VBoxOGL.dll"
73
74 SetOutPath "$0\VBoxVideo\OpenGL"
75 FILE "$%PATH_OUT%\bin\additions\d3d8.dll"
76 FILE "$%PATH_OUT%\bin\additions\d3d9.dll"
77 FILE "$%PATH_OUT%\bin\additions\VBoxD3D8.dll"
78 FILE "$%PATH_OUT%\bin\additions\VBoxD3D9.dll"
79 FILE "$%PATH_OUT%\bin\additions\wined3d.dll"
80
81 !if $%BUILD_TARGET_ARCH% == "amd64"
82 ; Only 64-bit installer: Also copy 32-bit DLLs on 64-bit target
83 SetOutPath "$0\VBoxVideo\OpenGL\SysWow64"
84 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d8.dll"
85 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d9.dll"
86 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxOGLarrayspu.dll"
87 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxOGLcrutil.dll"
88 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxOGLerrorspu.dll"
89 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxOGLpackspu.dll"
90 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxOGLpassthroughspu.dll"
91 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxOGLfeedbackspu.dll"
92 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxOGL.dll"
93 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxD3D8.dll"
94 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxD3D9.dll"
95 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\wined3d.dll"
96 !endif
97!endif
98
99!if $%VBOX_WITH_WDDM% == "1"
100 ; WDDM Video driver
101 SetOutPath "$0\VBoxWddm"
102
103 !ifdef VBOX_SIGN_ADDITIONS
104 FILE "$%PATH_OUT%\bin\additions\VBoxWddm.cat"
105 !endif
106 FILE "$%PATH_OUT%\bin\additions\VBoxWddm.sys"
107 FILE "$%PATH_OUT%\bin\additions\VBoxWddm.inf"
108 FILE "$%PATH_OUT%\bin\additions\VBoxDispD3D.dll"
109 !if $%VBOX_WITH_MESA3D% == "1"
110 FILE "$%PATH_OUT%\bin\additions\VBoxNine.dll"
111 FILE "$%PATH_OUT%\bin\additions\VBoxSVGA.dll"
112 FILE "$%PATH_OUT%\bin\additions\VBoxGL.dll"
113 !endif
114
115 !if $%VBOX_WITH_CROGL% == "1"
116 FILE "$%PATH_OUT%\bin\additions\VBoxOGLarrayspu.dll"
117 FILE "$%PATH_OUT%\bin\additions\VBoxOGLcrutil.dll"
118 FILE "$%PATH_OUT%\bin\additions\VBoxOGLerrorspu.dll"
119 FILE "$%PATH_OUT%\bin\additions\VBoxOGLpackspu.dll"
120 FILE "$%PATH_OUT%\bin\additions\VBoxOGLpassthroughspu.dll"
121 FILE "$%PATH_OUT%\bin\additions\VBoxOGLfeedbackspu.dll"
122 FILE "$%PATH_OUT%\bin\additions\VBoxOGL.dll"
123
124 FILE "$%PATH_OUT%\bin\additions\VBoxD3D9wddm.dll"
125 FILE "$%PATH_OUT%\bin\additions\wined3dwddm.dll"
126 !endif ; $%VBOX_WITH_CROGL% == "1"
127
128 !if $%BUILD_TARGET_ARCH% == "amd64"
129 FILE "$%PATH_OUT%\bin\additions\VBoxDispD3D-x86.dll"
130 !if $%VBOX_WITH_MESA3D% == "1"
131 FILE "$%PATH_OUT%\bin\additions\VBoxNine-x86.dll"
132 FILE "$%PATH_OUT%\bin\additions\VBoxSVGA-x86.dll"
133 FILE "$%PATH_OUT%\bin\additions\VBoxGL-x86.dll"
134 !endif
135
136 !if $%VBOX_WITH_CROGL% == "1"
137 FILE "$%PATH_OUT%\bin\additions\VBoxOGLarrayspu-x86.dll"
138 FILE "$%PATH_OUT%\bin\additions\VBoxOGLcrutil-x86.dll"
139 FILE "$%PATH_OUT%\bin\additions\VBoxOGLerrorspu-x86.dll"
140 FILE "$%PATH_OUT%\bin\additions\VBoxOGLpackspu-x86.dll"
141 FILE "$%PATH_OUT%\bin\additions\VBoxOGLpassthroughspu-x86.dll"
142 FILE "$%PATH_OUT%\bin\additions\VBoxOGLfeedbackspu-x86.dll"
143 FILE "$%PATH_OUT%\bin\additions\VBoxOGL-x86.dll"
144
145 FILE "$%PATH_OUT%\bin\additions\VBoxD3D9wddm-x86.dll"
146 FILE "$%PATH_OUT%\bin\additions\wined3dwddm-x86.dll"
147 !endif ; $%VBOX_WITH_CROGL% == "1"
148 !endif ; $%BUILD_TARGET_ARCH% == "amd64"
149!endif ; $%VBOX_WITH_WDDM% == "1"
150
151 ; Mouse driver
152 SetOutPath "$0\VBoxMouse"
153 FILE "$%PATH_OUT%\bin\additions\VBoxMouse.sys"
154 FILE "$%PATH_OUT%\bin\additions\VBoxMouse.inf"
155!ifdef VBOX_SIGN_ADDITIONS
156 FILE "$%PATH_OUT%\bin\additions\VBoxMouse.cat"
157!endif
158
159!if $%BUILD_TARGET_ARCH% == "x86"
160 SetOutPath "$0\VBoxMouse\NT4"
161 FILE "$%PATH_OUT%\bin\additions\VBoxMouseNT.sys"
162!endif
163
164 ; Guest driver
165 SetOutPath "$0\VBoxGuest"
166 FILE "$%PATH_OUT%\bin\additions\VBoxGuest.sys"
167 FILE "$%PATH_OUT%\bin\additions\VBoxGuest.inf"
168!ifdef VBOX_SIGN_ADDITIONS
169 FILE "$%PATH_OUT%\bin\additions\VBoxGuest.cat"
170!endif
171 FILE "$%PATH_OUT%\bin\additions\VBoxTray.exe"
172 FILE "$%PATH_OUT%\bin\additions\VBoxHook.dll"
173 FILE "$%PATH_OUT%\bin\additions\VBoxControl.exe"
174
175 ; VBoxService
176 SetOutPath "$0\Bin"
177 FILE "$%PATH_OUT%\bin\additions\VBoxService.exe"
178
179 ; Shared Folders
180 SetOutPath "$0\VBoxSF"
181 FILE "$%PATH_OUT%\bin\additions\VBoxSF.sys"
182 FILE "$%PATH_OUT%\bin\additions\VBoxMRXNP.dll"
183 !if $%BUILD_TARGET_ARCH% == "amd64"
184 ; Only 64-bit installer: Also copy 32-bit DLLs on 64-bit target
185 FILE "$%PATH_OUT%\bin\additions\VBoxMRXNP-x86.dll"
186 !endif
187
188 ; Auto-Logon
189 SetOutPath "$0\AutoLogon"
190 FILE "$%PATH_OUT%\bin\additions\VBoxGINA.dll"
191 FILE "$%PATH_OUT%\bin\additions\VBoxCredProv.dll"
192
193 ; Misc tools
194 SetOutPath "$0\Tools"
195 FILE "$%PATH_OUT%\bin\additions\VBoxDrvInst.exe"
196 FILE "$%VBOX_PATH_DIFX%\DIFxAPI.dll"
197
198!if $%BUILD_TARGET_ARCH% == "x86"
199 SetOutPath "$0\Tools\NT4"
200 FILE "$%PATH_OUT%\bin\additions\VBoxGuestDrvInst.exe"
201 FILE "$%PATH_OUT%\bin\additions\RegCleanup.exe"
202!endif
203
204 Pop $0
205
206FunctionEnd
207!endif ; UNINSTALLER_ONLY
208
209!macro CheckArchitecture un
210Function ${un}CheckArchitecture
211
212 Push $0
213
214 System::Call "kernel32::GetCurrentProcess() i .s"
215 System::Call "kernel32::IsWow64Process(i s, *i .r0)"
216 ; R0 now contains 1 if we're a 64-bit process, or 0 if not
217
218!if $%BUILD_TARGET_ARCH% == "amd64"
219 IntCmp $0 0 wrong_platform
220!else ; 32-bit
221 IntCmp $0 1 wrong_platform
222!endif
223
224 Push 0
225 Goto exit
226
227wrong_platform:
228
229 Push 1
230 Goto exit
231
232exit:
233
234FunctionEnd
235!macroend
236!insertmacro CheckArchitecture ""
237!insertmacro CheckArchitecture "un."
238
239;
240; Macro for retrieving the Windows version this installer is running on.
241;
242; @return Stack: Windows version string. Empty on error /
243; if not able to identify.
244;
245!macro GetWindowsVersionEx un
246Function ${un}GetWindowsVersionEx
247
248 Push $0
249 Push $1
250
251 ; Check if we are running on Windows 2000 or above
252 ; For other windows versions (> XP) it may be necessary to change winver.nsh
253 Call ${un}GetWindowsVersion
254 Pop $0 ; Windows Version
255
256 Push $0 ; The windows version string
257 Push "NT" ; String to search for. W2K+ returns no string containing "NT"
258 Call ${un}StrStr
259 Pop $1
260
261 ${If} $1 == "" ; If empty -> not NT 3.XX or 4.XX
262 ; $0 contains the original version string
263 ${Else}
264 ; Ok we know it is NT. Must be a string like NT X.XX
265 Push $0 ; The windows version string
266 Push "4." ; String to search for
267 Call ${un}StrStr
268 Pop $1
269 ${If} $1 == "" ; If empty -> not NT 4
270 ;; @todo NT <= 3.x ?
271 ; $0 contains the original version string
272 ${Else}
273 StrCpy $0 "NT4"
274 ${EndIf}
275 ${EndIf}
276
277 Pop $1
278 Exch $0
279
280FunctionEnd
281!macroend
282!insertmacro GetWindowsVersionEx ""
283!insertmacro GetWindowsVersionEx "un."
284
285!macro GetAdditionsVersion un
286Function ${un}GetAdditionsVersion
287
288 Push $0
289 Push $1
290
291 ; Get additions version
292 ReadRegStr $0 HKLM "SOFTWARE\$%VBOX_VENDOR_SHORT%\VirtualBox Guest Additions" "Version"
293
294 ; Get revision
295 ReadRegStr $g_strAddVerRev HKLM "SOFTWARE\$%VBOX_VENDOR_SHORT%\VirtualBox Guest Additions" "Revision"
296
297 ; Extract major version
298 Push "$0" ; String
299 Push "." ; SubString
300 Push ">" ; SearchDirection
301 Push "<" ; StrInclusionDirection
302 Push "0" ; IncludeSubString
303 Push "0" ; Loops
304 Push "0" ; CaseSensitive
305 Call ${un}StrStrAdv
306 Pop $g_strAddVerMaj
307
308 ; Extract minor version
309 Push "$0" ; String
310 Push "." ; SubString
311 Push ">" ; SearchDirection
312 Push ">" ; StrInclusionDirection
313 Push "0" ; IncludeSubString
314 Push "0" ; Loops
315 Push "0" ; CaseSensitive
316 Call ${un}StrStrAdv
317 Pop $1 ; Got first part (e.g. "1.5")
318
319 Push "$1" ; String
320 Push "." ; SubString
321 Push ">" ; SearchDirection
322 Push "<" ; StrInclusionDirection
323 Push "0" ; IncludeSubString
324 Push "0" ; Loops
325 Push "0" ; CaseSensitive
326 Call ${un}StrStrAdv
327 Pop $g_strAddVerMin ; Extracted second part (e.g. "5" from "1.5")
328
329 ; Extract build number
330 Push "$0" ; String
331 Push "." ; SubString
332 Push "<" ; SearchDirection
333 Push ">" ; StrInclusionDirection
334 Push "0" ; IncludeSubString
335 Push "0" ; Loops
336 Push "0" ; CaseSensitive
337 Call ${un}StrStrAdv
338 Pop $g_strAddVerBuild
339
340exit:
341
342 Pop $1
343 Pop $0
344
345FunctionEnd
346!macroend
347!insertmacro GetAdditionsVersion ""
348!insertmacro GetAdditionsVersion "un."
349
350!macro StopVBoxService un
351Function ${un}StopVBoxService
352
353 Push $0 ; Temp results
354 Push $1
355 Push $2 ; Image name of VBoxService
356 Push $3 ; Safety counter
357
358 StrCpy $3 "0" ; Init counter
359 ${LogVerbose} "Stopping VBoxService ..."
360
361svc_stop:
362
363 ${LogVerbose} "Stopping VBoxService via SCM ..."
364 ${If} $g_strWinVersion == "NT4"
365 nsExec::Exec '"$SYSDIR\net.exe" stop VBoxService'
366 ${Else}
367 nsExec::Exec '"$SYSDIR\SC.exe" stop VBoxService'
368 ${EndIf}
369 Sleep "1000" ; Wait a bit
370
371exe_stop:
372
373!ifdef _DEBUG
374 ${LogVerbose} "Stopping VBoxService (as exe) ..."
375!endif
376
377exe_stop_loop:
378
379 IntCmp $3 10 exit ; Only try this loop 10 times max
380 IntOp $3 $3 + 1 ; Increment
381
382!ifdef _DEBUG
383 ${LogVerbose} "Stopping attempt #$3"
384!endif
385
386 StrCpy $2 "VBoxService.exe"
387
388 ${nsProcess::FindProcess} $2 $0
389 StrCmp $0 0 0 exit
390
391 ${nsProcess::KillProcess} $2 $0
392 Sleep "1000" ; Wait a bit
393 Goto exe_stop_loop
394
395exit:
396
397 ${LogVerbose} "Stopping VBoxService done"
398
399 Pop $3
400 Pop $2
401 Pop $1
402 Pop $0
403
404FunctionEnd
405!macroend
406!insertmacro StopVBoxService ""
407!insertmacro StopVBoxService "un."
408
409!macro StopVBoxTray un
410Function ${un}StopVBoxTray
411
412 Push $0 ; Temp results
413 Push $1 ; Safety counter
414
415 StrCpy $1 "0" ; Init counter
416 ${LogVerbose} "Stopping VBoxTray ..."
417
418exe_stop:
419
420 IntCmp $1 10 exit ; Only try this loop 10 times max
421 IntOp $1 $1 + 1 ; Increment
422
423 ${nsProcess::FindProcess} "VBoxTray.exe" $0
424 StrCmp $0 0 0 exit
425
426 ${nsProcess::KillProcess} "VBoxTray.exe" $0
427 Sleep "1000" ; Wait a bit
428 Goto exe_stop
429
430exit:
431
432 ${LogVerbose} "Stopping VBoxTray done"
433
434 Pop $1
435 Pop $0
436
437FunctionEnd
438!macroend
439!insertmacro StopVBoxTray ""
440!insertmacro StopVBoxTray "un."
441
442!macro StopVBoxMMR un
443Function ${un}StopVBoxMMR
444
445 Push $0 ; Temp results
446 Push $1 ; Safety counter
447
448 StrCpy $1 "0" ; Init counter
449 DetailPrint "Stopping VBoxMMR ..."
450
451exe_stop:
452
453 IntCmp $1 10 exit ; Only try this loop 10 times max
454 IntOp $1 $1 + 1 ; Increment
455
456 ${nsProcess::FindProcess} "VBoxMMR.exe" $0
457 StrCmp $0 0 0 exit
458
459 ${nsProcess::KillProcess} "VBoxMMR.exe" $0
460 Sleep "1000" ; Wait a bit
461 Goto exe_stop
462
463exit:
464
465 DetailPrint "Stopping VBoxMMR done."
466
467 Pop $1
468 Pop $0
469
470FunctionEnd
471!macroend
472!insertmacro StopVBoxMMR ""
473!insertmacro StopVBoxMMR "un."
474
475!macro WriteRegBinR ROOT KEY NAME VALUE
476 WriteRegBin "${ROOT}" "${KEY}" "${NAME}" "${VALUE}"
477!macroend
478
479!macro AbortShutdown un
480Function ${un}AbortShutdown
481
482 ${If} ${FileExists} "$g_strSystemDir\shutdown.exe"
483 ; Try to abort the shutdown
484 ${CmdExecute} "$\"$g_strSystemDir\shutdown.exe$\" -a" "true"
485 ${Else}
486 ${LogVerbose} "Shutting down not supported: Binary $\"$g_strSystemDir\shutdown.exe$\" not found"
487 ${EndIf}
488
489FunctionEnd
490!macroend
491!insertmacro AbortShutdown ""
492!insertmacro AbortShutdown "un."
493
494!macro CheckForWDDMCapability un
495Function ${un}CheckForWDDMCapability
496
497!if $%VBOX_WITH_WDDM% == "1"
498 ; If we're on a 32-bit Windows Vista / 7 / 8 we can use the WDDM driver
499 ${If} $g_strWinVersion == "Vista"
500 ${OrIf} $g_strWinVersion == "7"
501 ${OrIf} $g_strWinVersion == "8"
502 ${OrIf} $g_strWinVersion == "8_1"
503 ${OrIf} $g_strWinVersion == "10"
504 StrCpy $g_bCapWDDM "true"
505 ${LogVerbose} "OS is WDDM driver capable"
506 ${EndIf}
507 ; If we're on Windows 8 we *have* to use the WDDM driver, so select it
508 ; by default
509 ${If} $g_strWinVersion == "8"
510 ${OrIf} $g_strWinVersion == "8_1"
511 ${OrIf} $g_strWinVersion == "10"
512 StrCpy $g_bWithWDDM "true"
513 ${LogVerbose} "OS needs WDDM driver by default"
514 ${EndIf}
515!endif
516
517FunctionEnd
518!macroend
519!insertmacro CheckForWDDMCapability ""
520!insertmacro CheckForWDDMCapability "un."
521
522!macro CheckForCapabilities un
523Function ${un}CheckForCapabilities
524
525 Push $0
526
527 ; Retrieve system mode and store result in
528 System::Call 'user32::GetSystemMetrics(i ${SM_CLEANBOOT}) i .r0'
529 StrCpy $g_iSystemMode $0
530
531 ; Does the guest have a DLL cache?
532 ${If} $g_strWinVersion == "NT4"
533 ${OrIf} $g_strWinVersion == "2000"
534 ${OrIf} $g_strWinVersion == "XP"
535 StrCpy $g_bCapDllCache "true"
536 ${LogVerbose} "OS has a DLL cache"
537 ${EndIf}
538
539 ; Check whether this OS is capable of handling WDDM drivers
540 Call ${un}CheckForWDDMCapability
541
542 Pop $0
543
544FunctionEnd
545!macroend
546!insertmacro CheckForCapabilities ""
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 $%BUILD_TARGET_ARCH% == "amd64"
554 ${EnableX64FSRedirection}
555 SetRegView 32
556 !endif
557FunctionEnd
558!macroend
559!insertmacro SetAppMode32 ""
560!insertmacro SetAppMode32 "un."
561
562; Because this NSIS installer is always built in 32-bit mode, we have to
563; do some tricks for the Windows paths + registry on 64-bit guests
564!macro SetAppMode64 un
565Function ${un}SetAppMode64
566 !if $%BUILD_TARGET_ARCH% == "amd64"
567 ${DisableX64FSRedirection}
568 SetRegView 64
569 !endif
570FunctionEnd
571!macroend
572!insertmacro SetAppMode64 ""
573!insertmacro SetAppMode64 "un."
574
575;
576; Retrieves the vendor ("CompanyName" of FILEINFO structure)
577; of a given file.
578; @return Stack: Company name, or "" on error/if not found.
579; @param Stack: File name to retrieve vendor for.
580;
581!macro GetFileVendor un
582Function ${un}GetFileVendor
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 VBoxGuestInstallHelper::FileGetVendor "$0"
594 ; Stack: <vendor> $1 $0
595 Pop $0 ; Get vendor
596 Pop $1 ; Restore $1
597 Exch $0 ; Restore $0, push vendor on top of stack
598 Goto end
599
600not_found:
601
602 Pop $1
603 Pop $0
604 Push "File not found"
605 Goto end
606
607end:
608
609FunctionEnd
610!macroend
611!insertmacro GetFileVendor ""
612!insertmacro GetFileVendor "un."
613
614;
615; Retrieves the architecture of a given file.
616; @return Stack: Architecture ("x86", "amd64") or error message.
617; @param Stack: File name to retrieve architecture for.
618;
619!macro GetFileArchitecture un
620Function ${un}GetFileArchitecture
621
622 ; Preserve values
623 Exch $0 ; Stack: $0 <filename> (Get file name into $0)
624 Push $1
625
626 IfFileExists "$0" found
627 Goto not_found
628
629found:
630
631 VBoxGuestInstallHelper::FileGetArchitecture "$0"
632 ; Stack: <architecture> $1 $0
633 Pop $0 ; Get architecture string
634 Pop $1 ; Restore $1
635 Exch $0 ; Restore $0, push vendor on top of stack
636 Goto end
637
638not_found:
639
640 Pop $1
641 Pop $0
642 Push "File not found"
643 Goto end
644
645end:
646
647FunctionEnd
648!macroend
649!insertmacro GetFileArchitecture ""
650!insertmacro GetFileArchitecture "un."
651
652;
653; Verifies a given file by checking its file vendor and target
654; architecture.
655; @return Stack: "0" if valid, "1" if not, "2" on error / not found.
656; @param Stack: Architecture ("x86" or "amd64").
657; @param Stack: Vendor.
658; @param Stack: File name to verify.
659;
660!macro VerifyFile un
661Function ${un}VerifyFile
662
663 ; Preserve values
664 Exch $0 ; File; S: old$0 vendor arch
665 Exch ; S: vendor old$0 arch
666 Exch $1 ; Vendor; S: old$1 old$0 arch
667 Exch ; S: old$0 old$1 arch
668 Exch 2 ; S: arch old$1 old$0
669 Exch $2 ; Architecture; S: old$2 old$1 old$0
670 Push $3 ; S: old$3 old$2 old$1 old$0
671
672 IfFileExists "$0" check_vendor
673 Goto not_found
674
675check_vendor:
676
677 Push $0
678 Call ${un}GetFileVendor
679 Pop $3
680
681 ${If} $3 == $1
682 Goto check_arch
683 ${EndIf}
684 StrCpy $3 "1" ; Invalid
685 Goto end
686
687check_arch:
688
689 Push $0
690 Call ${un}GetFileArchitecture
691 Pop $3
692
693 ${If} $3 == $2
694 StrCpy $3 "0" ; Valid
695 ${Else}
696 StrCpy $3 "1" ; Invalid
697 ${EndIf}
698 Goto end
699
700not_found:
701
702 StrCpy $3 "2" ; Not found
703 Goto end
704
705end:
706
707 ; S: old$3 old$2 old$1 old$0
708 Exch $3 ; S: $3 old$2 old$1 old$0
709 Exch ; S: old$2 $3 old$1
710 Pop $2 ; S: $3 old$1 old$0
711 Exch ; S: old$1 $3 old$0
712 Pop $1 ; S: $3 old$0
713 Exch ; S: old$0 $3
714 Pop $0 ; S: $3
715
716FunctionEnd
717!macroend
718!insertmacro VerifyFile ""
719!insertmacro VerifyFile "un."
720
721;
722; Macro for accessing VerifyFile in a more convenient way by using
723; a parameter list.
724; @return Stack: "0" if valid, "1" if not, "2" on error / not found.
725; @param Un/Installer prefix; either "" or "un".
726; @param Name of file to verify.
727; @param Vendor to check for.
728; @param Architecture ("x86" or "amd64") to check for.
729;
730!macro VerifyFileEx un File Vendor Architecture
731 Push $0
732 Push "${Architecture}"
733 Push "${Vendor}"
734 Push "${File}"
735 ${LogVerbose} "Verifying file $\"${File}$\" ..."
736 Call ${un}VerifyFile
737 Pop $0
738 ${If} $0 == "0"
739 ${LogVerbose} "Verification of file $\"${File}$\" successful (Vendor: ${Vendor}, Architecture: ${Architecture})"
740 ${ElseIf} $0 == "1"
741 ${LogVerbose} "Verification of file $\"${File}$\" failed (not Vendor: ${Vendor}, and/or not Architecture: ${Architecture})"
742 ${Else}
743 ${LogVerbose} "Skipping to file $\"${File}$\"; not found"
744 ${EndIf}
745 ; Push result popped off the stack to stack again
746 Push $0
747!macroend
748!define VerifyFileEx "!insertmacro VerifyFileEx"
749
750;
751; Macro for copying a file only if the source file is verified
752; to be from a certain vendor and architecture.
753; @return Stack: "0" if copied, "1" if not, "2" on error / not found.
754; @param Un/Installer prefix; either "" or "un".
755; @param Name of file to verify and copy to destination.
756; @param Destination name to copy verified file to.
757; @param Vendor to check for.
758; @param Architecture ("x86" or "amd64") to check for.
759;
760!macro CopyFileEx un FileSrc FileDest Vendor Architecture
761 Push $0
762 Push "${Architecture}"
763 Push "${Vendor}"
764 Push "${FileSrc}"
765 Call ${un}VerifyFile
766 Pop $0
767 ${If} $0 == "0"
768 ${LogVerbose} "Copying verified file $\"${FileSrc}$\" to $\"${FileDest}$\" ..."
769 ClearErrors
770 SetOverwrite on
771 CopyFiles /SILENT "${FileSrc}" "${FileDest}"
772 ${If} ${Errors}
773 CreateDirectory "$TEMP\${PRODUCT_NAME}"
774 ${GetFileName} "${FileSrc}" $0 ; Get the base name
775 CopyFiles /SILENT "${FileSrc}" "$TEMP\${PRODUCT_NAME}\$0"
776 ${LogVerbose} "Immediate installation failed, postponing to next reboot (temporary location is: $\"$TEMP\${PRODUCT_NAME}\$0$\") ..."
777 ;${InstallFileEx} "${un}" "${FileSrc}" "${FileDest}" "$TEMP" ; Only works with compile time files!
778 System::Call "kernel32::MoveFileEx(t '$TEMP\${PRODUCT_NAME}\$0', t '${FileDest}', i 5)"
779 ${EndIf}
780 ${Else}
781 ${LogVerbose} "Skipping to copy file $\"${FileSrc}$\" to $\"${FileDest}$\" (not Vendor: ${Vendor}, Architecture: ${Architecture})"
782 ${EndIf}
783 ; Push result popped off the stack to stack again
784 Push $0
785!macroend
786!define CopyFileEx "!insertmacro CopyFileEx"
787
788;
789; Macro for installing a library/DLL.
790; @return Stack: "0" if copied, "1" if not, "2" on error / not found.
791; @param Un/Installer prefix; either "" or "un".
792; @param Name of lib/DLL to copy to destination.
793; @param Destination name to copy the source file to.
794; @param Temporary folder used for exchanging the (locked) lib/DLL after a reboot.
795;
796!macro InstallFileEx un FileSrc FileDest DirTemp
797 ${LogVerbose} "Installing library $\"${FileSrc}$\" to $\"${FileDest}$\" ..."
798 ; Try the gentle way and replace the file instantly
799 !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "${FileSrc}" "${FileDest}" "${DirTemp}"
800 ; If the above call didn't help, use a (later) reboot to replace the file
801 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "${FileSrc}" "${FileDest}" "${DirTemp}"
802!macroend
803!define InstallFileEx "!insertmacro InstallFileEx"
804
805;
806; Macro for installing a library/DLL.
807; @return Stack: "0" if copied, "1" if not, "2" on error / not found.
808; @param Un/Installer prefix; either "" or "un".
809; @param Name of lib/DLL to verify and copy to destination.
810; @param Destination name to copy verified file to.
811; @param Temporary folder used for exchanging the (locked) lib/DLL after a reboot.
812; @param Vendor to check for.
813; @param Architecture ("x86" or "amd64") to check for.
814;
815!macro InstallFileVerify un FileSrc FileDest DirTemp Vendor Architecture
816 Push $0
817 Push "${Architecture}"
818 Push "${Vendor}"
819 Push "${FileSrc}"
820 ${LogVerbose} "Verifying library $\"${FileSrc}$\" ..."
821 Call ${un}VerifyFile
822 Pop $0
823 ${If} $0 == "0"
824 ${InstallFileEx} ${un} ${FileSrc} ${FileDest} ${DirTemp}
825 ${Else}
826 ${LogVerbose} "File $\"${FileSrc}$\" did not pass verification (Vendor: ${Vendor}, Architecture: ${Architecture})"
827 ${EndIf}
828 ; Push result popped off the stack to stack again.
829 Push $0
830!macroend
831!define InstallFileVerify "!insertmacro InstallFileVerify"
832
833; Prepares the access rights for replacing
834; a WRP (Windows Resource Protection) protected file
835!macro PrepareWRPFile un
836Function ${un}PrepareWRPFile
837
838 Pop $0
839 Push $1
840
841 ${IfNot} ${FileExists} "$0"
842 ${LogVerbose} "WRP: File $\"$0$\" does not exist, skipping"
843 Return
844 ${EndIf}
845
846 ${Switch} $g_strWinVersion
847 ${Case} "NT4"
848 ${Case} "2000"
849 ${Case} "XP"
850 ${LogVerbose} "WRP: changing ownership or permissions is not required on NT4, 2000, XP."
851 ${Break}
852 ${Default}
853 ${CmdExecute} "$\"$g_strSystemDir\takeown.exe$\" /A /F $\"$0$\"" "true"
854 Pop $1
855 ${LogVerbose} "WRP: Changing ownership for $\"$0$\" returned: $1"
856
857 ${CmdExecute} "icacls.exe $\"$0$\" /grant *S-1-5-32-544:F" "true"
858 Pop $1
859 ${LogVerbose} "WRP: Changing DACL for $\"$0$\" returned: $1"
860
861 Sleep 1000 ; TrustedInstaller needs some time to forget about the file
862 ${EndSwitch}
863
864!if $%VBOX_WITH_GUEST_INSTALL_HELPER% == "1"
865 !ifdef WFP_FILE_EXCEPTION
866 VBoxGuestInstallHelper::DisableWFP "$0"
867 Pop $1 ; Get return value (ignored for now)
868 ${LogVerbose} "WRP: Setting WFP exception for $\"$0$\" returned: $1"
869 !endif
870!endif
871
872 Pop $1
873
874FunctionEnd
875!macroend
876!insertmacro PrepareWRPFile ""
877!insertmacro PrepareWRPFile "un."
878
879;
880; Macro for preparing the access rights for replacing
881; a WRP (Windows Resource Protection) protected file.
882; @return None.
883; @param Path of file to prepare.
884;
885!macro PrepareWRPFileEx un FileSrc
886 Push $0
887 Push "${FileSrc}"
888 Call ${un}PrepareWRPFile
889 Pop $0
890!macroend
891!define PrepareWRPFileEx "!insertmacro PrepareWRPFileEx"
892
893;
894; Validates backed up and replaced Direct3D files; either the d3d*.dll have
895; to be from Microsoft or the (already) backed up msd3d*.dll files. If both
896; don't match we have a corrupted / invalid installation.
897; @return Stack: "0" if files are valid; otherwise "1".
898;
899!macro ValidateFilesDirect3D un
900Function ${un}ValidateD3DFiles
901
902 Push $0
903
904 ; We need to switch to 64-bit app mode to handle the "real" 64-bit files in
905 ; "system32" on a 64-bit guest
906 Call ${un}SetAppMode64
907
908 ; Note: Not finding a file (like *d3d8.dll) on Windows Vista/7 is fine;
909 ; it simply is not present there.
910
911 ; Note 2: On 64-bit systems there are no 64-bit *d3d8 DLLs, only 32-bit ones
912 ; in SysWOW64 (or in system32 on 32-bit systems).
913
914!if $%BUILD_TARGET_ARCH% == "x86"
915 ${VerifyFileEx} "${un}" "$SYSDIR\d3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
916 Pop $0
917 ${If} $0 == "1"
918 Goto verify_msd3d
919 ${EndIf}
920!endif
921
922 ${VerifyFileEx} "${un}" "$SYSDIR\d3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
923 Pop $0
924 ${If} $0 == "1"
925 Goto verify_msd3d
926 ${EndIf}
927
928 ${If} $g_bCapDllCache == "true"
929!if $%BUILD_TARGET_ARCH% == "x86"
930 ${VerifyFileEx} "${un}" "$SYSDIR\dllcache\d3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
931 Pop $0
932 ${If} $0 == "1"
933 Goto verify_msd3d
934 ${EndIf}
935!endif
936 ${VerifyFileEx} "${un}" "$SYSDIR\dllcache\d3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
937 Pop $0
938 ${If} $0 == "1"
939 Goto verify_msd3d
940 ${EndIf}
941 ${EndIf}
942
943!if $%BUILD_TARGET_ARCH% == "amd64"
944 ${VerifyFileEx} "${un}" "$g_strSysWow64\d3d8.dll" "Microsoft Corporation" "x86"
945 Pop $0
946 ${If} $0 == "1"
947 Goto verify_msd3d
948 ${EndIf}
949 ${VerifyFileEx} "${un}" "$g_strSysWow64\d3d9.dll" "Microsoft Corporation" "x86"
950 Pop $0
951 ${If} $0 == "1"
952 Goto verify_msd3d
953 ${EndIf}
954
955 ${If} $g_bCapDllCache == "true"
956 ${VerifyFileEx} "${un}" "$g_strSysWow64\dllcache\d3d8.dll" "Microsoft Corporation" "x86"
957 Pop $0
958 ${If} $0 == "1"
959 Goto verify_msd3d
960 ${EndIf}
961 ${VerifyFileEx} "${un}" "$g_strSysWow64\dllcache\d3d9.dll" "Microsoft Corporation" "x86"
962 Pop $0
963 ${If} $0 == "1"
964 Goto verify_msd3d
965 ${EndIf}
966 ${EndIf}
967
968!endif
969
970 Goto valid
971
972verify_msd3d:
973
974!if $%BUILD_TARGET_ARCH% == "x86"
975 ${VerifyFileEx} "${un}" "$SYSDIR\msd3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
976 Pop $0
977 ${If} $0 == "1"
978 Goto invalid
979 ${EndIf}
980!endif
981 ${VerifyFileEx} "${un}" "$SYSDIR\msd3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
982 Pop $0
983 ${If} $0 == "1"
984 Goto invalid
985 ${EndIf}
986
987 ${If} $g_bCapDllCache == "true"
988!if $%BUILD_TARGET_ARCH% == "x86"
989 ${VerifyFileEx} "${un}" "$SYSDIR\dllcache\msd3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
990 Pop $0
991 ${If} $0 == "1"
992 Goto invalid
993 ${EndIf}
994!endif
995 ${VerifyFileEx} "${un}" "$SYSDIR\dllcache\msd3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
996 Pop $0
997 ${If} $0 == "1"
998 Goto invalid
999 ${EndIf}
1000 ${EndIf}
1001
1002!if $%BUILD_TARGET_ARCH% == "amd64"
1003 ${VerifyFileEx} "${un}" "$g_strSysWow64\msd3d8.dll" "Microsoft Corporation" "x86"
1004 Pop $0
1005 ${If} $0 == "1"
1006 Goto invalid
1007 ${EndIf}
1008 ${VerifyFileEx} "${un}" "$g_strSysWow64\msd3d9.dll" "Microsoft Corporation" "x86"
1009 Pop $0
1010 ${If} $0 == "1"
1011 Goto invalid
1012 ${EndIf}
1013
1014 ${If} $g_bCapDllCache == "true"
1015 ${VerifyFileEx} "${un}" "$g_strSysWow64\dllcache\msd3d8.dll" "Microsoft Corporation" "x86"
1016 Pop $0
1017 ${If} $0 == "1"
1018 Goto invalid
1019 ${EndIf}
1020 ${VerifyFileEx} "${un}" "$g_strSysWow64\dllcache\msd3d9.dll" "Microsoft Corporation" "x86"
1021 Pop $0
1022 ${If} $0 == "1"
1023 Goto invalid
1024 ${EndIf}
1025 ${EndIf}
1026!endif
1027
1028 Goto valid
1029
1030valid:
1031
1032 StrCpy $0 "0" ; Installation valid
1033 Goto end
1034
1035invalid:
1036
1037 StrCpy $0 "1" ; Installation invalid / corrupted
1038 Goto end
1039
1040end:
1041
1042 Exch $0
1043
1044FunctionEnd
1045!macroend
1046!insertmacro ValidateFilesDirect3D ""
1047!insertmacro ValidateFilesDirect3D "un."
1048
1049;
1050; Restores formerly backed up Direct3D original files, which were replaced by
1051; a VBox XPDM driver installation before. This might be necessary for upgrading a
1052; XPDM installation to a WDDM one.
1053; @return Stack: "0" if files were restored successfully; otherwise "1".
1054;
1055!macro RestoreFilesDirect3D un
1056Function ${un}RestoreFilesDirect3D
1057
1058 Push $0
1059
1060 ; We need to switch to 64-bit app mode to handle the "real" 64-bit files in
1061 ; "system32" on a 64-bit guest
1062 Call ${un}SetAppMode64
1063
1064 ; Note: Not finding a file (like *d3d8.dll) on Windows Vista/7 is fine;
1065 ; it simply is not present there.
1066
1067 ; Note 2: On 64-bit systems there are no 64-bit *d3d8 DLLs, only 32-bit ones
1068 ; in SysWOW64 (or in system32 on 32-bit systems).
1069
1070 ${LogVerbose} "Restoring original D3D files ..."
1071!if $%BUILD_TARGET_ARCH% == "x86"
1072 ${PrepareWRPFileEx} "${un}" "$SYSDIR\d3d8.dll"
1073 ${CopyFileEx} "${un}" "$SYSDIR\msd3d8.dll" "$SYSDIR\d3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
1074!endif
1075 ${PrepareWRPFileEx} "${un}" "$SYSDIR\d3d9.dll"
1076 ${CopyFileEx} "${un}" "$SYSDIR\msd3d9.dll" "$SYSDIR\d3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
1077
1078 ${If} $g_bCapDllCache == "true"
1079!if $%BUILD_TARGET_ARCH% == "x86"
1080 ${PrepareWRPFileEx} "${un}" "$SYSDIR\dllcache\d3d8.dll"
1081 ${CopyFileEx} "${un}" "$SYSDIR\dllcache\msd3d8.dll" "$SYSDIR\dllcache\d3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
1082!endif
1083 ${PrepareWRPFileEx} "${un}" "$SYSDIR\dllcache\d3d9.dll"
1084 ${CopyFileEx} "${un}" "$SYSDIR\dllcache\msd3d9.dll" "$SYSDIR\dllcache\d3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
1085 ${EndIf}
1086
1087!if $%BUILD_TARGET_ARCH% == "amd64"
1088 ${PrepareWRPFileEx} "${un}" "$g_strSysWow64\d3d8.dll"
1089 ${CopyFileEx} "${un}" "$g_strSysWow64\msd3d8.dll" "$g_strSysWow64\d3d8.dll" "Microsoft Corporation" "x86"
1090 ${PrepareWRPFileEx} "${un}" "$g_strSysWow64\d3d9.dll"
1091 ${CopyFileEx} "${un}" "$g_strSysWow64\msd3d9.dll" "$g_strSysWow64\d3d9.dll" "Microsoft Corporation" "x86"
1092
1093 ${If} $g_bCapDllCache == "true"
1094 ${PrepareWRPFileEx} "${un}" "$g_strSysWow64\dllcache\d3d8.dll"
1095 ${CopyFileEx} "${un}" "$g_strSysWow64\dllcache\msd3d8.dll" "$g_strSysWow64\dllcache\d3d8.dll" "Microsoft Corporation" "x86"
1096 ${PrepareWRPFileEx} "${un}" "$g_strSysWow64\dllcache\d3d9.dll"
1097 ${CopyFileEx} "${un}" "$g_strSysWow64\dllcache\msd3d9.dll" "$g_strSysWow64\dllcache\d3d9.dll" "Microsoft Corporation" "x86"
1098 ${EndIf}
1099!endif
1100
1101 ; Do a re-validation afterwards.
1102 Call ${un}ValidateD3DFiles
1103 Pop $0
1104 ${If} $0 == "1" ; D3D files are invalid
1105 ${LogVerbose} $(VBOX_UNINST_UNABLE_TO_RESTORE_D3D)
1106 MessageBox MB_ICONSTOP|MB_OK $(VBOX_UNINST_UNABLE_TO_RESTORE_D3D) /SD IDOK
1107 ${EndIf}
1108
1109 Exch $0
1110
1111FunctionEnd
1112!macroend
1113!insertmacro RestoreFilesDirect3D ""
1114!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