Skip to content

Commit

Permalink
Store signing options in config.bat.
Browse files Browse the repository at this point in the history
Call this file from all .bat files that sign files.

Fix Windows 8 x64 driver signing.
  • Loading branch information
desowin committed Apr 4, 2013
1 parent 3687418 commit dc82e07
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 14 deletions.
10 changes: 10 additions & 0 deletions config.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set _USBPCAP_SIGNTOOL="C:\WinDDK\7600.16385.1\bin\amd64\SignTool.exe"

::In order to sign the binary with real certificate replace the
::certificates\USBPcapTestCert.pfx with path to your certificate
set _USBPCAP_SIGN_OPTS=sign /f %~dp0certificates\USBPcapTestCert.pfx /t https://timestamp.verisign.com/scripts/timestamp.dll

::_USBPCAP_VERSION specifies version of the installer.
::To update driver version edit USBPcapDriver\USBPcap.rc and
::USBPcapDriver\SOURCES
set _USBPCAP_VERSION="1.0.0.1"
10 changes: 6 additions & 4 deletions driver_build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,15 @@ if "%_BUILDARCH%"=="x86" (
)

cd %~dp0
CALL config.bat

build -ceZg
if exist build%BUILD_ALT_DIR%.err goto error

::Sign the USBPcapCMD.exe, it is not critical so do not fail on error
SignTool sign /f certificates\USBPcapTestCert.pfx /t https://timestamp.verisign.com/scripts/timestamp.dll USBPcapCMD\obj%BUILD_ALT_DIR%\%USBPcap_arch%\USBPcapCMD.exe
%_USBPCAP_SIGNTOOL% %_USBPCAP_SIGN_OPTS% USBPcapCMD\obj%BUILD_ALT_DIR%\%USBPcap_arch%\USBPcapCMD.exe

::In order to sign the binary with real certificate replace the
::certificates\USBPcapTestCert.pfx with path to your certificate
SignTool sign /f certificates\USBPcapTestCert.pfx /t https://timestamp.verisign.com/scripts/timestamp.dll USBPcapDriver\obj%BUILD_ALT_DIR%\%USBPcap_arch%\USBPcap.sys
%_USBPCAP_SIGNTOOL% %_USBPCAP_SIGN_OPTS% USBPcapDriver\obj%BUILD_ALT_DIR%\%USBPcap_arch%\USBPcap.sys
if errorlevel 1 goto error

Inf2cat.exe /driver:USBPcapDriver\obj%BUILD_ALT_DIR%\%USBPcap_arch%\ /os:%USBPcap_OS%
Expand All @@ -50,8 +49,11 @@ pause
exit /B 1

:end

copy USBPcapDriver\obj%BUILD_ALT_DIR%\%USBPcap_arch%\USBPcap.sys %3
copy USBPcapDriver\obj%BUILD_ALT_DIR%\%USBPcap_arch%\USBPcap.inf %3
copy USBPcapDriver\obj%BUILD_ALT_DIR%\%USBPcap_arch%\%USBPcap_catalog% %3
%_USBPCAP_SIGNTOOL% %_USBPCAP_SIGN_OPTS% %3\%USBPcap_catalog%
if errorlevel 1 goto error

exit /B 0
4 changes: 2 additions & 2 deletions driver_build_win7_64bit.bat
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ if "%_BUILDARCH%"=="x86" (
)

cd %~dp0

CALL config.bat

build -ceZg
if exist build%BUILD_ALT_DIR%.err goto error

SignTool sign /f certificates\USBPcapTestCert.pfx /t https://timestamp.verisign.com/scripts/timestamp.dll USBPcapDriver\obj%BUILD_ALT_DIR%\%USBPcap_arch%\USBPcap.sys
%_USBPCAP_SIGNTOOL% %_USBPCAP_SIGN_OPTS% USBPcapDriver\obj%BUILD_ALT_DIR%\%USBPcap_arch%\USBPcap.sys
if errorlevel 1 goto error

Inf2cat.exe /driver:USBPcapDriver\obj%BUILD_ALT_DIR%\%USBPcap_arch%\ /os:%USBPcap_OS%
Expand Down
7 changes: 4 additions & 3 deletions driver_build_win8.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ if "%1"=="x86" (
)

cd %~dp0
CALL config.bat

::Delete the release directory if it already exists
if exist %USBPcap_prefix%\Win8Release RMDIR /S /Q %USBPcap_prefix%\Win8Release

Nmake2MsBuild dirs
MSBuild dirs.sln /p:Configuration="Win8 Release"

::In order to sign the binary with real certificate replace the
::certificates\USBPcapTestCert.pfx with path to your certificate
SignTool sign /f certificates\USBPcapTestCert.pfx /t https://timestamp.verisign.com/scripts/timestamp.dll Win8Release\Package\USBPcap.sys
%_USBPCAP_SIGNTOOL% %_USBPCAP_SIGN_OPTS% %USBPcap_prefix%\Win8Release\Package\USBPcap.sys
if errorlevel 1 goto error

Inf2cat.exe /driver:%USBPcap_prefix%\Win8Release\Package\ /os:%USBPcap_OS%
Expand All @@ -39,5 +38,7 @@ exit /B 1
copy %USBPcap_prefix%\Win8Release\Package\USBPcap.sys %2
copy %USBPcap_prefix%\Win8Release\Package\USBPcap.inf %2
copy %USBPcap_prefix%\Win8Release\Package\%USBPcap_catalog% %2
%_USBPCAP_SIGNTOOL% %_USBPCAP_SIGN_OPTS% %2\%USBPcap_catalog%
if errorlevel 1 goto error

exit /B 0
7 changes: 2 additions & 5 deletions nsis/USBPcap.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

!include "GetWindowsVersion.nsh"

!define VERSION "1.0.0.1"
!define VERSION $%_USBPCAP_VERSION%

Name "USBPcap ${VERSION}"

Expand All @@ -30,10 +30,7 @@ RequestExecutionLevel admin

; That will have written an uninstaller binary for us. Now we sign it
; with your favourite code signing tool.
;
; Replace the amd64 in path with x86 when building on 32-bit Windows

!system "C:\WinDDK\7600.16385.1\bin\amd64\SignTool.exe sign /f ..\certificates\USBPcapTestCert.pfx /t https://timestamp.verisign.com/scripts/timestamp.dll $%TEMP%\Uninstall.exe" = 0
!system '$%_USBPCAP_SIGNTOOL% $%_USBPCAP_SIGN_OPTS% $%TEMP%\Uninstall.exe' = 0

; Good. Now we can carry on writing the real installer.

Expand Down
32 changes: 32 additions & 0 deletions nsis/build_installer.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@echo off

CALL ..\config.bat

set nsis_compiler=

if defined NSIS_HOME (
if exist "%NSIS_HOME%\makensis.exe" (
set "nsis_compiler=%NSIS_HOME%"
)
)

if %PROCESSOR_ARCHITECTURE%==x86 (
Set RegQry=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\NSIS
) else (
Set RegQry=HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\NSIS
)

if not defined nsis_compiler (
for /F "tokens=2*" %%a in ('reg query %RegQry% /v InstallLocation ^|findstr InstallLocation') do set nsis_compiler=%%b
)

if not defined nsis_compiler (
for %%X in (makensis.exe) do (set nsis_compiler=%%~dp$PATH:X)
)

if defined nsis_compiler (
"%nsis_compiler%\makensis.exe" %~dp0\USBPcap.nsi
pause
) else (
echo "Error, build system cannot find NSIS! Please reinstall it, add makensis.exe to your PATH, or defined the NSIS_HOME environment variable."
)

0 comments on commit dc82e07

Please sign in to comment.