VirtualBox

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

Last change on this file since 44864 was 44864, checked in by vboxsync, 12 years ago

VBoxMMR: ported from 4.2 to trunk (not enabled).

  • Property svn:eol-style set to native
File size: 27.2 KB
Line 
1; $Id$
2; @file
3; VBoxGuestAdditionsCommon.nsh - Common / shared utility functions.
4;
5
6;
7; Copyright (C) 2006-2013 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 CheckArchitecture un
250Function ${un}CheckArchitecture
251
252 Push $0
253
254 System::Call "kernel32::GetCurrentProcess() i .s"
255 System::Call "kernel32::IsWow64Process(i s, *i .r0)"
256 ; R0 now contains 1 if we're a 64-bit process, or 0 if not
257
258!if $%BUILD_TARGET_ARCH% == "amd64"
259 IntCmp $0 0 wrong_platform
260!else ; 32-bit
261 IntCmp $0 1 wrong_platform
262!endif
263
264 Push 0
265 Goto exit
266
267wrong_platform:
268
269 Push 1
270 Goto exit
271
272exit:
273
274FunctionEnd
275!macroend
276!insertmacro CheckArchitecture ""
277!insertmacro CheckArchitecture "un."
278
279;
280; Macro for retrieving the Windows version this installer is running on.
281;
282; @return Stack: Windows version string. Empty on error /
283; if not able to identify.
284;
285!macro GetWindowsVersionEx un
286Function ${un}GetWindowsVersionEx
287
288 Push $0
289 Push $1
290
291 ; Check if we are running on Windows 2000 or above
292 ; For other windows versions (> XP) it may be necessary to change winver.nsh
293 Call ${un}GetWindowsVersion
294 Pop $0 ; Windows Version
295
296 Push $0 ; The windows version string
297 Push "NT" ; String to search for. W2K+ returns no string containing "NT"
298 Call ${un}StrStr
299 Pop $1
300
301 ${If} $1 == "" ; If empty -> not NT 3.XX or 4.XX
302 ; $0 contains the original version string
303 ${Else}
304 ; Ok we know it is NT. Must be a string like NT X.XX
305 Push $0 ; The windows version string
306 Push "4." ; String to search for
307 Call ${un}StrStr
308 Pop $1
309 ${If} $1 == "" ; If empty -> not NT 4
310 ;; @todo NT <= 3.x ?
311 ; $0 contains the original version string
312 ${Else}
313 StrCpy $0 "NT4"
314 ${EndIf}
315 ${EndIf}
316
317 Pop $1
318 Exch $0
319
320FunctionEnd
321!macroend
322!insertmacro GetWindowsVersionEx ""
323!insertmacro GetWindowsVersionEx "un."
324
325!macro GetAdditionsVersion un
326Function ${un}GetAdditionsVersion
327
328 Push $0
329 Push $1
330
331 ; Get additions version
332 ReadRegStr $0 HKLM "SOFTWARE\$%VBOX_VENDOR_SHORT%\VirtualBox Guest Additions" "Version"
333
334 ; Get revision
335 ReadRegStr $g_strAddVerRev HKLM "SOFTWARE\$%VBOX_VENDOR_SHORT%\VirtualBox Guest Additions" "Revision"
336
337 ; Extract major version
338 Push "$0" ; String
339 Push "." ; SubString
340 Push ">" ; SearchDirection
341 Push "<" ; StrInclusionDirection
342 Push "0" ; IncludeSubString
343 Push "0" ; Loops
344 Push "0" ; CaseSensitive
345 Call ${un}StrStrAdv
346 Pop $g_strAddVerMaj
347
348 ; Extract minor version
349 Push "$0" ; String
350 Push "." ; SubString
351 Push ">" ; SearchDirection
352 Push ">" ; StrInclusionDirection
353 Push "0" ; IncludeSubString
354 Push "0" ; Loops
355 Push "0" ; CaseSensitive
356 Call ${un}StrStrAdv
357 Pop $1 ; Got first part (e.g. "1.5")
358
359 Push "$1" ; String
360 Push "." ; SubString
361 Push ">" ; SearchDirection
362 Push "<" ; StrInclusionDirection
363 Push "0" ; IncludeSubString
364 Push "0" ; Loops
365 Push "0" ; CaseSensitive
366 Call ${un}StrStrAdv
367 Pop $g_strAddVerMin ; Extracted second part (e.g. "5" from "1.5")
368
369 ; Extract build number
370 Push "$0" ; String
371 Push "." ; SubString
372 Push "<" ; SearchDirection
373 Push ">" ; StrInclusionDirection
374 Push "0" ; IncludeSubString
375 Push "0" ; Loops
376 Push "0" ; CaseSensitive
377 Call ${un}StrStrAdv
378 Pop $g_strAddVerBuild
379
380exit:
381
382 Pop $1
383 Pop $0
384
385FunctionEnd
386!macroend
387!insertmacro GetAdditionsVersion ""
388!insertmacro GetAdditionsVersion "un."
389
390!macro StopVBoxService un
391Function ${un}StopVBoxService
392
393 Push $0 ; Temp results
394 Push $1
395 Push $2 ; Image name of VBoxService
396 Push $3 ; Safety counter
397
398 StrCpy $3 "0" ; Init counter
399 ${LogVerbose} "Stopping VBoxService ..."
400
401svc_stop:
402
403 ${LogVerbose} "Stopping VBoxService via SCM ..."
404 ${If} $g_strWinVersion == "NT4"
405 nsExec::Exec '"$SYSDIR\net.exe" stop VBoxService'
406 ${Else}
407 nsExec::Exec '"$SYSDIR\SC.exe" stop VBoxService'
408 ${EndIf}
409 Sleep "1000" ; Wait a bit
410
411exe_stop:
412
413!ifdef _DEBUG
414 ${LogVerbose} "Stopping VBoxService (as exe) ..."
415!endif
416
417exe_stop_loop:
418
419 IntCmp $3 10 exit ; Only try this loop 10 times max
420 IntOp $3 $3 + 1 ; Increment
421
422!ifdef _DEBUG
423 ${LogVerbose} "Stopping attempt #$3"
424!endif
425
426 ${If} $g_strWinVersion == "NT4"
427 StrCpy $2 "VBoxServiceNT.exe"
428 ${Else}
429 StrCpy $2 "VBoxService.exe"
430 ${EndIf}
431
432 ${nsProcess::FindProcess} $2 $0
433 StrCmp $0 0 0 exit
434
435 ${nsProcess::KillProcess} $2 $0
436 Sleep "1000" ; Wait a bit
437 Goto exe_stop_loop
438
439exit:
440
441 ${LogVerbose} "Stopping VBoxService done"
442
443 Pop $3
444 Pop $2
445 Pop $1
446 Pop $0
447
448FunctionEnd
449!macroend
450!insertmacro StopVBoxService ""
451!insertmacro StopVBoxService "un."
452
453!macro StopVBoxTray un
454Function ${un}StopVBoxTray
455
456 Push $0 ; Temp results
457 Push $1 ; Safety counter
458
459 StrCpy $1 "0" ; Init counter
460 ${LogVerbose} "Stopping VBoxTray ..."
461
462exe_stop:
463
464 IntCmp $1 10 exit ; Only try this loop 10 times max
465 IntOp $1 $1 + 1 ; Increment
466
467 ${nsProcess::FindProcess} "VBoxTray.exe" $0
468 StrCmp $0 0 0 exit
469
470 ${nsProcess::KillProcess} "VBoxTray.exe" $0
471 Sleep "1000" ; Wait a bit
472 Goto exe_stop
473
474exit:
475
476 ${LogVerbose} "Stopping VBoxTray done"
477
478 Pop $1
479 Pop $0
480
481FunctionEnd
482!macroend
483!insertmacro StopVBoxTray ""
484!insertmacro StopVBoxTray "un."
485
486!macro StopVBoxMMR un
487Function ${un}StopVBoxMMR
488
489 Push $0 ; Temp results
490 Push $1 ; Safety counter
491
492 StrCpy $1 "0" ; Init counter
493 DetailPrint "Stopping VBoxMMR ..."
494
495exe_stop:
496
497 IntCmp $1 10 exit ; Only try this loop 10 times max
498 IntOp $1 $1 + 1 ; Increment
499
500 ${nsProcess::FindProcess} "VBoxMMR.exe" $0
501 StrCmp $0 0 0 exit
502
503 ${nsProcess::KillProcess} "VBoxMMR.exe" $0
504 Sleep "1000" ; Wait a bit
505 Goto exe_stop
506
507exit:
508
509 DetailPrint "Stopping VBoxMMR done."
510
511 Pop $1
512 Pop $0
513
514FunctionEnd
515!macroend
516!insertmacro StopVBoxMMR ""
517!insertmacro StopVBoxMMR "un."
518
519!macro WriteRegBinR ROOT KEY NAME VALUE
520 WriteRegBin "${ROOT}" "${KEY}" "${NAME}" "${VALUE}"
521!macroend
522
523!macro AbortShutdown un
524Function ${un}AbortShutdown
525
526 ${If} ${FileExists} "$g_strSystemDir\shutdown.exe"
527 ; Try to abort the shutdown
528 ${CmdExecute} "$\"$g_strSystemDir\shutdown.exe$\" -a" "true"
529 ${Else}
530 ${LogVerbose} "Shutting down not supported: Binary $\"$g_strSystemDir\shutdown.exe$\" not found"
531 ${EndIf}
532
533FunctionEnd
534!macroend
535!insertmacro AbortShutdown ""
536!insertmacro AbortShutdown "un."
537
538!macro CheckForWDDMCapability un
539Function ${un}CheckForWDDMCapability
540
541!if $%VBOX_WITH_WDDM% == "1"
542 ; If we're on a 32-bit Windows Vista / 7 / 8 we can use the WDDM driver
543 ${If} $g_strWinVersion == "Vista"
544 ${OrIf} $g_strWinVersion == "7"
545 ${OrIf} $g_strWinVersion == "8"
546 StrCpy $g_bCapWDDM "true"
547 ${LogVerbose} "OS is WDDM driver capable"
548 ${EndIf}
549 ; If we're on Windows 8 we *have* to use the WDDM driver, so select it
550 ; by default
551 ${If} $g_strWinVersion == "8"
552 StrCpy $g_bWithWDDM "true"
553 ${LogVerbose} "OS needs WDDM driver by default"
554 ${EndIf}
555!endif
556
557FunctionEnd
558!macroend
559!insertmacro CheckForWDDMCapability ""
560!insertmacro CheckForWDDMCapability "un."
561
562!macro CheckForCapabilities un
563Function ${un}CheckForCapabilities
564
565 Push $0
566
567 ; Retrieve system mode and store result in
568 System::Call 'user32::GetSystemMetrics(i ${SM_CLEANBOOT}) i .r0'
569 StrCpy $g_iSystemMode $0
570
571 ; Does the guest have a DLL cache?
572 ${If} $g_strWinVersion == "Vista"
573 ${OrIf} $g_strWinVersion == "7"
574 ${OrIf} $g_strWinVersion == "8"
575 StrCpy $g_bCapDllCache "true"
576 ${LogVerbose} "OS has a DLL cache"
577 ${EndIf}
578
579 ; Check whether this OS is capable of handling WDDM drivers
580 Call ${un}CheckForWDDMCapability
581
582 Pop $0
583
584FunctionEnd
585!macroend
586!insertmacro CheckForCapabilities ""
587!insertmacro CheckForCapabilities "un."
588
589; Switches (back) the path + registry view to
590; 32-bit mode (SysWOW64) on 64-bit guests
591!macro SetAppMode32 un
592Function ${un}SetAppMode32
593 !if $%BUILD_TARGET_ARCH% == "amd64"
594 ${EnableX64FSRedirection}
595 SetRegView 32
596 !endif
597FunctionEnd
598!macroend
599!insertmacro SetAppMode32 ""
600!insertmacro SetAppMode32 "un."
601
602; Because this NSIS installer is always built in 32-bit mode, we have to
603; do some tricks for the Windows paths + registry on 64-bit guests
604!macro SetAppMode64 un
605Function ${un}SetAppMode64
606 !if $%BUILD_TARGET_ARCH% == "amd64"
607 ${DisableX64FSRedirection}
608 SetRegView 64
609 !endif
610FunctionEnd
611!macroend
612!insertmacro SetAppMode64 ""
613!insertmacro SetAppMode64 "un."
614
615;
616; Retrieves the vendor ("CompanyName" of FILEINFO structure)
617; of a given file.
618; @return Stack: Company name, or "" on error/if not found.
619; @param Stack: File name to retrieve vendor for.
620;
621!macro GetFileVendor un
622Function ${un}GetFileVendor
623
624 ; Preserve values
625 Exch $0 ; Stack: $0 <filename> (Get file name into $0)
626 Push $1
627
628 IfFileExists "$0" found
629 Goto not_found
630
631found:
632
633 VBoxGuestInstallHelper::FileGetVendor "$0"
634 ; Stack: <vendor> $1 $0
635 Pop $0 ; Get vendor
636 Pop $1 ; Restore $1
637 Exch $0 ; Restore $0, push vendor on top of stack
638 Goto end
639
640not_found:
641
642 Pop $1
643 Pop $0
644 Push "File not found"
645 Goto end
646
647end:
648
649FunctionEnd
650!macroend
651!insertmacro GetFileVendor ""
652!insertmacro GetFileVendor "un."
653
654;
655; Retrieves the architecture of a given file.
656; @return Stack: Architecture ("x86", "amd64") or error message.
657; @param Stack: File name to retrieve architecture for.
658;
659!macro GetFileArchitecture un
660Function ${un}GetFileArchitecture
661
662 ; Preserve values
663 Exch $0 ; Stack: $0 <filename> (Get file name into $0)
664 Push $1
665
666 IfFileExists "$0" found
667 Goto not_found
668
669found:
670
671 VBoxGuestInstallHelper::FileGetArchitecture "$0"
672 ; Stack: <architecture> $1 $0
673 Pop $0 ; Get architecture string
674 Pop $1 ; Restore $1
675 Exch $0 ; Restore $0, push vendor on top of stack
676 Goto end
677
678not_found:
679
680 Pop $1
681 Pop $0
682 Push "File not found"
683 Goto end
684
685end:
686
687FunctionEnd
688!macroend
689!insertmacro GetFileArchitecture ""
690!insertmacro GetFileArchitecture "un."
691
692;
693; Verifies a given file by checking its file vendor and target
694; architecture.
695; @return Stack: "0" if valid, "1" if not, "2" on error / not found.
696; @param Stack: Architecture ("x86" or "amd64").
697; @param Stack: Vendor.
698; @param Stack: File name to verify.
699;
700!macro VerifyFile un
701Function ${un}VerifyFile
702
703 ; Preserve values
704 Exch $0 ; File; S: old$0 vendor arch
705 Exch ; S: vendor old$0 arch
706 Exch $1 ; Vendor; S: old$1 old$0 arch
707 Exch ; S: old$0 old$1 arch
708 Exch 2 ; S: arch old$1 old$0
709 Exch $2 ; Architecture; S: old$2 old$1 old$0
710 Push $3 ; S: old$3 old$2 old$1 old$0
711
712 IfFileExists "$0" check_vendor
713 Goto not_found
714
715check_vendor:
716
717 Push $0
718 Call ${un}GetFileVendor
719 Pop $3
720
721 ${If} $3 == $1
722 Goto check_arch
723 ${EndIf}
724 StrCpy $3 "1" ; Invalid
725 Goto end
726
727check_arch:
728
729 Push $0
730 Call ${un}GetFileArchitecture
731 Pop $3
732
733 ${If} $3 == $2
734 StrCpy $3 "0" ; Valid
735 ${Else}
736 StrCpy $3 "1" ; Invalid
737 ${EndIf}
738 Goto end
739
740not_found:
741
742 StrCpy $3 "2" ; Not found
743 Goto end
744
745end:
746
747 ; S: old$3 old$2 old$1 old$0
748 Exch $3 ; S: $3 old$2 old$1 old$0
749 Exch ; S: old$2 $3 old$1
750 Pop $2 ; S: $3 old$1 old$0
751 Exch ; S: old$1 $3 old$0
752 Pop $1 ; S: $3 old$0
753 Exch ; S: old$0 $3
754 Pop $0 ; S: $3
755
756FunctionEnd
757!macroend
758!insertmacro VerifyFile ""
759!insertmacro VerifyFile "un."
760
761;
762; Macro for accessing VerifyFile in a more convenient way by using
763; a parameter list.
764; @return Stack: "0" if valid, "1" if not, "2" on error / not found.
765; @param Un/Installer prefix; either "" or "un".
766; @param Name of file to verify.
767; @param Vendor to check for.
768; @param Architecture ("x86" or "amd64") to check for.
769;
770!macro VerifyFileEx un File Vendor Architecture
771 Push $0
772 Push "${Architecture}"
773 Push "${Vendor}"
774 Push "${File}"
775 ${LogVerbose} "Verifying file $\"${File}$\" ..."
776 Call ${un}VerifyFile
777 Pop $0
778 ${If} $0 == "0"
779 ${LogVerbose} "Verification of file $\"${File}$\" successful (Vendor: ${Vendor}, Architecture: ${Architecture})"
780 ${ElseIf} $0 == "1"
781 ${LogVerbose} "Verification of file $\"${File}$\" failed (not Vendor: ${Vendor}, and/or not Architecture: ${Architecture})"
782 ${Else}
783 ${LogVerbose} "Skipping to file $\"${File}$\"; not found"
784 ${EndIf}
785 ; Push result popped off the stack to stack again
786 Push $0
787!macroend
788!define VerifyFileEx "!insertmacro VerifyFileEx"
789
790;
791; Macro for copying a file only if the source file is verified
792; to be from a certain vendor and architecture.
793; @return Stack: "0" if copied, "1" if not, "2" on error / not found.
794; @param Un/Installer prefix; either "" or "un".
795; @param Name of file to verify and copy to destination.
796; @param Destination name to copy verified file to.
797; @param Vendor to check for.
798; @param Architecture ("x86" or "amd64") to check for.
799;
800!macro CopyFileEx un FileSrc FileDest Vendor Architecture
801 Push $0
802 Push "${Architecture}"
803 Push "${Vendor}"
804 Push "${FileSrc}"
805 Call ${un}VerifyFile
806 Pop $0
807 ${If} $0 == "0"
808 ${LogVerbose} "Copying verified file $\"${FileSrc}$\" to $\"${FileDest}$\" ..."
809 CopyFiles /SILENT "${FileSrc}" "${FileDest}"
810 ${Else}
811 ${LogVerbose} "Skipping to copy file $\"${FileSrc}$\" to $\"${FileDest}$\" (not Vendor: ${Vendor}, Architecture: ${Architecture})"
812 ${EndIf}
813 ; Push result popped off the stack to stack again
814 Push $0
815!macroend
816!define CopyFileEx "!insertmacro CopyFileEx"
817
818;
819; Macro for installing a library/DLL.
820; @return Stack: "0" if copied, "1" if not, "2" on error / not found.
821; @param Un/Installer prefix; either "" or "un".
822; @param Name of lib/DLL to verify and copy to destination.
823; @param Destination name to copy verified file to.
824; @param Temporary folder used for exchanging the (locked) lib/DLL after a reboot.
825;
826!macro InstallFileEx un FileSrc FileDest DirTemp
827 ${LogVerbose} "Installing library $\"${FileSrc}$\" to $\"${FileDest}$\" ..."
828 ; Try the gentle way and replace the file instantly
829 !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "${FileSrc}" "${FileDest}" "${DirTemp}"
830 ; If the above call didn't help, use a (later) reboot to replace the file
831 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "${FileSrc}" "${FileDest}" "${DirTemp}"
832!macroend
833!define InstallFileEx "!insertmacro InstallFileEx"
834
835;
836; Macro for installing a library/DLL.
837; @return Stack: "0" if copied, "1" if not, "2" on error / not found.
838; @param Un/Installer prefix; either "" or "un".
839; @param Name of lib/DLL to verify and copy to destination.
840; @param Destination name to copy verified file to.
841; @param Temporary folder used for exchanging the (locked) lib/DLL after a reboot.
842; @param Vendor to check for.
843; @param Architecture ("x86" or "amd64") to check for.
844;
845!macro InstallFileVerify un FileSrc FileDest DirTemp Vendor Architecture
846 Push $0
847 Push "${Architecture}"
848 Push "${Vendor}"
849 Push "${FileSrc}"
850 ${LogVerbose} "Verifying library $\"${FileSrc}$\" ..."
851 Call ${un}VerifyFile
852 Pop $0
853 ${If} $0 == "0"
854 ${InstallFileEx} ${un} ${FileSrc} ${FileDest} ${DirTemp}
855 ${Else}
856 ${LogVerbose} "File $\"${FileSrc}$\" did not pass verification (Vendor: ${Vendor}, Architecture: ${Architecture})"
857 ${EndIf}
858 ; Push result popped off the stack to stack again.
859 Push $0
860!macroend
861!define InstallFileVerify "!insertmacro InstallFileVerify"
862
863;
864; Validates backed up and replaced Direct3D files; either the d3d*.dll have
865; to be from Microsoft or the (already) backed up msd3d*.dll files. If both
866; don't match we have a corrupted / invalid installation.
867; @return Stack: "0" if files are valid; otherwise "1".
868;
869!macro ValidateFilesDirect3D un
870Function ${un}ValidateD3DFiles
871
872 Push $0
873
874 ; We need to switch to 64-bit app mode to handle the "real" 64-bit files in
875 ; ""system32" on a 64-bit guest
876 Call ${un}SetAppMode64
877
878 ; Note: Not finding a file (like *d3d8.dll) on Windows Vista/7 is fine;
879 ; it simply is not present there.
880
881 ; Note 2: On 64-bit systems there are no 64-bit *d3d8 DLLs, only 32-bit ones
882 ; in SysWOW64 (or in system32 on 32-bit systems).
883
884!if $%BUILD_TARGET_ARCH% == "x86"
885 ${VerifyFileEx} "${un}" "$SYSDIR\d3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
886 Pop $0
887 ${If} $0 == "1"
888 Goto verify_msd3d
889 ${EndIf}
890!endif
891
892 ${VerifyFileEx} "${un}" "$SYSDIR\d3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
893 Pop $0
894 ${If} $0 == "1"
895 Goto verify_msd3d
896 ${EndIf}
897
898 ${If} $g_bCapDllCache == "true"
899!if $%BUILD_TARGET_ARCH% == "x86"
900 ${VerifyFileEx} "${un}" "$SYSDIR\dllcache\d3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
901 Pop $0
902 ${If} $0 == "1"
903 Goto verify_msd3d
904 ${EndIf}
905!endif
906 ${VerifyFileEx} "${un}" "$SYSDIR\dllcache\d3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
907 Pop $0
908 ${If} $0 == "1"
909 Goto verify_msd3d
910 ${EndIf}
911 ${EndIf}
912
913!if $%BUILD_TARGET_ARCH% == "amd64"
914 ${VerifyFileEx} "${un}" "$g_strSysWow64\d3d8.dll" "Microsoft Corporation" "x86"
915 Pop $0
916 ${If} $0 == "1"
917 Goto verify_msd3d
918 ${EndIf}
919 ${VerifyFileEx} "${un}" "$g_strSysWow64\d3d9.dll" "Microsoft Corporation" "x86"
920 Pop $0
921 ${If} $0 == "1"
922 Goto verify_msd3d
923 ${EndIf}
924
925 ${If} $g_bCapDllCache == "true"
926 ${VerifyFileEx} "${un}" "$g_strSysWow64\dllcache\d3d8.dll" "Microsoft Corporation" "x86"
927 Pop $0
928 ${If} $0 == "1"
929 Goto verify_msd3d
930 ${EndIf}
931 ${VerifyFileEx} "${un}" "$g_strSysWow64\dllcache\d3d9.dll" "Microsoft Corporation" "x86"
932 Pop $0
933 ${If} $0 == "1"
934 Goto verify_msd3d
935 ${EndIf}
936 ${EndIf}
937
938!endif
939
940 Goto valid
941
942verify_msd3d:
943
944!if $%BUILD_TARGET_ARCH% == "x86"
945 ${VerifyFileEx} "${un}" "$SYSDIR\msd3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
946 Pop $0
947 ${If} $0 == "1"
948 Goto invalid
949 ${EndIf}
950!endif
951 ${VerifyFileEx} "${un}" "$SYSDIR\msd3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
952 Pop $0
953 ${If} $0 == "1"
954 Goto invalid
955 ${EndIf}
956
957 ${If} $g_bCapDllCache == "true"
958!if $%BUILD_TARGET_ARCH% == "x86"
959 ${VerifyFileEx} "${un}" "$SYSDIR\dllcache\msd3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
960 Pop $0
961 ${If} $0 == "1"
962 Goto invalid
963 ${EndIf}
964!endif
965 ${VerifyFileEx} "${un}" "$SYSDIR\dllcache\msd3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
966 Pop $0
967 ${If} $0 == "1"
968 Goto invalid
969 ${EndIf}
970 ${EndIf}
971
972!if $%BUILD_TARGET_ARCH% == "amd64"
973 ${VerifyFileEx} "${un}" "$g_strSysWow64\msd3d8.dll" "Microsoft Corporation" "x86"
974 Pop $0
975 ${If} $0 == "1"
976 Goto invalid
977 ${EndIf}
978 ${VerifyFileEx} "${un}" "$g_strSysWow64\msd3d9.dll" "Microsoft Corporation" "x86"
979 Pop $0
980 ${If} $0 == "1"
981 Goto invalid
982 ${EndIf}
983
984 ${If} $g_bCapDllCache == "true"
985 ${VerifyFileEx} "${un}" "$g_strSysWow64\dllcache\msd3d8.dll" "Microsoft Corporation" "x86"
986 Pop $0
987 ${If} $0 == "1"
988 Goto invalid
989 ${EndIf}
990 ${VerifyFileEx} "${un}" "$g_strSysWow64\dllcache\msd3d9.dll" "Microsoft Corporation" "x86"
991 Pop $0
992 ${If} $0 == "1"
993 Goto invalid
994 ${EndIf}
995 ${EndIf}
996!endif
997
998 Goto valid
999
1000valid:
1001
1002 StrCpy $0 "0" ; Installation valid
1003 Goto end
1004
1005invalid:
1006
1007 StrCpy $0 "1" ; Installation invalid / corrupted
1008 Goto end
1009
1010end:
1011
1012 Exch $0
1013
1014FunctionEnd
1015!macroend
1016!insertmacro ValidateFilesDirect3D ""
1017!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