Mercurial > mplayer.hg
annotate libmpdvdkit2/ioctl.c @ 8994:06d7ef3c7b01
export fmt2str()
author | arpi |
---|---|
date | Sat, 18 Jan 2003 17:31:58 +0000 |
parents | c932c17042bf |
children | f0f0f176d298 |
rev | line source |
---|---|
7027 | 1 /***************************************************************************** |
2 * ioctl.c: DVD ioctl replacement function | |
3 ***************************************************************************** | |
4 * Copyright (C) 1999-2001 VideoLAN | |
5 * $Id$ | |
6 * | |
7 * Authors: Markus Kuespert <ltlBeBoy@beosmail.com> | |
8 * Samuel Hocevar <sam@zoy.org> | |
9 * Jon Lech Johansen <jon-vl@nanocrew.net> | |
10 * Håkan Hjort <d95hjort@dtek.chalmers.se> | |
11 * Eugenio Jarosiewicz <ej0@cise.ufl.edu> | |
12 * David Siebörger <drs-videolan@rucus.ru.ac.za> | |
13 * Alex Strelnikov <lelik@os2.ru> | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
14 * Gildas Bazin <gbazin@netcourrier.com> |
7027 | 15 * |
16 * This program is free software; you can redistribute it and/or modify | |
17 * it under the terms of the GNU General Public License as published by | |
18 * the Free Software Foundation; either version 2 of the License, or | |
19 * (at your option) any later version. | |
20 * | |
21 * This program is distributed in the hope that it will be useful, | |
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
24 * GNU General Public License for more details. | |
25 * | |
26 * You should have received a copy of the GNU General Public License | |
27 * along with this program; if not, write to the Free Software | |
28 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. | |
29 *****************************************************************************/ | |
30 | |
31 /***************************************************************************** | |
32 * Preamble | |
33 *****************************************************************************/ | |
34 #include "config.h" | |
35 | |
36 #include <stdio.h> | |
37 | |
38 #include <string.h> /* memcpy(), memset() */ | |
39 #include <sys/types.h> | |
40 | |
41 #if defined( WIN32 ) | |
8142 | 42 # undef DATADIR /* clashes with /usr/include/w32api/objidl.h */ |
7027 | 43 # include <windows.h> |
44 # include <winioctl.h> | |
45 #elif defined ( SYS_OS2 ) | |
46 # define INCL_DOSFILEMGR | |
47 # define INCL_DOSDEVICES | |
48 # define INCL_DOSDEVIOCTL | |
49 # define INCL_DOSERRORS | |
50 # include <os2.h> | |
51 # include <sys/ioctl.h> | |
52 #else | |
53 # include <netinet/in.h> | |
54 # include <sys/ioctl.h> | |
55 #endif | |
56 | |
57 #ifdef DVD_STRUCT_IN_SYS_CDIO_H | |
58 # include <sys/cdio.h> | |
59 #endif | |
60 #ifdef DVD_STRUCT_IN_SYS_DVDIO_H | |
61 # include <sys/dvdio.h> | |
62 #endif | |
63 #ifdef DVD_STRUCT_IN_LINUX_CDROM_H | |
64 # include <linux/cdrom.h> | |
65 #endif | |
66 #ifdef DVD_STRUCT_IN_DVD_H | |
67 # include <dvd.h> | |
68 #endif | |
69 #ifdef DVD_STRUCT_IN_BSDI_DVDIOCTL_DVD_H | |
70 # include "bsdi_dvd.h" | |
71 #endif | |
72 #ifdef SYS_BEOS | |
73 # include <malloc.h> | |
74 # include <scsi.h> | |
75 #endif | |
76 #ifdef HPUX_SCTL_IO | |
77 # include <sys/scsi.h> | |
78 #endif | |
79 #ifdef SOLARIS_USCSI | |
8575 | 80 # include <dlfcn.h> |
7027 | 81 # include <unistd.h> |
82 # include <stropts.h> | |
83 # include <sys/scsi/scsi_types.h> | |
84 # include <sys/scsi/impl/uscsi.h> | |
85 #endif | |
86 #ifdef DARWIN_DVD_IOCTL | |
87 # include <IOKit/storage/IODVDMediaBSDClient.h> | |
88 #endif | |
89 #ifdef __QNXNTO__ | |
90 # include <sys/mman.h> | |
91 # include <sys/dcmd_cam.h> | |
92 #endif | |
93 | |
94 #include "common.h" | |
95 | |
96 #include "ioctl.h" | |
97 | |
98 /***************************************************************************** | |
99 * Local prototypes, BeOS specific | |
100 *****************************************************************************/ | |
101 #if defined( SYS_BEOS ) | |
102 static void BeInitRDC ( raw_device_command *, int ); | |
103 #endif | |
104 | |
105 /***************************************************************************** | |
106 * Local prototypes, HP-UX specific | |
107 *****************************************************************************/ | |
108 #if defined( HPUX_SCTL_IO ) | |
109 static void HPUXInitSCTL ( struct sctl_io *sctl_io, int i_type ); | |
110 #endif | |
111 | |
112 /***************************************************************************** | |
113 * Local prototypes, Solaris specific | |
114 *****************************************************************************/ | |
115 #if defined( SOLARIS_USCSI ) | |
116 static void SolarisInitUSCSI( struct uscsi_cmd *p_sc, int i_type ); | |
8575 | 117 static int SolarisSendUSCSI( int fd, struct uscsi_cmd *p_sc ); |
7027 | 118 #endif |
119 | |
120 /***************************************************************************** | |
121 * Local prototypes, win32 (aspi) specific | |
122 *****************************************************************************/ | |
123 #if defined( WIN32 ) | |
124 static void WinInitSSC ( struct SRB_ExecSCSICmd *, int ); | |
125 static int WinSendSSC ( int, struct SRB_ExecSCSICmd * ); | |
126 #endif | |
127 | |
128 /***************************************************************************** | |
129 * Local prototypes, QNX specific | |
130 *****************************************************************************/ | |
131 #if defined( __QNXNTO__ ) | |
132 static void QNXInitCPT ( CAM_PASS_THRU *, int ); | |
133 #endif | |
134 | |
135 /***************************************************************************** | |
136 * Local prototypes, OS2 specific | |
137 *****************************************************************************/ | |
138 #if defined( SYS_OS2 ) | |
139 static void OS2InitSDC( struct OS2_ExecSCSICmd *, int ); | |
140 #endif | |
141 | |
142 /***************************************************************************** | |
143 * ioctl_ReadCopyright: check whether the disc is encrypted or not | |
144 *****************************************************************************/ | |
145 int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright ) | |
146 { | |
147 int i_ret; | |
148 | |
149 #if defined( HAVE_LINUX_DVD_STRUCT ) | |
150 dvd_struct dvd; | |
151 | |
152 memset( &dvd, 0, sizeof( dvd ) ); | |
153 dvd.type = DVD_STRUCT_COPYRIGHT; | |
154 dvd.copyright.layer_num = i_layer; | |
155 | |
156 i_ret = ioctl( i_fd, DVD_READ_STRUCT, &dvd ); | |
157 | |
158 *pi_copyright = dvd.copyright.cpst; | |
159 | |
160 #elif defined( HAVE_BSD_DVD_STRUCT ) | |
161 struct dvd_struct dvd; | |
162 | |
163 memset( &dvd, 0, sizeof( dvd ) ); | |
164 dvd.format = DVD_STRUCT_COPYRIGHT; | |
165 dvd.layer_num = i_layer; | |
166 | |
167 i_ret = ioctl( i_fd, DVDIOCREADSTRUCTURE, &dvd ); | |
168 | |
169 *pi_copyright = dvd.cpst; | |
170 | |
171 #elif defined( SYS_BEOS ) | |
172 INIT_RDC( GPCMD_READ_DVD_STRUCTURE, 8 ); | |
173 | |
174 rdc.command[ 6 ] = i_layer; | |
175 rdc.command[ 7 ] = DVD_STRUCT_COPYRIGHT; | |
176 | |
177 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); | |
178 | |
179 *pi_copyright = p_buffer[ 4 ]; | |
180 | |
181 #elif defined( HPUX_SCTL_IO ) | |
182 INIT_SCTL_IO( GPCMD_READ_DVD_STRUCTURE, 8 ); | |
183 | |
184 sctl_io.cdb[ 6 ] = i_layer; | |
185 sctl_io.cdb[ 7 ] = DVD_STRUCT_COPYRIGHT; | |
186 | |
187 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); | |
188 | |
189 *pi_copyright = p_buffer[ 4 ]; | |
190 | |
191 #elif defined( SOLARIS_USCSI ) | |
192 INIT_USCSI( GPCMD_READ_DVD_STRUCTURE, 8 ); | |
193 | |
194 rs_cdb.cdb_opaque[ 6 ] = i_layer; | |
195 rs_cdb.cdb_opaque[ 7 ] = DVD_STRUCT_COPYRIGHT; | |
196 | |
8575 | 197 i_ret = SolarisSendUSCSI(i_fd, &sc); |
7027 | 198 |
199 if( i_ret < 0 || sc.uscsi_status ) { | |
200 i_ret = -1; | |
201 } | |
202 | |
203 *pi_copyright = p_buffer[ 4 ]; | |
204 /* s->copyright.rmi = p_buffer[ 5 ]; */ | |
205 | |
206 #elif defined( DARWIN_DVD_IOCTL ) | |
207 INIT_DVDIOCTL( dk_dvd_read_structure_t, DVDCopyrightInfo, | |
208 kDVDStructureFormatCopyrightInfo ); | |
209 | |
210 dvd.layer = i_layer; | |
211 | |
212 i_ret = ioctl( i_fd, DKIOCDVDREADSTRUCTURE, &dvd ); | |
213 | |
214 *pi_copyright = dvdbs.copyrightProtectionSystemType; | |
215 | |
216 #elif defined( WIN32 ) | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
217 if( WIN2K ) /* NT/2k/XP */ |
7027 | 218 { |
219 DWORD tmp; | |
220 u8 p_buffer[ 8 ]; | |
221 SCSI_PASS_THROUGH_DIRECT sptd; | |
222 | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
223 /* When using IOCTL_DVD_READ_STRUCTURE and |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
224 DVD_COPYRIGHT_DESCRIPTOR, CopyrightProtectionType |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
225 seems to be always 6 ??? |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
226 To work around this M$ bug we try to send a raw scsi command |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
227 instead (if we've got enough privileges to do so). */ |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
228 |
7027 | 229 memset( &sptd, 0, sizeof( sptd ) ); |
230 memset( &p_buffer, 0, sizeof( p_buffer ) ); | |
231 | |
232 sptd.Length = sizeof( SCSI_PASS_THROUGH_DIRECT ); | |
233 sptd.CdbLength = 12; | |
234 sptd.DataIn = SCSI_IOCTL_DATA_IN; | |
235 sptd.DataTransferLength = 8; | |
236 sptd.TimeOutValue = 2; | |
237 sptd.DataBuffer = p_buffer; | |
238 sptd.Cdb[ 0 ] = GPCMD_READ_DVD_STRUCTURE; | |
239 sptd.Cdb[ 6 ] = i_layer; | |
240 sptd.Cdb[ 7 ] = DVD_STRUCT_COPYRIGHT; | |
241 sptd.Cdb[ 8 ] = (8 >> 8) & 0xff; | |
242 sptd.Cdb[ 9 ] = 8 & 0xff; | |
243 | |
244 i_ret = DeviceIoControl( (HANDLE) i_fd, | |
245 IOCTL_SCSI_PASS_THROUGH_DIRECT, | |
246 &sptd, sizeof( SCSI_PASS_THROUGH_DIRECT ), | |
247 &sptd, sizeof( SCSI_PASS_THROUGH_DIRECT ), | |
248 &tmp, NULL ) ? 0 : -1; | |
249 | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
250 if( i_ret == 0 ) |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
251 { |
7027 | 252 *pi_copyright = p_buffer[ 4 ]; |
253 } | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
254 } |
7027 | 255 else |
256 { | |
257 INIT_SSC( GPCMD_READ_DVD_STRUCTURE, 8 ); | |
258 | |
259 ssc.CDBByte[ 6 ] = i_layer; | |
260 ssc.CDBByte[ 7 ] = DVD_STRUCT_COPYRIGHT; | |
261 | |
262 i_ret = WinSendSSC( i_fd, &ssc ); | |
263 | |
264 *pi_copyright = p_buffer[ 4 ]; | |
265 } | |
266 | |
267 #elif defined( __QNXNTO__ ) | |
268 | |
269 INIT_CPT( GPCMD_READ_DVD_STRUCTURE, 8 ); | |
270 | |
271 p_cpt->cam_cdb[ 6 ] = i_layer; | |
272 p_cpt->cam_cdb[ 7 ] = DVD_STRUCT_COPYRIGHT; | |
273 | |
274 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); | |
275 | |
276 *pi_copyright = p_buffer[4]; | |
277 | |
278 #elif defined( SYS_OS2 ) | |
279 INIT_SSC( GPCMD_READ_DVD_STRUCTURE, 8 ); | |
280 | |
281 sdc.command[ 6 ] = i_layer; | |
282 sdc.command[ 7 ] = DVD_STRUCT_COPYRIGHT; | |
283 | |
284 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, | |
285 &sdc, sizeof(sdc), &ulParamLen, | |
286 p_buffer, sizeof(p_buffer), &ulDataLen); | |
287 | |
288 *pi_copyright = p_buffer[ 4 ]; | |
289 | |
290 #else | |
291 # error "DVD ioctls are unavailable on this system" | |
292 | |
293 #endif | |
294 return i_ret; | |
295 } | |
296 | |
297 /***************************************************************************** | |
298 * ioctl_ReadDiscKey: get the disc key | |
299 *****************************************************************************/ | |
300 int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key ) | |
301 { | |
302 int i_ret; | |
303 | |
304 #if defined( HAVE_LINUX_DVD_STRUCT ) | |
305 dvd_struct dvd; | |
306 | |
307 memset( &dvd, 0, sizeof( dvd ) ); | |
308 dvd.type = DVD_STRUCT_DISCKEY; | |
309 dvd.disckey.agid = *pi_agid; | |
310 memset( dvd.disckey.value, 0, DVD_DISCKEY_SIZE ); | |
311 | |
312 i_ret = ioctl( i_fd, DVD_READ_STRUCT, &dvd ); | |
313 | |
314 if( i_ret < 0 ) | |
315 { | |
316 return i_ret; | |
317 } | |
318 | |
319 memcpy( p_key, dvd.disckey.value, DVD_DISCKEY_SIZE ); | |
320 | |
321 #elif defined( HAVE_BSD_DVD_STRUCT ) | |
322 struct dvd_struct dvd; | |
323 | |
324 memset( &dvd, 0, sizeof( dvd ) ); | |
325 dvd.format = DVD_STRUCT_DISCKEY; | |
326 dvd.agid = *pi_agid; | |
327 memset( dvd.data, 0, DVD_DISCKEY_SIZE ); | |
328 | |
329 i_ret = ioctl( i_fd, DVDIOCREADSTRUCTURE, &dvd ); | |
330 | |
331 if( i_ret < 0 ) | |
332 { | |
333 return i_ret; | |
334 } | |
335 | |
336 memcpy( p_key, dvd.data, DVD_DISCKEY_SIZE ); | |
337 | |
338 #elif defined( SYS_BEOS ) | |
339 INIT_RDC( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 ); | |
340 | |
341 rdc.command[ 7 ] = DVD_STRUCT_DISCKEY; | |
342 rdc.command[ 10 ] = *pi_agid << 6; | |
343 | |
344 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); | |
345 | |
346 if( i_ret < 0 ) | |
347 { | |
348 return i_ret; | |
349 } | |
350 | |
351 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE ); | |
352 | |
353 #elif defined( HPUX_SCTL_IO ) | |
354 INIT_SCTL_IO( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 ); | |
355 | |
356 sctl_io.cdb[ 7 ] = DVD_STRUCT_DISCKEY; | |
357 sctl_io.cdb[ 10 ] = *pi_agid << 6; | |
358 | |
359 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); | |
360 | |
361 if( i_ret < 0 ) | |
362 { | |
363 return i_ret; | |
364 } | |
365 | |
366 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE ); | |
367 | |
368 #elif defined( SOLARIS_USCSI ) | |
369 INIT_USCSI( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 ); | |
370 | |
371 rs_cdb.cdb_opaque[ 7 ] = DVD_STRUCT_DISCKEY; | |
372 rs_cdb.cdb_opaque[ 10 ] = *pi_agid << 6; | |
373 | |
8575 | 374 i_ret = SolarisSendUSCSI( i_fd, &sc ); |
7027 | 375 |
376 if( i_ret < 0 || sc.uscsi_status ) | |
377 { | |
378 i_ret = -1; | |
379 return i_ret; | |
380 } | |
381 | |
382 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE ); | |
383 | |
384 #elif defined( DARWIN_DVD_IOCTL ) | |
385 INIT_DVDIOCTL( dk_dvd_read_structure_t, DVDDiscKeyInfo, | |
386 kDVDStructureFormatDiscKeyInfo ); | |
387 | |
388 dvd.grantID = *pi_agid; | |
389 | |
390 i_ret = ioctl( i_fd, DKIOCDVDREADSTRUCTURE, &dvd ); | |
391 | |
392 memcpy( p_key, dvdbs.discKeyStructures, DVD_DISCKEY_SIZE ); | |
393 | |
394 #elif defined( WIN32 ) | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
395 if( WIN2K ) /* NT/2k/XP */ |
7027 | 396 { |
397 DWORD tmp; | |
398 u8 buffer[DVD_DISK_KEY_LENGTH]; | |
399 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; | |
400 | |
401 memset( &buffer, 0, sizeof( buffer ) ); | |
402 | |
403 key->KeyLength = DVD_DISK_KEY_LENGTH; | |
404 key->SessionId = *pi_agid; | |
405 key->KeyType = DvdDiskKey; | |
406 key->KeyFlags = 0; | |
407 | |
408 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key, | |
409 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; | |
410 | |
411 if( i_ret < 0 ) | |
412 { | |
413 return i_ret; | |
414 } | |
415 | |
416 memcpy( p_key, key->KeyData, DVD_DISCKEY_SIZE ); | |
417 } | |
418 else | |
419 { | |
420 INIT_SSC( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 ); | |
421 | |
422 ssc.CDBByte[ 7 ] = DVD_STRUCT_DISCKEY; | |
423 ssc.CDBByte[ 10 ] = *pi_agid << 6; | |
424 | |
425 i_ret = WinSendSSC( i_fd, &ssc ); | |
426 | |
427 if( i_ret < 0 ) | |
428 { | |
429 return i_ret; | |
430 } | |
431 | |
432 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE ); | |
433 } | |
434 | |
435 #elif defined( __QNXNTO__ ) | |
436 | |
437 INIT_CPT( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 ); | |
438 | |
439 p_cpt->cam_cdb[ 7 ] = DVD_STRUCT_DISCKEY; | |
440 p_cpt->cam_cdb[ 10 ] = *pi_agid << 6; | |
441 | |
442 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); | |
443 | |
444 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE ); | |
445 | |
446 #elif defined ( SYS_OS2 ) | |
447 INIT_SSC( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 ); | |
448 | |
449 sdc.command[ 7 ] = DVD_STRUCT_DISCKEY; | |
450 sdc.command[ 10 ] = *pi_agid << 6; | |
451 | |
452 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, | |
453 &sdc, sizeof(sdc), &ulParamLen, | |
454 p_buffer, sizeof(p_buffer), &ulDataLen); | |
455 | |
456 if( i_ret < 0 ) | |
457 { | |
458 return i_ret; | |
459 } | |
460 | |
461 memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE ); | |
462 | |
463 #else | |
464 # error "DVD ioctls are unavailable on this system" | |
465 | |
466 #endif | |
467 return i_ret; | |
468 } | |
469 | |
470 /***************************************************************************** | |
471 * ioctl_ReadTitleKey: get the title key | |
472 *****************************************************************************/ | |
473 int ioctl_ReadTitleKey( int i_fd, int *pi_agid, int i_pos, u8 *p_key ) | |
474 { | |
475 int i_ret; | |
476 | |
477 #if defined( HAVE_LINUX_DVD_STRUCT ) | |
478 dvd_authinfo auth_info; | |
479 | |
480 memset( &auth_info, 0, sizeof( auth_info ) ); | |
481 auth_info.type = DVD_LU_SEND_TITLE_KEY; | |
482 auth_info.lstk.agid = *pi_agid; | |
483 auth_info.lstk.lba = i_pos; | |
484 | |
485 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); | |
486 | |
487 memcpy( p_key, auth_info.lstk.title_key, DVD_KEY_SIZE ); | |
488 | |
489 #elif defined( HAVE_BSD_DVD_STRUCT ) | |
490 struct dvd_authinfo auth_info; | |
491 | |
492 memset( &auth_info, 0, sizeof( auth_info ) ); | |
493 auth_info.format = DVD_REPORT_TITLE_KEY; | |
494 auth_info.agid = *pi_agid; | |
495 auth_info.lba = i_pos; | |
496 | |
497 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); | |
498 | |
499 memcpy( p_key, auth_info.keychal, DVD_KEY_SIZE ); | |
500 | |
501 #elif defined( SYS_BEOS ) | |
502 INIT_RDC( GPCMD_REPORT_KEY, 12 ); | |
503 | |
504 rdc.command[ 2 ] = ( i_pos >> 24 ) & 0xff; | |
505 rdc.command[ 3 ] = ( i_pos >> 16 ) & 0xff; | |
506 rdc.command[ 4 ] = ( i_pos >> 8 ) & 0xff; | |
507 rdc.command[ 5 ] = ( i_pos ) & 0xff; | |
508 rdc.command[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6); | |
509 | |
510 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); | |
511 | |
512 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE ); | |
513 | |
514 #elif defined( HPUX_SCTL_IO ) | |
515 INIT_SCTL_IO( GPCMD_REPORT_KEY, 12 ); | |
516 | |
517 sctl_io.cdb[ 2 ] = ( i_pos >> 24 ) & 0xff; | |
518 sctl_io.cdb[ 3 ] = ( i_pos >> 16 ) & 0xff; | |
519 sctl_io.cdb[ 4 ] = ( i_pos >> 8 ) & 0xff; | |
520 sctl_io.cdb[ 5 ] = ( i_pos ) & 0xff; | |
521 sctl_io.cdb[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6); | |
522 | |
523 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); | |
524 | |
525 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE ); | |
526 | |
527 #elif defined( SOLARIS_USCSI ) | |
528 INIT_USCSI( GPCMD_REPORT_KEY, 12 ); | |
529 | |
530 rs_cdb.cdb_opaque[ 2 ] = ( i_pos >> 24 ) & 0xff; | |
531 rs_cdb.cdb_opaque[ 3 ] = ( i_pos >> 16 ) & 0xff; | |
532 rs_cdb.cdb_opaque[ 4 ] = ( i_pos >> 8 ) & 0xff; | |
533 rs_cdb.cdb_opaque[ 5 ] = ( i_pos ) & 0xff; | |
534 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6); | |
535 | |
8575 | 536 i_ret = SolarisSendUSCSI( i_fd, &sc ); |
7027 | 537 |
538 if( i_ret < 0 || sc.uscsi_status ) | |
539 { | |
540 i_ret = -1; | |
541 } | |
542 | |
543 /* Do we want to return the cp_sec flag perhaps? */ | |
544 /* a->lstk.cpm = (buf[ 4 ] >> 7) & 1; */ | |
545 /* a->lstk.cp_sec = (buf[ 4 ] >> 6) & 1; */ | |
546 /* a->lstk.cgms = (buf[ 4 ] >> 4) & 3; */ | |
547 | |
548 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE ); | |
549 | |
550 #elif defined( DARWIN_DVD_IOCTL ) | |
551 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDTitleKeyInfo, | |
552 kDVDKeyFormatTitleKey ); | |
553 | |
554 dvd.address = i_pos; | |
555 dvd.grantID = *pi_agid; | |
556 dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM; | |
557 | |
558 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd ); | |
559 | |
560 memcpy( p_key, dvdbs.titleKeyValue, DVD_KEY_SIZE ); | |
561 | |
562 #elif defined( WIN32 ) | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
563 if( WIN2K ) /* NT/2k/XP */ |
7027 | 564 { |
565 DWORD tmp; | |
566 u8 buffer[DVD_BUS_KEY_LENGTH]; | |
567 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; | |
568 | |
569 memset( &buffer, 0, sizeof( buffer ) ); | |
570 | |
571 key->KeyLength = DVD_TITLE_KEY_LENGTH; | |
572 key->SessionId = *pi_agid; | |
573 key->KeyType = DvdTitleKey; | |
574 key->KeyFlags = 0; | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
575 key->Parameters.TitleOffset.QuadPart = (LONGLONG) i_pos * |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
576 2048 /*DVDCSS_BLOCK_SIZE*/; |
7027 | 577 |
578 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key, | |
579 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; | |
580 | |
581 memcpy( p_key, key->KeyData, DVD_KEY_SIZE ); | |
582 } | |
583 else | |
584 { | |
585 INIT_SSC( GPCMD_REPORT_KEY, 12 ); | |
586 | |
587 ssc.CDBByte[ 2 ] = ( i_pos >> 24 ) & 0xff; | |
588 ssc.CDBByte[ 3 ] = ( i_pos >> 16 ) & 0xff; | |
589 ssc.CDBByte[ 4 ] = ( i_pos >> 8 ) & 0xff; | |
590 ssc.CDBByte[ 5 ] = ( i_pos ) & 0xff; | |
591 ssc.CDBByte[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6); | |
592 | |
593 i_ret = WinSendSSC( i_fd, &ssc ); | |
594 | |
595 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE ); | |
596 } | |
597 | |
598 #elif defined( __QNXNTO__ ) | |
599 | |
600 INIT_CPT( GPCMD_REPORT_KEY, 12 ); | |
601 | |
602 p_cpt->cam_cdb[ 2 ] = ( i_pos >> 24 ) & 0xff; | |
603 p_cpt->cam_cdb[ 3 ] = ( i_pos >> 16 ) & 0xff; | |
604 p_cpt->cam_cdb[ 4 ] = ( i_pos >> 8 ) & 0xff; | |
605 p_cpt->cam_cdb[ 5 ] = ( i_pos ) & 0xff; | |
606 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6); | |
607 | |
608 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); | |
609 | |
610 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE ); | |
611 | |
612 #elif defined( SYS_OS2 ) | |
613 INIT_SSC( GPCMD_REPORT_KEY, 12 ); | |
614 | |
615 sdc.command[ 2 ] = ( i_pos >> 24 ) & 0xff; | |
616 sdc.command[ 3 ] = ( i_pos >> 16 ) & 0xff; | |
617 sdc.command[ 4 ] = ( i_pos >> 8 ) & 0xff; | |
618 sdc.command[ 5 ] = ( i_pos ) & 0xff; | |
619 sdc.command[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6); | |
620 | |
621 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, | |
622 &sdc, sizeof(sdc), &ulParamLen, | |
623 p_buffer, sizeof(p_buffer), &ulDataLen); | |
624 | |
625 memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE ); | |
626 | |
627 #else | |
628 # error "DVD ioctls are unavailable on this system" | |
629 | |
630 #endif | |
631 | |
632 return i_ret; | |
633 } | |
634 | |
635 | |
636 /***************************************************************************** | |
637 * ioctl_ReportAgid: get AGID from the drive | |
638 *****************************************************************************/ | |
639 int ioctl_ReportAgid( int i_fd, int *pi_agid ) | |
640 { | |
641 int i_ret; | |
642 | |
643 #if defined( HAVE_LINUX_DVD_STRUCT ) | |
644 dvd_authinfo auth_info; | |
645 | |
646 memset( &auth_info, 0, sizeof( auth_info ) ); | |
647 auth_info.type = DVD_LU_SEND_AGID; | |
648 auth_info.lsa.agid = *pi_agid; | |
649 | |
650 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); | |
651 | |
652 *pi_agid = auth_info.lsa.agid; | |
653 | |
654 #elif defined( HAVE_BSD_DVD_STRUCT ) | |
655 struct dvd_authinfo auth_info; | |
656 | |
657 memset( &auth_info, 0, sizeof( auth_info ) ); | |
658 auth_info.format = DVD_REPORT_AGID; | |
659 auth_info.agid = *pi_agid; | |
660 | |
661 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); | |
662 | |
663 *pi_agid = auth_info.agid; | |
664 | |
665 #elif defined( SYS_BEOS ) | |
666 INIT_RDC( GPCMD_REPORT_KEY, 8 ); | |
667 | |
668 rdc.command[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6); | |
669 | |
670 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); | |
671 | |
672 *pi_agid = p_buffer[ 7 ] >> 6; | |
673 | |
674 #elif defined( HPUX_SCTL_IO ) | |
675 INIT_SCTL_IO( GPCMD_REPORT_KEY, 8 ); | |
676 | |
677 sctl_io.cdb[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6); | |
678 | |
679 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); | |
680 | |
681 *pi_agid = p_buffer[ 7 ] >> 6; | |
682 | |
683 #elif defined( SOLARIS_USCSI ) | |
684 INIT_USCSI( GPCMD_REPORT_KEY, 8 ); | |
685 | |
686 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6); | |
687 | |
8575 | 688 i_ret = SolarisSendUSCSI( i_fd, &sc ); |
7027 | 689 |
690 if( i_ret < 0 || sc.uscsi_status ) | |
691 { | |
692 i_ret = -1; | |
693 } | |
694 | |
695 *pi_agid = p_buffer[ 7 ] >> 6; | |
696 | |
697 #elif defined( DARWIN_DVD_IOCTL ) | |
698 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDAuthenticationGrantIDInfo, | |
699 kDVDKeyFormatAGID_CSS ); | |
700 | |
701 dvd.grantID = *pi_agid; | |
702 dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM; | |
703 | |
704 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd ); | |
705 | |
706 *pi_agid = dvdbs.grantID; | |
707 | |
708 #elif defined( WIN32 ) | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
709 if( WIN2K ) /* NT/2k/XP */ |
7027 | 710 { |
711 ULONG id; | |
712 DWORD tmp; | |
713 | |
714 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_START_SESSION, | |
715 &tmp, 4, &id, sizeof( id ), &tmp, NULL ) ? 0 : -1; | |
716 | |
717 *pi_agid = id; | |
718 } | |
719 else | |
720 { | |
721 INIT_SSC( GPCMD_REPORT_KEY, 8 ); | |
722 | |
723 ssc.CDBByte[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6); | |
724 | |
725 i_ret = WinSendSSC( i_fd, &ssc ); | |
726 | |
727 *pi_agid = p_buffer[ 7 ] >> 6; | |
728 } | |
729 | |
730 #elif defined( __QNXNTO__ ) | |
731 | |
732 INIT_CPT( GPCMD_REPORT_KEY, 8 ); | |
733 | |
734 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6); | |
735 | |
736 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); | |
737 | |
738 *pi_agid = p_buffer[ 7 ] >> 6; | |
739 | |
740 #elif defined( SYS_OS2 ) | |
741 INIT_SSC( GPCMD_REPORT_KEY, 8 ); | |
742 | |
743 sdc.command[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6); | |
744 | |
745 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, | |
746 &sdc, sizeof(sdc), &ulParamLen, | |
747 p_buffer, sizeof(p_buffer), &ulDataLen); | |
748 | |
749 *pi_agid = p_buffer[ 7 ] >> 6; | |
750 | |
751 #else | |
752 # error "DVD ioctls are unavailable on this system" | |
753 | |
754 #endif | |
755 return i_ret; | |
756 } | |
757 | |
758 /***************************************************************************** | |
759 * ioctl_ReportChallenge: get challenge from the drive | |
760 *****************************************************************************/ | |
761 int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge ) | |
762 { | |
763 int i_ret; | |
764 | |
765 #if defined( HAVE_LINUX_DVD_STRUCT ) | |
766 dvd_authinfo auth_info; | |
767 | |
768 memset( &auth_info, 0, sizeof( auth_info ) ); | |
769 auth_info.type = DVD_LU_SEND_CHALLENGE; | |
770 auth_info.lsc.agid = *pi_agid; | |
771 | |
772 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); | |
773 | |
774 memcpy( p_challenge, auth_info.lsc.chal, DVD_CHALLENGE_SIZE ); | |
775 | |
776 #elif defined( HAVE_BSD_DVD_STRUCT ) | |
777 struct dvd_authinfo auth_info; | |
778 | |
779 memset( &auth_info, 0, sizeof( auth_info ) ); | |
780 auth_info.format = DVD_REPORT_CHALLENGE; | |
781 auth_info.agid = *pi_agid; | |
782 | |
783 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); | |
784 | |
785 memcpy( p_challenge, auth_info.keychal, DVD_CHALLENGE_SIZE ); | |
786 | |
787 #elif defined( SYS_BEOS ) | |
788 INIT_RDC( GPCMD_REPORT_KEY, 16 ); | |
789 | |
790 rdc.command[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6); | |
791 | |
792 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); | |
793 | |
794 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE ); | |
795 | |
796 #elif defined( HPUX_SCTL_IO ) | |
797 INIT_SCTL_IO( GPCMD_REPORT_KEY, 16 ); | |
798 | |
799 sctl_io.cdb[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6); | |
800 | |
801 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); | |
802 | |
803 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE ); | |
804 | |
805 #elif defined( SOLARIS_USCSI ) | |
806 INIT_USCSI( GPCMD_REPORT_KEY, 16 ); | |
807 | |
808 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6); | |
809 | |
8575 | 810 i_ret = SolarisSendUSCSI( i_fd, &sc ); |
7027 | 811 |
812 if( i_ret < 0 || sc.uscsi_status ) | |
813 { | |
814 i_ret = -1; | |
815 } | |
816 | |
817 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE ); | |
818 | |
819 #elif defined( DARWIN_DVD_IOCTL ) | |
820 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDChallengeKeyInfo, | |
821 kDVDKeyFormatChallengeKey ); | |
822 | |
823 dvd.grantID = *pi_agid; | |
824 | |
825 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd ); | |
826 | |
827 memcpy( p_challenge, dvdbs.challengeKeyValue, DVD_CHALLENGE_SIZE ); | |
828 | |
829 #elif defined( WIN32 ) | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
830 if( WIN2K ) /* NT/2k/XP */ |
7027 | 831 { |
832 DWORD tmp; | |
833 u8 buffer[DVD_CHALLENGE_KEY_LENGTH]; | |
834 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; | |
835 | |
836 memset( &buffer, 0, sizeof( buffer ) ); | |
837 | |
838 key->KeyLength = DVD_CHALLENGE_KEY_LENGTH; | |
839 key->SessionId = *pi_agid; | |
840 key->KeyType = DvdChallengeKey; | |
841 key->KeyFlags = 0; | |
842 | |
843 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key, | |
844 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; | |
845 | |
846 if( i_ret < 0 ) | |
847 { | |
848 return i_ret; | |
849 } | |
850 | |
851 memcpy( p_challenge, key->KeyData, DVD_CHALLENGE_SIZE ); | |
852 } | |
853 else | |
854 { | |
855 INIT_SSC( GPCMD_REPORT_KEY, 16 ); | |
856 | |
857 ssc.CDBByte[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6); | |
858 | |
859 i_ret = WinSendSSC( i_fd, &ssc ); | |
860 | |
861 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE ); | |
862 } | |
863 | |
864 #elif defined( __QNXNTO__ ) | |
865 | |
866 INIT_CPT( GPCMD_REPORT_KEY, 16 ); | |
867 | |
868 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6); | |
869 | |
870 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); | |
871 | |
872 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE ); | |
873 | |
874 #elif defined( SYS_OS2 ) | |
875 INIT_SSC( GPCMD_REPORT_KEY, 16 ); | |
876 | |
877 sdc.command[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6); | |
878 | |
879 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, | |
880 &sdc, sizeof(sdc), &ulParamLen, | |
881 p_buffer, sizeof(p_buffer), &ulDataLen); | |
882 | |
883 memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE ); | |
884 | |
885 #else | |
886 # error "DVD ioctls are unavailable on this system" | |
887 | |
888 #endif | |
889 return i_ret; | |
890 } | |
891 | |
892 /***************************************************************************** | |
893 * ioctl_ReportASF: get ASF from the drive | |
894 *****************************************************************************/ | |
895 int ioctl_ReportASF( int i_fd, int *pi_remove_me, int *pi_asf ) | |
896 { | |
897 int i_ret; | |
898 | |
899 #if defined( HAVE_LINUX_DVD_STRUCT ) | |
900 dvd_authinfo auth_info; | |
901 | |
902 memset( &auth_info, 0, sizeof( auth_info ) ); | |
903 auth_info.type = DVD_LU_SEND_ASF; | |
904 auth_info.lsasf.asf = *pi_asf; | |
905 | |
906 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); | |
907 | |
908 *pi_asf = auth_info.lsasf.asf; | |
909 | |
910 #elif defined( HAVE_BSD_DVD_STRUCT ) | |
911 struct dvd_authinfo auth_info; | |
912 | |
913 memset( &auth_info, 0, sizeof( auth_info ) ); | |
914 auth_info.format = DVD_REPORT_ASF; | |
915 auth_info.asf = *pi_asf; | |
916 | |
917 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); | |
918 | |
919 *pi_asf = auth_info.asf; | |
920 | |
921 #elif defined( SYS_BEOS ) | |
922 INIT_RDC( GPCMD_REPORT_KEY, 8 ); | |
923 | |
924 rdc.command[ 10 ] = DVD_REPORT_ASF; | |
925 | |
926 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); | |
927 | |
928 *pi_asf = p_buffer[ 7 ] & 1; | |
929 | |
930 #elif defined( HPUX_SCTL_IO ) | |
931 INIT_SCTL_IO( GPCMD_REPORT_KEY, 8 ); | |
932 | |
933 sctl_io.cdb[ 10 ] = DVD_REPORT_ASF; | |
934 | |
935 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); | |
936 | |
937 *pi_asf = p_buffer[ 7 ] & 1; | |
938 | |
939 #elif defined( SOLARIS_USCSI ) | |
940 INIT_USCSI( GPCMD_REPORT_KEY, 8 ); | |
941 | |
942 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_ASF; | |
943 | |
8575 | 944 i_ret = SolarisSendUSCSI( i_fd, &sc ); |
7027 | 945 |
946 if( i_ret < 0 || sc.uscsi_status ) | |
947 { | |
948 i_ret = -1; | |
949 } | |
950 | |
951 *pi_asf = p_buffer[ 7 ] & 1; | |
952 | |
953 #elif defined( DARWIN_DVD_IOCTL ) | |
954 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDAuthenticationSuccessFlagInfo, | |
955 kDVDKeyFormatASF ); | |
956 | |
957 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd ); | |
958 | |
959 *pi_asf = dvdbs.successFlag; | |
960 | |
961 #elif defined( WIN32 ) | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
962 if( WIN2K ) /* NT/2k/XP */ |
7027 | 963 { |
964 DWORD tmp; | |
965 u8 buffer[DVD_ASF_LENGTH]; | |
966 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; | |
967 | |
968 memset( &buffer, 0, sizeof( buffer ) ); | |
969 | |
970 key->KeyLength = DVD_ASF_LENGTH; | |
971 key->KeyType = DvdAsf; | |
972 key->KeyFlags = 0; | |
973 | |
974 ((PDVD_ASF)key->KeyData)->SuccessFlag = *pi_asf; | |
975 | |
976 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key, | |
977 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; | |
978 | |
979 if( i_ret < 0 ) | |
980 { | |
981 return i_ret; | |
982 } | |
983 | |
984 *pi_asf = ((PDVD_ASF)key->KeyData)->SuccessFlag; | |
985 } | |
986 else | |
987 { | |
988 INIT_SSC( GPCMD_REPORT_KEY, 8 ); | |
989 | |
990 ssc.CDBByte[ 10 ] = DVD_REPORT_ASF; | |
991 | |
992 i_ret = WinSendSSC( i_fd, &ssc ); | |
993 | |
994 *pi_asf = p_buffer[ 7 ] & 1; | |
995 } | |
996 | |
997 #elif defined( __QNXNTO__ ) | |
998 | |
999 INIT_CPT( GPCMD_REPORT_KEY, 8 ); | |
1000 | |
1001 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_ASF; | |
1002 | |
1003 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); | |
1004 | |
1005 *pi_asf = p_buffer[ 7 ] & 1; | |
1006 | |
1007 #elif defined( SYS_OS2 ) | |
1008 INIT_SSC( GPCMD_REPORT_KEY, 8 ); | |
1009 | |
1010 sdc.command[ 10 ] = DVD_REPORT_ASF; | |
1011 | |
1012 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, | |
1013 &sdc, sizeof(sdc), &ulParamLen, | |
1014 p_buffer, sizeof(p_buffer), &ulDataLen); | |
1015 | |
1016 *pi_asf = p_buffer[ 7 ] & 1; | |
1017 | |
1018 #else | |
1019 # error "DVD ioctls are unavailable on this system" | |
1020 | |
1021 #endif | |
1022 return i_ret; | |
1023 } | |
1024 | |
1025 /***************************************************************************** | |
1026 * ioctl_ReportKey1: get the first key from the drive | |
1027 *****************************************************************************/ | |
1028 int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key ) | |
1029 { | |
1030 int i_ret; | |
1031 | |
1032 #if defined( HAVE_LINUX_DVD_STRUCT ) | |
1033 dvd_authinfo auth_info; | |
1034 | |
1035 memset( &auth_info, 0, sizeof( auth_info ) ); | |
1036 auth_info.type = DVD_LU_SEND_KEY1; | |
1037 auth_info.lsk.agid = *pi_agid; | |
1038 | |
1039 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); | |
1040 | |
1041 memcpy( p_key, auth_info.lsk.key, DVD_KEY_SIZE ); | |
1042 | |
1043 #elif defined( HAVE_BSD_DVD_STRUCT ) | |
1044 struct dvd_authinfo auth_info; | |
1045 | |
1046 memset( &auth_info, 0, sizeof( auth_info ) ); | |
1047 auth_info.format = DVD_REPORT_KEY1; | |
1048 auth_info.agid = *pi_agid; | |
1049 | |
1050 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); | |
1051 | |
1052 memcpy( p_key, auth_info.keychal, DVD_KEY_SIZE ); | |
1053 | |
1054 #elif defined( SYS_BEOS ) | |
1055 INIT_RDC( GPCMD_REPORT_KEY, 12 ); | |
1056 | |
1057 rdc.command[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6); | |
1058 | |
1059 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); | |
1060 | |
1061 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE ); | |
1062 | |
1063 #elif defined( HPUX_SCTL_IO ) | |
1064 INIT_SCTL_IO( GPCMD_REPORT_KEY, 12 ); | |
1065 | |
1066 sctl_io.cdb[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6); | |
1067 | |
1068 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); | |
1069 | |
1070 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE ); | |
1071 | |
1072 #elif defined( SOLARIS_USCSI ) | |
1073 INIT_USCSI( GPCMD_REPORT_KEY, 12 ); | |
1074 | |
1075 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6); | |
1076 | |
8575 | 1077 i_ret = SolarisSendUSCSI( i_fd, &sc ); |
7027 | 1078 |
1079 if( i_ret < 0 || sc.uscsi_status ) | |
1080 { | |
1081 i_ret = -1; | |
1082 } | |
1083 | |
1084 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE ); | |
1085 | |
1086 #elif defined( DARWIN_DVD_IOCTL ) | |
1087 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDKey1Info, | |
1088 kDVDKeyFormatKey1 ); | |
1089 | |
1090 dvd.grantID = *pi_agid; | |
1091 | |
1092 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd ); | |
1093 | |
1094 memcpy( p_key, dvdbs.key1Value, DVD_KEY_SIZE ); | |
1095 | |
1096 #elif defined( WIN32 ) | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1097 if( WIN2K ) /* NT/2k/XP */ |
7027 | 1098 { |
1099 DWORD tmp; | |
1100 u8 buffer[DVD_BUS_KEY_LENGTH]; | |
1101 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; | |
1102 | |
1103 memset( &buffer, 0, sizeof( buffer ) ); | |
1104 | |
1105 key->KeyLength = DVD_BUS_KEY_LENGTH; | |
1106 key->SessionId = *pi_agid; | |
1107 key->KeyType = DvdBusKey1; | |
1108 key->KeyFlags = 0; | |
1109 | |
1110 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key, | |
1111 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; | |
1112 | |
1113 memcpy( p_key, key->KeyData, DVD_KEY_SIZE ); | |
1114 } | |
1115 else | |
1116 { | |
1117 INIT_SSC( GPCMD_REPORT_KEY, 12 ); | |
1118 | |
1119 ssc.CDBByte[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6); | |
1120 | |
1121 i_ret = WinSendSSC( i_fd, &ssc ); | |
1122 | |
1123 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE ); | |
1124 } | |
1125 | |
1126 #elif defined( __QNXNTO__ ) | |
1127 | |
1128 INIT_CPT( GPCMD_REPORT_KEY, 12 ); | |
1129 | |
1130 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6); | |
1131 | |
1132 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); | |
1133 | |
1134 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE ); | |
1135 | |
1136 #elif defined( SYS_OS2 ) | |
1137 INIT_SSC( GPCMD_REPORT_KEY, 12 ); | |
1138 | |
1139 sdc.command[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6); | |
1140 | |
1141 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, | |
1142 &sdc, sizeof(sdc), &ulParamLen, | |
1143 p_buffer, sizeof(p_buffer), &ulDataLen); | |
1144 | |
1145 memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE ); | |
1146 | |
1147 #else | |
1148 # error "DVD ioctls are unavailable on this system" | |
1149 | |
1150 #endif | |
1151 return i_ret; | |
1152 } | |
1153 | |
1154 /***************************************************************************** | |
1155 * ioctl_InvalidateAgid: invalidate the current AGID | |
1156 *****************************************************************************/ | |
1157 int ioctl_InvalidateAgid( int i_fd, int *pi_agid ) | |
1158 { | |
1159 int i_ret; | |
1160 | |
1161 #if defined( HAVE_LINUX_DVD_STRUCT ) | |
1162 dvd_authinfo auth_info; | |
1163 | |
1164 memset( &auth_info, 0, sizeof( auth_info ) ); | |
1165 auth_info.type = DVD_INVALIDATE_AGID; | |
1166 auth_info.lsa.agid = *pi_agid; | |
1167 | |
1168 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); | |
1169 | |
1170 #elif defined( HAVE_BSD_DVD_STRUCT ) | |
1171 struct dvd_authinfo auth_info; | |
1172 | |
1173 memset( &auth_info, 0, sizeof( auth_info ) ); | |
1174 auth_info.format = DVD_INVALIDATE_AGID; | |
1175 auth_info.agid = *pi_agid; | |
1176 | |
1177 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); | |
1178 | |
1179 #elif defined( SYS_BEOS ) | |
1180 INIT_RDC( GPCMD_REPORT_KEY, 0 ); | |
1181 | |
1182 rdc.command[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6); | |
1183 | |
1184 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); | |
1185 | |
1186 #elif defined( HPUX_SCTL_IO ) | |
1187 INIT_SCTL_IO( GPCMD_REPORT_KEY, 0 ); | |
1188 | |
1189 sctl_io.cdb[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6); | |
1190 | |
1191 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); | |
1192 | |
1193 #elif defined( SOLARIS_USCSI ) | |
1194 INIT_USCSI( GPCMD_REPORT_KEY, 0 ); | |
1195 | |
1196 rs_cdb.cdb_opaque[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6); | |
1197 | |
8575 | 1198 i_ret = SolarisSendUSCSI( i_fd, &sc ); |
7027 | 1199 |
1200 if( i_ret < 0 || sc.uscsi_status ) | |
1201 { | |
1202 i_ret = -1; | |
1203 } | |
1204 | |
1205 #elif defined( DARWIN_DVD_IOCTL ) | |
1206 INIT_DVDIOCTL( dk_dvd_send_key_t, DVDAuthenticationGrantIDInfo, | |
1207 kDVDKeyFormatAGID_Invalidate ); | |
1208 | |
1209 dvd.grantID = *pi_agid; | |
1210 | |
1211 i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd ); | |
1212 | |
1213 #elif defined( WIN32 ) | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1214 if( WIN2K ) /* NT/2k/XP */ |
7027 | 1215 { |
1216 DWORD tmp; | |
1217 | |
1218 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_END_SESSION, | |
1219 pi_agid, sizeof( *pi_agid ), NULL, 0, &tmp, NULL ) ? 0 : -1; | |
1220 } | |
1221 else | |
1222 { | |
1223 #if defined( __MINGW32__ ) | |
1224 INIT_SSC( GPCMD_REPORT_KEY, 0 ); | |
1225 #else | |
1226 INIT_SSC( GPCMD_REPORT_KEY, 1 ); | |
1227 | |
1228 ssc.SRB_BufLen = 0; | |
1229 ssc.CDBByte[ 8 ] = 0; | |
1230 ssc.CDBByte[ 9 ] = 0; | |
1231 #endif | |
1232 | |
1233 ssc.CDBByte[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6); | |
1234 | |
1235 i_ret = WinSendSSC( i_fd, &ssc ); | |
1236 } | |
1237 | |
1238 #elif defined( __QNXNTO__ ) | |
1239 | |
1240 INIT_CPT( GPCMD_REPORT_KEY, 0 ); | |
1241 | |
1242 p_cpt->cam_cdb[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6); | |
1243 | |
1244 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); | |
1245 | |
1246 #elif defined( SYS_OS2 ) | |
1247 INIT_SSC( GPCMD_REPORT_KEY, 1 ); | |
1248 | |
1249 sdc.data_length = 0; | |
1250 sdc.command[ 8 ] = 0; | |
1251 sdc.command[ 9 ] = 0; | |
1252 | |
1253 sdc.command[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6); | |
1254 | |
1255 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, | |
1256 &sdc, sizeof(sdc), &ulParamLen, | |
1257 NULL, 0, &ulDataLen); | |
1258 #else | |
1259 # error "DVD ioctls are unavailable on this system" | |
1260 | |
1261 #endif | |
1262 return i_ret; | |
1263 } | |
1264 | |
1265 /***************************************************************************** | |
1266 * ioctl_SendChallenge: send challenge to the drive | |
1267 *****************************************************************************/ | |
1268 int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge ) | |
1269 { | |
1270 int i_ret; | |
1271 | |
1272 #if defined( HAVE_LINUX_DVD_STRUCT ) | |
1273 dvd_authinfo auth_info; | |
1274 | |
1275 memset( &auth_info, 0, sizeof( auth_info ) ); | |
1276 auth_info.type = DVD_HOST_SEND_CHALLENGE; | |
1277 auth_info.hsc.agid = *pi_agid; | |
1278 | |
1279 memcpy( auth_info.hsc.chal, p_challenge, DVD_CHALLENGE_SIZE ); | |
1280 | |
1281 return ioctl( i_fd, DVD_AUTH, &auth_info ); | |
1282 | |
1283 #elif defined( HAVE_BSD_DVD_STRUCT ) | |
1284 struct dvd_authinfo auth_info; | |
1285 | |
1286 memset( &auth_info, 0, sizeof( auth_info ) ); | |
1287 auth_info.format = DVD_SEND_CHALLENGE; | |
1288 auth_info.agid = *pi_agid; | |
1289 | |
1290 memcpy( auth_info.keychal, p_challenge, DVD_CHALLENGE_SIZE ); | |
1291 | |
1292 return ioctl( i_fd, DVDIOCSENDKEY, &auth_info ); | |
1293 | |
1294 #elif defined( SYS_BEOS ) | |
1295 INIT_RDC( GPCMD_SEND_KEY, 16 ); | |
1296 | |
1297 rdc.command[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6); | |
1298 | |
1299 p_buffer[ 1 ] = 0xe; | |
1300 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE ); | |
1301 | |
1302 return ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); | |
1303 | |
1304 #elif defined( HPUX_SCTL_IO ) | |
1305 INIT_SCTL_IO( GPCMD_SEND_KEY, 16 ); | |
1306 | |
1307 sctl_io.cdb[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6); | |
1308 | |
1309 p_buffer[ 1 ] = 0xe; | |
1310 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE ); | |
1311 | |
1312 return ioctl( i_fd, SIOC_IO, &sctl_io ); | |
1313 | |
1314 #elif defined( SOLARIS_USCSI ) | |
1315 INIT_USCSI( GPCMD_SEND_KEY, 16 ); | |
1316 | |
1317 rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6); | |
1318 | |
1319 p_buffer[ 1 ] = 0xe; | |
1320 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE ); | |
1321 | |
8575 | 1322 if( SolarisSendUSCSI( i_fd, &sc ) < 0 || sc.uscsi_status ) |
7027 | 1323 { |
1324 return -1; | |
1325 } | |
1326 | |
1327 return 0; | |
1328 | |
1329 #elif defined( DARWIN_DVD_IOCTL ) | |
1330 INIT_DVDIOCTL( dk_dvd_send_key_t, DVDChallengeKeyInfo, | |
1331 kDVDKeyFormatChallengeKey ); | |
1332 | |
1333 dvd.grantID = *pi_agid; | |
1334 dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM; | |
1335 | |
1336 dvdbs.dataLength[ 1 ] = 0xe; | |
1337 memcpy( dvdbs.challengeKeyValue, p_challenge, DVD_CHALLENGE_SIZE ); | |
1338 | |
1339 i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd ); | |
1340 | |
1341 #elif defined( WIN32 ) | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1342 if( WIN2K ) /* NT/2k/XP */ |
7027 | 1343 { |
1344 DWORD tmp; | |
1345 u8 buffer[DVD_CHALLENGE_KEY_LENGTH]; | |
1346 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; | |
1347 | |
1348 memset( &buffer, 0, sizeof( buffer ) ); | |
1349 | |
1350 key->KeyLength = DVD_CHALLENGE_KEY_LENGTH; | |
1351 key->SessionId = *pi_agid; | |
1352 key->KeyType = DvdChallengeKey; | |
1353 key->KeyFlags = 0; | |
1354 | |
1355 memcpy( key->KeyData, p_challenge, DVD_CHALLENGE_SIZE ); | |
1356 | |
1357 return DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key, | |
1358 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; | |
1359 } | |
1360 else | |
1361 { | |
1362 INIT_SSC( GPCMD_SEND_KEY, 16 ); | |
1363 | |
1364 ssc.CDBByte[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6); | |
1365 | |
1366 p_buffer[ 1 ] = 0xe; | |
1367 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE ); | |
1368 | |
1369 return WinSendSSC( i_fd, &ssc ); | |
1370 } | |
1371 | |
1372 #elif defined( __QNXNTO__ ) | |
1373 | |
1374 INIT_CPT( GPCMD_SEND_KEY, 16 ); | |
1375 | |
1376 p_cpt->cam_cdb[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6); | |
1377 | |
1378 p_buffer[ 1 ] = 0xe; | |
1379 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE ); | |
1380 | |
1381 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); | |
1382 | |
1383 #elif defined( SYS_OS2 ) | |
1384 INIT_SSC( GPCMD_SEND_KEY, 16 ); | |
1385 | |
1386 sdc.command[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6); | |
1387 | |
1388 p_buffer[ 1 ] = 0xe; | |
1389 memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE ); | |
1390 | |
1391 return DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, | |
1392 &sdc, sizeof(sdc), &ulParamLen, | |
1393 p_buffer, sizeof(p_buffer), &ulDataLen); | |
1394 | |
1395 #else | |
1396 # error "DVD ioctls are unavailable on this system" | |
1397 | |
1398 #endif | |
1399 return i_ret; | |
1400 } | |
1401 | |
1402 /***************************************************************************** | |
1403 * ioctl_SendKey2: send the second key to the drive | |
1404 *****************************************************************************/ | |
1405 int ioctl_SendKey2( int i_fd, int *pi_agid, u8 *p_key ) | |
1406 { | |
1407 int i_ret; | |
1408 | |
1409 #if defined( HAVE_LINUX_DVD_STRUCT ) | |
1410 dvd_authinfo auth_info; | |
1411 | |
1412 memset( &auth_info, 0, sizeof( auth_info ) ); | |
1413 auth_info.type = DVD_HOST_SEND_KEY2; | |
1414 auth_info.hsk.agid = *pi_agid; | |
1415 | |
1416 memcpy( auth_info.hsk.key, p_key, DVD_KEY_SIZE ); | |
1417 | |
1418 return ioctl( i_fd, DVD_AUTH, &auth_info ); | |
1419 | |
1420 #elif defined( HAVE_BSD_DVD_STRUCT ) | |
1421 struct dvd_authinfo auth_info; | |
1422 | |
1423 memset( &auth_info, 0, sizeof( auth_info ) ); | |
1424 auth_info.format = DVD_SEND_KEY2; | |
1425 auth_info.agid = *pi_agid; | |
1426 | |
1427 memcpy( auth_info.keychal, p_key, DVD_KEY_SIZE ); | |
1428 | |
1429 return ioctl( i_fd, DVDIOCSENDKEY, &auth_info ); | |
1430 | |
1431 #elif defined( SYS_BEOS ) | |
1432 INIT_RDC( GPCMD_SEND_KEY, 12 ); | |
1433 | |
1434 rdc.command[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6); | |
1435 | |
1436 p_buffer[ 1 ] = 0xa; | |
1437 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE ); | |
1438 | |
1439 return ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); | |
1440 | |
1441 #elif defined( HPUX_SCTL_IO ) | |
1442 INIT_SCTL_IO( GPCMD_SEND_KEY, 12 ); | |
1443 | |
1444 sctl_io.cdb[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6); | |
1445 | |
1446 p_buffer[ 1 ] = 0xa; | |
1447 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE ); | |
1448 | |
1449 return ioctl( i_fd, SIOC_IO, &sctl_io ); | |
1450 | |
1451 #elif defined( SOLARIS_USCSI ) | |
1452 INIT_USCSI( GPCMD_SEND_KEY, 12 ); | |
1453 | |
1454 rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6); | |
1455 | |
1456 p_buffer[ 1 ] = 0xa; | |
1457 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE ); | |
1458 | |
8575 | 1459 if( SolarisSendUSCSI( i_fd, &sc ) < 0 || sc.uscsi_status ) |
7027 | 1460 { |
1461 return -1; | |
1462 } | |
1463 | |
1464 return 0; | |
1465 | |
1466 #elif defined( DARWIN_DVD_IOCTL ) | |
1467 INIT_DVDIOCTL( dk_dvd_send_key_t, DVDKey2Info, | |
1468 kDVDKeyFormatKey2 ); | |
1469 | |
1470 dvd.grantID = *pi_agid; | |
1471 dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM; | |
1472 | |
1473 dvdbs.dataLength[ 1 ] = 0xa; | |
1474 memcpy( dvdbs.key2Value, p_key, DVD_KEY_SIZE ); | |
1475 | |
1476 i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd ); | |
1477 | |
1478 #elif defined( WIN32 ) | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1479 if( WIN2K ) /* NT/2k/XP */ |
7027 | 1480 { |
1481 DWORD tmp; | |
1482 u8 buffer[DVD_BUS_KEY_LENGTH]; | |
1483 PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; | |
1484 | |
1485 memset( &buffer, 0, sizeof( buffer ) ); | |
1486 | |
1487 key->KeyLength = DVD_BUS_KEY_LENGTH; | |
1488 key->SessionId = *pi_agid; | |
1489 key->KeyType = DvdBusKey2; | |
1490 key->KeyFlags = 0; | |
1491 | |
1492 memcpy( key->KeyData, p_key, DVD_KEY_SIZE ); | |
1493 | |
1494 return DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key, | |
1495 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; | |
1496 } | |
1497 else | |
1498 { | |
1499 INIT_SSC( GPCMD_SEND_KEY, 12 ); | |
1500 | |
1501 ssc.CDBByte[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6); | |
1502 | |
1503 p_buffer[ 1 ] = 0xa; | |
1504 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE ); | |
1505 | |
1506 return WinSendSSC( i_fd, &ssc ); | |
1507 } | |
1508 | |
1509 #elif defined( __QNXNTO__ ) | |
1510 | |
1511 INIT_CPT( GPCMD_SEND_KEY, 12 ); | |
1512 | |
1513 p_cpt->cam_cdb[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6); | |
1514 | |
1515 p_buffer[ 1 ] = 0xa; | |
1516 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE ); | |
1517 | |
1518 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); | |
1519 | |
1520 #elif defined( SYS_OS2 ) | |
1521 INIT_SSC( GPCMD_SEND_KEY, 12 ); | |
1522 | |
1523 sdc.command[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6); | |
1524 | |
1525 p_buffer[ 1 ] = 0xa; | |
1526 memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE ); | |
1527 | |
1528 return DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, | |
1529 &sdc, sizeof(sdc), &ulParamLen, | |
1530 p_buffer, sizeof(p_buffer), &ulDataLen); | |
1531 | |
1532 #else | |
1533 # error "DVD ioctls are unavailable on this system" | |
1534 | |
1535 #endif | |
1536 return i_ret; | |
1537 } | |
1538 | |
1539 /***************************************************************************** | |
1540 * ioctl_ReportRPC: get RPC status for the drive | |
1541 *****************************************************************************/ | |
1542 int ioctl_ReportRPC( int i_fd, int *p_type, int *p_mask, int *p_scheme ) | |
1543 { | |
1544 int i_ret; | |
1545 | |
1546 #if defined( HAVE_LINUX_DVD_STRUCT ) && defined( DVD_LU_SEND_RPC_STATE ) | |
1547 dvd_authinfo auth_info; | |
1548 | |
1549 memset( &auth_info, 0, sizeof( auth_info ) ); | |
1550 auth_info.type = DVD_LU_SEND_RPC_STATE; | |
1551 | |
1552 i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); | |
1553 | |
1554 *p_type = auth_info.lrpcs.type; | |
1555 *p_mask = auth_info.lrpcs.region_mask; | |
1556 *p_scheme = auth_info.lrpcs.rpc_scheme; | |
1557 | |
1558 #elif defined( HAVE_LINUX_DVD_STRUCT ) | |
1559 /* FIXME: OpenBSD doesn't know this */ | |
1560 i_ret = -1; | |
1561 | |
1562 #elif defined( HAVE_BSD_DVD_STRUCT ) | |
1563 struct dvd_authinfo auth_info; | |
1564 | |
1565 memset( &auth_info, 0, sizeof( auth_info ) ); | |
1566 auth_info.format = DVD_REPORT_RPC; | |
1567 | |
1568 i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); | |
1569 | |
1570 *p_type = auth_info.reg_type; | |
1571 *p_mask = auth_info.region; // ?? | |
1572 *p_scheme = auth_info.rpc_scheme; | |
1573 | |
1574 #elif defined( SYS_BEOS ) | |
1575 INIT_RDC( GPCMD_REPORT_KEY, 8 ); | |
1576 | |
1577 rdc.command[ 10 ] = DVD_REPORT_RPC; | |
1578 | |
1579 i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); | |
1580 | |
1581 *p_type = p_buffer[ 4 ] >> 6; | |
1582 *p_mask = p_buffer[ 5 ]; | |
1583 *p_scheme = p_buffer[ 6 ]; | |
1584 | |
1585 #elif defined( HPUX_SCTL_IO ) | |
1586 INIT_SCTL_IO( GPCMD_REPORT_KEY, 8 ); | |
1587 | |
1588 sctl_io.cdb[ 10 ] = DVD_REPORT_RPC; | |
1589 | |
1590 i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); | |
1591 | |
1592 *p_type = p_buffer[ 4 ] >> 6; | |
1593 *p_mask = p_buffer[ 5 ]; | |
1594 *p_scheme = p_buffer[ 6 ]; | |
1595 | |
1596 #elif defined( SOLARIS_USCSI ) | |
1597 INIT_USCSI( GPCMD_REPORT_KEY, 8 ); | |
1598 | |
1599 rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_RPC; | |
1600 | |
8575 | 1601 i_ret = SolarisSendUSCSI( i_fd, &sc ); |
7027 | 1602 |
1603 if( i_ret < 0 || sc.uscsi_status ) | |
1604 { | |
1605 i_ret = -1; | |
1606 } | |
1607 | |
1608 *p_type = p_buffer[ 4 ] >> 6; | |
1609 *p_mask = p_buffer[ 5 ]; | |
1610 *p_scheme = p_buffer[ 6 ]; | |
1611 | |
1612 #elif defined( DARWIN_DVD_IOCTL ) | |
1613 INIT_DVDIOCTL( dk_dvd_report_key_t, DVDRegionPlaybackControlInfo, | |
1614 kDVDKeyFormatRegionState ); | |
1615 | |
1616 dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM; | |
1617 | |
1618 i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd ); | |
1619 | |
1620 *p_type = dvdbs.typeCode; | |
1621 *p_mask = dvdbs.driveRegion; | |
1622 *p_scheme = dvdbs.rpcScheme; | |
1623 | |
1624 #elif defined( WIN32 ) | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1625 if( WIN2K ) /* NT/2k/XP */ |
7027 | 1626 { |
1627 DWORD tmp; | |
1628 u8 buffer[ DVD_REGION_LENGTH ]; | |
1629 PDVD_REGION region = (PDVD_REGION) &buffer; | |
1630 | |
1631 memset( &buffer, 0, sizeof( buffer ) ); | |
1632 | |
1633 i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_GET_REGION, NULL, 0, | |
1634 region, DVD_REGION_LENGTH, &tmp, NULL ) ? 0 : -1; | |
1635 | |
1636 /* Someone who has the headers should correct all this. */ | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1637 /* Use the IOCTL_SCSI_PASS_THROUGH_DIRECT so we get the real |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1638 * values of theses entities? */ |
7027 | 1639 if(region->SystemRegion != 0) { |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1640 *p_type = region->ResetCount > 1 ? 1 : 3 - region->ResetCount; |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1641 *p_mask = 0xff ^ (1 << (region->SystemRegion - 1)); |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1642 *p_scheme = 1; |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1643 } |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1644 else |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1645 { |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1646 *p_type = 0; /* ?? */ |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1647 *p_mask = 0xff; |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1648 *p_scheme = 1; /* ?? */ |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1649 } |
7027 | 1650 } |
1651 else | |
1652 { | |
1653 INIT_SSC( GPCMD_REPORT_KEY, 8 ); | |
1654 | |
1655 ssc.CDBByte[ 10 ] = DVD_REPORT_RPC; | |
1656 | |
1657 i_ret = WinSendSSC( i_fd, &ssc ); | |
1658 | |
1659 *p_type = p_buffer[ 4 ] >> 6; | |
1660 *p_mask = p_buffer[ 5 ]; | |
1661 *p_scheme = p_buffer[ 6 ]; | |
1662 } | |
1663 | |
1664 #elif defined( __QNXNTO__ ) | |
1665 | |
1666 INIT_CPT( GPCMD_REPORT_KEY, 8 ); | |
1667 | |
1668 p_cpt->cam_cdb[ 10 ] = DVD_REPORT_RPC; | |
1669 | |
1670 i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); | |
1671 | |
1672 *p_type = p_buffer[ 4 ] >> 6; | |
1673 *p_mask = p_buffer[ 5 ]; | |
1674 *p_scheme = p_buffer[ 6 ]; | |
1675 | |
1676 #elif defined( SYS_OS2 ) | |
1677 INIT_SSC( GPCMD_REPORT_KEY, 8 ); | |
1678 | |
1679 sdc.command[ 10 ] = DVD_REPORT_RPC; | |
1680 | |
1681 i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, | |
1682 &sdc, sizeof(sdc), &ulParamLen, | |
1683 p_buffer, sizeof(p_buffer), &ulDataLen); | |
1684 | |
1685 *p_type = p_buffer[ 4 ] >> 6; | |
1686 *p_mask = p_buffer[ 5 ]; | |
1687 *p_scheme = p_buffer[ 6 ]; | |
1688 | |
1689 #else | |
1690 # error "DVD ioctls are unavailable on this system" | |
1691 | |
1692 #endif | |
1693 return i_ret; | |
1694 } | |
1695 | |
1696 /* Local prototypes */ | |
1697 | |
1698 #if defined( SYS_BEOS ) | |
1699 /***************************************************************************** | |
1700 * BeInitRDC: initialize a RDC structure for the BeOS kernel | |
1701 ***************************************************************************** | |
1702 * This function initializes a BeOS raw device command structure for future | |
1703 * use, either a read command or a write command. | |
1704 *****************************************************************************/ | |
1705 static void BeInitRDC( raw_device_command *p_rdc, int i_type ) | |
1706 { | |
1707 memset( p_rdc->data, 0, p_rdc->data_length ); | |
1708 | |
1709 switch( i_type ) | |
1710 { | |
1711 case GPCMD_SEND_KEY: | |
1712 /* leave the flags to 0 */ | |
1713 break; | |
1714 | |
1715 case GPCMD_READ_DVD_STRUCTURE: case GPCMD_REPORT_KEY: | |
1716 p_rdc->flags = B_RAW_DEVICE_DATA_IN; break; } | |
1717 | |
1718 p_rdc->command[ 0 ] = i_type; | |
1719 | |
1720 p_rdc->command[ 8 ] = (p_rdc->data_length >> 8) & 0xff; | |
1721 p_rdc->command[ 9 ] = p_rdc->data_length & 0xff; | |
1722 p_rdc->command_length = 12; | |
1723 | |
1724 p_rdc->sense_data = NULL; | |
1725 p_rdc->sense_data_length = 0; | |
1726 | |
1727 p_rdc->timeout = 1000000; | |
1728 } | |
1729 #endif | |
1730 | |
1731 #if defined( HPUX_SCTL_IO ) | |
1732 /***************************************************************************** | |
1733 * HPUXInitSCTL: initialize a sctl_io structure for the HP-UX kernel | |
1734 ***************************************************************************** | |
1735 * This function initializes a HP-UX command structure for future | |
1736 * use, either a read command or a write command. | |
1737 *****************************************************************************/ | |
1738 static void HPUXInitSCTL( struct sctl_io *sctl_io, int i_type ) | |
1739 { | |
1740 memset( sctl_io->data, 0, sctl_io->data_length ); | |
1741 | |
1742 switch( i_type ) | |
1743 { | |
1744 case GPCMD_SEND_KEY: | |
1745 /* leave the flags to 0 */ | |
1746 break; | |
1747 | |
1748 case GPCMD_READ_DVD_STRUCTURE: | |
1749 case GPCMD_REPORT_KEY: | |
1750 sctl_io->flags = SCTL_READ; | |
1751 break; | |
1752 } | |
1753 | |
1754 sctl_io->cdb[ 0 ] = i_type; | |
1755 | |
1756 sctl_io->cdb[ 8 ] = (sctl_io->data_length >> 8) & 0xff; | |
1757 sctl_io->cdb[ 9 ] = sctl_io->data_length & 0xff; | |
1758 sctl_io->cdb_length = 12; | |
1759 | |
1760 sctl_io->max_msecs = 1000000; | |
1761 } | |
1762 #endif | |
1763 | |
1764 #if defined( SOLARIS_USCSI ) | |
1765 /***************************************************************************** | |
1766 * SolarisInitUSCSI: initialize a USCSICMD structure for the Solaris kernel | |
1767 ***************************************************************************** | |
1768 * This function initializes a Solaris userspace scsi command structure for | |
1769 * future use, either a read command or a write command. | |
1770 *****************************************************************************/ | |
1771 static void SolarisInitUSCSI( struct uscsi_cmd *p_sc, int i_type ) | |
1772 { | |
1773 union scsi_cdb *rs_cdb; | |
1774 memset( p_sc->uscsi_cdb, 0, sizeof( union scsi_cdb ) ); | |
1775 memset( p_sc->uscsi_bufaddr, 0, p_sc->uscsi_buflen ); | |
1776 | |
1777 switch( i_type ) | |
1778 { | |
1779 case GPCMD_SEND_KEY: | |
1780 p_sc->uscsi_flags = USCSI_ISOLATE | USCSI_WRITE; | |
1781 break; | |
1782 | |
1783 case GPCMD_READ_DVD_STRUCTURE: | |
1784 case GPCMD_REPORT_KEY: | |
1785 p_sc->uscsi_flags = USCSI_ISOLATE | USCSI_READ; | |
1786 break; | |
1787 } | |
1788 | |
1789 rs_cdb = (union scsi_cdb *)p_sc->uscsi_cdb; | |
1790 | |
1791 rs_cdb->scc_cmd = i_type; | |
1792 | |
1793 rs_cdb->cdb_opaque[ 8 ] = (p_sc->uscsi_buflen >> 8) & 0xff; | |
1794 rs_cdb->cdb_opaque[ 9 ] = p_sc->uscsi_buflen & 0xff; | |
1795 p_sc->uscsi_cdblen = 12; | |
1796 | |
1797 USCSI_TIMEOUT( p_sc, 15 ); | |
1798 } | |
8575 | 1799 |
1800 /***************************************************************************** | |
1801 * SolarisSendUSCSI: send a USCSICMD structure to the Solaris kernel | |
1802 * for execution | |
1803 ***************************************************************************** | |
1804 * When available, this function uses the function smedia_uscsi_cmd() | |
1805 * from solaris' libsmedia library (solaris 9 or newer) to execute the | |
1806 * USCSI command. smedia_uscsi_cmd() allows USCSI commands for | |
1807 * non-root users on removable media devices on solaris 9; sending the | |
1808 * USCSI command directly to the device using the USCSICMD ioctl fails | |
1809 * with an EPERM error on solaris 9. | |
1810 * | |
1811 * The code will fall back to the USCSICMD ioctl method, when | |
1812 * libsmedia.so is not available or does not export the | |
1813 * smedia_uscsi_cmd() function (on solaris releases upto and including | |
1814 * solaris 8). Fortunatelly, on these old releases non-root users are | |
1815 * allowed to perform USCSICMD ioctls on removable media devices. | |
1816 *****************************************************************************/ | |
1817 static int SolarisSendUSCSI( int i_fd, struct uscsi_cmd *p_sc ) { | |
1818 void *sm_hdl; | |
1819 static int initialized; | |
1820 static void* (*sm_get_handle)(int32_t); | |
1821 static int (*sm_release_handle)(void*); | |
1822 static int (*sm_uscsi_cmd)(void*, struct uscsi_cmd *); | |
1823 | |
1824 if (!initialized) | |
1825 { | |
1826 void *smedia_lib; | |
1827 | |
1828 smedia_lib = dlopen("libsmedia.so", RTLD_NOW); | |
1829 if (smedia_lib) { | |
1830 sm_get_handle = dlsym(smedia_lib, "smedia_get_handle"); | |
1831 sm_release_handle = dlsym(smedia_lib, "smedia_release_handle"); | |
1832 sm_uscsi_cmd = dlsym(smedia_lib, "smedia_uscsi_cmd"); | |
1833 } | |
1834 initialized = 1; | |
1835 } | |
1836 | |
1837 if (sm_get_handle && sm_uscsi_cmd && sm_release_handle | |
1838 && (sm_hdl = sm_get_handle(i_fd))) | |
1839 { | |
1840 int i_ret = sm_uscsi_cmd(sm_hdl, p_sc); | |
1841 sm_release_handle(sm_hdl); | |
1842 return i_ret; | |
1843 } | |
1844 | |
1845 return ioctl( i_fd, USCSICMD, p_sc ); | |
1846 } | |
7027 | 1847 #endif |
1848 | |
1849 #if defined( WIN32 ) | |
1850 /***************************************************************************** | |
1851 * WinInitSSC: initialize a ssc structure for the win32 aspi layer | |
1852 ***************************************************************************** | |
1853 * This function initializes a ssc raw device command structure for future | |
1854 * use, either a read command or a write command. | |
1855 *****************************************************************************/ | |
1856 static void WinInitSSC( struct SRB_ExecSCSICmd *p_ssc, int i_type ) | |
1857 { | |
1858 memset( p_ssc->SRB_BufPointer, 0, p_ssc->SRB_BufLen ); | |
1859 | |
1860 switch( i_type ) | |
1861 { | |
1862 case GPCMD_SEND_KEY: | |
1863 p_ssc->SRB_Flags = SRB_DIR_OUT; | |
1864 break; | |
1865 | |
1866 case GPCMD_READ_DVD_STRUCTURE: | |
1867 case GPCMD_REPORT_KEY: | |
1868 p_ssc->SRB_Flags = SRB_DIR_IN; | |
1869 break; | |
1870 } | |
1871 | |
1872 p_ssc->SRB_Cmd = SC_EXEC_SCSI_CMD; | |
1873 p_ssc->SRB_Flags |= SRB_EVENT_NOTIFY; | |
1874 | |
1875 p_ssc->CDBByte[ 0 ] = i_type; | |
1876 | |
1877 p_ssc->CDBByte[ 8 ] = (u8)(p_ssc->SRB_BufLen >> 8) & 0xff; | |
1878 p_ssc->CDBByte[ 9 ] = (u8) p_ssc->SRB_BufLen & 0xff; | |
1879 p_ssc->SRB_CDBLen = 12; | |
1880 | |
1881 p_ssc->SRB_SenseLen = SENSE_LEN; | |
1882 } | |
1883 | |
1884 /***************************************************************************** | |
1885 * WinSendSSC: send a ssc structure to the aspi layer | |
1886 *****************************************************************************/ | |
1887 static int WinSendSSC( int i_fd, struct SRB_ExecSCSICmd *p_ssc ) | |
1888 { | |
1889 HANDLE hEvent = NULL; | |
1890 struct w32_aspidev *fd = (struct w32_aspidev *) i_fd; | |
1891 | |
1892 hEvent = CreateEvent( NULL, TRUE, FALSE, NULL ); | |
1893 if( hEvent == NULL ) | |
1894 { | |
1895 return -1; | |
1896 } | |
1897 | |
1898 p_ssc->SRB_PostProc = hEvent; | |
1899 p_ssc->SRB_HaId = LOBYTE( fd->i_sid ); | |
1900 p_ssc->SRB_Target = HIBYTE( fd->i_sid ); | |
1901 | |
1902 ResetEvent( hEvent ); | |
1903 if( fd->lpSendCommand( (void*) p_ssc ) == SS_PENDING ) | |
1904 WaitForSingleObject( hEvent, INFINITE ); | |
1905 | |
1906 CloseHandle( hEvent ); | |
1907 | |
1908 return p_ssc->SRB_Status == SS_COMP ? 0 : -1; | |
1909 } | |
1910 #endif | |
1911 | |
1912 #if defined( __QNXNTO__ ) | |
1913 /***************************************************************************** | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1914 * QNXInitCPT: initialize a CPT structure for QNX Neutrino |
7027 | 1915 ***************************************************************************** |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1916 * This function initializes a cpt command structure for future use, |
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1917 * either a read command or a write command. |
7027 | 1918 *****************************************************************************/ |
1919 static void QNXInitCPT( CAM_PASS_THRU * p_cpt, int i_type ) | |
1920 { | |
1921 switch( i_type ) | |
1922 { | |
1923 case GPCMD_SEND_KEY: | |
1924 p_cpt->cam_flags = CAM_DIR_OUT; | |
1925 break; | |
1926 | |
1927 case GPCMD_READ_DVD_STRUCTURE: | |
1928 case GPCMD_REPORT_KEY: | |
1929 p_cpt->cam_flags = CAM_DIR_IN; | |
1930 break; | |
1931 } | |
1932 | |
1933 p_cpt->cam_cdb[0] = i_type; | |
1934 | |
1935 p_cpt->cam_cdb[ 8 ] = (p_cpt->cam_dxfer_len >> 8) & 0xff; | |
1936 p_cpt->cam_cdb[ 9 ] = p_cpt->cam_dxfer_len & 0xff; | |
1937 p_cpt->cam_cdb_len = 12; | |
1938 | |
8637
0211de3039eb
update libdvdcss in libmpdvdkit to latest version (1.2.4)
arpi
parents:
8575
diff
changeset
|
1939 p_cpt->cam_timeout = CAM_TIME_DEFAULT; |
7027 | 1940 } |
1941 #endif | |
1942 | |
1943 #if defined( SYS_OS2 ) | |
1944 /***************************************************************************** | |
1945 * OS2InitSDC: initialize a SDC structure for the Execute SCSI-command | |
1946 ***************************************************************************** | |
1947 * This function initializes a OS2 'execute SCSI command' structure for | |
1948 * future use, either a read command or a write command. | |
1949 *****************************************************************************/ | |
1950 static void OS2InitSDC( struct OS2_ExecSCSICmd *p_sdc, int i_type ) | |
1951 { | |
1952 switch( i_type ) | |
1953 { | |
1954 case GPCMD_SEND_KEY: | |
1955 p_sdc->flags = 0; | |
1956 break; | |
1957 | |
1958 case GPCMD_READ_DVD_STRUCTURE: | |
1959 case GPCMD_REPORT_KEY: | |
1960 p_sdc->flags = EX_DIRECTION_IN; | |
1961 break; | |
1962 } | |
1963 | |
1964 p_sdc->command[ 0 ] = i_type; | |
1965 p_sdc->command[ 8 ] = (p_sdc->data_length >> 8) & 0xff; | |
1966 p_sdc->command[ 9 ] = p_sdc->data_length & 0xff; | |
1967 p_sdc->id_code = 0x31304443; // 'CD01' | |
1968 p_sdc->cmd_length = 12; | |
1969 } | |
1970 #endif |