VirtualBox

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

Last change on this file since 107464 was 106061, checked in by vboxsync, 4 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
1@echo off
2rem $Id: UnpackBlessedDrivers.cmd 106061 2024-09-16 14:03:52Z vboxsync $
3rem rem @file
4rem Windows NT batch script for unpacking drivers after being signed.
5rem
6
7rem
8rem Copyright (C) 2018-2024 Oracle and/or its affiliates.
9rem
10rem This file is part of VirtualBox base platform packages, as
11rem available from https://www.virtualbox.org.
12rem
13rem This program is free software; you can redistribute it and/or
14rem modify it under the terms of the GNU General Public License
15rem as published by the Free Software Foundation, in version 3 of the
16rem License.
17rem
18rem This program is distributed in the hope that it will be useful, but
19rem WITHOUT ANY WARRANTY; without even the implied warranty of
20rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21rem General Public License for more details.
22rem
23rem You should have received a copy of the GNU General Public License
24rem along with this program; if not, see <https://www.gnu.org/licenses>.
25rem
26rem SPDX-License-Identifier: GPL-3.0-only
27rem
28
29
30setlocal ENABLEEXTENSIONS
31setlocal
32
33rem
34rem Globals and Check for environment variables we need.
35rem
36if ".%KBUILD_DEVTOOLS%" == "." (echo KBUILD_DEVTOOLS is not set & goto end_failed)
37set _MY_DRIVER_BASE_NAMES=VBoxSup VBoxNetAdp6 VBoxNetLwf VBoxUSB VBoxUSBMon
38set _MY_GUEST_ADDITIONS_DRIVER_BASE_NAMES=VBoxVideo VBoxWddm VBoxGuest VBoxMouse
39set _MY_UNZIP=%KBUILD_DEVTOOLS%\win.x86\bin\unzip.exe
40if not exist "%_MY_UNZIP%" (echo "%_MY_UNZIP%" does not exist & goto end_failed)
41
42rem
43rem Parse arguments.
44rem
45set _MY_OPT_BINDIR=..\bin
46set _MY_OPT_INPUT=
47set _MY_OPT_SIGN_CAT=1
48set _MY_OPT_SIGN_VERIFY=1
49
50:argument_loop
51if ".%1" == "." goto no_more_arguments
52
53if ".%1" == ".-h" goto opt_h
54if ".%1" == ".-?" goto opt_h
55if ".%1" == "./h" goto opt_h
56if ".%1" == "./H" goto opt_h
57if ".%1" == "./?" goto opt_h
58if ".%1" == ".-help" goto opt_h
59if ".%1" == ".--help" goto opt_h
60
61if ".%1" == ".-b" goto opt_b
62if ".%1" == ".--bindir" goto opt_b
63if ".%1" == ".-i" goto opt_i
64if ".%1" == ".--input" goto opt_i
65if ".%1" == ".-n" goto opt_n
66if ".%1" == ".--no-sign-cat" goto opt_n
67if ".%1" == ".-v" goto opt_v
68if ".%1" == ".--no-sign-verify" goto opt_v
69if ".%1" == ".--guest-additions" goto opt_ga
70
71echo syntax error: Unknown option: %1
72echo Try --help to list valid options.
73goto end_failed
74
75:argument_loop_next_with_value
76shift
77shift
78goto argument_loop
79
80:opt_b
81if ".%~2" == "." goto syntax_error_missing_value
82set _MY_OPT_BINDIR=%~2
83goto argument_loop_next_with_value
84
85:opt_h
86echo This script unpacks the zip-file containing the blessed driver files from
87echo Microsoft, replacing original files in the bin directory. The catalog files
88echo will be signed again and the Microsoft signature merged with ours.
89echo .
90echo Usage: UnpackBlessedDrivers.cmd [-b bindir] [-n/--no-sign-cat] [-v/--no-sign-verify] -i input.zip
91echo .
92echo Warning! This script should normally be invoked from the repack directory
93goto end_failed
94
95:opt_i
96if ".%~2" == "." goto syntax_error_missing_value
97set _MY_OPT_INPUT=%~2
98goto argument_loop_next_with_value
99
100:opt_n
101set _MY_OPT_SIGN_CAT=0
102shift
103goto argument_loop
104
105:opt_v
106set _MY_OPT_SIGN_VERIFY=0
107shift
108goto argument_loop
109
110:opt_ga
111set _MY_DRIVER_BASE_NAMES=%_MY_GUEST_ADDITIONS_DRIVER_BASE_NAMES%
112shift
113goto argument_loop
114
115:syntax_error_missing_value
116echo syntax error: missing or empty option value after %1
117goto end_failed
118
119:error_bindir_does_not_exist
120echo syntax error: Specified BIN directory does not exist: "%_MY_OPT_BINDIR%"
121goto end_failed
122
123:error_input_not_found
124echo error: Input file does not exist: "%_MY_OPT_INPUT%"
125goto end_failed
126
127:no_more_arguments
128rem validate specified options
129if not exist "%_MY_OPT_BINDIR%" goto error_bindir_does_not_exist
130
131rem figure defaults here: if ".%_MY_OPT_INPUT%" == "." if exist "%_MY_OPT_BINDIR%\x86" set _MY_OPT_INPUT=VBoxDrivers-amd64.cab
132rem figure defaults here: if ".%_MY_OPT_INPUT%" == "." set _MY_OPT_INPUT=VBoxDrivers-x86.cab
133if not exist "%_MY_OPT_INPUT%" goto error_input_not_found
134
135rem
136rem Unpack the stuff.
137rem We ignore error level 1 here as that is what unzip returns on warning (slashes).
138rem
139"%_MY_UNZIP%" -o -j "%_MY_OPT_INPUT%" -d "%_MY_OPT_BINDIR%" && goto unzip_okay
140if NOT ERRORLEVEL 1 goto end_failed
141:unzip_okay
142
143if ".%_MY_OPT_SIGN_VERIFY%" == ".0" goto no_sign_verify
144rem
145rem Verify it against the PreW10 catalog files we saved.
146rem
147set _MY_SIGNTOOL=%KBUILD_DEVTOOLS%\win.x86\sdk\v8.1\bin\x86\signtool.exe
148if not exist "%_MY_SIGNTOOL%" set _MY_SIGNTOOL=%KBUILD_DEVTOOLS%\win.x86\selfsign\r3\signtool.exe
149
150for %%d in (%_MY_DRIVER_BASE_NAMES%) do (
151 @echo * Verifying %%d against %%d.cat...
152 "%_MY_SIGNTOOL%" verify /kp /c "%_MY_OPT_BINDIR%\%%d.cat" "%_MY_OPT_BINDIR%\%%d.inf" || goto end_failed
153 "%_MY_SIGNTOOL%" verify /kp /c "%_MY_OPT_BINDIR%\%%d.cat" "%_MY_OPT_BINDIR%\%%d.sys" || goto end_failed
154 rem The following is disabled because signtool.exe does not accept these
155 rem signatures because it fails to look at the timestamp. Eventually should
156 rem replace this by doing out own signature verification in RTSignTool.
157 rem @echo * Verifying %%d against %%d-PreW10.cat...
158 rem "%_MY_SIGNTOOL%" verify /kp /c "%_MY_OPT_BINDIR%\%%d-PreW10.cat" "%_MY_OPT_BINDIR%\%%d.inf" || goto end_failed
159 rem "%_MY_SIGNTOOL%" verify /kp /c "%_MY_OPT_BINDIR%\%%d-PreW10.cat" "%_MY_OPT_BINDIR%\%%d.sys" || goto end_failed
160)
161:no_sign_verify
162
163rem
164rem Modify the catalog signatures.
165rem
166if "%_MY_OPT_SIGN_CAT%" == "0" goto no_sign_cat
167set PATH=%PATH%;%_MY_OPT_BINDIR%
168for %%d in (%_MY_DRIVER_BASE_NAMES%) do (
169 copy /y "%_MY_OPT_BINDIR%\%%d.cat" "%_MY_OPT_BINDIR%\%%d.cat.ms" || goto end_failed
170 call sign-dual.cmd "%_MY_OPT_BINDIR%\%%d.cat" || goto end_failed
171 "%_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
172)
173:no_sign_cat
174goto end
175
176:end_failed
177@echo failed (%ERRORLEVEL%)
178@endlocal
179@endlocal
180@exit /b 1
181
182:end
183@endlocal
184@endlocal
185
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