VirtualBox

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

Last change on this file since 42903 was 42280, checked in by vboxsync, 13 years ago

Enabled the W8 display miniport driver. Cleaned up some mess.

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