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.

92 lines
2.3 KiB

  1. /*++
  2. Copyright (c) 1998-2000 Microsoft Corporation
  3. Module Name:
  4. w32utl.h
  5. Abstract:
  6. Win32-Specific Utilities for the RDP Client Device Redirector
  7. Author:
  8. Tad Brockway
  9. Revision History:
  10. --*/
  11. #ifndef __W32UTL_H__
  12. #define __W32UTL_H__
  13. //
  14. // Converts a Unicode string to Ansi
  15. //
  16. ULONG RDPConvertToAnsi(LPWSTR lpwszUnicodeString, LPSTR lpszAnsiString,
  17. ULONG ulAnsiBufferLen);
  18. //
  19. // Converts a Ansi string to Unicode.
  20. //
  21. ULONG RDPConvertToUnicode(LPSTR lpszAnsiString,
  22. LPWSTR lpwszUnicodeString,
  23. ULONG ulUnicodeBufferLen);
  24. //
  25. // Translate a Windows Error (winerror.h) code into a Windows NT
  26. // Status (ntstatus.h) code.
  27. //
  28. inline NTSTATUS TranslateWinError(DWORD error)
  29. {
  30. //
  31. // Would be faster if it were table-driven.
  32. //
  33. switch (error) {
  34. case ERROR_SUCCESS :
  35. return STATUS_SUCCESS;
  36. case ERROR_FILE_NOT_FOUND :
  37. return STATUS_NO_SUCH_FILE;
  38. case ERROR_INSUFFICIENT_BUFFER:
  39. return STATUS_INSUFFICIENT_RESOURCES;
  40. case ERROR_SERVICE_NO_THREAD:
  41. return STATUS_WAIT_0;
  42. case ERROR_OPEN_FAILED:
  43. return STATUS_OPEN_FAILED;
  44. case ERROR_NO_MORE_FILES:
  45. return STATUS_NO_MORE_FILES;
  46. case ERROR_FILE_EXISTS:
  47. case ERROR_ALREADY_EXISTS:
  48. return STATUS_OBJECT_NAME_COLLISION;
  49. case ERROR_INVALID_FUNCTION:
  50. return STATUS_INVALID_DEVICE_REQUEST;
  51. case ERROR_ACCESS_DENIED:
  52. return STATUS_ACCESS_DENIED;
  53. case ERROR_INVALID_PARAMETER:
  54. return STATUS_INVALID_PARAMETER;
  55. case ERROR_PATH_NOT_FOUND:
  56. return STATUS_OBJECT_PATH_NOT_FOUND;
  57. case ERROR_SHARING_VIOLATION:
  58. return STATUS_SHARING_VIOLATION;
  59. case ERROR_DISK_FULL:
  60. return STATUS_DISK_FULL;
  61. case ERROR_DIRECTORY:
  62. return STATUS_NOT_A_DIRECTORY;
  63. case ERROR_WRITE_PROTECT:
  64. return STATUS_MEDIA_WRITE_PROTECTED;
  65. case ERROR_PRIVILEGE_NOT_HELD:
  66. return STATUS_PRIVILEGE_NOT_HELD;
  67. case ERROR_NOT_READY:
  68. return STATUS_DEVICE_NOT_READY;
  69. case ERROR_UNRECOGNIZED_MEDIA:
  70. return STATUS_UNRECOGNIZED_MEDIA;
  71. case ERROR_UNRECOGNIZED_VOLUME:
  72. return STATUS_UNRECOGNIZED_VOLUME;
  73. default:
  74. return STATUS_UNSUCCESSFUL;
  75. }
  76. }
  77. #endif