server: Make the fd passing code slightly more portable.
[wine] / include / ddk / ntddcdvd.h
1 /*
2  * DDK information for DVD
3  *
4  * Copyright (C) 2004 Uwe Bonnes
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #ifndef __NTDDCDVD_H
22 #define __NTDDCDVD_H
23
24 /* definitions taken from libdvdcss, modified to reflect Windows names and data types in places */
25
26 #define IOCTL_DVD_BASE                 FILE_DEVICE_DVD
27
28 #define IOCTL_DVD_START_SESSION     CTL_CODE(IOCTL_DVD_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS)
29 #define IOCTL_DVD_READ_KEY          CTL_CODE(IOCTL_DVD_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS)
30 #define IOCTL_DVD_SEND_KEY          CTL_CODE(IOCTL_DVD_BASE, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS)
31 #define IOCTL_DVD_END_SESSION       CTL_CODE(IOCTL_DVD_BASE, 0x0403, METHOD_BUFFERED, FILE_READ_ACCESS)
32 #define IOCTL_DVD_SET_READ_AHEAD    CTL_CODE(IOCTL_DVD_BASE, 0x0404, METHOD_BUFFERED, FILE_READ_ACCESS)
33 #define IOCTL_DVD_GET_REGION        CTL_CODE(IOCTL_DVD_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS)
34 #define IOCTL_DVD_SEND_KEY2         CTL_CODE(IOCTL_DVD_BASE, 0x0406, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
35
36 #define IOCTL_DVD_READ_STRUCTURE    CTL_CODE(IOCTL_DVD_BASE, 0x0450, METHOD_BUFFERED, FILE_READ_ACCESS)
37
38 typedef enum {
39     DvdChallengeKey = 0x01,
40     DvdBusKey1,
41     DvdBusKey2,
42     DvdTitleKey,
43     DvdAsf,
44     DvdSetRpcKey = 0x6,
45     DvdGetRpcKey = 0x8,
46     DvdDiskKey = 0x80,
47     DvdInvalidateAGID = 0x3f
48 } DVD_KEY_TYPE;
49
50 typedef ULONG DVD_SESSION_ID, *PDVD_SESSION_ID;
51
52 typedef struct _DVD_COPY_PROTECT_KEY {
53     ULONG KeyLength;
54     DVD_SESSION_ID SessionId;
55     DVD_KEY_TYPE KeyType;
56     ULONG KeyFlags;
57     union {
58         struct {
59             ULONG FileHandle;
60             ULONG Reserved;   /* used for NT alignment */
61         } s;
62         LARGE_INTEGER TitleOffset;
63     } Parameters;
64     UCHAR KeyData[1];
65 } DVD_COPY_PROTECT_KEY, *PDVD_COPY_PROTECT_KEY;
66
67 typedef struct _DVD_RPC_KEY {
68     UCHAR UserResetsAvailable:3;
69     UCHAR ManufacturerResetsAvailable:3;
70     UCHAR TypeCode:2;
71     UCHAR RegionMask;
72     UCHAR RpcScheme;
73     UCHAR Reserved2[1];
74 } DVD_RPC_KEY, * PDVD_RPC_KEY;
75
76 typedef struct _DVD_ASF {
77     UCHAR Reserved0[3];
78     UCHAR SuccessFlag:1;
79     UCHAR Reserved1:7;
80 } DVD_ASF, * PDVD_ASF;
81
82 typedef struct _DVD_REGION
83 {
84         UCHAR CopySystem;
85         UCHAR RegionData;              /* current media region (not playable when set) */
86         UCHAR SystemRegion;            /* current drive region (playable when set) */
87         UCHAR ResetCount;              /* number of resets available */
88 } DVD_REGION, * PDVD_REGION;
89
90 typedef enum _DVD_STRUCTURE_FORMAT
91 {
92         DvdPhysicalDescriptor,
93         DvdCopyrightDescriptor,
94         DvdDiskKeyDescriptor,
95         DvdBCADescriptor,
96         DvdManufacturerDescriptor,
97         DvdMaxDescriptor
98 } DVD_STRUCTURE_FORMAT, *PDVD_STRUCTURE_FORMAT;
99
100 typedef struct _DVD_READ_STRUCTURE {
101         /* Contains an offset to the logical block address of the descriptor to be retrieved. */
102         LARGE_INTEGER BlockByteOffset;
103
104         /* 0:Physical descriptor, 1:Copyright descriptor, 2:Disk key descriptor
105            3:BCA descriptor, 4:Manufacturer descriptor, 5:Max descriptor
106          */
107         DVD_STRUCTURE_FORMAT Format;
108
109         /* Session ID, that is obtained by IOCTL_DVD_START_SESSION */
110         DVD_SESSION_ID SessionId;
111
112         /* From 0 to 4 */
113         UCHAR LayerNumber;
114 }DVD_READ_STRUCTURE, * PDVD_READ_STRUCTURE;
115
116 typedef struct _DVD_LAYER_DESCRIPTOR
117 {
118     UCHAR BookVersion : 4;
119
120     /* 0:DVD-ROM, 1:DVD-RAM, 2:DVD-R, 3:DVD-RW, 9:DVD-RW */
121     UCHAR BookType : 4;
122
123     UCHAR MinimumRate : 4;
124
125     /* The physical size of the media. 0:120 mm, 1:80 mm. */
126     UCHAR DiskSize : 4;
127
128     /* 1:Read-only layer, 2:Recordable layer, 4:Rewritable layer */
129     UCHAR LayerType : 4;
130
131     /* 0:parallel track path, 1:opposite track path */
132     UCHAR TrackPath : 1;
133
134     /* 0:one layers, 1:two layers, and so on */
135     UCHAR NumberOfLayers : 2;
136
137     UCHAR Reserved1 : 1;
138
139     /* 0:0.74 µm/track, 1:0.80 µm/track, 2:0.615 µm/track */
140     UCHAR TrackDensity : 4;
141
142     /* 0:0.267 µm/bit, 1:0.293 µm/bit, 2:0.409 to 0.435 µm/bit, 4:0.280 to 0.291 µm/bit, 8:0.353 µm/bit */
143     UCHAR LinearDensity : 4;
144
145     /* Must be either 0x30000:DVD-ROM or DVD-R/-RW or 0x31000:DVD-RAM or DVD+RW */
146     ULONG StartingDataSector;
147
148     ULONG EndDataSector;
149     ULONG EndLayerZeroSector;
150     UCHAR Reserved5 : 7;
151
152     /* 0 indicates no BCA data */
153     UCHAR BCAFlag : 1;
154
155     UCHAR Reserved6;
156 }DVD_LAYER_DESCRIPTOR, * PDVD_LAYER_DESCRIPTOR;
157
158 typedef struct _DVD_COPYRIGHT_DESCRIPTOR
159 {
160     UCHAR CopyrightProtectionType;
161     UCHAR RegionManagementInformation;
162     USHORT Reserved;
163 }DVD_COPYRIGHT_DESCRIPTOR, * PDVD_COPYRIGHT_DESCRIPTOR;
164
165 typedef struct _DVD_DISK_KEY_DESCRIPTOR
166 {
167     UCHAR DiskKeyData[2048];
168 }DVD_DISK_KEY_DESCRIPTOR, * PDVD_DISK_KEY_DESCRIPTOR;
169
170 typedef struct _DVD_BCA_DESCRIPTOR
171 {
172     UCHAR BCAInformation[1];
173 }DVD_BCA_DESCRIPTOR, * PDVD_BCA_DESCRIPTOR;
174
175 typedef struct _DVD_MANUFACTURER_DESCRIPTOR
176 {
177         UCHAR ManufacturingInformation[2048];
178 }DVD_MANUFACTURER_DESCRIPTOR, * PDVD_MANUFACTURER_DESCRIPTOR;
179
180 #define DVD_CHALLENGE_KEY_LENGTH    (12 + sizeof(DVD_COPY_PROTECT_KEY) - sizeof(UCHAR))
181
182 #define DVD_DISK_KEY_LENGTH         (2048 + sizeof(DVD_COPY_PROTECT_KEY) - sizeof(UCHAR))
183
184 #define DVD_KEY_SIZE 5
185 #define DVD_CHALLENGE_SIZE 10
186 #define DVD_DISCKEY_SIZE 2048
187 #define DVD_SECTOR_PROTECTED            0x00000020
188
189 #endif /* __NTDDCDVD_H */