VirtualBox

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

Last change on this file since 39695 was 39558, checked in by vboxsync, 13 years ago

Windows Guest Additions installer: Check for invalid/corrupted D3D files.

  • Property svn:eol-style set to native
File size: 21.6 KB
Line 
1; $Id: $
2;; @file
3; VBoxGuestAdditionsCommon.nsh - Common / shared utility functions.
4;
5
6;
7; Copyright (C) 2006-2011 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 !if $%BUILD_TARGET_ARCH% == "x86"
78 ; libWine is used for 32bit d3d only
79 ; @todo: remove it for 32bit as well
80 FILE "$%PATH_OUT%\bin\additions\libWine.dll"
81 !endif
82 FILE "$%PATH_OUT%\bin\additions\VBoxD3D8.dll"
83 FILE "$%PATH_OUT%\bin\additions\VBoxD3D9.dll"
84 FILE "$%PATH_OUT%\bin\additions\wined3d.dll"
85
86 !if $%BUILD_TARGET_ARCH% == "amd64"
87 ; Only 64-bit installer: Also copy 32-bit DLLs on 64-bit target
88 SetOutPath "$0\VBoxVideo\OpenGL\SysWow64"
89 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d8.dll"
90 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d9.dll"
91 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\libWine.dll"
92 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxOGLarrayspu.dll"
93 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxOGLcrutil.dll"
94 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxOGLerrorspu.dll"
95 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxOGLpackspu.dll"
96 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxOGLpassthroughspu.dll"
97 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxOGLfeedbackspu.dll"
98 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxOGL.dll"
99 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxD3D8.dll"
100 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxD3D9.dll"
101 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\wined3d.dll"
102 !endif
103!endif
104
105!if $%VBOX_WITH_WDDM% == "1"
106 ; WDDM Video driver
107 SetOutPath "$0\VBoxVideoWddm"
108
109 !ifdef VBOX_SIGN_ADDITIONS
110 FILE "$%PATH_OUT%\bin\additions\VBoxVideoWddm.cat"
111 !endif
112 FILE "$%PATH_OUT%\bin\additions\VBoxVideoWddm.sys"
113 FILE "$%PATH_OUT%\bin\additions\VBoxVideoWddm.inf"
114 FILE "$%PATH_OUT%\bin\additions\VBoxDispD3D.dll"
115
116 !if $%VBOX_WITH_CROGL% == "1"
117 FILE "$%PATH_OUT%\bin\additions\VBoxOGLarrayspu.dll"
118 FILE "$%PATH_OUT%\bin\additions\VBoxOGLcrutil.dll"
119 FILE "$%PATH_OUT%\bin\additions\VBoxOGLerrorspu.dll"
120 FILE "$%PATH_OUT%\bin\additions\VBoxOGLpackspu.dll"
121 FILE "$%PATH_OUT%\bin\additions\VBoxOGLpassthroughspu.dll"
122 FILE "$%PATH_OUT%\bin\additions\VBoxOGLfeedbackspu.dll"
123 FILE "$%PATH_OUT%\bin\additions\VBoxOGL.dll"
124
125 FILE "$%PATH_OUT%\bin\additions\VBoxD3D9wddm.dll"
126 FILE "$%PATH_OUT%\bin\additions\wined3dwddm.dll"
127 !endif ; $%VBOX_WITH_CROGL% == "1"
128
129 !if $%BUILD_TARGET_ARCH% == "amd64"
130 FILE "$%PATH_OUT%\bin\additions\VBoxDispD3D-x86.dll"
131
132 !if $%VBOX_WITH_CROGL% == "1"
133 FILE "$%PATH_OUT%\bin\additions\VBoxOGLarrayspu-x86.dll"
134 FILE "$%PATH_OUT%\bin\additions\VBoxOGLcrutil-x86.dll"
135 FILE "$%PATH_OUT%\bin\additions\VBoxOGLerrorspu-x86.dll"
136 FILE "$%PATH_OUT%\bin\additions\VBoxOGLpackspu-x86.dll"
137 FILE "$%PATH_OUT%\bin\additions\VBoxOGLpassthroughspu-x86.dll"
138 FILE "$%PATH_OUT%\bin\additions\VBoxOGLfeedbackspu-x86.dll"
139 FILE "$%PATH_OUT%\bin\additions\VBoxOGL-x86.dll"
140
141 FILE "$%PATH_OUT%\bin\additions\VBoxD3D9wddm-x86.dll"
142 FILE "$%PATH_OUT%\bin\additions\wined3dwddm-x86.dll"
143 !endif ; $%VBOX_WITH_CROGL% == "1"
144 !endif ; $%BUILD_TARGET_ARCH% == "amd64"
145!endif ; $%VBOX_WITH_WDDM% == "1"
146
147 ; Mouse driver
148 SetOutPath "$0\VBoxMouse"
149 FILE "$%PATH_OUT%\bin\additions\VBoxMouse.sys"
150 FILE "$%PATH_OUT%\bin\additions\VBoxMouse.inf"
151!ifdef VBOX_SIGN_ADDITIONS
152 FILE "$%PATH_OUT%\bin\additions\VBoxMouse.cat"
153!endif
154
155!if $%BUILD_TARGET_ARCH% == "x86"
156 SetOutPath "$0\VBoxMouse\NT4"
157 FILE "$%PATH_OUT%\bin\additions\VBoxMouseNT.sys"
158!endif
159
160 ; Guest driver
161 SetOutPath "$0\VBoxGuest"
162 FILE "$%PATH_OUT%\bin\additions\VBoxGuest.sys"
163 FILE "$%PATH_OUT%\bin\additions\VBoxGuest.inf"
164!ifdef VBOX_SIGN_ADDITIONS
165 FILE "$%PATH_OUT%\bin\additions\VBoxGuest.cat"
166!endif
167 FILE "$%PATH_OUT%\bin\additions\VBoxTray.exe"
168 FILE "$%PATH_OUT%\bin\additions\VBoxHook.dll"
169 FILE "$%PATH_OUT%\bin\additions\VBoxControl.exe"
170
171!if $%BUILD_TARGET_ARCH% == "x86"
172 SetOutPath "$0\VBoxGuest\NT4"
173 FILE "$%PATH_OUT%\bin\additions\VBoxGuestNT.sys"
174!endif
175
176 ; VBoxService
177 SetOutPath "$0\Bin"
178 FILE "$%PATH_OUT%\bin\additions\VBoxService.exe"
179!if $%BUILD_TARGET_ARCH% == "x86"
180 FILE "$%PATH_OUT%\bin\additions\VBoxServiceNT.exe"
181!endif
182
183 ; Shared Folders
184 SetOutPath "$0\VBoxSF"
185 FILE "$%PATH_OUT%\bin\additions\VBoxSF.sys"
186 FILE "$%PATH_OUT%\bin\additions\VBoxMRXNP.dll"
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 EnableLog un
210Function ${un}EnableLog
211
212!ifdef _DEBUG
213 Goto log
214!endif
215
216 StrCmp $g_bLogEnable "true" log
217 Goto exit
218
219log:
220
221 LogSet on
222 LogText "Start logging."
223
224exit:
225
226FunctionEnd
227!macroend
228!insertmacro EnableLog ""
229!insertmacro EnableLog "un."
230
231!macro WriteLogUI un
232Function ${un}WriteLogUI
233
234 IfSilent exit
235
236!ifdef _DEBUG
237 Goto log
238!endif
239
240 StrCmp $g_bLogEnable "true" log
241 Goto exit
242
243log:
244
245 ; Dump log to see what happened
246 StrCpy $0 "$INSTDIR\${un}install_ui.log"
247 Push $0
248 Call ${un}DumpLog
249
250exit:
251
252FunctionEnd
253!macroend
254!insertmacro WriteLogUI ""
255!insertmacro WriteLogUI "un."
256
257!macro WriteLogVBoxTray un
258Function ${un}WriteLogVBoxTray
259
260 ; Pop function parameters off the stack
261 ; in reverse order
262 Exch $1 ; Message type (0=Info, 1=Warning, 2=Error)
263 Exch
264 Exch $0 ; Body string
265
266 ; @todo Add more paramters here!
267!if $%VBOX_WITH_GUEST_INSTALL_HELPER% == "1"
268 ${If} $g_bPostInstallStatus == "true"
269 ; Parameters:
270 ; - String: Description / Body
271 ; - String: Title / Name of application
272 ; - Integer: Type of message: 0 (Info), 1 (Warning), 2 (Error)
273 ; - Integer: Time (in msec) to show the notification
274 VBoxGuestInstallHelper::VBoxTrayShowBallonMsg "$0" "VirtualBox Guest Additions Setup" $1 5000
275 Pop $0 ; Get return value (ignored for now)
276 ${EndIf}
277!endif
278 Pop $0
279 Pop $1
280
281FunctionEnd
282!macroend
283!insertmacro WriteLogVBoxTray ""
284!insertmacro WriteLogVBoxTray "un."
285
286!macro CheckArchitecture un
287Function ${un}CheckArchitecture
288
289 Push $0
290
291 System::Call "kernel32::GetCurrentProcess() i .s"
292 System::Call "kernel32::IsWow64Process(i s, *i .r0)"
293 ; R0 now contains 1 if we're a 64-bit process, or 0 if not
294
295!if $%BUILD_TARGET_ARCH% == "amd64"
296 IntCmp $0 0 wrong_platform
297!else ; 32-bit
298 IntCmp $0 1 wrong_platform
299!endif
300
301 Push 0
302 Goto exit
303
304wrong_platform:
305
306 Push 1
307 Goto exit
308
309exit:
310
311FunctionEnd
312!macroend
313!insertmacro CheckArchitecture ""
314!insertmacro CheckArchitecture "un."
315
316!macro GetWindowsVer un
317Function ${un}GetWindowsVer
318
319 ; Check if we are running on w2k or above
320 ; For other windows versions (>XP) it may be necessary to change winver.nsh
321 Call ${un}GetWindowsVersion
322 Pop $R3 ; Windows Version
323
324 Push $R3 ; The windows version string
325 Push "NT" ; String to search for. Win 2k family returns no string containing 'NT'
326 Call ${un}StrStr
327 Pop $R0
328 StrCmp $R0 '' nt5plus ; Not NT 3.XX or 4.XX
329
330 ; Ok we know it is NT. Must be a string like NT X.XX
331 Push $R3 ; The windows version string
332 Push "4." ; String to search for
333 Call ${un}StrStr
334 Pop $R0
335 StrCmp $R0 "" nt5plus nt4 ; If empty -> not NT 4
336
337nt5plus: ; Windows 2000+ (XP, Vista, ...)
338
339 StrCpy $g_strWinVersion $R3
340 goto exit
341
342nt4: ; NT 4.0
343
344 StrCpy $g_strWinVersion "NT4"
345 goto exit
346
347exit:
348
349FunctionEnd
350!macroend
351!insertmacro GetWindowsVer ""
352!insertmacro GetWindowsVer "un."
353
354!macro GetAdditionsVersion un
355Function ${un}GetAdditionsVersion
356
357 Push $0
358 Push $1
359
360 ; Get additions version
361 ReadRegStr $0 HKLM "SOFTWARE\$%VBOX_VENDOR_SHORT%\VirtualBox Guest Additions" "Version"
362
363 ; Get revision
364 ReadRegStr $g_strAddVerRev HKLM "SOFTWARE\$%VBOX_VENDOR_SHORT%\VirtualBox Guest Additions" "Revision"
365
366 ; Extract major version
367 Push "$0" ; String
368 Push "." ; SubString
369 Push ">" ; SearchDirection
370 Push "<" ; StrInclusionDirection
371 Push "0" ; IncludeSubString
372 Push "0" ; Loops
373 Push "0" ; CaseSensitive
374 Call ${un}StrStrAdv
375 Pop $g_strAddVerMaj
376
377 ; Extract minor version
378 Push "$0" ; String
379 Push "." ; SubString
380 Push ">" ; SearchDirection
381 Push ">" ; StrInclusionDirection
382 Push "0" ; IncludeSubString
383 Push "0" ; Loops
384 Push "0" ; CaseSensitive
385 Call ${un}StrStrAdv
386 Pop $1 ; Got first part (e.g. "1.5")
387
388 Push "$1" ; String
389 Push "." ; SubString
390 Push ">" ; SearchDirection
391 Push "<" ; StrInclusionDirection
392 Push "0" ; IncludeSubString
393 Push "0" ; Loops
394 Push "0" ; CaseSensitive
395 Call ${un}StrStrAdv
396 Pop $g_strAddVerMin ; Extracted second part (e.g. "5" from "1.5")
397
398 ; Extract build number
399 Push "$0" ; String
400 Push "." ; SubString
401 Push "<" ; SearchDirection
402 Push ">" ; StrInclusionDirection
403 Push "0" ; IncludeSubString
404 Push "0" ; Loops
405 Push "0" ; CaseSensitive
406 Call ${un}StrStrAdv
407 Pop $g_strAddVerBuild
408
409exit:
410
411 Pop $1
412 Pop $0
413
414FunctionEnd
415!macroend
416!insertmacro GetAdditionsVersion ""
417!insertmacro GetAdditionsVersion "un."
418
419!macro StopVBoxService un
420Function ${un}StopVBoxService
421
422 Push $0 ; Temp results
423 Push $1
424 Push $2 ; Image name of VBoxService
425 Push $3 ; Safety counter
426
427 StrCpy $3 "0" ; Init counter
428 DetailPrint "Stopping VBoxService ..."
429
430svc_stop:
431
432 LogText "Stopping VBoxService (as service) ..."
433 ${If} $g_strWinVersion == "NT4"
434 nsExec::Exec '"$SYSDIR\net.exe" stop VBoxService'
435 ${Else}
436 nsExec::Exec '"$SYSDIR\SC.exe" stop VBoxService'
437 ${EndIf}
438 Sleep "1000" ; Wait a bit
439
440exe_stop:
441
442!ifdef _DEBUG
443 DetailPrint "Stopping VBoxService (as exe) ..."
444!endif
445
446exe_stop_loop:
447
448 IntCmp $3 10 exit ; Only try this loop 10 times max
449 IntOp $3 $3 + 1 ; Increment
450
451 LogText "Try: $3"
452
453 ${If} $g_strWinVersion == "NT4"
454 StrCpy $2 "VBoxServiceNT.exe"
455 ${Else}
456 StrCpy $2 "VBoxService.exe"
457 ${EndIf}
458
459 ${nsProcess::FindProcess} $2 $0
460 StrCmp $0 0 0 exit
461
462 ${nsProcess::KillProcess} $2 $0
463 Sleep "1000" ; Wait a bit
464 Goto exe_stop_loop
465
466exit:
467
468 DetailPrint "Stopping VBoxService done."
469
470 Pop $3
471 Pop $2
472 Pop $1
473 Pop $0
474
475FunctionEnd
476!macroend
477!insertmacro StopVBoxService ""
478!insertmacro StopVBoxService "un."
479
480!macro StopVBoxTray un
481Function ${un}StopVBoxTray
482
483 Push $0 ; Temp results
484 Push $1 ; Safety counter
485
486 StrCpy $1 "0" ; Init counter
487 DetailPrint "Stopping VBoxTray ..."
488
489exe_stop:
490
491 IntCmp $1 10 exit ; Only try this loop 10 times max
492 IntOp $1 $1 + 1 ; Increment
493
494 ${nsProcess::FindProcess} "VBoxTray.exe" $0
495 StrCmp $0 0 0 exit
496
497 ${nsProcess::KillProcess} "VBoxTray.exe" $0
498 Sleep "1000" ; Wait a bit
499 Goto exe_stop
500
501exit:
502
503 DetailPrint "Stopping VBoxTray done."
504
505 Pop $1
506 Pop $0
507
508FunctionEnd
509!macroend
510!insertmacro StopVBoxTray ""
511!insertmacro StopVBoxTray "un."
512
513!macro WriteRegBinR ROOT KEY NAME VALUE
514 WriteRegBin "${ROOT}" "${KEY}" "${NAME}" "${VALUE}"
515!macroend
516
517!macro AbortShutdown un
518Function ${un}AbortShutdown
519
520 Push $0
521
522 ; Try to abort the shutdown
523 nsExec::ExecToLog '"$g_strSystemDir\shutdown.exe" -a' $0
524
525 Pop $0
526
527FunctionEnd
528!macroend
529!insertmacro AbortShutdown ""
530!insertmacro AbortShutdown "un."
531
532!macro CheckForWDDMCapability un
533Function ${un}CheckForWDDMCapability
534
535!if $%VBOX_WITH_WDDM% == "1"
536 ; If we're on a 32-bit Windows Vista / 7 / 8 we can use the WDDM driver
537 ${If} $g_strWinVersion == "Vista"
538 ${OrIf} $g_strWinVersion == "7"
539 ${OrIf} $g_strWinVersion == "8"
540 StrCpy $g_bCapWDDM "true"
541 ${EndIf}
542 ; If we're on Windows 8 we *have* to use the WDDM driver, so select it
543 ; by default
544 ${If} $g_strWinVersion == "8"
545 StrCpy $g_bWithWDDM "true"
546 ${EndIf}
547!endif
548
549FunctionEnd
550!macroend
551!insertmacro CheckForWDDMCapability ""
552!insertmacro CheckForWDDMCapability "un."
553
554!macro CheckForCapabilities un
555Function ${un}CheckForCapabilities
556
557 Push $0
558
559 ; Retrieve system mode and store result in
560 System::Call 'user32::GetSystemMetrics(i ${SM_CLEANBOOT}) i .r0'
561 StrCpy $g_iSystemMode $0
562
563 ; Check whether this OS is capable of handling WDDM drivers
564 Call ${un}CheckForWDDMCapability
565
566 Pop $0
567
568FunctionEnd
569!macroend
570!insertmacro CheckForCapabilities ""
571!insertmacro CheckForCapabilities "un."
572
573; Switches (back) the path + registry view to
574; 32-bit mode (SysWOW64) on 64-bit guests
575!macro SetAppMode32 un
576Function ${un}SetAppMode32
577 !if $%BUILD_TARGET_ARCH% == "amd64"
578 ${EnableX64FSRedirection}
579 SetRegView 32
580 !endif
581FunctionEnd
582!macroend
583!insertmacro SetAppMode32 ""
584!insertmacro SetAppMode32 "un."
585
586; Because this NSIS installer is always built in 32-bit mode, we have to
587; do some tricks for the Windows paths + registry on 64-bit guests
588!macro SetAppMode64 un
589Function ${un}SetAppMode64
590 !if $%BUILD_TARGET_ARCH% == "amd64"
591 ${DisableX64FSRedirection}
592 SetRegView 64
593 !endif
594FunctionEnd
595!macroend
596!insertmacro SetAppMode64 ""
597!insertmacro SetAppMode64 "un."
598
599;
600; Retrieves the vendor ("CompanyName" of FILEINFO structure)
601; of a given file.
602; @return Stack: Company name, or "" on error/if not found.
603; @param Stack: File name to retrieve vendor for.
604;
605!macro GetFileVendor un
606Function ${un}GetFileVendor
607
608 ; Preserve values
609 Exch $0 ; Stack: $0 <filename> (Get file name into $0)
610 Push $1
611
612 IfFileExists "$0" found
613 Goto not_found
614
615found:
616
617 VBoxGuestInstallHelper::FileGetVendor "$0"
618 ; Stack: <vendor> $1 $0
619 Pop $0 ; Get vendor
620 Pop $1 ; Restore $1
621 Exch $0 ; Restore $0, push vendor on top of stack
622 Goto end
623
624not_found:
625
626 Pop $1
627 Pop $0
628 Push "File not found"
629 Goto end
630
631end:
632
633FunctionEnd
634!macroend
635!insertmacro GetFileVendor ""
636!insertmacro GetFileVendor "un."
637
638;
639; Retrieves the architecture of a given file.
640; @return Stack: Architecture ("x86", "amd64") or error message.
641; @param Stack: File name to retrieve architecture for.
642;
643!macro GetFileArchitecture un
644Function ${un}GetFileArchitecture
645
646 ; Preserve values
647 Exch $0 ; Stack: $0 <filename> (Get file name into $0)
648 Push $1
649
650 IfFileExists "$0" found
651 Goto not_found
652
653found:
654
655 VBoxGuestInstallHelper::FileGetArchitecture "$0"
656 ; Stack: <architecture> $1 $0
657 Pop $0 ; Get architecture string
658 Pop $1 ; Restore $1
659 Exch $0 ; Restore $0, push vendor on top of stack
660 Goto end
661
662not_found:
663
664 Pop $1
665 Pop $0
666 Push "File not found"
667 Goto end
668
669end:
670
671FunctionEnd
672!macroend
673!insertmacro GetFileArchitecture ""
674!insertmacro GetFileArchitecture "un."
675
676;
677; Verifies a given file by checking its file vendor and target
678; architecture.
679; @return Stack: "0" if valid, "1" if not, "2" on error / not found.
680; @param Stack: Architecture ("x86" or "amd64").
681; @param Stack: Vendor.
682; @param Stack: File name to verify.
683;
684!macro VerifyFile un
685Function ${un}VerifyFile
686
687 ; Preserve values
688 Exch $0 ; File; S: old$0 vendor arch
689 Exch ; S: vendor old$0 arch
690 Exch $1 ; Vendor; S: old$1 old$0 arch
691 Exch ; S: old$0 old$1 arch
692 Exch 2 ; S: arch old$1 old$0
693 Exch $2 ; Architecture; S: old$2 old$1 old$0
694 Push $3 ; S: old$3 old$2 old$1 old$0
695
696 IfFileExists "$0" check_vendor
697 Goto not_found
698
699check_vendor:
700
701 Push $0
702 Call ${un}GetFileVendor
703 Pop $3
704
705 ${If} $3 == $1
706 Goto check_arch
707 ${EndIf}
708 StrCpy $3 "1" ; Invalid
709 Goto end
710
711check_arch:
712
713 Push $0
714 Call ${un}GetFileArchitecture
715 Pop $3
716
717 ${If} $3 == $2
718 StrCpy $3 "0" ; Valid
719 ${Else}
720 StrCpy $3 "1" ; Invalid
721 ${EndIf}
722 Goto end
723
724not_found:
725
726 StrCpy $3 "2" ; Not found
727 Goto end
728
729end:
730
731 ; S: old$3 old$2 old$1 old$0
732 Exch $3 ; S: $3 old$2 old$1 old$0
733 Exch ; S: old$2 $3 old$1
734 Pop $2 ; S: $3 old$1 old$0
735 Exch ; S: old$1 $3 old$0
736 Pop $1 ; S: $3 old$0
737 Exch ; S: old$0 $3
738 Pop $0 ; S: $3
739
740FunctionEnd
741!macroend
742!insertmacro VerifyFile ""
743!insertmacro VerifyFile "un."
744
745;
746; Macro for accessing VerifyFile in a more convenient way by using
747; a parameter list.
748; @return Stack: "0" if valid, "1" if not, "2" on error / not found.
749; @param Un/Installer prefix; either "" or "un".
750; @param Name of file to verify.
751; @param Vendor to check for.
752; @param Architecture ("x86" or "amd64") to check for.
753;
754!macro VerifyFileEx un File Vendor Architecture
755 Push "${Architecture}"
756 Push "${Vendor}"
757 Push "${File}"
758 Call ${un}VerifyFile
759!macroend
760!define VerifyFileEx "!insertmacro VerifyFileEx"
761
762;
763; Validates backed up and replaced Direct3D files; either the d3d*.dll have
764; to be from Microsoft or the (already) backed up msd3d*.dll files. If both
765; don't match we have a corrupted / invalid installation.
766; @return Stack: "0" if files are valid; otherwise "1".
767;
768!macro ValidateFilesDirect3D un
769Function ${un}ValidateD3DFiles
770
771 Push $0
772
773 ; We need to switch to 64-bit app mode to handle the "real" 64-bit files in
774 ; ""system32" on a 64-bit guest
775 Call ${un}SetAppMode64
776
777 ; Note: Not finding a file (like *d3d8.dll) on Windows Vista/7 is fine;
778 ; it simply is not present there.
779
780 ${VerifyFileEx} "${un}" "$SYSDIR\d3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
781 Pop $0
782 ${If} $0 == "1"
783 Goto verify_msd3d
784 ${EndIf}
785 ${VerifyFileEx} "${un}" "$SYSDIR\d3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
786 Pop $0
787 ${If} $0 == "1"
788 Goto verify_msd3d
789 ${EndIf}
790
791 ${VerifyFileEx} "${un}" "$SYSDIR\dllcache\d3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
792 Pop $0
793 ${If} $0 == "1"
794 Goto verify_msd3d
795 ${EndIf}
796 ${VerifyFileEx} "${un}" "$SYSDIR\dllcache\d3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
797 Pop $0
798 ${If} $0 == "1"
799 Goto verify_msd3d
800 ${EndIf}
801
802!if $%BUILD_TARGET_ARCH% == "amd64"
803
804 ${VerifyFileEx} "${un}" "$g_strSysWow64\d3d8.dll" "Microsoft Corporation" "x86"
805 Pop $0
806 ${If} $0 == "1"
807 Goto verify_msd3d
808 ${EndIf}
809 ${VerifyFileEx} "${un}" "$g_strSysWow64\d3d9.dll" "Microsoft Corporation" "x86"
810 Pop $0
811 ${If} $0 == "1"
812 Goto verify_msd3d
813 ${EndIf}
814
815 ${VerifyFileEx} "${un}" "$g_strSysWow64\dllcache\d3d8.dll" "Microsoft Corporation" "x86"
816 Pop $0
817 ${If} $0 == "1"
818 Goto verify_msd3d
819 ${EndIf}
820 ${VerifyFileEx} "${un}" "$g_strSysWow64\dllcache\d3d9.dll" "Microsoft Corporation" "x86"
821 Pop $0
822 ${If} $0 == "1"
823 Goto verify_msd3d
824 ${EndIf}
825
826!endif
827
828 Goto valid
829
830verify_msd3d:
831
832 ${VerifyFileEx} "${un}" "$SYSDIR\msd3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
833 Pop $0
834 ${If} $0 == "1"
835 Goto invalid
836 ${EndIf}
837 ${VerifyFileEx} "${un}" "$SYSDIR\msd3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
838 Pop $0
839 ${If} $0 == "1"
840 Goto invalid
841 ${EndIf}
842
843 ${VerifyFileEx} "${un}" "$SYSDIR\dllcache\msd3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
844 Pop $0
845 ${If} $0 == "1"
846 Goto invalid
847 ${EndIf}
848 ${VerifyFileEx} "${un}" "$SYSDIR\dllcache\msd3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
849 Pop $0
850 ${If} $0 == "1"
851 Goto invalid
852 ${EndIf}
853
854!if $%BUILD_TARGET_ARCH% == "amd64"
855
856 ${VerifyFileEx} "${un}" "$g_strSysWow64\msd3d8.dll" "Microsoft Corporation" "x86"
857 Pop $0
858 ${If} $0 == "1"
859 Goto invalid
860 ${EndIf}
861 ${VerifyFileEx} "${un}" "$g_strSysWow64\msd3d9.dll" "Microsoft Corporation" "x86"
862 Pop $0
863 ${If} $0 == "1"
864 Goto invalid
865 ${EndIf}
866
867 ${VerifyFileEx} "${un}" "$g_strSysWow64\dllcache\msd3d8.dll" "Microsoft Corporation" "x86"
868 Pop $0
869 ${If} $0 == "1"
870 Goto invalid
871 ${EndIf}
872 ${VerifyFileEx} "${un}" "$g_strSysWow64\dllcache\msd3d9.dll" "Microsoft Corporation" "x86"
873 Pop $0
874 ${If} $0 == "1"
875 Goto invalid
876 ${EndIf}
877
878!endif
879
880 Goto valid
881
882valid:
883
884 StrCpy $0 "0" ; Installation valid
885 Goto end
886
887invalid:
888
889 StrCpy $0 "1" ; Installation invalid / corrupted
890 Goto end
891
892end:
893
894 Exch $0
895
896FunctionEnd
897!macroend
898!insertmacro ValidateFilesDirect3D ""
899!insertmacro ValidateFilesDirect3D "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