VirtualBox

source: vbox/trunk/src/VBox/Installer/win/Scripts/UnpackBlessedDrivers.cmd@ 76882

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

scm --update-copyright-year

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1@echo off
2rem $Id: UnpackBlessedDrivers.cmd 76553 2019-01-01 01:45:53Z vboxsync $
3rem rem @file
4rem Windows NT batch script for unpacking drivers after being signed.
5rem
6
7rem
8rem Copyright (C) 2018-2019 Oracle Corporation
9rem
10rem This file is part of VirtualBox Open Source Edition (OSE), as
11rem available from http://www.virtualbox.org. This file is free software;
12rem you can redistribute it and/or modify it under the terms of the GNU
13rem General Public License (GPL) as published by the Free Software
14rem Foundation, in version 2 as it comes in the "COPYING" file of the
15rem VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16rem hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17rem
18
19
20setlocal ENABLEEXTENSIONS
21setlocal
22
23rem
24rem Globals and Check for environment variables we need.
25rem
26if ".%KBUILD_DEVTOOLS%" == "." (echo KBUILD_DEVTOOLS is not set & goto end_failed)
27set _MY_DRIVER_BASE_NAMES=VBoxDrv VBoxNetAdp6 VBoxNetLwf VBoxUSB VBoxUSBMon
28set _MY_DRIVER_BASE_NAMES=VBoxDrv VBoxNetAdp6 VBoxNetLwf VBoxUSB VBoxUSBMon
29set _MY_UNZIP=%KBUILD_DEVTOOLS%\win.x86\bin\unzip.exe
30if not exist "%_MY_UNZIP%" (echo "%_MY_UNZIP%" does not exist & goto end_failed)
31
32rem
33rem Parse arguments.
34rem
35set _MY_OPT_BINDIR=..\bin
36set _MY_OPT_INPUT=
37set _MY_OPT_SIGN_CAT=1
38
39:argument_loop
40if ".%1" == "." goto no_more_arguments
41
42if ".%1" == ".-h" goto opt_h
43if ".%1" == ".-?" goto opt_h
44if ".%1" == "./h" goto opt_h
45if ".%1" == "./H" goto opt_h
46if ".%1" == "./?" goto opt_h
47if ".%1" == ".-help" goto opt_h
48if ".%1" == ".--help" goto opt_h
49
50if ".%1" == ".-b" goto opt_b
51if ".%1" == ".--bindir" goto opt_b
52if ".%1" == ".-i" goto opt_i
53if ".%1" == ".--input" goto opt_i
54if ".%1" == ".-n" goto opt_n
55if ".%1" == ".--no-sign-cat" goto opt_n
56echo syntax error: Unknown option: %1
57echo Try --help to list valid options.
58goto end_failed
59
60:argument_loop_next_with_value
61shift
62shift
63goto argument_loop
64
65:opt_b
66if ".%~2" == "." goto syntax_error_missing_value
67set _MY_OPT_BINDIR=%~2
68goto argument_loop_next_with_value
69
70:opt_h
71echo This script unpacks the zip-file containing the blessed driver files from
72echo Microsoft, replacing original files in the bin directory. The catalog files
73echo will be signed again and the Microsoft signature merged with ours.
74echo .
75echo Usage: UnpackBlessedDrivers.cmd [-b bindir] [-n/--no-sign-cat] -i input.zip
76echo .
77echo Warning! This script should normally be invoked from the repack directory
78goto end_failed
79
80:opt_i
81if ".%~2" == "." goto syntax_error_missing_value
82set _MY_OPT_INPUT=%~2
83goto argument_loop_next_with_value
84
85:opt_n
86set _MY_OPT_SIGN_CAT=0
87shift
88goto argument_loop
89
90:syntax_error_missing_value
91echo syntax error: missing or empty option value after %1
92goto end_failed
93
94:error_bindir_does_not_exist
95echo syntax error: Specified BIN directory does not exist: "%_MY_OPT_BINDIR%"
96goto end_failed
97
98:error_input_not_found
99echo error: Input file does not exist: "%_MY_OPT_INPUT%"
100goto end_failed
101
102:no_more_arguments
103rem validate specified options
104if not exist "%_MY_OPT_BINDIR%" goto error_bindir_does_not_exist
105
106rem figure defaults here: if ".%_MY_OPT_INPUT%" == "." if exist "%_MY_OPT_BINDIR%\x86" set _MY_OPT_INPUT=VBoxDrivers-amd64.cab
107rem figure defaults here: if ".%_MY_OPT_INPUT%" == "." set _MY_OPT_INPUT=VBoxDrivers-x86.cab
108if not exist "%_MY_OPT_INPUT%" goto error_input_not_found
109
110rem
111rem Unpack the stuff.
112rem We ignore error level 1 here as that is what unzip returns on warning (slashes).
113rem
114"%_MY_UNZIP%" -o -j "%_MY_OPT_INPUT%" -d "%_MY_OPT_BINDIR%" && goto unzip_okay
115if NOT ERRORLEVEL 1 goto end_failed
116:unzip_okay
117
118rem
119rem Verify it against the PreW10 catalog files we saved.
120rem
121set _MY_SIGNTOOL=%KBUILD_DEVTOOLS%\win.x86\sdk\v8.1\bin\x86\signtool.exe
122if not exist "%_MY_SIGNTOOL%" set _MY_SIGNTOOL=%KBUILD_DEVTOOLS%\win.x86\selfsign\r3\signtool.exe
123
124for %%d in (%_MY_DRIVER_BASE_NAMES%) do (
125 @echo * Verifying %%d against %%d.cat...
126 "%_MY_SIGNTOOL%" verify /kp /c "%_MY_OPT_BINDIR%\%%d.cat" "%_MY_OPT_BINDIR%\%%d.inf" || goto end_failed
127 "%_MY_SIGNTOOL%" verify /kp /c "%_MY_OPT_BINDIR%\%%d.cat" "%_MY_OPT_BINDIR%\%%d.sys" || goto end_failed
128 @echo * Verifying %%d against %%d-PreW10.cat...
129 "%_MY_SIGNTOOL%" verify /kp /c "%_MY_OPT_BINDIR%\%%d-PreW10.cat" "%_MY_OPT_BINDIR%\%%d.inf" || goto end_failed
130 "%_MY_SIGNTOOL%" verify /kp /c "%_MY_OPT_BINDIR%\%%d-PreW10.cat" "%_MY_OPT_BINDIR%\%%d.sys" || goto end_failed
131)
132
133
134rem
135rem Modify the catalog signatures.
136rem
137if "%_MY_OPT_SIGN_CAT%" == "0" goto no_sign_cat
138set PATH=%PATH%;%_MY_OPT_BINDIR%
139for %%d in (%_MY_DRIVER_BASE_NAMES%) do (
140 copy /y "%_MY_OPT_BINDIR%\%%d.cat" "%_MY_OPT_BINDIR%\%%d.cat.ms" || goto end_failed
141 call sign-dual.cmd "%_MY_OPT_BINDIR%\%%d.cat" || goto end_failed
142 "%_MY_OPT_BINDIR%\tools\RTSignTool.exe" add-nested-cat-signature -v "%_MY_OPT_BINDIR%\%%d.cat" "%_MY_OPT_BINDIR%\%%d.cat.ms" || goto end_failed
143)
144:no_sign_cat
145goto end
146
147:end_failed
148@echo failed (%ERRORLEVEL%)
149@endlocal
150@endlocal
151@exit /b 1
152
153:end
154@endlocal
155@endlocal
156
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