VirtualBox

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

Last change on this file since 79241 was 78408, checked in by vboxsync, 6 years ago

Additions,GuestHost/OpenGL,HostServices/SharedOpenGL: Get rid of the individual SPU shared libraries and merge them into the VBoxSharedCrOpenGL shared libraries on the host and VBoxOGL{,-x86} shared libraries for the guest additions, bugref:9435

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

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