diff --git a/reactos/drivers/storage/cdrom/cdrom.c b/reactos/drivers/storage/cdrom/cdrom.c index a202109e83c..84801952ab1 100644 --- a/reactos/drivers/storage/cdrom/cdrom.c +++ b/reactos/drivers/storage/cdrom/cdrom.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: cdrom.c,v 1.15 2002/09/15 22:19:16 hbirr Exp $ +/* $Id: cdrom.c,v 1.16 2002/09/17 20:35:21 hbirr Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -552,6 +552,32 @@ CdromClassReadTocEntry(PDEVICE_OBJECT DeviceObject, UINT TrackNo, PVOID Buffer, FALSE); } +static NTSTATUS +CdromClassReadLastSession(PDEVICE_OBJECT DeviceObject, UINT TrackNo, PVOID Buffer, UINT Length) +{ + PDEVICE_EXTENSION DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension; + SCSI_REQUEST_BLOCK Srb; + PCDB Cdb; + + RtlZeroMemory(&Srb, sizeof(SCSI_REQUEST_BLOCK)); + Srb.CdbLength = 10; + Srb.TimeOutValue = DeviceExtension->TimeOutValue; + + Cdb = (PCDB)Srb.Cdb; + Cdb->READ_TOC.OperationCode = SCSIOP_READ_TOC; + Cdb->READ_TOC.StartingTrack = TrackNo; + Cdb->READ_TOC.Format = 1; + Cdb->READ_TOC.AllocationLength[0] = Length >> 8; + Cdb->READ_TOC.AllocationLength[1] = Length & 0xff; + Cdb->READ_TOC.Msf = 0; + + return ScsiClassSendSrbSynchronous(DeviceObject, + &Srb, + Buffer, + Length, + FALSE); +} + /********************************************************************** * NAME EXPORTED * CdromClassDeviceControl @@ -661,6 +687,25 @@ CdromClassDeviceControl(IN PDEVICE_OBJECT DeviceObject, } } break; + case IOCTL_CDROM_GET_LAST_SESSION: + DPRINT("IOCTL_CDROM_GET_LAST_SESSION\n"); + if (IrpStack->Parameters.DeviceIoControl.OutputBufferLength < 4 + sizeof(TRACK_DATA)) + { + Status = STATUS_INFO_LENGTH_MISMATCH; + } + else + { + USHORT Length; + PCDROM_TOC TocBuffer = Irp->AssociatedIrp.SystemBuffer; + + Length = 4 + sizeof(TRACK_DATA); + Status = CdromClassReadLastSession(DeviceObject, 0, TocBuffer, Length); + if (NT_SUCCESS(Status)) + { + Information = Length; + } + } + break; default: /* Call the common device control function */ return(ScsiClassDeviceControl(DeviceObject, Irp)); diff --git a/reactos/include/ntos/cdrom.h b/reactos/include/ntos/cdrom.h index 3dc5c8d3afb..4fd8f402808 100644 --- a/reactos/include/ntos/cdrom.h +++ b/reactos/include/ntos/cdrom.h @@ -1,4 +1,4 @@ -/* $Id: cdrom.h,v 1.2 2002/09/15 22:19:16 hbirr Exp $ +/* $Id: cdrom.h,v 1.3 2002/09/17 20:35:22 hbirr Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -13,6 +13,7 @@ #define __INCLUDE_NTOS_CDROM_H #define IOCTL_CDROM_READ_TOC CTL_CODE(FILE_DEVICE_CD_ROM, 0x0000, METHOD_BUFFERED, FILE_READ_ACCESS) +#define IOCTL_CDROM_GET_LAST_SESSION CTL_CODE(FILE_DEVICE_CD_ROM, 0x000E, METHOD_BUFFERED, FILE_READ_ACCESS) #define IOCTL_CDROM_GET_DRIVE_GEOMETRY CTL_CODE(FILE_DEVICE_CD_ROM, 0x0013, METHOD_BUFFERED, FILE_READ_ACCESS) #define MAXIMUM_NUMBER_TRACKS 100