Long needed start to improve WIN2k native support.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: _cdio_win32.c,v 1.26 2004/02/08 23:49:17 rocky Exp $
|
$Id: _cdio_win32.c,v 1.27 2004/03/03 02:41:18 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: _cdio_win32.c,v 1.26 2004/02/08 23:49:17 rocky Exp $";
|
static const char _rcsid[] = "$Id: _cdio_win32.c,v 1.27 2004/03/03 02:41:18 rocky Exp $";
|
||||||
|
|
||||||
#include <cdio/cdio.h>
|
#include <cdio/cdio.h>
|
||||||
#include <cdio/sector.h>
|
#include <cdio/sector.h>
|
||||||
@@ -531,14 +531,18 @@ cdio_is_device_win32(const char *source_name)
|
|||||||
if (NULL == source_name) return false;
|
if (NULL == source_name) return false;
|
||||||
|
|
||||||
#ifdef HAVE_WIN32_CDROM
|
#ifdef HAVE_WIN32_CDROM
|
||||||
if ( WIN_NT )
|
if ((len == 2) && isalpha(source_name[0])
|
||||||
/* Really should test to see if of form: \\.\x: */
|
&& (source_name[len-1] == ':'))
|
||||||
return ((len == 6) && isalpha(source_name[len-2])
|
return true;
|
||||||
&& (source_name[len-1] == ':'));
|
|
||||||
else
|
if ( ! WIN_NT ) return false;
|
||||||
/* See if is of form: x: */
|
|
||||||
return ((len == 2) && isalpha(source_name[0])
|
/* Test to see if of form: \\.\x: */
|
||||||
&& (source_name[len-1] == ':'));
|
return ( (len == 6)
|
||||||
|
&& source_name[0] == '\\' && source_name[1] == '\\'
|
||||||
|
&& source_name[2] == '.' && source_name[3] == '\\'
|
||||||
|
&& isalpha(source_name[len-2])
|
||||||
|
&& (source_name[len-1] == ':') );
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
117
lib/win32ioctl.c
117
lib/win32ioctl.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: win32ioctl.c,v 1.3 2004/02/05 03:02:16 rocky Exp $
|
$Id: win32ioctl.c,v 1.4 2004/03/03 02:41:18 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: win32ioctl.c,v 1.3 2004/02/05 03:02:16 rocky Exp $";
|
static const char _rcsid[] = "$Id: win32ioctl.c,v 1.4 2004/03/03 02:41:18 rocky Exp $";
|
||||||
|
|
||||||
#include <cdio/cdio.h>
|
#include <cdio/cdio.h>
|
||||||
#include <cdio/sector.h>
|
#include <cdio/sector.h>
|
||||||
@@ -46,6 +46,44 @@ static const char _rcsid[] = "$Id: win32ioctl.c,v 1.3 2004/02/05 03:02:16 rocky
|
|||||||
modify it a little.
|
modify it a little.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define SCSI_IOCTL_DATA_OUT 0 //Give data to SCSI device (e.g. for writing)
|
||||||
|
#define SCSI_IOCTL_DATA_IN 1 //Get data from SCSI device (e.g. for reading)
|
||||||
|
#define SCSI_IOCTL_DATA_UNSPECIFIED 2 //No data (e.g. for ejecting)
|
||||||
|
|
||||||
|
#define IOCTL_SCSI_PASS_THROUGH 0x4D004
|
||||||
|
typedef struct ScsiPassThrough {
|
||||||
|
unsigned short Length;
|
||||||
|
unsigned char ScsiStatus;
|
||||||
|
unsigned char PathId;
|
||||||
|
unsigned char TargetId;
|
||||||
|
unsigned char Lun;
|
||||||
|
unsigned char CdbLength;
|
||||||
|
unsigned char SenseInfoLength;
|
||||||
|
unsigned char DataIn;
|
||||||
|
unsigned int DataTransferLength;
|
||||||
|
unsigned int TimeOutValue;
|
||||||
|
unsigned int DataBufferOffset;
|
||||||
|
unsigned int SenseInfoOffset;
|
||||||
|
unsigned char Cdb[16];
|
||||||
|
} SCSI_PASS_THROUGH;
|
||||||
|
|
||||||
|
#define IOCTL_SCSI_PASS_THROUGH_DIRECT 0x4D014
|
||||||
|
typedef struct _SCSI_PASS_THROUGH_DIRECT {
|
||||||
|
USHORT Length;
|
||||||
|
UCHAR ScsiStatus;
|
||||||
|
UCHAR PathId;
|
||||||
|
UCHAR TargetId;
|
||||||
|
UCHAR Lun;
|
||||||
|
UCHAR CdbLength;
|
||||||
|
UCHAR SenseInfoLength;
|
||||||
|
UCHAR DataIn;
|
||||||
|
ULONG DataTransferLength;
|
||||||
|
ULONG TimeOutValue;
|
||||||
|
PVOID DataBuffer;
|
||||||
|
ULONG SenseInfoOffset;
|
||||||
|
UCHAR Cdb[16];
|
||||||
|
}SCSI_PASS_THROUGH_DIRECT, *PSCSI_PASS_THROUGH_DIRECT;
|
||||||
|
|
||||||
#ifndef IOCTL_CDROM_BASE
|
#ifndef IOCTL_CDROM_BASE
|
||||||
# define IOCTL_CDROM_BASE FILE_DEVICE_CD_ROM
|
# define IOCTL_CDROM_BASE FILE_DEVICE_CD_ROM
|
||||||
#endif
|
#endif
|
||||||
@@ -125,35 +163,34 @@ typedef struct _SUB_Q_MEDIA_CATALOG_NUMBER {
|
|||||||
|
|
||||||
#include "_cdio_win32.h"
|
#include "_cdio_win32.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Returns a string that can be used in a CreateFile call if
|
||||||
|
c_drive letter is a character. If not NULL is returned.
|
||||||
|
*/
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
win32ioctl_is_cdrom(const char drive_letter)
|
win32ioctl_is_cdrom(const char c_drive_letter)
|
||||||
{
|
{
|
||||||
static char psz_win32_drive[7];
|
|
||||||
static char root_path_name[8];
|
|
||||||
_img_private_t env;
|
|
||||||
|
|
||||||
/* Initializations */
|
UINT uDriveType;
|
||||||
env.h_device_handle = NULL;
|
char sz_win32_drive[5];
|
||||||
env.i_sid = 0;
|
DWORD dwAccessFlags;
|
||||||
env.hASPI = 0;
|
|
||||||
env.lpSendCommand = 0;
|
|
||||||
|
|
||||||
sprintf( psz_win32_drive, "\\\\.\\%c:", drive_letter );
|
sz_win32_drive[0]= c_drive_letter;
|
||||||
sprintf( root_path_name, "\\\\.\\%c:\\", drive_letter );
|
sz_win32_drive[1]=':';
|
||||||
|
sz_win32_drive[2]='\\';
|
||||||
|
sz_win32_drive[3]='\0';
|
||||||
|
|
||||||
env.h_device_handle = CreateFile( psz_win32_drive, GENERIC_READ,
|
uDriveType = GetDriveType(sz_win32_drive);
|
||||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
|
||||||
NULL, OPEN_EXISTING,
|
switch(uDriveType) {
|
||||||
FILE_FLAG_NO_BUFFERING |
|
case DRIVE_CDROM:
|
||||||
FILE_FLAG_RANDOM_ACCESS, NULL );
|
dwAccessFlags = GENERIC_READ | GENERIC_WRITE;
|
||||||
if (env.h_device_handle != NULL
|
return strdup(sz_win32_drive);
|
||||||
&& (DRIVE_CDROM == GetDriveType(root_path_name))) {
|
default:
|
||||||
CloseHandle(env.h_device_handle);
|
cdio_debug("Drive %c is not a CD-ROM", c_drive_letter);
|
||||||
return strdup(psz_win32_drive);
|
return NULL;
|
||||||
} else {
|
}
|
||||||
CloseHandle(env.h_device_handle);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -248,7 +285,7 @@ win32ioctl_init_win32 (_img_private_t *env)
|
|||||||
char psz_win32_drive[7];
|
char psz_win32_drive[7];
|
||||||
unsigned int len=strlen(env->gen.source_name);
|
unsigned int len=strlen(env->gen.source_name);
|
||||||
OSVERSIONINFO ov;
|
OSVERSIONINFO ov;
|
||||||
DWORD dwFlags;
|
DWORD dw_access_flags;
|
||||||
|
|
||||||
cdio_debug("using winNT/2K/XP ioctl layer");
|
cdio_debug("using winNT/2K/XP ioctl layer");
|
||||||
|
|
||||||
@@ -258,22 +295,30 @@ win32ioctl_init_win32 (_img_private_t *env)
|
|||||||
|
|
||||||
if((ov.dwPlatformId==VER_PLATFORM_WIN32_NT) &&
|
if((ov.dwPlatformId==VER_PLATFORM_WIN32_NT) &&
|
||||||
(ov.dwMajorVersion>4))
|
(ov.dwMajorVersion>4))
|
||||||
dwFlags = GENERIC_READ|GENERIC_WRITE; /* add gen write on W2k/XP */
|
dw_access_flags = GENERIC_READ|GENERIC_WRITE; /* add gen write on W2k/XP */
|
||||||
else dwFlags = GENERIC_READ;
|
else dw_access_flags = GENERIC_READ;
|
||||||
|
|
||||||
if (cdio_is_device_win32(env->gen.source_name)) {
|
if (cdio_is_device_win32(env->gen.source_name)) {
|
||||||
sprintf( psz_win32_drive, "\\\\.\\%c:", env->gen.source_name[len-2] );
|
sprintf( psz_win32_drive, "\\\\.\\%c:", env->gen.source_name[len-2] );
|
||||||
|
|
||||||
env->h_device_handle = CreateFile( psz_win32_drive, dwFlags,
|
env->h_device_handle = CreateFile( psz_win32_drive,
|
||||||
FILE_SHARE_READ, NULL, OPEN_EXISTING,
|
dw_access_flags,
|
||||||
0, NULL );
|
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
|
NULL,
|
||||||
|
OPEN_EXISTING,
|
||||||
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
|
NULL );
|
||||||
if( env->h_device_handle == INVALID_HANDLE_VALUE )
|
if( env->h_device_handle == INVALID_HANDLE_VALUE )
|
||||||
{
|
{
|
||||||
/* No good. try toggle write. */
|
/* No good. try toggle write. */
|
||||||
dwFlags ^= GENERIC_WRITE;
|
dw_access_flags ^= GENERIC_WRITE;
|
||||||
env->h_device_handle = CreateFile( psz_win32_drive, dwFlags,
|
env->h_device_handle = CreateFile( psz_win32_drive,
|
||||||
FILE_SHARE_READ, NULL,
|
dw_access_flags,
|
||||||
OPEN_EXISTING, 0, NULL );
|
FILE_SHARE_READ,
|
||||||
|
NULL,
|
||||||
|
OPEN_EXISTING,
|
||||||
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
|
NULL );
|
||||||
return (env->h_device_handle == NULL) ? false : true;
|
return (env->h_device_handle == NULL) ? false : true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user