1 | @echo off
|
---|
2 | rem $Id: UnpackBlessedDrivers.cmd 72019 2018-04-25 14:19:58Z vboxsync $
|
---|
3 | rem rem @file
|
---|
4 | rem Windows NT batch script for unpacking drivers after being signed.
|
---|
5 | rem
|
---|
6 |
|
---|
7 | rem
|
---|
8 | rem Copyright (C) 2018 Oracle Corporation
|
---|
9 | rem
|
---|
10 | rem This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | rem available from http://www.virtualbox.org. This file is free software;
|
---|
12 | rem you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | rem General Public License (GPL) as published by the Free Software
|
---|
14 | rem Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | rem VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | rem hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | rem
|
---|
18 |
|
---|
19 |
|
---|
20 | setlocal ENABLEEXTENSIONS
|
---|
21 | setlocal
|
---|
22 |
|
---|
23 | rem
|
---|
24 | rem Check for environment variables we need.
|
---|
25 | rem
|
---|
26 | if ".%KBUILD_DEVTOOLS%" == "." (echo KBUILD_BIN_PATH is not set & goto end_failed)
|
---|
27 |
|
---|
28 | rem
|
---|
29 | rem Parse arguments.
|
---|
30 | rem
|
---|
31 | set _MY_OPT_BINDIR=..\bin
|
---|
32 | set _MY_OPT_INPUT=
|
---|
33 | set _MY_OPT_SIGN_CAT=1
|
---|
34 |
|
---|
35 | :argument_loop
|
---|
36 | if ".%1" == "." goto no_more_arguments
|
---|
37 |
|
---|
38 | if ".%1" == ".-h" goto opt_h
|
---|
39 | if ".%1" == ".-?" goto opt_h
|
---|
40 | if ".%1" == "./h" goto opt_h
|
---|
41 | if ".%1" == "./H" goto opt_h
|
---|
42 | if ".%1" == "./?" goto opt_h
|
---|
43 | if ".%1" == ".-help" goto opt_h
|
---|
44 | if ".%1" == ".--help" goto opt_h
|
---|
45 |
|
---|
46 | if ".%1" == ".-b" goto opt_b
|
---|
47 | if ".%1" == ".--bindir" goto opt_b
|
---|
48 | if ".%1" == ".-i" goto opt_i
|
---|
49 | if ".%1" == ".--input" goto opt_i
|
---|
50 | if ".%1" == ".-n" goto opt_n
|
---|
51 | if ".%1" == ".--no-sign-cat" goto opt_n
|
---|
52 | echo syntax error: Unknown option: %1
|
---|
53 | echo Try --help to list valid options.
|
---|
54 | goto end_failed
|
---|
55 |
|
---|
56 | :argument_loop_next_with_value
|
---|
57 | shift
|
---|
58 | shift
|
---|
59 | goto argument_loop
|
---|
60 |
|
---|
61 | :opt_b
|
---|
62 | if ".%2" == "." goto syntax_error_missing_value
|
---|
63 | set _MY_OPT_BINDIR=%2
|
---|
64 | goto argument_loop_next_with_value
|
---|
65 |
|
---|
66 | :opt_h
|
---|
67 | echo This script unpacks the zip-file containing the blessed driver files from
|
---|
68 | echo Microsoft, replacing original files in the bin directory. The catalog files
|
---|
69 | echo will be signed again and the Microsoft signature merged with ours.
|
---|
70 | echo .
|
---|
71 | echo Usage: UnpackBlessedDrivers.cmd [-b bindir] [-n/--no-sign-cat] -i input.zip
|
---|
72 | echo .
|
---|
73 | echo Warning! This script should normally be invoked from the repack directory
|
---|
74 | goto end_failed
|
---|
75 |
|
---|
76 | :opt_i
|
---|
77 | if ".%2" == "." goto syntax_error_missing_value
|
---|
78 | set _MY_OPT_INPUT=%2
|
---|
79 | goto argument_loop_next_with_value
|
---|
80 |
|
---|
81 | :opt_n
|
---|
82 | set _MY_OPT_SIGN_CAT=0
|
---|
83 | shift
|
---|
84 | goto argument_loop
|
---|
85 |
|
---|
86 | :syntax_error_missing_value
|
---|
87 | echo syntax error: missing or empty option value after %1
|
---|
88 | goto end_failed
|
---|
89 |
|
---|
90 | :error_bindir_does_not_exist
|
---|
91 | echo syntax error: Specified BIN directory does not exist: "%_MY_OPT_BINDIR%"
|
---|
92 | goto end_failed
|
---|
93 |
|
---|
94 | :error_input_not_found
|
---|
95 | echo error: Input file does not exist: "%_MY_OPT_INPUT%"
|
---|
96 | goto end_failed
|
---|
97 |
|
---|
98 | :no_more_arguments
|
---|
99 | rem validate specified options
|
---|
100 | if not exist "%_MY_OPT_BINDIR%" goto error_bindir_does_not_exist
|
---|
101 |
|
---|
102 | rem figure defaults here: if ".%_MY_OPT_INPUT%" == "." if exist "%_MY_OPT_BINDIR%\x86" set _MY_OPT_INPUT=VBoxDrivers-amd64.cab
|
---|
103 | rem figure defaults here: if ".%_MY_OPT_INPUT%" == "." set _MY_OPT_INPUT=VBoxDrivers-x86.cab
|
---|
104 | if not exist "%_MY_OPT_INPUT%" goto error_input_exists
|
---|
105 |
|
---|
106 | rem
|
---|
107 | rem Unpack the stuff.
|
---|
108 | rem
|
---|
109 | %KBUILD_DEVTOOLS%\win.x86\bin\unzip.exe -o -j "%_MY_OPT_INPUT%" -d "%_MY_OPT_BINDIR%" || goto end_failed
|
---|
110 |
|
---|
111 | rem
|
---|
112 | rem Modify the catalog signatures.
|
---|
113 | rem
|
---|
114 | for %cat in (VBoxDrv.cat VBoxNetAdp6.cat VBoxNetLwf.cat VBoxUSB.cat VBoxUSBMon.cat) do (
|
---|
115 | copy /y "%_MY_OPT_BINDIR%\%cat%" "%_MY_OPT_BINDIR%\%cat%.ms" || goto end_failed
|
---|
116 | call sign-dual.cmd "%_MY_OPT_BINDIR%\%cat%" || goto end_failed
|
---|
117 | "%_MY_OPT_BINDIR%\tools\RTSignTool.exe" add-nested-exe-signature -v "%_MY_OPT_BINDIR%\%cat%" "%_MY_OPT_BINDIR%\%cat%.ms" || goto end_failed
|
---|
118 | )
|
---|
119 |
|
---|
120 | goto end
|
---|
121 |
|
---|
122 | :end_failed
|
---|
123 | @endlocal
|
---|
124 | @endlocal
|
---|
125 | @exit /b 1
|
---|
126 |
|
---|
127 | :end
|
---|
128 | @endlocal
|
---|
129 | @endlocal
|
---|
130 |
|
---|