xref: /reactos/sdk/include/psdk/ntddcdvd.h (revision 99489553)
1 /*
2  * ntddcdvd.h
3  *
4  * DVD 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 _NTDDCDVD_
24 #define _NTDDCDVD_
25 
26 #include "ntddstor.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #define IOCTL_DVD_BASE                    FILE_DEVICE_DVD
33 
34 #define IOCTL_STORAGE_SET_READ_AHEAD \
35   CTL_CODE(IOCTL_STORAGE_BASE, 0x0100, METHOD_BUFFERED, FILE_READ_ACCESS)
36 
37 #define IOCTL_DVD_START_SESSION \
38   CTL_CODE(IOCTL_DVD_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS)
39 
40 #define IOCTL_DVD_READ_KEY \
41   CTL_CODE(IOCTL_DVD_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS)
42 
43 #define IOCTL_DVD_SEND_KEY \
44   CTL_CODE(IOCTL_DVD_BASE, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS)
45 
46 #define IOCTL_DVD_END_SESSION \
47   CTL_CODE(IOCTL_DVD_BASE, 0x0403, METHOD_BUFFERED, FILE_READ_ACCESS)
48 
49 #define IOCTL_DVD_SET_READ_AHEAD \
50   CTL_CODE(IOCTL_DVD_BASE, 0x0404, METHOD_BUFFERED, FILE_READ_ACCESS)
51 
52 #define IOCTL_DVD_GET_REGION \
53   CTL_CODE(IOCTL_DVD_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS)
54 
55 #define IOCTL_DVD_SEND_KEY2 \
56   CTL_CODE(IOCTL_DVD_BASE, 0x0406, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
57 
58 #define IOCTL_AACS_READ_MEDIA_KEY_BLOCK_SIZE \
59   CTL_CODE(IOCTL_DVD_BASE, 0x430, METHOD_BUFFERED, FILE_READ_ACCESS)
60 
61 #define IOCTL_AACS_READ_MEDIA_KEY_BLOCK \
62   CTL_CODE(IOCTL_DVD_BASE, 0x431, METHOD_BUFFERED, FILE_READ_ACCESS)
63 
64 #define IOCTL_AACS_START_SESSION \
65   CTL_CODE(IOCTL_DVD_BASE, 0x432, METHOD_BUFFERED, FILE_READ_ACCESS)
66 
67 #define IOCTL_AACS_END_SESSION \
68   CTL_CODE(IOCTL_DVD_BASE, 0x433, METHOD_BUFFERED, FILE_READ_ACCESS)
69 
70 #define IOCTL_AACS_SEND_CERTIFICATE \
71   CTL_CODE(IOCTL_DVD_BASE, 0x434, METHOD_BUFFERED, FILE_READ_ACCESS)
72 
73 #define IOCTL_AACS_GET_CERTIFICATE \
74   CTL_CODE(IOCTL_DVD_BASE, 0x435, METHOD_BUFFERED, FILE_READ_ACCESS)
75 
76 #define IOCTL_AACS_GET_CHALLENGE_KEY \
77   CTL_CODE(IOCTL_DVD_BASE, 0x436, METHOD_BUFFERED, FILE_READ_ACCESS)
78 
79 #define IOCTL_AACS_SEND_CHALLENGE_KEY \
80   CTL_CODE(IOCTL_DVD_BASE, 0x437, METHOD_BUFFERED, FILE_READ_ACCESS)
81 
82 #define IOCTL_AACS_READ_VOLUME_ID \
83   CTL_CODE(IOCTL_DVD_BASE, 0x438, METHOD_BUFFERED, FILE_READ_ACCESS)
84 
85 #define IOCTL_AACS_READ_SERIAL_NUMBER \
86   CTL_CODE(IOCTL_DVD_BASE, 0x439, METHOD_BUFFERED, FILE_READ_ACCESS)
87 
88 #define IOCTL_AACS_READ_MEDIA_ID \
89   CTL_CODE(IOCTL_DVD_BASE, 0x43A, METHOD_BUFFERED, FILE_READ_ACCESS)
90 
91 #define IOCTL_AACS_READ_BINDING_NONCE \
92   CTL_CODE(IOCTL_DVD_BASE, 0x43B, METHOD_BUFFERED, FILE_READ_ACCESS)
93 
94 #define IOCTL_AACS_GENERATE_BINDING_NONCE \
95   CTL_CODE(IOCTL_DVD_BASE, 0x43C, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
96 
97 #define IOCTL_DVD_READ_STRUCTURE \
98   CTL_CODE(IOCTL_DVD_BASE, 0x0450, METHOD_BUFFERED, FILE_READ_ACCESS)
99 
100 
101 typedef ULONG DVD_SESSION_ID, *PDVD_SESSION_ID;
102 
103 typedef struct _STORAGE_SET_READ_AHEAD {
104   LARGE_INTEGER  TriggerAddress;
105   LARGE_INTEGER  TargetAddress;
106 } STORAGE_SET_READ_AHEAD, *PSTORAGE_SET_READ_AHEAD;
107 
108 typedef enum DVD_STRUCTURE_FORMAT {
109   DvdPhysicalDescriptor,
110   DvdCopyrightDescriptor,
111   DvdDiskKeyDescriptor,
112   DvdBCADescriptor,
113   DvdManufacturerDescriptor,
114   DvdMaxDescriptor
115 } DVD_STRUCTURE_FORMAT, *PDVD_STRUCTURE_FORMAT;
116 
117 #include <pshpack1.h>
118 typedef struct DVD_READ_STRUCTURE {
119   LARGE_INTEGER  BlockByteOffset;
120   DVD_STRUCTURE_FORMAT  Format;
121   DVD_SESSION_ID  SessionId;
122   UCHAR  LayerNumber;
123 } DVD_READ_STRUCTURE, *PDVD_READ_STRUCTURE;
124 #include <poppack.h>
125 
126 typedef struct _DVD_DESCRIPTOR_HEADER {
127     USHORT Length;
128     UCHAR Reserved[2];
129     UCHAR Data[0];
130 } DVD_DESCRIPTOR_HEADER, *PDVD_DESCRIPTOR_HEADER;
131 
132 #include <pshpack1.h>
133 typedef struct _DVD_LAYER_DESCRIPTOR {
134   UCHAR  BookVersion : 4;
135   UCHAR  BookType : 4;
136   UCHAR  MinimumRate : 4;
137   UCHAR  DiskSize : 4;
138   UCHAR  LayerType : 4;
139   UCHAR  TrackPath : 1;
140   UCHAR  NumberOfLayers : 2;
141   UCHAR  Reserved1 : 1;
142   UCHAR  TrackDensity : 4;
143   UCHAR  LinearDensity : 4;
144   ULONG  StartingDataSector;
145   ULONG  EndDataSector;
146   ULONG  EndLayerZeroSector;
147   UCHAR  Reserved5 : 7;
148   UCHAR  BCAFlag : 1;
149   UCHAR  Reserved6;
150 } DVD_LAYER_DESCRIPTOR, *PDVD_LAYER_DESCRIPTOR;
151 #include <poppack.h>
152 
153 typedef struct _DVD_COPYRIGHT_DESCRIPTOR {
154   UCHAR  CopyrightProtectionType;
155   UCHAR  RegionManagementInformation;
156   USHORT  Reserved;
157 } DVD_COPYRIGHT_DESCRIPTOR, *PDVD_COPYRIGHT_DESCRIPTOR;
158 
159 typedef struct _DVD_DISK_KEY_DESCRIPTOR {
160   UCHAR  DiskKeyData[2048];
161 } DVD_DISK_KEY_DESCRIPTOR, *PDVD_DISK_KEY_DESCRIPTOR;
162 
163 typedef enum _DVD_KEY_TYPE {
164   DvdChallengeKey = 0x01,
165   DvdBusKey1,
166   DvdBusKey2,
167   DvdTitleKey,
168   DvdAsf,
169   DvdSetRpcKey = 0x6,
170   DvdGetRpcKey = 0x8,
171   DvdDiskKey = 0x80,
172   DvdInvalidateAGID = 0x3f
173 } DVD_KEY_TYPE;
174 
175 typedef struct _DVD_COPY_PROTECT_KEY {
176   ULONG  KeyLength;
177   DVD_SESSION_ID  SessionId;
178   DVD_KEY_TYPE  KeyType;
179   ULONG  KeyFlags;
180   union {
181     HANDLE  FileHandle;
182     LARGE_INTEGER  TitleOffset;
183   } Parameters;
184   UCHAR  KeyData[0];
185 } DVD_COPY_PROTECT_KEY, *PDVD_COPY_PROTECT_KEY;
186 
187 #define DVD_CHALLENGE_KEY_LENGTH          (12 + sizeof(DVD_COPY_PROTECT_KEY))
188 #define DVD_BUS_KEY_LENGTH                (8 + sizeof(DVD_COPY_PROTECT_KEY))
189 #define DVD_TITLE_KEY_LENGTH              (8 + sizeof(DVD_COPY_PROTECT_KEY))
190 #define DVD_DISK_KEY_LENGTH               (2048 + sizeof(DVD_COPY_PROTECT_KEY))
191 #define DVD_RPC_KEY_LENGTH                (sizeof(DVD_RPC_KEY) + sizeof(DVD_COPY_PROTECT_KEY))
192 #define DVD_SET_RPC_KEY_LENGTH            (sizeof(DVD_SET_RPC_KEY) + sizeof(DVD_COPY_PROTECT_KEY))
193 #define DVD_ASF_LENGTH                    (sizeof(DVD_ASF) + sizeof(DVD_COPY_PROTECT_KEY))
194 
195 #define DVD_END_ALL_SESSIONS              ((DVD_SESSION_ID) 0xffffffff)
196 
197 
198 #define DVD_CGMS_RESERVED_MASK            0x00000078
199 
200 #define DVD_CGMS_COPY_PROTECT_MASK        0x00000018
201 #define DVD_CGMS_COPY_PERMITTED           0x00000000
202 #define DVD_CGMS_COPY_ONCE                0x00000010
203 #define DVD_CGMS_NO_COPY                  0x00000018
204 
205 #define DVD_COPYRIGHT_MASK                0x00000040
206 #define DVD_NOT_COPYRIGHTED               0x00000000
207 #define DVD_COPYRIGHTED                   0x00000040
208 
209 #define DVD_SECTOR_PROTECT_MASK           0x00000020
210 #define DVD_SECTOR_NOT_PROTECTED          0x00000000
211 #define DVD_SECTOR_PROTECTED              0x00000020
212 
213 
214 typedef struct _DVD_BCA_DESCRIPTOR {
215   UCHAR  BCAInformation[0];
216 } DVD_BCA_DESCRIPTOR, *PDVD_BCA_DESCRIPTOR;
217 
218 typedef struct _DVD_MANUFACTURER_DESCRIPTOR {
219   UCHAR  ManufacturingInformation[2048];
220 } DVD_MANUFACTURER_DESCRIPTOR, *PDVD_MANUFACTURER_DESCRIPTOR;
221 
222 typedef struct _DVD_RPC_KEY {
223   UCHAR  UserResetsAvailable : 3;
224   UCHAR  ManufacturerResetsAvailable : 3;
225   UCHAR  TypeCode : 2;
226   UCHAR  RegionMask;
227   UCHAR  RpcScheme;
228   UCHAR  Reserved2[1];
229 } DVD_RPC_KEY, *PDVD_RPC_KEY;
230 
231 typedef struct _DVD_SET_RPC_KEY {
232   UCHAR  PreferredDriveRegionCode;
233   UCHAR  Reserved[3];
234 } DVD_SET_RPC_KEY, *PDVD_SET_RPC_KEY;
235 
236 typedef struct _DVD_ASF {
237   UCHAR  Reserved0[3];
238   UCHAR  SuccessFlag : 1;
239   UCHAR  Reserved1 : 7;
240 } DVD_ASF, *PDVD_ASF;
241 
242 typedef struct _DVD_REGION {
243   UCHAR  CopySystem;
244   UCHAR  RegionData;
245   UCHAR  SystemRegion;
246   UCHAR  ResetCount;
247 } DVD_REGION, *PDVD_REGION;
248 
249 #ifdef __cplusplus
250 }
251 #endif
252 
253 // for IOCTLS_AACS_*
254 
255 typedef _Field_range_(0,255) ULONG AACS_LAYER_NUMBER, *PAACS_LAYER_NUMBER;
256 typedef _Field_range_(0,255) const ULONG CAACS_LAYER_NUMBER, *PCAACS_LAYER_NUMBER;
257 
258 typedef struct _AACS_CERTIFICATE
259 {
260   UCHAR Nonce[20];
261   UCHAR Certificate[92];
262 } AACS_CERTIFICATE, *PAACS_CERTIFICATE;
263 typedef const AACS_CERTIFICATE CAACS_CERTIFICATE, *PCAACS_CERTIFICATE;
264 C_ASSERT(sizeof(AACS_CERTIFICATE) == 112);
265 
266 typedef struct _AACS_CHALLENGE_KEY
267 {
268   UCHAR EllipticCurvePoint[40];
269   UCHAR Signature[40];
270 } AACS_CHALLENGE_KEY, *PAACS_CHALLENGE_KEY;
271 typedef const AACS_CHALLENGE_KEY CAACS_CHALLENGE_KEY, *PCAACS_CHALLENGE_KEY;
272 C_ASSERT(sizeof(AACS_CHALLENGE_KEY) == 80);
273 
274 typedef struct _AACS_VOLUME_ID
275 {
276   UCHAR VolumeID[16];
277   UCHAR MAC[16];
278 } AACS_VOLUME_ID, *PAACS_VOLUME_ID;
279 typedef const AACS_VOLUME_ID CAACS_VOLUME_ID, *PCAACS_VOLUME_ID;
280 C_ASSERT(sizeof(AACS_VOLUME_ID) == 32);
281 
282 typedef struct _AACS_SERIAL_NUMBER
283 {
284   UCHAR PrerecordedSerialNumber[16];
285   UCHAR MAC[16];
286 } AACS_SERIAL_NUMBER, *PAACS_SERIAL_NUMBER;
287 typedef const AACS_SERIAL_NUMBER CAACS_SERIAL_NUMBER, *PCAACS_SERIAL_NUMBER;
288 C_ASSERT(sizeof(AACS_SERIAL_NUMBER) == 32);
289 
290 typedef struct _AACS_MEDIA_ID
291 {
292   UCHAR MediaID[16];
293   UCHAR MAC[16];
294 } AACS_MEDIA_ID, *PAACS_MEDIA_ID;
295 typedef const AACS_MEDIA_ID CAACS_MEDIA_ID, *PCAACS_MEDIA_ID;
296 C_ASSERT(sizeof(AACS_MEDIA_ID) == 32);
297 
298 typedef struct _AACS_SEND_CERTIFICATE
299 {
300   DVD_SESSION_ID SessionId;
301   AACS_CERTIFICATE Certificate;
302 } AACS_SEND_CERTIFICATE, *PAACS_SEND_CERTIFICATE;
303 typedef const AACS_SEND_CERTIFICATE CAACS_SEND_CERTIFICATE, *PCAACS_SEND_CERTIFICATE;
304 
305 typedef struct _AACS_SEND_CHALLENGE_KEY
306 {
307   DVD_SESSION_ID SessionId;
308   AACS_CHALLENGE_KEY ChallengeKey;
309 } AACS_SEND_CHALLENGE_KEY, *PAACS_SEND_CHALLENGE_KEY;
310 typedef const AACS_SEND_CHALLENGE_KEY CAACS_SEND_CHALLENGE_KEY, *PCAACS_SEND_CHALLENGE_KEY;
311 
312 typedef struct _AACS_BINDING_NONCE
313 {
314   UCHAR BindingNonce[16];
315   UCHAR MAC[16];
316 } AACS_BINDING_NONCE, *PAACS_BINDING_NONCE;
317 typedef const AACS_BINDING_NONCE CAACS_BINDING_NONCE, *PCAACS_BINDING_NONCE;
318 C_ASSERT(sizeof(AACS_BINDING_NONCE) == 32);
319 
320 typedef struct _AACS_READ_BINDING_NONCE
321 {
322   DVD_SESSION_ID SessionId;
323   _Field_range_(0,255) ULONG NumberOfSectors;
324   ULONGLONG StartLba;
325   union
326   {
327     HANDLE Handle;
328     ULONGLONG ForceStructureLengthToMatch64bit;
329   };
330 } AACS_READ_BINDING_NONCE, *PAACS_READ_BINDING_NONCE;
331 
332 #endif /* _NTDDCDVD_ */
333