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.

147 lines
2.3 KiB

  1. /*++
  2. Copyright (c) 2000-2001 Microsoft Corporation
  3. Module Name:
  4. Internal.cpp
  5. Abstract:
  6. Common functions that use internals.
  7. Notes:
  8. None
  9. History:
  10. 01/10/2000 linstev Created
  11. 08/14/2001 robkenny Moved code inside the ShimLib namespace.
  12. --*/
  13. #include <nt.h>
  14. #include <ntrtl.h>
  15. #include <windef.h>
  16. namespace ShimLib
  17. {
  18. /*++
  19. Function Description:
  20. Determine the device type from an open handle.
  21. Arguments:
  22. IN hFile - Handle to an open file
  23. Return Value:
  24. Same as GetDriveType
  25. History:
  26. 01/10/2000 linstev Updated
  27. --*/
  28. // These are in winbase, which we don't want to include
  29. #define DRIVE_UNKNOWN 0
  30. #define DRIVE_NO_ROOT_DIR 1
  31. #define DRIVE_REMOVABLE 2
  32. #define DRIVE_FIXED 3
  33. #define DRIVE_REMOTE 4
  34. #define DRIVE_CDROM 5
  35. #define DRIVE_RAMDISK 6
  36. UINT
  37. GetDriveTypeFromHandle(HANDLE hFile)
  38. {
  39. NTSTATUS Status;
  40. IO_STATUS_BLOCK IoStatusBlock;
  41. FILE_FS_DEVICE_INFORMATION DeviceInformation;
  42. Status = NtQueryVolumeInformationFile(
  43. hFile,
  44. &IoStatusBlock,
  45. &DeviceInformation,
  46. sizeof(DeviceInformation),
  47. FileFsDeviceInformation);
  48. UINT uRet;
  49. if (NT_SUCCESS(Status))
  50. {
  51. switch (DeviceInformation.DeviceType)
  52. {
  53. case FILE_DEVICE_NETWORK:
  54. case FILE_DEVICE_NETWORK_FILE_SYSTEM:
  55. uRet = DRIVE_REMOTE;
  56. break;
  57. case FILE_DEVICE_CD_ROM:
  58. case FILE_DEVICE_CD_ROM_FILE_SYSTEM:
  59. uRet = DRIVE_CDROM;
  60. break;
  61. case FILE_DEVICE_VIRTUAL_DISK:
  62. uRet = DRIVE_RAMDISK;
  63. break;
  64. case FILE_DEVICE_DISK:
  65. case FILE_DEVICE_DISK_FILE_SYSTEM:
  66. if (DeviceInformation.Characteristics & FILE_REMOVABLE_MEDIA)
  67. {
  68. uRet = DRIVE_REMOVABLE;
  69. }
  70. else
  71. {
  72. uRet = DRIVE_FIXED;
  73. }
  74. break;
  75. default:
  76. uRet = DRIVE_UNKNOWN;
  77. break;
  78. }
  79. }
  80. else
  81. {
  82. uRet = DRIVE_UNKNOWN;
  83. }
  84. return uRet;
  85. }
  86. /*++
  87. Function Description:
  88. Cause a break
  89. Arguments:
  90. None
  91. Return Value:
  92. None
  93. History:
  94. 10/25/2000 linstev Added this comment
  95. --*/
  96. void APPBreakPoint(void)
  97. {
  98. DbgBreakPoint();
  99. }
  100. }; // end of namespace ShimLib