shithub: libdvdcss

Download patch

ref: 273ace3c9a24e0e2ef72c3892f67549c56ea25f6
parent: 0329c59f62eec519e8cfacf20d11398f67819e60
author: Gildas Bazin <gbazin@videolan.org>
date: Thu Apr 4 18:44:20 EST 2002

* added two patches that have been forgot from the vlc tree.

 1- Under NT/2K/XP try to open the dvd device in read only mode if we don't
    have right access. With only read access we can't use ioctls but if the
    disc has already been authenticated, then we can decrypt it with the
    TITLE method.
 2- Small compilation fix for msvc.


--- a/src/ioctl.c
+++ b/src/ioctl.c
@@ -2,7 +2,7 @@
  * ioctl.c: DVD ioctl replacement function
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: ioctl.c,v 1.5 2002/04/04 01:26:54 sam Exp $
+ * $Id: ioctl.c,v 1.6 2002/04/04 23:44:20 gbazin Exp $
  *
  * Authors: Markus Kuespert <ltlBeBoy@beosmail.com>
  *          Samuel Hocevar <sam@zoy.org>
@@ -1451,7 +1451,9 @@
         key->KeyType    = DvdGetRpcKey;
         key->KeyFlags   = 0;
 
-#warning "Fix ReportRPC for WIN32!"
+#if !defined(_MSC_VER)
+#   warning "Fix ReportRPC for WIN32!"
+#endif
         /* The IOCTL_DVD_READ_KEY might be the right IOCTL */
         i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key, 
                 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -2,7 +2,7 @@
  * libdvdcss.c: DVD reading library.
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: libdvdcss.c,v 1.5 2002/04/03 15:19:21 sam Exp $
+ * $Id: libdvdcss.c,v 1.6 2002/04/04 23:44:20 gbazin Exp $
  *
  * Authors: St�phane Borel <stef@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -506,10 +506,25 @@
     {
         char psz_dvd[7];
         _snprintf( psz_dvd, 7, "\\\\.\\%c:", psz_target[0] );
+
+        /* To have access to ioctls, we need read and write access to the
+         * device. This is only allowed if you have administrator priviledges
+         * so we allow for a fallback method where ioctls are not available but
+         * we at least have read access to the device.
+         * (See Microsoft Q241374: Read and Write Access Required for SCSI
+         * Pass Through Requests) */
         (HANDLE) dvdcss->i_fd =
                 CreateFile( psz_dvd, GENERIC_READ | GENERIC_WRITE,
                                 FILE_SHARE_READ | FILE_SHARE_WRITE,
-                                NULL, OPEN_EXISTING, 0, NULL );
+                                NULL, OPEN_EXISTING,
+                                FILE_FLAG_RANDOM_ACCESS, NULL );
+
+        if( (HANDLE) dvdcss->i_fd == INVALID_HANDLE_VALUE )
+            (HANDLE) dvdcss->i_fd =
+                    CreateFile( psz_dvd, GENERIC_READ, FILE_SHARE_READ,
+                                    NULL, OPEN_EXISTING,
+                                    FILE_FLAG_RANDOM_ACCESS, NULL );
+
         if( (HANDLE) dvdcss->i_fd == INVALID_HANDLE_VALUE )
         {
             _dvdcss_error( dvdcss, "failed opening device" );