ref: 6b11d456299603869c7f87705c52b7aefff45a0b
parent: 06626375c5f96a98eabddcd928ba1c269665498f
author: Gildas Bazin <gbazin@videolan.org>
date: Sat Oct 19 05:53:33 EDT 2002
* src/device.c, src/ioctl.h: on win9x, when using ASPI, make sure the drive we are trying to open is actually a cdrom/dvdrom drive.
--- a/src/device.c
+++ b/src/device.c
@@ -2,7 +2,7 @@
* device.h: DVD device access
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
- * $Id: device.c,v 1.5 2002/10/18 18:48:59 sam Exp $
+ * $Id: device.c,v 1.6 2002/10/19 09:53:33 gbazin Exp $
*
* Authors: St�phane Borel <stef@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
@@ -372,9 +372,30 @@
if( (srbDiskInfo.SRB_Status == SS_COMP) &&
(srbDiskInfo.SRB_Int13HDriveInfo == c_drive) )
{
- fd->i_sid = MAKEWORD( i, j );
- dvdcss->i_fd = (int) fd;
- return 0;
+ /* Make sure this is a cdrom device */
+ struct SRB_GDEVBlock srbGDEVBlock;
+
+ memset( &srbGDEVBlock, 0, sizeof(struct SRB_GDEVBlock) );
+ srbGDEVBlock.SRB_Cmd = SC_GET_DEV_TYPE;
+ srbGDEVBlock.SRB_HaId = i;
+ srbGDEVBlock.SRB_Target = j;
+
+ lpSendCommand( (void*) &srbGDEVBlock );
+
+ if( ( srbGDEVBlock.SRB_Status == SS_COMP ) &&
+ ( srbGDEVBlock.SRB_DeviceType == DTYPE_CDROM ) )
+ {
+ fd->i_sid = MAKEWORD( i, j );
+ dvdcss->i_fd = (int) fd;
+ return 0;
+ }
+ else
+ {
+ free( (void*) fd );
+ FreeLibrary( hASPI );
+ _dvdcss_error( dvdcss,"this is not a cdrom drive" );
+ return -1;
+ }
}
}
}
--- 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.9 2002/10/12 12:41:24 gbazin Exp $
+ * $Id: ioctl.h,v 1.10 2002/10/19 09:53:33 gbazin Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
@@ -302,8 +302,10 @@
#define WIN2K ( GetVersion() < 0x80000000 )
#define ASPI_HAID 0
#define ASPI_TARGET 0
+#define DTYPE_CDROM 0x05
#define SENSE_LEN 0x0E
+#define SC_GET_DEV_TYPE 0x01
#define SC_EXEC_SCSI_CMD 0x02
#define SC_GET_DISK_INFO 0x06
#define SS_COMP 0x01
@@ -337,6 +339,19 @@
unsigned char SRB_Heads;
unsigned char SRB_Sectors;
unsigned char SRB_Rsvd1[22];
+};
+
+struct SRB_GDEVBlock
+{
+ unsigned char SRB_Cmd;
+ unsigned char SRB_Status;
+ unsigned char SRB_HaId;
+ unsigned char SRB_Flags;
+ unsigned long SRB_Hdr_Rsvd;
+ unsigned char SRB_Target;
+ unsigned char SRB_Lun;
+ unsigned char SRB_DeviceType;
+ unsigned char SRB_Rsvd1;
};
struct SRB_ExecSCSICmd