Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.3 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM
  4. REM ntsign.cmd
  5. REM Signs a given catalog file.
  6. REM
  7. REM Copyright (c) Microsoft Corporation. All rights reserved.
  8. REM
  9. REM ------------------------------------------------------------------
  10. if defined _CPCMAGIC goto CPCBegin
  11. perl -x "%~f0" %*
  12. goto :EOF
  13. #!perl
  14. use strict;
  15. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  16. use lib $ENV{RAZZLETOOLPATH};
  17. use PbuildEnv;
  18. use ParseArgs;
  19. use Logmsg;
  20. sub Usage { print<<USAGE; exit(1) }
  21. ntsign -f <filename> [-t]
  22. Signs a given catalog file.
  23. -f File to be signed
  24. -t Use a timestamp.
  25. USAGE
  26. delete $ENV{CATALOGFILE}; # undef seems to give warnings when used on %ENV
  27. parseargs('?' => \&Usage,
  28. 'n' => sub { infomsg "No timestamp is now the default, ignoring -n" },
  29. 't' => \$ENV{TIMESTAMP},
  30. 'f:' => \$ENV{CATALOGFILE}, # for backwards compatibility
  31. \$ENV{CATALOGFILE}
  32. );
  33. # *** NEXT FEW LINES ARE TEMPLATE ***
  34. $ENV{"_CPCMAGIC"}++;exit(system($0)>>8);
  35. __END__
  36. :CPCBegin
  37. set _CPCMAGIC=
  38. setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  39. REM *** BEGIN YOUR CMD SCRIPT BELOW ***
  40. REM ------------------------------------------------
  41. REM Sign the given file with the NT TEST certificate.
  42. REM ------------------------------------------------
  43. set CERT_FILE=%RazzleToolPath%\driver
  44. if "%NT_CERTHASH%" == "" (
  45. set CERT_FLAGS=-v %CERT_FILE%.pvk -spc %CERT_FILE%.spc
  46. ) else (
  47. set CERT_FLAGS=-sha1 %NT_CERTHASH%
  48. )
  49. set INFO_FLAGS=-n "Microsoft Windows NT Driver Catalog TEST"
  50. set INFO_FLAGS=%INFO_FLAGS% -i "http://ntbld"
  51. if "%TIMESTAMP%" == "1" (
  52. set SIGNTOOL_TS=/t http://timestamp.verisign.com/scripts/timestamp.dll
  53. )
  54. if exist "%CATALOGFILE%" (
  55. call logmsg.cmd "Signing %CATALOGFILE%..."
  56. ) else (
  57. call errmsg.cmd "Cannot sign catalog file %CATALOGFILE%, file does not exist"
  58. goto :EOF
  59. )
  60. REM trust the testroot certificate
  61. setreg -q 1 TRUE
  62. if not "%errorlevel%" == "0" call errmsg.cmd "setreg.exe failed."& goto :EOF
  63. if defined SIGNTOOL_SIGN (
  64. signtool sign /q %SIGNTOOL_SIGN% %SIGNTOOL_TS% "%CATALOGFILE%"
  65. if not "%errorlevel%" == "0" (
  66. call errmsg.cmd "signtool.exe failed on %CATALOGFILE%"
  67. )
  68. ) else (
  69. signcode.exe %CERT_FLAGS% %INFO_FLAGS% "%CATALOGFILE%"
  70. if not "%errorlevel%" == "0" (
  71. call errmsg.cmd "signcode.exe failed on %CATALOGFILE%"
  72. )
  73. )