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.

68 lines
1.3 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: nsrevchk.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. #include <windows.h>
  11. extern "C" void __cdecl
  12. wmain(
  13. int argc,
  14. WCHAR *argv[])
  15. {
  16. char status[2];
  17. unsigned long bytesRead;
  18. HANDLE df;
  19. BOOL ret;
  20. if (argc != 2)
  21. {
  22. MessageBox(0, L"Usage: nsrevchk filename", L"Error", MB_OK);
  23. exit(-1);
  24. }
  25. df = CreateFile(
  26. argv[1],
  27. GENERIC_READ,
  28. FILE_SHARE_READ,
  29. 0,
  30. OPEN_EXISTING,
  31. FILE_ATTRIBUTE_NORMAL,
  32. 0);
  33. if (INVALID_HANDLE_VALUE == df)
  34. {
  35. MessageBox(0, L"Unable to open file", L"Error", MB_OK);
  36. exit(-1);
  37. }
  38. ret = ReadFile(df, &status, 2, &bytesRead, 0);
  39. if (!ret)
  40. {
  41. MessageBox(0, L"Unable to read from file", L"Error", MB_OK);
  42. exit(-1);
  43. }
  44. if (bytesRead != 1)
  45. {
  46. MessageBox(0, L"Invalid file format", L"Error", MB_OK);
  47. exit(-1);
  48. }
  49. if (status[0] == '1')
  50. {
  51. MessageBox(0, L"Cert is Invalid", L"Certificate Status", MB_OK);
  52. }
  53. else if (status[0] == '0')
  54. {
  55. MessageBox(0, L"Cert is Valid", L"Certificate Status", MB_OK);
  56. }
  57. else
  58. {
  59. MessageBox(0, L"Unknown Certificate Status", L"Error", MB_OK);
  60. }
  61. }