Leaked source code of windows server 2003
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.

101 lines
2.6 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // FILE : client.cxx //
  3. // DESCRIPTION : Crypto API interface //
  4. // AUTHOR : //
  5. // HISTORY : //
  6. // Mar 8 1996 larrys New //
  7. // dbarlow //
  8. // //
  9. // Copyright (C) 1996 Microsoft Corporation All Rights Reserved //
  10. /////////////////////////////////////////////////////////////////////////////
  11. #include <nt.h>
  12. #include <ntrtl.h>
  13. #include <nturtl.h>
  14. #include <windows.h>
  15. #include <stdlib.h>
  16. #include <stddef.h>
  17. #include <stdio.h>
  18. NTSTATUS MACTheBinary(
  19. IN LPWSTR pszImage
  20. );
  21. void ShowHelp()
  22. {
  23. printf("Internal FIPS Module MACing Utility\n");
  24. printf("macutil <filename>\n");
  25. }
  26. void __cdecl main( int argc, char *argv[])
  27. {
  28. LPWSTR szInFile = NULL;
  29. ULONG cch = 0;
  30. ULONG dwErr;
  31. NTSTATUS Status;
  32. DWORD dwRet = 1;
  33. //
  34. // Parse the command line.
  35. //
  36. if (argc != 2)
  37. {
  38. ShowHelp();
  39. goto Ret;
  40. }
  41. //
  42. // convert to UNICODE file name
  43. //
  44. if (0 == (cch = MultiByteToWideChar(CP_ACP,
  45. MB_COMPOSITE,
  46. &argv[1][0],
  47. -1,
  48. NULL,
  49. cch)))
  50. {
  51. dwErr = GetLastError();
  52. goto Ret;
  53. }
  54. if (NULL == (szInFile = LocalAlloc(LMEM_ZEROINIT, (cch + 1) * sizeof(WCHAR))))
  55. {
  56. dwErr = ERROR_NOT_ENOUGH_MEMORY;
  57. goto Ret;
  58. }
  59. if (0 == (cch = MultiByteToWideChar(CP_ACP,
  60. MB_COMPOSITE,
  61. &argv[1][0],
  62. -1,
  63. szInFile,
  64. cch)))
  65. {
  66. dwErr = GetLastError();
  67. goto Ret;
  68. }
  69. // MAC the binary
  70. Status = MACTheBinary(szInFile);
  71. if (!NT_SUCCESS(Status))
  72. {
  73. ShowHelp();
  74. goto Ret;
  75. }
  76. //
  77. // Clean up and return.
  78. //
  79. dwRet = 0;
  80. printf("SUCCESS\n");
  81. Ret:
  82. exit(dwRet);
  83. }