VirtualBox

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

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

Additions: Remove the VBoxOGLarrayspu library as it is unused for a long time already bugref:9435

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