1 /* 2 * ntddcdrm.h 3 * 4 * CDROM IOCTL interface. 5 * 6 * This file is part of the w32api package. 7 * 8 * Contributors: 9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net> 10 * 11 * THIS SOFTWARE IS NOT COPYRIGHTED 12 * 13 * This source code is offered for use in the public domain. You may 14 * use, modify or distribute it freely. 15 * 16 * This code is distributed in the hope that it will be useful but 17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 * DISCLAIMED. This includes but is not limited to warranties of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 * 21 */ 22 23 #ifndef _NTDDCDRM_ 24 #define _NTDDCDRM_ 25 26 #include "ntddstor.h" 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 32 #define IOCTL_CDROM_BASE FILE_DEVICE_CD_ROM 33 34 #define IOCTL_CDROM_CHECK_VERIFY \ 35 CTL_CODE(IOCTL_CDROM_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS) 36 37 #define IOCTL_CDROM_FIND_NEW_DEVICES \ 38 CTL_CODE(IOCTL_CDROM_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS) 39 40 #define IOCTL_CDROM_GET_CONFIGURATION \ 41 CTL_CODE(IOCTL_CDROM_BASE, 0x0016, METHOD_BUFFERED, FILE_READ_ACCESS) 42 43 #define IOCTL_CDROM_GET_CONTROL \ 44 CTL_CODE(IOCTL_CDROM_BASE, 0x000D, METHOD_BUFFERED, FILE_READ_ACCESS) 45 46 #define IOCTL_CDROM_GET_DRIVE_GEOMETRY \ 47 CTL_CODE(IOCTL_CDROM_BASE, 0x0013, METHOD_BUFFERED, FILE_READ_ACCESS) 48 49 #define IOCTL_CDROM_GET_DRIVE_GEOMETRY_EX \ 50 CTL_CODE(IOCTL_CDROM_BASE, 0x0014, METHOD_BUFFERED, FILE_READ_ACCESS) 51 52 #define IOCTL_CDROM_GET_LAST_SESSION \ 53 CTL_CODE(IOCTL_CDROM_BASE, 0x000E, METHOD_BUFFERED, FILE_READ_ACCESS) 54 55 #define IOCTL_CDROM_GET_VOLUME \ 56 CTL_CODE(IOCTL_CDROM_BASE, 0x0005, METHOD_BUFFERED, FILE_READ_ACCESS) 57 58 #define IOCTL_CDROM_PAUSE_AUDIO \ 59 CTL_CODE(IOCTL_CDROM_BASE, 0x0003, METHOD_BUFFERED, FILE_READ_ACCESS) 60 61 #define IOCTL_CDROM_PLAY_AUDIO_MSF \ 62 CTL_CODE(IOCTL_CDROM_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS) 63 64 #define IOCTL_CDROM_RAW_READ \ 65 CTL_CODE(IOCTL_CDROM_BASE, 0x000F, METHOD_OUT_DIRECT, FILE_READ_ACCESS) 66 67 #define IOCTL_CDROM_DISK_TYPE \ 68 CTL_CODE(IOCTL_CDROM_BASE, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS) 69 70 #define IOCTL_CDROM_READ_Q_CHANNEL \ 71 CTL_CODE(IOCTL_CDROM_BASE, 0x000B, METHOD_BUFFERED, FILE_READ_ACCESS) 72 73 #define IOCTL_CDROM_READ_TOC \ 74 CTL_CODE(IOCTL_CDROM_BASE, 0x0000, METHOD_BUFFERED, FILE_READ_ACCESS) 75 76 #define IOCTL_CDROM_READ_TOC_EX \ 77 CTL_CODE(IOCTL_CDROM_BASE, 0x0015, METHOD_BUFFERED, FILE_READ_ACCESS) 78 79 #define IOCTL_CDROM_RESUME_AUDIO \ 80 CTL_CODE(IOCTL_CDROM_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS) 81 82 #define IOCTL_CDROM_SEEK_AUDIO_MSF \ 83 CTL_CODE(IOCTL_CDROM_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS) 84 85 #define IOCTL_CDROM_SET_VOLUME \ 86 CTL_CODE(IOCTL_CDROM_BASE, 0x000A, METHOD_BUFFERED, FILE_READ_ACCESS) 87 88 #define IOCTL_CDROM_SIMBAD \ 89 CTL_CODE(IOCTL_CDROM_BASE, 0x1003, METHOD_BUFFERED, FILE_READ_ACCESS) 90 91 #define IOCTL_CDROM_STOP_AUDIO \ 92 CTL_CODE(IOCTL_CDROM_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS) 93 94 #define IOCTL_CDROM_EJECT_MEDIA \ 95 CTL_CODE(IOCTL_CDROM_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS) 96 97 98 #define MAXIMUM_NUMBER_TRACKS 100 99 #define MAXIMUM_CDROM_SIZE 804 100 #define MINIMUM_CDROM_READ_TOC_EX_SIZE 2 101 102 typedef struct _TRACK_DATA { 103 UCHAR Reserved; 104 UCHAR Control : 4; 105 UCHAR Adr : 4; 106 UCHAR TrackNumber; 107 UCHAR Reserved1; 108 UCHAR Address[4]; 109 } TRACK_DATA, *PTRACK_DATA; 110 111 /* CDROM_DISK_DATA.DiskData flags */ 112 #define CDROM_DISK_AUDIO_TRACK 0x00000001 113 #define CDROM_DISK_DATA_TRACK 0x00000002 114 115 typedef struct _CDROM_DISK_DATA { 116 ULONG DiskData; 117 } CDROM_DISK_DATA, *PCDROM_DISK_DATA; 118 119 typedef struct _CDROM_PLAY_AUDIO_MSF { 120 UCHAR StartingM; 121 UCHAR StartingS; 122 UCHAR StartingF; 123 UCHAR EndingM; 124 UCHAR EndingS; 125 UCHAR EndingF; 126 } CDROM_PLAY_AUDIO_MSF, *PCDROM_PLAY_AUDIO_MSF; 127 128 /* CDROM_READ_TOC_EX.Format constants */ 129 #define CDROM_READ_TOC_EX_FORMAT_TOC 0x00 130 #define CDROM_READ_TOC_EX_FORMAT_SESSION 0x01 131 #define CDROM_READ_TOC_EX_FORMAT_FULL_TOC 0x02 132 #define CDROM_READ_TOC_EX_FORMAT_PMA 0x03 133 #define CDROM_READ_TOC_EX_FORMAT_ATIP 0x04 134 #define CDROM_READ_TOC_EX_FORMAT_CDTEXT 0x05 135 136 typedef struct _CDROM_READ_TOC_EX { 137 UCHAR Format : 4; 138 UCHAR Reserved1 : 3; 139 UCHAR Msf : 1; 140 UCHAR SessionTrack; 141 UCHAR Reserved2; 142 UCHAR Reserved3; 143 } CDROM_READ_TOC_EX, *PCDROM_READ_TOC_EX; 144 145 typedef struct _CDROM_SEEK_AUDIO_MSF { 146 UCHAR M; 147 UCHAR S; 148 UCHAR F; 149 } CDROM_SEEK_AUDIO_MSF, *PCDROM_SEEK_AUDIO_MSF; 150 151 /* CDROM_SUB_Q_DATA_FORMAT.Format constants */ 152 #define IOCTL_CDROM_SUB_Q_CHANNEL 0x00 153 #define IOCTL_CDROM_CURRENT_POSITION 0x01 154 #define IOCTL_CDROM_MEDIA_CATALOG 0x02 155 #define IOCTL_CDROM_TRACK_ISRC 0x03 156 157 typedef struct _CDROM_SUB_Q_DATA_FORMAT { 158 UCHAR Format; 159 UCHAR Track; 160 } CDROM_SUB_Q_DATA_FORMAT, *PCDROM_SUB_Q_DATA_FORMAT; 161 162 typedef struct _CDROM_TOC { 163 UCHAR Length[2]; 164 UCHAR FirstTrack; 165 UCHAR LastTrack; 166 TRACK_DATA TrackData[MAXIMUM_NUMBER_TRACKS]; 167 } CDROM_TOC, *PCDROM_TOC; 168 169 #define CDROM_TOC_SIZE sizeof(CDROM_TOC) 170 171 typedef struct _CDROM_TOC_SESSION_DATA { 172 UCHAR Length[2]; 173 UCHAR FirstCompleteSession; 174 UCHAR LastCompleteSession; 175 TRACK_DATA TrackData[1]; 176 } CDROM_TOC_SESSION_DATA, *PCDROM_TOC_SESSION_DATA; 177 178 typedef struct _CDROM_TOC_ATIP_DATA_BLOCK { 179 UCHAR CdrwReferenceSpeed : 3; 180 UCHAR Reserved3 : 1; 181 UCHAR WritePower : 3; 182 UCHAR True1 : 1; 183 UCHAR Reserved4 : 6; 184 UCHAR UnrestrictedUse : 1; 185 UCHAR Reserved5 : 1; 186 UCHAR A3Valid : 1; 187 UCHAR A2Valid : 1; 188 UCHAR A1Valid : 1; 189 UCHAR Reserved6 : 3; 190 UCHAR IsCdrw : 1; 191 UCHAR True2 : 1; 192 UCHAR Reserved7; 193 UCHAR LeadInMsf[3]; 194 UCHAR Reserved8; 195 UCHAR LeadOutMsf[3]; 196 UCHAR Reserved9; 197 UCHAR A1Values[3]; 198 UCHAR Reserved10; 199 UCHAR A2Values[3]; 200 UCHAR Reserved11; 201 UCHAR A3Values[3]; 202 UCHAR Reserved12; 203 } CDROM_TOC_ATIP_DATA_BLOCK, *PCDROM_TOC_ATIP_DATA_BLOCK; 204 205 typedef struct _CDROM_TOC_ATIP_DATA { 206 UCHAR Length[2]; 207 UCHAR Reserved1; 208 UCHAR Reserved2; 209 CDROM_TOC_ATIP_DATA_BLOCK Descriptors[0]; 210 } CDROM_TOC_ATIP_DATA, *PCDROM_TOC_ATIP_DATA; 211 212 /* CDROM_TOC_CD_TEXT_DATA_BLOCK.PackType constants */ 213 #define CDROM_CD_TEXT_PACK_ALBUM_NAME 0x80 214 #define CDROM_CD_TEXT_PACK_PERFORMER 0x81 215 #define CDROM_CD_TEXT_PACK_SONGWRITER 0x82 216 #define CDROM_CD_TEXT_PACK_COMPOSER 0x83 217 #define CDROM_CD_TEXT_PACK_ARRANGER 0x84 218 #define CDROM_CD_TEXT_PACK_MESSAGES 0x85 219 #define CDROM_CD_TEXT_PACK_DISC_ID 0x86 220 #define CDROM_CD_TEXT_PACK_GENRE 0x87 221 #define CDROM_CD_TEXT_PACK_TOC_INFO 0x88 222 #define CDROM_CD_TEXT_PACK_TOC_INFO2 0x89 223 #define CDROM_CD_TEXT_PACK_UPC_EAN 0x8e 224 #define CDROM_CD_TEXT_PACK_SIZE_INFO 0x8f 225 226 typedef struct _CDROM_TOC_CD_TEXT_DATA_BLOCK { 227 UCHAR PackType; 228 UCHAR TrackNumber : 7; 229 UCHAR ExtensionFlag : 1; 230 UCHAR SequenceNumber; 231 UCHAR CharacterPosition : 4; 232 UCHAR BlockNumber : 3; 233 UCHAR Unicode : 1; 234 _ANONYMOUS_UNION union { 235 UCHAR Text[12]; 236 WCHAR WText[6]; 237 } DUMMYUNIONNAME; 238 UCHAR CRC[2]; 239 } CDROM_TOC_CD_TEXT_DATA_BLOCK, *PCDROM_TOC_CD_TEXT_DATA_BLOCK; 240 241 typedef struct _CDROM_TOC_CD_TEXT_DATA { 242 UCHAR Length[2]; 243 UCHAR Reserved1; 244 UCHAR Reserved2; 245 CDROM_TOC_CD_TEXT_DATA_BLOCK Descriptors[0]; 246 } CDROM_TOC_CD_TEXT_DATA, *PCDROM_TOC_CD_TEXT_DATA; 247 248 /* CDROM_TOC_FULL_TOC_DATA_BLOCK.Adr constants */ 249 #define ADR_NO_MODE_INFORMATION 0x0 250 #define ADR_ENCODES_CURRENT_POSITION 0x1 251 #define ADR_ENCODES_MEDIA_CATALOG 0x2 252 #define ADR_ENCODES_ISRC 0x3 253 254 typedef struct _CDROM_TOC_FULL_TOC_DATA_BLOCK { 255 UCHAR SessionNumber; 256 UCHAR Control : 4; 257 UCHAR Adr : 4; 258 UCHAR Reserved1; 259 UCHAR Point; 260 UCHAR MsfExtra[3]; 261 UCHAR Zero; 262 UCHAR Msf[3]; 263 } CDROM_TOC_FULL_TOC_DATA_BLOCK, *PCDROM_TOC_FULL_TOC_DATA_BLOCK; 264 265 typedef struct _CDROM_TOC_FULL_TOC_DATA { 266 UCHAR Length[2]; 267 UCHAR FirstCompleteSession; 268 UCHAR LastCompleteSession; 269 CDROM_TOC_FULL_TOC_DATA_BLOCK Descriptors[0]; 270 } CDROM_TOC_FULL_TOC_DATA, *PCDROM_TOC_FULL_TOC_DATA; 271 272 typedef struct _CDROM_TOC_PMA_DATA { 273 UCHAR Length[2]; 274 UCHAR Reserved1; 275 UCHAR Reserved2; 276 CDROM_TOC_FULL_TOC_DATA_BLOCK Descriptors[0]; 277 } CDROM_TOC_PMA_DATA, *PCDROM_TOC_PMA_DATA; 278 279 /* SUB_Q_HEADER.AudioStatus constants */ 280 #define AUDIO_STATUS_NOT_SUPPORTED 0x00 281 #define AUDIO_STATUS_IN_PROGRESS 0x11 282 #define AUDIO_STATUS_PAUSED 0x12 283 #define AUDIO_STATUS_PLAY_COMPLETE 0x13 284 #define AUDIO_STATUS_PLAY_ERROR 0x14 285 #define AUDIO_STATUS_NO_STATUS 0x15 286 287 typedef struct _SUB_Q_HEADER { 288 UCHAR Reserved; 289 UCHAR AudioStatus; 290 UCHAR DataLength[2]; 291 } SUB_Q_HEADER, *PSUB_Q_HEADER; 292 293 typedef struct _SUB_Q_MEDIA_CATALOG_NUMBER { 294 SUB_Q_HEADER Header; 295 UCHAR FormatCode; 296 UCHAR Reserved[3]; 297 UCHAR Reserved1 : 7; 298 UCHAR Mcval :1; 299 UCHAR MediaCatalog[15]; 300 } SUB_Q_MEDIA_CATALOG_NUMBER, *PSUB_Q_MEDIA_CATALOG_NUMBER; 301 302 typedef struct _SUB_Q_TRACK_ISRC { 303 SUB_Q_HEADER Header; 304 UCHAR FormatCode; 305 UCHAR Reserved0; 306 UCHAR Track; 307 UCHAR Reserved1; 308 UCHAR Reserved2 : 7; 309 UCHAR Tcval : 1; 310 UCHAR TrackIsrc[15]; 311 } SUB_Q_TRACK_ISRC, *PSUB_Q_TRACK_ISRC; 312 313 typedef struct _SUB_Q_CURRENT_POSITION { 314 SUB_Q_HEADER Header; 315 UCHAR FormatCode; 316 UCHAR Control : 4; 317 UCHAR ADR : 4; 318 UCHAR TrackNumber; 319 UCHAR IndexNumber; 320 UCHAR AbsoluteAddress[4]; 321 UCHAR TrackRelativeAddress[4]; 322 } SUB_Q_CURRENT_POSITION, *PSUB_Q_CURRENT_POSITION; 323 324 typedef union _SUB_Q_CHANNEL_DATA { 325 SUB_Q_CURRENT_POSITION CurrentPosition; 326 SUB_Q_MEDIA_CATALOG_NUMBER MediaCatalog; 327 SUB_Q_TRACK_ISRC TrackIsrc; 328 } SUB_Q_CHANNEL_DATA, *PSUB_Q_CHANNEL_DATA; 329 330 /* CDROM_AUDIO_CONTROL.LbaFormat constants */ 331 #define AUDIO_WITH_PREEMPHASIS 0x1 332 #define DIGITAL_COPY_PERMITTED 0x2 333 #define AUDIO_DATA_TRACK 0x4 334 #define TWO_FOUR_CHANNEL_AUDIO 0x8 335 336 typedef struct _CDROM_AUDIO_CONTROL { 337 UCHAR LbaFormat; 338 USHORT LogicalBlocksPerSecond; 339 } CDROM_AUDIO_CONTROL, *PCDROM_AUDIO_CONTROL; 340 341 typedef struct _VOLUME_CONTROL { 342 UCHAR PortVolume[4]; 343 } VOLUME_CONTROL, *PVOLUME_CONTROL; 344 345 typedef enum _TRACK_MODE_TYPE { 346 YellowMode2, 347 XAForm2, 348 CDDA 349 } TRACK_MODE_TYPE, *PTRACK_MODE_TYPE; 350 351 typedef struct __RAW_READ_INFO { 352 LARGE_INTEGER DiskOffset; 353 ULONG SectorCount; 354 TRACK_MODE_TYPE TrackMode; 355 } RAW_READ_INFO, *PRAW_READ_INFO; 356 357 #ifdef __cplusplus 358 } 359 #endif 360 361 #endif /* _NTDDCDRM_ */ 362