VirtualBox

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

Last change on this file since 41541 was 41432, checked in by vboxsync, 13 years ago

don't build libwine & don't include it in GA installer

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