Home | History | Annotate | Download | only in include
      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 (at) 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 
     95 #define MAXIMUM_NUMBER_TRACKS             100
     96 #define MAXIMUM_CDROM_SIZE                804
     97 #define MINIMUM_CDROM_READ_TOC_EX_SIZE    2
     98 
     99 typedef struct _TRACK_DATA {
    100   UCHAR  Reserved;
    101   UCHAR  Control : 4;
    102   UCHAR  Adr : 4;
    103   UCHAR  TrackNumber;
    104   UCHAR  Reserved1;
    105   UCHAR  Address[4];
    106 } TRACK_DATA, *PTRACK_DATA;
    107 
    108 /* CDROM_DISK_DATA.DiskData flags */
    109 #define CDROM_DISK_AUDIO_TRACK            0x00000001
    110 #define CDROM_DISK_DATA_TRACK             0x00000002
    111 
    112 typedef struct _CDROM_DISK_DATA {
    113   ULONG  DiskData;
    114 } CDROM_DISK_DATA, *PCDROM_DISK_DATA;
    115 
    116 typedef struct _CDROM_PLAY_AUDIO_MSF {
    117   UCHAR  StartingM;
    118   UCHAR  StartingS;
    119   UCHAR  StartingF;
    120   UCHAR  EndingM;
    121   UCHAR  EndingS;
    122   UCHAR  EndingF;
    123 } CDROM_PLAY_AUDIO_MSF, *PCDROM_PLAY_AUDIO_MSF;
    124 
    125 /* CDROM_READ_TOC_EX.Format constants */
    126 #define CDROM_READ_TOC_EX_FORMAT_TOC      0x00
    127 #define CDROM_READ_TOC_EX_FORMAT_SESSION  0x01
    128 #define CDROM_READ_TOC_EX_FORMAT_FULL_TOC 0x02
    129 #define CDROM_READ_TOC_EX_FORMAT_PMA      0x03
    130 #define CDROM_READ_TOC_EX_FORMAT_ATIP     0x04
    131 #define CDROM_READ_TOC_EX_FORMAT_CDTEXT   0x05
    132 
    133 typedef struct _CDROM_READ_TOC_EX {
    134   UCHAR  Format : 4;
    135   UCHAR  Reserved1 : 3;
    136   UCHAR  Msf : 1;
    137   UCHAR  SessionTrack;
    138   UCHAR  Reserved2;
    139   UCHAR  Reserved3;
    140 } CDROM_READ_TOC_EX, *PCDROM_READ_TOC_EX;
    141 
    142 typedef struct _CDROM_SEEK_AUDIO_MSF {
    143   UCHAR  M;
    144   UCHAR  S;
    145   UCHAR  F;
    146 } CDROM_SEEK_AUDIO_MSF, *PCDROM_SEEK_AUDIO_MSF;
    147 
    148 /* CDROM_SUB_Q_DATA_FORMAT.Format constants */
    149 #define IOCTL_CDROM_SUB_Q_CHANNEL         0x00
    150 #define IOCTL_CDROM_CURRENT_POSITION      0x01
    151 #define IOCTL_CDROM_MEDIA_CATALOG         0x02
    152 #define IOCTL_CDROM_TRACK_ISRC            0x03
    153 
    154 typedef struct _CDROM_SUB_Q_DATA_FORMAT {
    155   UCHAR Format;
    156   UCHAR Track;
    157 } CDROM_SUB_Q_DATA_FORMAT, *PCDROM_SUB_Q_DATA_FORMAT;
    158 
    159 typedef struct _CDROM_TOC {
    160   UCHAR  Length[2];
    161   UCHAR  FirstTrack;
    162   UCHAR  LastTrack;
    163   TRACK_DATA  TrackData[MAXIMUM_NUMBER_TRACKS];
    164 } CDROM_TOC, *PCDROM_TOC;
    165 
    166 #define CDROM_TOC_SIZE sizeof(CDROM_TOC)
    167 
    168 typedef struct _CDROM_TOC_SESSION_DATA {
    169   UCHAR Length[2];
    170   UCHAR FirstCompleteSession;
    171   UCHAR LastCompleteSession;
    172   TRACK_DATA TrackData[1];
    173 } CDROM_TOC_SESSION_DATA, *PCDROM_TOC_SESSION_DATA;
    174 
    175 typedef struct _CDROM_TOC_ATIP_DATA_BLOCK {
    176   UCHAR  CdrwReferenceSpeed : 3;
    177   UCHAR  Reserved3 : 1;
    178   UCHAR  WritePower : 3;
    179   UCHAR  True1 : 1;
    180   UCHAR  Reserved4 : 6;
    181   UCHAR  UnrestrictedUse : 1;
    182   UCHAR  Reserved5 : 1;
    183   UCHAR  A3Valid : 1;
    184   UCHAR  A2Valid : 1;
    185   UCHAR  A1Valid : 1;
    186   UCHAR  Reserved6 : 3;
    187   UCHAR  IsCdrw : 1;
    188   UCHAR  True2 : 1;
    189   UCHAR  Reserved7;
    190   UCHAR  LeadInMsf[3];
    191   UCHAR  Reserved8;
    192   UCHAR  LeadOutMsf[3];
    193   UCHAR  Reserved9;
    194   UCHAR  A1Values[3];
    195   UCHAR  Reserved10;
    196   UCHAR  A2Values[3];
    197   UCHAR  Reserved11;
    198   UCHAR  A3Values[3];
    199   UCHAR  Reserved12;
    200 } CDROM_TOC_ATIP_DATA_BLOCK, *PCDROM_TOC_ATIP_DATA_BLOCK;
    201 
    202 typedef struct _CDROM_TOC_ATIP_DATA {
    203   UCHAR  Length[2];
    204   UCHAR  Reserved1;
    205   UCHAR  Reserved2;
    206   CDROM_TOC_ATIP_DATA_BLOCK  Descriptors[0];
    207 } CDROM_TOC_ATIP_DATA, *PCDROM_TOC_ATIP_DATA;
    208 
    209 /* CDROM_TOC_CD_TEXT_DATA_BLOCK.PackType constants */
    210 #define CDROM_CD_TEXT_PACK_ALBUM_NAME 0x80
    211 #define CDROM_CD_TEXT_PACK_PERFORMER  0x81
    212 #define CDROM_CD_TEXT_PACK_SONGWRITER 0x82
    213 #define CDROM_CD_TEXT_PACK_COMPOSER   0x83
    214 #define CDROM_CD_TEXT_PACK_ARRANGER   0x84
    215 #define CDROM_CD_TEXT_PACK_MESSAGES   0x85
    216 #define CDROM_CD_TEXT_PACK_DISC_ID    0x86
    217 #define CDROM_CD_TEXT_PACK_GENRE      0x87
    218 #define CDROM_CD_TEXT_PACK_TOC_INFO   0x88
    219 #define CDROM_CD_TEXT_PACK_TOC_INFO2  0x89
    220 #define CDROM_CD_TEXT_PACK_UPC_EAN    0x8e
    221 #define CDROM_CD_TEXT_PACK_SIZE_INFO  0x8f
    222 
    223 typedef struct _CDROM_TOC_CD_TEXT_DATA_BLOCK {
    224   UCHAR  PackType;
    225   UCHAR  TrackNumber : 7;
    226   UCHAR  ExtensionFlag : 1;
    227   UCHAR  SequenceNumber;
    228   UCHAR  CharacterPosition : 4;
    229   UCHAR  BlockNumber : 3;
    230   UCHAR  Unicode : 1;
    231   _ANONYMOUS_UNION union {
    232     UCHAR  Text[12];
    233     WCHAR  WText[6];
    234   } DUMMYUNIONNAME;
    235   UCHAR  CRC[2];
    236 } CDROM_TOC_CD_TEXT_DATA_BLOCK, *PCDROM_TOC_CD_TEXT_DATA_BLOCK;
    237 
    238 typedef struct _CDROM_TOC_CD_TEXT_DATA {
    239   UCHAR  Length[2];
    240   UCHAR  Reserved1;
    241   UCHAR  Reserved2;
    242   CDROM_TOC_CD_TEXT_DATA_BLOCK  Descriptors[0];
    243 } CDROM_TOC_CD_TEXT_DATA, *PCDROM_TOC_CD_TEXT_DATA;
    244 
    245 /* CDROM_TOC_FULL_TOC_DATA_BLOCK.Adr constants */
    246 #define ADR_NO_MODE_INFORMATION           0x0
    247 #define ADR_ENCODES_CURRENT_POSITION      0x1
    248 #define ADR_ENCODES_MEDIA_CATALOG         0x2
    249 #define ADR_ENCODES_ISRC                  0x3
    250 
    251 typedef struct _CDROM_TOC_FULL_TOC_DATA_BLOCK {
    252   UCHAR  SessionNumber;
    253   UCHAR  Control : 4;
    254   UCHAR  Adr : 4;
    255   UCHAR  Reserved1;
    256   UCHAR  Point;
    257   UCHAR  MsfExtra[3];
    258   UCHAR  Zero;
    259   UCHAR  Msf[3];
    260 } CDROM_TOC_FULL_TOC_DATA_BLOCK, *PCDROM_TOC_FULL_TOC_DATA_BLOCK;
    261 
    262 typedef struct _CDROM_TOC_FULL_TOC_DATA {
    263   UCHAR  Length[2];
    264   UCHAR  FirstCompleteSession;
    265   UCHAR  LastCompleteSession;
    266   CDROM_TOC_FULL_TOC_DATA_BLOCK  Descriptors[0];
    267 } CDROM_TOC_FULL_TOC_DATA, *PCDROM_TOC_FULL_TOC_DATA;
    268 
    269 typedef struct _CDROM_TOC_PMA_DATA {
    270   UCHAR  Length[2];
    271   UCHAR  Reserved1;
    272   UCHAR  Reserved2;
    273   CDROM_TOC_FULL_TOC_DATA_BLOCK  Descriptors[0];
    274 } CDROM_TOC_PMA_DATA, *PCDROM_TOC_PMA_DATA;
    275 
    276 /* SUB_Q_HEADER.AudioStatus constants */
    277 #define AUDIO_STATUS_NOT_SUPPORTED  0x00
    278 #define AUDIO_STATUS_IN_PROGRESS    0x11
    279 #define AUDIO_STATUS_PAUSED         0x12
    280 #define AUDIO_STATUS_PLAY_COMPLETE  0x13
    281 #define AUDIO_STATUS_PLAY_ERROR     0x14
    282 #define AUDIO_STATUS_NO_STATUS      0x15
    283 
    284 typedef struct _SUB_Q_HEADER {
    285   UCHAR  Reserved;
    286   UCHAR  AudioStatus;
    287   UCHAR  DataLength[2];
    288 } SUB_Q_HEADER, *PSUB_Q_HEADER;
    289 
    290 typedef struct _SUB_Q_MEDIA_CATALOG_NUMBER {
    291   SUB_Q_HEADER  Header;
    292   UCHAR  FormatCode;
    293   UCHAR  Reserved[3];
    294   UCHAR  Reserved1 : 7;
    295   UCHAR  Mcval :1;
    296   UCHAR  MediaCatalog[15];
    297 } SUB_Q_MEDIA_CATALOG_NUMBER, *PSUB_Q_MEDIA_CATALOG_NUMBER;
    298 
    299 typedef struct _SUB_Q_TRACK_ISRC {
    300   SUB_Q_HEADER  Header;
    301   UCHAR  FormatCode;
    302   UCHAR  Reserved0;
    303   UCHAR  Track;
    304   UCHAR  Reserved1;
    305   UCHAR  Reserved2 : 7;
    306   UCHAR  Tcval : 1;
    307   UCHAR  TrackIsrc[15];
    308 } SUB_Q_TRACK_ISRC, *PSUB_Q_TRACK_ISRC;
    309 
    310 typedef struct _SUB_Q_CURRENT_POSITION {
    311   SUB_Q_HEADER  Header;
    312   UCHAR  FormatCode;
    313   UCHAR  Control : 4;
    314   UCHAR  ADR : 4;
    315   UCHAR  TrackNumber;
    316   UCHAR  IndexNumber;
    317   UCHAR  AbsoluteAddress[4];
    318   UCHAR  TrackRelativeAddress[4];
    319 } SUB_Q_CURRENT_POSITION, *PSUB_Q_CURRENT_POSITION;
    320 
    321 typedef union _SUB_Q_CHANNEL_DATA {
    322   SUB_Q_CURRENT_POSITION  CurrentPosition;
    323   SUB_Q_MEDIA_CATALOG_NUMBER  MediaCatalog;
    324   SUB_Q_TRACK_ISRC  TrackIsrc;
    325 } SUB_Q_CHANNEL_DATA, *PSUB_Q_CHANNEL_DATA;
    326 
    327 /* CDROM_AUDIO_CONTROL.LbaFormat constants */
    328 #define AUDIO_WITH_PREEMPHASIS            0x1
    329 #define DIGITAL_COPY_PERMITTED            0x2
    330 #define AUDIO_DATA_TRACK                  0x4
    331 #define TWO_FOUR_CHANNEL_AUDIO            0x8
    332 
    333 typedef struct _CDROM_AUDIO_CONTROL {
    334 	UCHAR  LbaFormat;
    335 	USHORT  LogicalBlocksPerSecond;
    336 } CDROM_AUDIO_CONTROL, *PCDROM_AUDIO_CONTROL;
    337 
    338 typedef struct _VOLUME_CONTROL {
    339   UCHAR  PortVolume[4];
    340 } VOLUME_CONTROL, *PVOLUME_CONTROL;
    341 
    342 typedef enum _TRACK_MODE_TYPE {
    343 	YellowMode2,
    344 	XAForm2,
    345 	CDDA
    346 } TRACK_MODE_TYPE, *PTRACK_MODE_TYPE;
    347 
    348 typedef struct __RAW_READ_INFO {
    349 	LARGE_INTEGER  DiskOffset;
    350 	ULONG  SectorCount;
    351 	TRACK_MODE_TYPE  TrackMode;
    352 } RAW_READ_INFO, *PRAW_READ_INFO;
    353 
    354 #ifdef __cplusplus
    355 }
    356 #endif
    357 
    358 #endif /* _NTDDCDRM_ */
    359