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.

293 lines
8.5 KiB

  1. /*++
  2. Copyright (c) 1993-2001 Microsoft Corporation
  3. Module Name:
  4. ntddramd.w
  5. Abstract:
  6. This header file defines constants and types for accessing the RAMDISK driver.
  7. Author:
  8. Chuck Lenzmeier (ChuckL) 14-Aug-2001
  9. --*/
  10. #ifndef _NTDDRAMD_
  11. #define _NTDDRAMD_
  12. //
  13. // Strings for device names, etc.
  14. //
  15. // RAMDISK_DEVICENAME is the name of the control device. It is also the prefix
  16. // for the name of disk devices, which are named \Device\Ramdisk{guid}.
  17. //
  18. // RAMDISK_DOSNAME is the prefix for the DosDevices name of disk devices, which
  19. // are named Ramdisk{guid}.
  20. //
  21. // The remaining strings are used in conjunction with PnP.
  22. //
  23. #define RAMDISK_DEVICENAME L"\\Device\\Ramdisk"
  24. #define RAMDISK_DEVICE_NAME L"\\Device\\Ramdisk"
  25. #define RAMDISK_DRIVER_NAME L"RAMDISK"
  26. #define RAMDISK_DOSNAME L"Ramdisk"
  27. #define RAMDISK_FULL_DOSNAME L"\\global??\\Ramdisk"
  28. #define RAMDISK_VOLUME_DEVICE_TEXT L"RamVolume"
  29. #define RAMDISK_VOLUME_DEVICE_TEXT_ANSI "RamVolume"
  30. #define RAMDISK_DISK_DEVICE_TEXT L"RamDisk"
  31. #define RAMDISK_DISK_DEVICE_TEXT_ANSI "RamDisk"
  32. #define RAMDISK_ENUMERATOR_TEXT L"Ramdisk\\"
  33. #define RAMDISK_ENUMERATOR_BUS_TEXT L"Ramdisk\\0"
  34. //
  35. // Ramdisk device name maximum size ( in characters )
  36. //
  37. #define RAMDISK_MAX_DEVICE_NAME ( sizeof( L"\\Device\\Ramdisk{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" ) / sizeof( WCHAR ) )
  38. //
  39. // IOCTL codes.
  40. //
  41. #define FSCTL_CREATE_RAM_DISK \
  42. CTL_CODE( FILE_DEVICE_VIRTUAL_DISK, 0, METHOD_BUFFERED, FILE_ANY_ACCESS)
  43. #define FSCTL_MARK_RAM_DISK_FOR_DELETION \
  44. CTL_CODE( FILE_DEVICE_VIRTUAL_DISK, 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
  45. #define FSCTL_QUERY_RAM_DISK \
  46. CTL_CODE( FILE_DEVICE_VIRTUAL_DISK, 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
  47. //
  48. // FSCTL_CREATE_RAM_DISK
  49. //
  50. // This IOCTL is used to create a new RAMDISK device.
  51. //
  52. //
  53. // These are disk types. FILE_BACKED_DISK is an emulated disk backed by a file.
  54. // FILE_BACKED_VOLUME is an emulated volume backed by a file. BOOT_DISK is an
  55. // in-memory emulated boot volume. This type can only be specified by the OS during
  56. // boot. VIRTUAL_FLOPPY is an in-memory emulated floppy disk. This type can only be
  57. // specified (via the registry) during textmode setup.
  58. //
  59. #define RAMDISK_TYPE_FILE_BACKED_DISK 1
  60. #define RAMDISK_TYPE_FILE_BACKED_VOLUME 2
  61. #define RAMDISK_TYPE_BOOT_DISK 3
  62. #define RAMDISK_TYPE_VIRTUAL_FLOPPY 4
  63. #define RAMDISK_IS_FILE_BACKED(_type) ((_type) <= RAMDISK_TYPE_FILE_BACKED_VOLUME)
  64. //
  65. // These are options related to the RAM disk.
  66. //
  67. // Readonly - The disk is write-protected.
  68. // Fixed - The "media" in the "disk" is not removable.
  69. // NoDriveLetter - No drive letter should be assigned to the disk.
  70. // NoDosDevice - No Ramdisk{GUID} DosDevices link should be created for the disk.
  71. // Hidden - No Volume{GUID} link should be created for the disk.
  72. //
  73. // Note that all of these options are ignored when creating a boot disk or
  74. // a virtual floppy. For a boot disk, all of the options are treated as FALSE,
  75. // except Fixed, which is TRUE. For a virtual floppy, Fixed and NoDriveLetter
  76. // are TRUE, and the rest are FALSE.
  77. //
  78. typedef struct _RAMDISK_CREATE_OPTIONS {
  79. ULONG Readonly : 1;
  80. ULONG Fixed : 1;
  81. ULONG NoDriveLetter : 1;
  82. ULONG NoDosDevice : 1;
  83. ULONG Hidden : 1;
  84. } RAMDISK_CREATE_OPTIONS, *PRAMDISK_CREATE_OPTIONS;
  85. typedef struct _RAMDISK_CREATE_INPUT {
  86. ULONG Version; // == sizeof(RAMDISK_CREATE_INPUT)
  87. //
  88. // DiskGuid is a GUID assigned to the disk. For file-backed disks, this
  89. // GUID should be assigned when the backing file is created, and should
  90. // stay the same for the life of the backing file.
  91. //
  92. GUID DiskGuid;
  93. //
  94. // DiskType is the RAM disk type. It is one of RAMDISK_TYPE_XXX above.
  95. //
  96. ULONG DiskType;
  97. //
  98. // Options is various options related to the disk, as described above.
  99. //
  100. RAMDISK_CREATE_OPTIONS Options;
  101. //
  102. // DiskLength is the length of the disk image. DiskOffset is the offset
  103. // from the start of the backing file or memory block to the actual start
  104. // of the disk image. (DiskLength does NOT include DiskOffset.)
  105. ULONGLONG DiskLength;
  106. ULONG DiskOffset;
  107. union {
  108. //
  109. // The following are used when the disk type is FILE_BACKED.
  110. //
  111. struct {
  112. //
  113. // ViewCount indicates, for file-backed disks, how many view
  114. // windows can be mapped simultaneously. ViewLength indicates the
  115. // length of each view.
  116. //
  117. ULONG ViewCount;
  118. ULONG ViewLength;
  119. //
  120. // FileName is the name of the backing file. The driver only
  121. // touches the part of this file that is specified by DiskOffset
  122. // and DiskLength.
  123. //
  124. WCHAR FileName[1];
  125. } ;
  126. //
  127. // The following are used when the disk type is BOOT_DISK.
  128. //
  129. struct {
  130. //
  131. // BasePage is the starting physical page of the memory region
  132. // containing the disk image. The driver only touches the part
  133. // of this region that is specified by DiskOffset and DiskLength.
  134. //
  135. ULONG_PTR BasePage;
  136. //
  137. // DriveLetter is the drive letter to assign to the boot device.
  138. // This is done directly by the driver, not by mountmgr.
  139. //
  140. WCHAR DriveLetter;
  141. } ;
  142. //
  143. // The following are used when the disk type is VIRTUAL_FLOPPY.
  144. //
  145. struct {
  146. //
  147. // BaseAddress is the starting virtual address of the memory region
  148. // containing the disk image. The virtual address must be mapped in
  149. // system space (e.g., pool). The driver only touches the part of
  150. // this region that is specified by DiskOffset and DiskLength.
  151. //
  152. PVOID BaseAddress;
  153. } ;
  154. } ;
  155. } RAMDISK_CREATE_INPUT, *PRAMDISK_CREATE_INPUT;
  156. //
  157. // FSCTL_QUERY_RAM_DISK
  158. //
  159. // This IOCTL is used to retrieve information about an existing RAMDISK device.
  160. //
  161. typedef struct _RAMDISK_QUERY_INPUT {
  162. ULONG Version; // == sizeof(RAMDISK_QUERY_INPUT)
  163. //
  164. // DiskGuid specifies the DiskGuid assigned to the disk at creation time.
  165. //
  166. GUID DiskGuid;
  167. } RAMDISK_QUERY_INPUT, *PRAMDISK_QUERY_INPUT;
  168. typedef struct _RAMDISK_QUERY_OUTPUT {
  169. //
  170. // This unnamed field returns the creation parameters for the disk.
  171. //
  172. struct _RAMDISK_CREATE_INPUT ;
  173. } RAMDISK_QUERY_OUTPUT, *PRAMDISK_QUERY_OUTPUT;
  174. //
  175. // FSCTL_MARK_RAM_DISK_FOR_DELETION
  176. //
  177. // This IOCTL is used to mark a RAMDISK device for deletion. It doesn't
  178. // actually delete the device. The program doing the deletion must
  179. // subsequently call CM_Query_And_Remove_SubTree() to delete the device.
  180. // The purpose of the IOCTL is to indicate to the driver that the PnP
  181. // removal sequence that comes down is a real deletion, not just user-mode
  182. // PnP temporarily stopping the device.
  183. //
  184. typedef struct _RAMDISK_MARK_FOR_DELETION_INPUT {
  185. ULONG Version; // == sizeof(RAMDISK_MARK_DISK_FOR_DELETION_INPUT)
  186. //
  187. // DiskGuid specifies the DiskGuid assigned to the disk at creation time.
  188. //
  189. GUID DiskGuid;
  190. } RAMDISK_MARK_FOR_DELETION_INPUT, *PRAMDISK_MARK_FOR_DELETION_INPUT;
  191. #endif // _NTDDRAMD_
  192. //
  193. // Note: The remainder of this file is outside of the #if !defined(_NTDDRAMD_).
  194. // This allows ntddramd.h to be included again after including initguid.h,
  195. // thus turning the DEFINE_GUIDs below into data initializers, not just
  196. // extern declarations.
  197. //
  198. // GUID_BUS_TYPE_RAMDISK is the GUID for the RAM disk "bus".
  199. //
  200. // RamdiskBusInterface is the GUID for the RAM disk bus enumerator device's
  201. // device interface.
  202. //
  203. // RamdiskDiskInterface is the GUID for the device interface for RAM disk
  204. // devices that are emulating disks. (RAM disk devices that are emulating
  205. // volumes are given MOUNTDEV_MOUNTED_DEVICE_GUID.)
  206. //
  207. // RamdiskBootDiskGuid is the GUID for the device instance for the boot disk.
  208. // This is a static ID so that disk image preparation can pre-expose
  209. // the boot disk device to PnP, avoiding PnP trying to install the
  210. // device at boot time.
  211. //
  212. DEFINE_GUID( GUID_BUS_TYPE_RAMDISK, 0x9D6D66A6, 0x0B0C, 0x4563, 0x90, 0x77, 0xA0, 0xE9, 0xA7, 0x95, 0x5A, 0xE4);
  213. DEFINE_GUID( RamdiskBusInterface, 0x5DC52DF0, 0x2F8A, 0x410F, 0x80, 0xE4, 0x05, 0xF8, 0x10, 0xE7, 0xAB, 0x8A);
  214. DEFINE_GUID( RamdiskDiskInterface, 0x31D909F0, 0x2CDF, 0x4A20, 0x9E, 0xD4, 0x7D, 0x65, 0x47, 0x6C, 0xA7, 0x68);
  215. DEFINE_GUID( RamdiskBootDiskGuid, 0xD9B257FC, 0x684E, 0x4DCB, 0xAB, 0x79, 0x03, 0xCF, 0xA2, 0xF6, 0xB7, 0x50);