shithub: libdvdcss

Download patch

ref: a150a631e85f3ee338597e29b29f5460e7a8d45f
parent: 33e1fe0bac871b3edb9e40291460cc1ab6bf50b1
author: Gildas Bazin <gbazin@videolan.org>
date: Thu Nov 14 07:38:57 EST 2002

* src/css.c src/ioctl.c, src/libdvdcss.c: changed the work-around to detect
   if the dvd is encrypted on Win2K in non-administrator mode.
   Because we cannot use an ioctl to get the copyright status of the DVD
   we try to get the disc key and if this succeed, we assume the DVD is
   encrypted, otherwise we assume it to be unencrypted.
   I hope this logic is not too much flawed... at least it seems to be working
   with the few DVDs I've got.


--- a/src/css.c
+++ b/src/css.c
@@ -2,7 +2,7 @@
  * css.c: Functions for DVD authentication and descrambling
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: css.c,v 1.18 2002/10/18 18:48:58 sam Exp $
+ * $Id: css.c,v 1.19 2002/11/14 12:38:57 gbazin Exp $
  *
  * Author: St�phane Borel <stef@via.ecp.fr>
  *         H�kan Hjort <d95hjort@dtek.chalmers.se>
@@ -77,6 +77,21 @@
     int i_ret, i_copyright;
 
     i_ret = ioctl_ReadCopyright( dvdcss->i_fd, 0 /* i_layer */, &i_copyright );
+
+#ifdef WIN32
+    if( i_ret < 0 )
+    {
+        /* Maybe we didn't have enough priviledges to read the copyright
+         * (see ioctl_ReadCopyright comments).
+         * Apparently, on unencrypted DVDs _dvdcss_disckey() always fails, so
+         * we can check this as a work-around. */
+        i_ret = 0;
+        if( _dvdcss_disckey( dvdcss ) < 0 )
+            i_copyright = 0;
+        else
+            i_copyright = 1;
+    }
+#endif
 
     if( i_ret < 0 )
     {
--- 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.18 2002/11/14 01:32:37 jlj Exp $
+ * $Id: ioctl.c,v 1.19 2002/11/14 12:38:57 gbazin Exp $
  *
  * Authors: Markus Kuespert <ltlBeBoy@beosmail.com>
  *          Samuel Hocevar <sam@zoy.org>
@@ -247,40 +247,6 @@
         if( i_ret == 0 )
         {
             *pi_copyright = p_buffer[ 4 ];
-        }
-        else
-        {
-            /* We don't have the privileges to send a SCSI_PASS_THROUGH
-               command, let's try to read a title key to check if the DVD is
-               encrypted. */
-
-            int i_agid;
-            u8 buffer[DVD_DISK_KEY_LENGTH];
-            PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
-
-            if( ioctl_ReportAgid( i_fd, &i_agid ) < 0 )
-                return -1;
-
-            memset( &buffer, 0, sizeof( buffer ) );
-
-            key->KeyLength  = DVD_DISK_KEY_LENGTH;
-            key->SessionId  = i_agid;
-            key->KeyType    = DvdDiskKey;
-            key->KeyFlags   = 0;
-
-            i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key, 
-                    key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
-            if( i_ret < 0 )
-            {   
-                /* Ok, let's assume the disc is not encrypted */
-                *pi_copyright = 0;
-                i_ret = 0;
-            }
-            else
-            {
-                *pi_copyright = ((key->KeyFlags & DVD_SECTOR_PROTECT_MASK) ==
-                                 DVD_SECTOR_PROTECTED) ? 0 : 1;
-            }
         }
     }
     else