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.

80 lines
2.2 KiB

  1. // --------------------------------------------------------------------------
  2. // Module Name: StatusCode.cpp
  3. //
  4. // Copyright (c) 1999-2000, Microsoft Corporation
  5. //
  6. // Class that implements translation of Win32 error code to NTSTATUS and
  7. // the reverse.
  8. //
  9. // History: 1999-08-18 vtan created
  10. // 1999-11-16 vtan separate file
  11. // 2000-02-01 vtan moved from Neptune to Whistler
  12. // --------------------------------------------------------------------------
  13. #include "StandardHeader.h"
  14. #include "StatusCode.h"
  15. // --------------------------------------------------------------------------
  16. // CStatusCode::ErrorCodeOfStatusCode
  17. //
  18. // Arguments: errorCode
  19. //
  20. // Returns: NTSTATUS
  21. //
  22. // Purpose: Converts NTSTATUS status code to Win32 error code.
  23. //
  24. // History: 1999-08-18 vtan created
  25. // --------------------------------------------------------------------------
  26. LONG CStatusCode::ErrorCodeOfStatusCode (NTSTATUS statusCode)
  27. {
  28. return(RtlNtStatusToDosError(statusCode));
  29. }
  30. // --------------------------------------------------------------------------
  31. // CStatusCode::StatusCodeOfErrorCode
  32. //
  33. // Arguments: errorCode
  34. //
  35. // Returns: NTSTATUS
  36. //
  37. // Purpose: Converts Win32 error code to NTSTATUS status code.
  38. //
  39. // History: 1999-08-18 vtan created
  40. // --------------------------------------------------------------------------
  41. NTSTATUS CStatusCode::StatusCodeOfErrorCode (LONG errorCode)
  42. {
  43. NTSTATUS status;
  44. if (errorCode != ERROR_SUCCESS)
  45. {
  46. status = MAKE_SCODE(STATUS_SEVERITY_ERROR, FACILITY_WIN32, errorCode);
  47. }
  48. else
  49. {
  50. status = STATUS_SUCCESS;
  51. }
  52. return(status);
  53. }
  54. // --------------------------------------------------------------------------
  55. // CStatusCode::StatusCodeOfLastError
  56. //
  57. // Arguments: errorCode
  58. //
  59. // Returns: NTSTATUS
  60. //
  61. // Purpose: Converts last Win32 error code to NTSTATUS status code.
  62. //
  63. // History: 1999-08-18 vtan created
  64. // --------------------------------------------------------------------------
  65. NTSTATUS CStatusCode::StatusCodeOfLastError (void)
  66. {
  67. return(StatusCodeOfErrorCode(GetLastError()));
  68. }