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.

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