shithub: libdvdcss

Download patch

ref: 763cb3c28ac91ae0b847a3b6913114c651d003ae
parent: 75926842ab179c9354ff726532679b58c0fc7fb0
author: Håkan Hjort <d95hjort@dtek.chalmers.se>
date: Mon Jul 1 05:02:25 EDT 2002

Getting ReportRPC for WIN32 a bit closer to working.


--- 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.10 2002/06/04 07:10:07 sam Exp $
+ * $Id: ioctl.c,v 1.11 2002/07/01 09:02:25 hjort Exp $
  *
  * Authors: Markus Kuespert <ltlBeBoy@beosmail.com>
  *          Samuel Hocevar <sam@zoy.org>
@@ -1476,28 +1476,31 @@
     if( WIN2K ) /* NT/Win2000/Whistler */
     {
         DWORD tmp;
-        u8 buffer[ DVD_ASF_LENGTH ]; /* correct this */
-        PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
+        u8 buffer[ DVD_REGION_LENGTH ];
+        PDVD_REGION region = (PDVD_REGION) &buffer;
 
         memset( &buffer, 0, sizeof( buffer ) );
 
-        key->KeyLength  = DVD_ASF_LENGTH; /* correct this */
-        key->KeyType    = DvdGetRpcKey;
-        key->KeyFlags   = 0;
-
 #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;
+        i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_GET_REGION, NULL, 0,
+                region, DVD_REGION_LENGTH, &tmp, NULL ) ? 0 : -1;
 
         /* Someone who has the headers should correct all this. */
-        *p_type = 0;
-        *p_mask = 0;
-        *p_scheme = 0;
-        i_ret = -1; /* Remove this line when implemented. */
-
+	/* Use the IOCTL_SCSI_PASS_THROUGH_DIRECT so we get the reall
+	 * values of theses entities?  */
+        if(key->SystemRegion != 0) {
+	    *p_type = key->ResetCount > 1 ? 1 : 3 - key->ResetCount;
+	    *p_mask =  0xff ^ (1 << (key->SystemRegion - 1));
+	    *p_scheme = 1;
+	}
+	else
+	{
+	    *p_type = 0;  /* ?? */
+	    *p_mask = 0xff;
+	    *p_scheme = 1; /* ?? */
+	}
     }
     else
     {
--- a/src/ioctl.h
+++ b/src/ioctl.h
@@ -2,7 +2,7 @@
  * ioctl.h: DVD ioctl replacement function
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: ioctl.h,v 1.4 2002/06/02 16:14:48 sam Exp $
+ * $Id: ioctl.h,v 1.5 2002/07/01 09:02:25 hjort Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -178,6 +178,7 @@
 #define DVD_TITLE_KEY_LENGTH            (8 + sizeof(DVD_COPY_PROTECT_KEY))
 #define DVD_DISK_KEY_LENGTH             (2048 + sizeof(DVD_COPY_PROTECT_KEY))
 #define DVD_ASF_LENGTH                  (sizeof(DVD_ASF) + sizeof(DVD_COPY_PROTECT_KEY))
+#define DVD_REGION_LENGTH               (sizeof(DVD_REGION))
 
 #define SCSI_IOCTL_DATA_OUT             0
 #define SCSI_IOCTL_DATA_IN              1
@@ -221,6 +222,13 @@
     UCHAR SuccessFlag:1;
     UCHAR Reserved1:7;
 } DVD_ASF, * PDVD_ASF;
+
+typedef struct _DVD_REGION {
+  UCHAR  CopySystem;
+  UCHAR  RegionData;
+  UCHAR  SystemRegion;
+  UCHAR  ResetCount;
+} DVD_REGION, *PDVD_REGION;
 
 typedef struct _SCSI_PASS_THROUGH_DIRECT
 {