ntddcdrm.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. ntddcdrm.h
  5. Abstract:
  6. This module contains structures and definitions
  7. associated with CDROM IOCTls.
  8. Author:
  9. Mike Glass
  10. Revision History:
  11. --*/
  12. // begin_winioctl
  13. #ifndef _NTDDCDRM_
  14. #define _NTDDCDRM_
  15. #if _MSC_VER >= 1200
  16. #pragma warning(push)
  17. #endif
  18. #if _MSC_VER > 1000
  19. #pragma once
  20. #endif
  21. //
  22. // remove some level 4 warnings for this header file:
  23. #pragma warning(disable:4200) // array[0]
  24. #pragma warning(disable:4201) // nameless struct/unions
  25. #pragma warning(disable:4214) // bit fields other than int
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. //
  30. // NtDeviceIoControlFile IoControlCode values for this device.
  31. //
  32. // Warning: Remember that the low two bits of the code specify how the
  33. // buffers are passed to the driver!
  34. //
  35. #define IOCTL_CDROM_BASE FILE_DEVICE_CD_ROM
  36. #define IOCTL_CDROM_UNLOAD_DRIVER CTL_CODE(IOCTL_CDROM_BASE, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS)
  37. //
  38. // CDROM Audio Device Control Functions
  39. //
  40. #define IOCTL_CDROM_READ_TOC CTL_CODE(IOCTL_CDROM_BASE, 0x0000, METHOD_BUFFERED, FILE_READ_ACCESS)
  41. #define IOCTL_CDROM_SEEK_AUDIO_MSF CTL_CODE(IOCTL_CDROM_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
  42. #define IOCTL_CDROM_STOP_AUDIO CTL_CODE(IOCTL_CDROM_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS)
  43. #define IOCTL_CDROM_PAUSE_AUDIO CTL_CODE(IOCTL_CDROM_BASE, 0x0003, METHOD_BUFFERED, FILE_READ_ACCESS)
  44. #define IOCTL_CDROM_RESUME_AUDIO CTL_CODE(IOCTL_CDROM_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS)
  45. #define IOCTL_CDROM_GET_VOLUME CTL_CODE(IOCTL_CDROM_BASE, 0x0005, METHOD_BUFFERED, FILE_READ_ACCESS)
  46. #define IOCTL_CDROM_PLAY_AUDIO_MSF CTL_CODE(IOCTL_CDROM_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS)
  47. #define IOCTL_CDROM_SET_VOLUME CTL_CODE(IOCTL_CDROM_BASE, 0x000A, METHOD_BUFFERED, FILE_READ_ACCESS)
  48. #define IOCTL_CDROM_READ_Q_CHANNEL CTL_CODE(IOCTL_CDROM_BASE, 0x000B, METHOD_BUFFERED, FILE_READ_ACCESS)
  49. #define IOCTL_CDROM_GET_CONTROL CTL_CODE(IOCTL_CDROM_BASE, 0x000D, METHOD_BUFFERED, FILE_READ_ACCESS)
  50. #define IOCTL_CDROM_GET_LAST_SESSION CTL_CODE(IOCTL_CDROM_BASE, 0x000E, METHOD_BUFFERED, FILE_READ_ACCESS)
  51. #define IOCTL_CDROM_RAW_READ CTL_CODE(IOCTL_CDROM_BASE, 0x000F, METHOD_OUT_DIRECT, FILE_READ_ACCESS)
  52. #define IOCTL_CDROM_DISK_TYPE CTL_CODE(IOCTL_CDROM_BASE, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS)
  53. #define IOCTL_CDROM_GET_DRIVE_GEOMETRY CTL_CODE(IOCTL_CDROM_BASE, 0x0013, METHOD_BUFFERED, FILE_READ_ACCESS)
  54. #define IOCTL_CDROM_GET_DRIVE_GEOMETRY_EX CTL_CODE(IOCTL_CDROM_BASE, 0x0014, METHOD_BUFFERED, FILE_READ_ACCESS)
  55. #define IOCTL_CDROM_READ_TOC_EX CTL_CODE(IOCTL_CDROM_BASE, 0x0015, METHOD_BUFFERED, FILE_READ_ACCESS)
  56. #define IOCTL_CDROM_GET_CONFIGURATION CTL_CODE(IOCTL_CDROM_BASE, 0x0016, METHOD_BUFFERED, FILE_READ_ACCESS)
  57. // end_winioctl
  58. //
  59. // The following device control codes are common for all class drivers. The
  60. // functions codes defined here must match all of the other class drivers.
  61. //
  62. // Warning: these codes will be replaced in the future with the IOCTL_STORAGE
  63. // codes included below
  64. //
  65. #define IOCTL_CDROM_CHECK_VERIFY CTL_CODE(IOCTL_CDROM_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
  66. #define IOCTL_CDROM_MEDIA_REMOVAL CTL_CODE(IOCTL_CDROM_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
  67. #define IOCTL_CDROM_EJECT_MEDIA CTL_CODE(IOCTL_CDROM_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
  68. #define IOCTL_CDROM_LOAD_MEDIA CTL_CODE(IOCTL_CDROM_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
  69. #define IOCTL_CDROM_RESERVE CTL_CODE(IOCTL_CDROM_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
  70. #define IOCTL_CDROM_RELEASE CTL_CODE(IOCTL_CDROM_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
  71. #define IOCTL_CDROM_FIND_NEW_DEVICES CTL_CODE(IOCTL_CDROM_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
  72. //
  73. // The following file contains the IOCTL_STORAGE class ioctl definitions
  74. //
  75. //#include "ntddstor.h"
  76. // begin_winioctl
  77. //
  78. // The following device control code is for the SIMBAD simulated bad
  79. // sector facility. See SIMBAD.H in this directory for related structures.
  80. //
  81. #define IOCTL_CDROM_SIMBAD CTL_CODE(IOCTL_CDROM_BASE, 0x1003, METHOD_BUFFERED, FILE_READ_ACCESS)
  82. //
  83. // Maximum CD Rom size
  84. //
  85. #define MAXIMUM_NUMBER_TRACKS 100
  86. #define MAXIMUM_CDROM_SIZE 804
  87. #define MINIMUM_CDROM_READ_TOC_EX_SIZE 2 // two bytes min transferred
  88. //
  89. // READ_TOC_EX structure
  90. //
  91. typedef struct _CDROM_READ_TOC_EX {
  92. UCHAR Format : 4;
  93. UCHAR Reserved1 : 3; // future expansion
  94. UCHAR Msf : 1;
  95. UCHAR SessionTrack;
  96. UCHAR Reserved2; // future expansion
  97. UCHAR Reserved3; // future expansion
  98. } CDROM_READ_TOC_EX, *PCDROM_READ_TOC_EX;
  99. #define CDROM_READ_TOC_EX_FORMAT_TOC 0x00
  100. #define CDROM_READ_TOC_EX_FORMAT_SESSION 0x01
  101. #define CDROM_READ_TOC_EX_FORMAT_FULL_TOC 0x02
  102. #define CDROM_READ_TOC_EX_FORMAT_PMA 0x03
  103. #define CDROM_READ_TOC_EX_FORMAT_ATIP 0x04
  104. #define CDROM_READ_TOC_EX_FORMAT_CDTEXT 0x05
  105. //
  106. // CD ROM Table OF Contents (TOC)
  107. // Format 0 - Get table of contents
  108. //
  109. typedef struct _TRACK_DATA {
  110. UCHAR Reserved;
  111. UCHAR Control : 4;
  112. UCHAR Adr : 4;
  113. UCHAR TrackNumber;
  114. UCHAR Reserved1;
  115. UCHAR Address[4];
  116. } TRACK_DATA, *PTRACK_DATA;
  117. typedef struct _CDROM_TOC {
  118. //
  119. // Header
  120. //
  121. UCHAR Length[2]; // add two bytes for this field
  122. UCHAR FirstTrack;
  123. UCHAR LastTrack;
  124. //
  125. // Track data
  126. //
  127. TRACK_DATA TrackData[MAXIMUM_NUMBER_TRACKS];
  128. } CDROM_TOC, *PCDROM_TOC;
  129. #define CDROM_TOC_SIZE sizeof(CDROM_TOC)
  130. //
  131. // CD ROM Table OF Contents
  132. // Format 1 - Session Information
  133. //
  134. typedef struct _CDROM_TOC_SESSION_DATA {
  135. //
  136. // Header
  137. //
  138. UCHAR Length[2]; // add two bytes for this field
  139. UCHAR FirstCompleteSession;
  140. UCHAR LastCompleteSession;
  141. //
  142. // One track, representing the first track
  143. // of the last finished session
  144. //
  145. TRACK_DATA TrackData[1];
  146. } CDROM_TOC_SESSION_DATA, *PCDROM_TOC_SESSION_DATA;
  147. //
  148. // CD ROM Table OF Contents
  149. // Format 2 - Full TOC
  150. //
  151. typedef struct _CDROM_TOC_FULL_TOC_DATA_BLOCK {
  152. UCHAR SessionNumber;
  153. UCHAR Control : 4;
  154. UCHAR Adr : 4;
  155. UCHAR Reserved1;
  156. UCHAR Point;
  157. UCHAR MsfExtra[3];
  158. UCHAR Zero;
  159. UCHAR Msf[3];
  160. } CDROM_TOC_FULL_TOC_DATA_BLOCK, *PCDROM_TOC_FULL_TOC_DATA_BLOCK;
  161. typedef struct _CDROM_TOC_FULL_TOC_DATA {
  162. //
  163. // Header
  164. //
  165. UCHAR Length[2]; // add two bytes for this field
  166. UCHAR FirstCompleteSession;
  167. UCHAR LastCompleteSession;
  168. //
  169. // one to N descriptors included
  170. //
  171. CDROM_TOC_FULL_TOC_DATA_BLOCK Descriptors[0];
  172. } CDROM_TOC_FULL_TOC_DATA, *PCDROM_TOC_FULL_TOC_DATA;
  173. //
  174. // CD ROM Table OF Contents
  175. // Format 3 - Program Memory Area
  176. //
  177. typedef struct _CDROM_TOC_PMA_DATA {
  178. //
  179. // Header
  180. //
  181. UCHAR Length[2]; // add two bytes for this field
  182. UCHAR Reserved1;
  183. UCHAR Reserved2;
  184. //
  185. // one to N descriptors included
  186. //
  187. CDROM_TOC_FULL_TOC_DATA_BLOCK Descriptors[0];
  188. } CDROM_TOC_PMA_DATA, *PCDROM_TOC_PMA_DATA;
  189. //
  190. // CD ROM Table OF Contents
  191. // Format 4 - Absolute Time In Pregroove
  192. //
  193. typedef struct _CDROM_TOC_ATIP_DATA_BLOCK {
  194. UCHAR CdrwReferenceSpeed : 3;
  195. UCHAR Reserved3 : 1;
  196. UCHAR WritePower : 3;
  197. UCHAR True1 : 1;
  198. UCHAR Reserved4 : 6;
  199. UCHAR UnrestrictedUse : 1;
  200. UCHAR Reserved5 : 1;
  201. UCHAR A3Valid : 1;
  202. UCHAR A2Valid : 1;
  203. UCHAR A1Valid : 1;
  204. UCHAR DiscSubType : 3;
  205. UCHAR IsCdrw : 1;
  206. UCHAR True2 : 1;
  207. UCHAR Reserved7;
  208. UCHAR LeadInMsf[3];
  209. UCHAR Reserved8;
  210. UCHAR LeadOutMsf[3];
  211. UCHAR Reserved9;
  212. UCHAR A1Values[3];
  213. UCHAR Reserved10;
  214. UCHAR A2Values[3];
  215. UCHAR Reserved11;
  216. UCHAR A3Values[3];
  217. UCHAR Reserved12;
  218. } CDROM_TOC_ATIP_DATA_BLOCK, *PCDROM_TOC_ATIP_DATA_BLOCK;
  219. typedef struct _CDROM_TOC_ATIP_DATA {
  220. //
  221. // Header
  222. //
  223. UCHAR Length[2]; // add two bytes for this field
  224. UCHAR Reserved1;
  225. UCHAR Reserved2;
  226. //
  227. // zero? to N descriptors included.
  228. //
  229. CDROM_TOC_ATIP_DATA_BLOCK Descriptors[0];
  230. } CDROM_TOC_ATIP_DATA, *PCDROM_TOC_ATIP_DATA;
  231. //
  232. // CD ROM Table OF Contents
  233. // Format 5 - CD Text Info
  234. //
  235. #define CD_TEXT_FIELD_LENGTH 12
  236. typedef struct _CDROM_TOC_CD_TEXT_DATA_BLOCK {
  237. UCHAR PackType;
  238. UCHAR TrackNumber : 7;
  239. UCHAR ExtensionFlag : 1; // should be zero!
  240. UCHAR SequenceNumber;
  241. UCHAR CharacterPosition : 4;
  242. UCHAR BlockNumber : 3;
  243. UCHAR Unicode : 1;
  244. union {
  245. UCHAR Text[12];
  246. WCHAR WText[6];
  247. };
  248. UCHAR CRC[2];
  249. } CDROM_TOC_CD_TEXT_DATA_BLOCK, *PCDROM_TOC_CD_TEXT_DATA_BLOCK;
  250. typedef struct _CDROM_TOC_CD_TEXT_DATA {
  251. //
  252. // Header
  253. //
  254. UCHAR Length[2]; // add two bytes for this field
  255. UCHAR Reserved1;
  256. UCHAR Reserved2;
  257. //
  258. // the text info comes in discrete blocks of
  259. // a heavily-overloaded structure
  260. //
  261. CDROM_TOC_CD_TEXT_DATA_BLOCK Descriptors[0];
  262. } CDROM_TOC_CD_TEXT_DATA, *PCDROM_TOC_CD_TEXT_DATA;
  263. //
  264. // These are the types used for PackType field in CDROM_TOC_CD_TEXT_DATA_BLOCK
  265. // and also for requesting specific info from IOCTL_CDROM_READ_CD_TEXT
  266. //
  267. #define CDROM_CD_TEXT_PACK_ALBUM_NAME 0x80
  268. #define CDROM_CD_TEXT_PACK_PERFORMER 0x81
  269. #define CDROM_CD_TEXT_PACK_SONGWRITER 0x82
  270. #define CDROM_CD_TEXT_PACK_COMPOSER 0x83
  271. #define CDROM_CD_TEXT_PACK_ARRANGER 0x84
  272. #define CDROM_CD_TEXT_PACK_MESSAGES 0x85
  273. #define CDROM_CD_TEXT_PACK_DISC_ID 0x86
  274. #define CDROM_CD_TEXT_PACK_GENRE 0x87
  275. #define CDROM_CD_TEXT_PACK_TOC_INFO 0x88
  276. #define CDROM_CD_TEXT_PACK_TOC_INFO2 0x89
  277. // 0x8a - 0x8d are reserved....
  278. #define CDROM_CD_TEXT_PACK_UPC_EAN 0x8e
  279. #define CDROM_CD_TEXT_PACK_SIZE_INFO 0x8f
  280. //
  281. // Play audio starting at MSF and ending at MSF
  282. //
  283. typedef struct _CDROM_PLAY_AUDIO_MSF {
  284. UCHAR StartingM;
  285. UCHAR StartingS;
  286. UCHAR StartingF;
  287. UCHAR EndingM;
  288. UCHAR EndingS;
  289. UCHAR EndingF;
  290. } CDROM_PLAY_AUDIO_MSF, *PCDROM_PLAY_AUDIO_MSF;
  291. //
  292. // Seek to MSF
  293. //
  294. typedef struct _CDROM_SEEK_AUDIO_MSF {
  295. UCHAR M;
  296. UCHAR S;
  297. UCHAR F;
  298. } CDROM_SEEK_AUDIO_MSF, *PCDROM_SEEK_AUDIO_MSF;
  299. //
  300. // Flags for the disk type
  301. //
  302. typedef struct _CDROM_DISK_DATA {
  303. ULONG DiskData;
  304. } CDROM_DISK_DATA, *PCDROM_DISK_DATA;
  305. #define CDROM_DISK_AUDIO_TRACK (0x00000001)
  306. #define CDROM_DISK_DATA_TRACK (0x00000002)
  307. //
  308. // CD ROM Data Mode Codes, used with IOCTL_CDROM_READ_Q_CHANNEL
  309. //
  310. #define IOCTL_CDROM_SUB_Q_CHANNEL 0x00
  311. #define IOCTL_CDROM_CURRENT_POSITION 0x01
  312. #define IOCTL_CDROM_MEDIA_CATALOG 0x02
  313. #define IOCTL_CDROM_TRACK_ISRC 0x03
  314. typedef struct _CDROM_SUB_Q_DATA_FORMAT {
  315. UCHAR Format;
  316. UCHAR Track;
  317. } CDROM_SUB_Q_DATA_FORMAT, *PCDROM_SUB_Q_DATA_FORMAT;
  318. //
  319. // CD ROM Sub-Q Channel Data Format
  320. //
  321. typedef struct _SUB_Q_HEADER {
  322. UCHAR Reserved;
  323. UCHAR AudioStatus;
  324. UCHAR DataLength[2];
  325. } SUB_Q_HEADER, *PSUB_Q_HEADER;
  326. typedef struct _SUB_Q_CURRENT_POSITION {
  327. SUB_Q_HEADER Header;
  328. UCHAR FormatCode;
  329. UCHAR Control : 4;
  330. UCHAR ADR : 4;
  331. UCHAR TrackNumber;
  332. UCHAR IndexNumber;
  333. UCHAR AbsoluteAddress[4];
  334. UCHAR TrackRelativeAddress[4];
  335. } SUB_Q_CURRENT_POSITION, *PSUB_Q_CURRENT_POSITION;
  336. typedef struct _SUB_Q_MEDIA_CATALOG_NUMBER {
  337. SUB_Q_HEADER Header;
  338. UCHAR FormatCode;
  339. UCHAR Reserved[3];
  340. UCHAR Reserved1 : 7;
  341. UCHAR Mcval : 1;
  342. UCHAR MediaCatalog[15];
  343. } SUB_Q_MEDIA_CATALOG_NUMBER, *PSUB_Q_MEDIA_CATALOG_NUMBER;
  344. typedef struct _SUB_Q_TRACK_ISRC {
  345. SUB_Q_HEADER Header;
  346. UCHAR FormatCode;
  347. UCHAR Reserved0;
  348. UCHAR Track;
  349. UCHAR Reserved1;
  350. UCHAR Reserved2 : 7;
  351. UCHAR Tcval : 1;
  352. UCHAR TrackIsrc[15];
  353. } SUB_Q_TRACK_ISRC, *PSUB_Q_TRACK_ISRC;
  354. typedef union _SUB_Q_CHANNEL_DATA {
  355. SUB_Q_CURRENT_POSITION CurrentPosition;
  356. SUB_Q_MEDIA_CATALOG_NUMBER MediaCatalog;
  357. SUB_Q_TRACK_ISRC TrackIsrc;
  358. } SUB_Q_CHANNEL_DATA, *PSUB_Q_CHANNEL_DATA;
  359. //
  360. // Audio Status Codes
  361. //
  362. #define AUDIO_STATUS_NOT_SUPPORTED 0x00
  363. #define AUDIO_STATUS_IN_PROGRESS 0x11
  364. #define AUDIO_STATUS_PAUSED 0x12
  365. #define AUDIO_STATUS_PLAY_COMPLETE 0x13
  366. #define AUDIO_STATUS_PLAY_ERROR 0x14
  367. #define AUDIO_STATUS_NO_STATUS 0x15
  368. //
  369. // ADR Sub-channel Q Field
  370. //
  371. #define ADR_NO_MODE_INFORMATION 0x0
  372. #define ADR_ENCODES_CURRENT_POSITION 0x1
  373. #define ADR_ENCODES_MEDIA_CATALOG 0x2
  374. #define ADR_ENCODES_ISRC 0x3
  375. //
  376. // Sub-channel Q Control Bits
  377. //
  378. #define AUDIO_WITH_PREEMPHASIS 0x1
  379. #define DIGITAL_COPY_PERMITTED 0x2
  380. #define AUDIO_DATA_TRACK 0x4
  381. #define TWO_FOUR_CHANNEL_AUDIO 0x8
  382. //
  383. // Get Audio control parameters
  384. //
  385. typedef struct _CDROM_AUDIO_CONTROL {
  386. UCHAR LbaFormat;
  387. USHORT LogicalBlocksPerSecond;
  388. } CDROM_AUDIO_CONTROL, *PCDROM_AUDIO_CONTROL;
  389. //
  390. // Volume control - Volume takes a value between 1 and 0xFF.
  391. // SCSI-II CDROM audio suppports up to 4 audio ports with
  392. // Independent volume control.
  393. //
  394. typedef struct _VOLUME_CONTROL {
  395. UCHAR PortVolume[4];
  396. } VOLUME_CONTROL, *PVOLUME_CONTROL;
  397. typedef enum _TRACK_MODE_TYPE {
  398. YellowMode2,
  399. XAForm2,
  400. CDDA
  401. } TRACK_MODE_TYPE, *PTRACK_MODE_TYPE;
  402. //
  403. // Passed to cdrom to describe the raw read, ie. Mode 2, Form 2, CDDA...
  404. //
  405. typedef struct __RAW_READ_INFO {
  406. LARGE_INTEGER DiskOffset;
  407. ULONG SectorCount;
  408. TRACK_MODE_TYPE TrackMode;
  409. } RAW_READ_INFO, *PRAW_READ_INFO;
  410. #ifdef __cplusplus
  411. }
  412. #endif
  413. #if _MSC_VER >= 1200
  414. #pragma warning(pop) // un-sets any local warning changes
  415. #else
  416. #pragma warning(default:4200) // array[0] is not a warning for this file
  417. #pragma warning(default:4201) // nameless struct/unions
  418. #pragma warning(default:4214) // bit fields other than int
  419. #endif
  420. #endif // _NTDDCDRM_
  421. // end_winioctl