Gathering IRP_MJ_SCSI

Dear People,

Is it possible that a driver that IS NOT a SCSI miniport can dispatch IRP_MJ_SCSI?

For example:

DriverObject->MajorFunction[IRP_MJ_SCSI] = ScsiHandler;

in order to get SRB COMMAND requested and process OperationCode SCSIOP_WRITE o SCSIOP_READ?

Thanks in advance,

Christian D’Orazio

First if you look at wdm.h you will see:

#define IRP_MJ_SCSI IRP_MJ_INTERNAL_DEVICE_CONTROL

So yes you can get SCSI requests if you can convince the driver sending
them to do so.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

wrote in message news:xxxxx@ntdev…
> Dear People,
>
> Is it possible that a driver that IS NOT a SCSI miniport can dispatch
> IRP_MJ_SCSI?
>
> For example:
>
> DriverObject->MajorFunction[IRP_MJ_SCSI] = ScsiHandler;
>
> in order to get SRB COMMAND requested and process OperationCode
> SCSIOP_WRITE o SCSIOP_READ?
>
> Thanks in advance,
>
> Christian D’Orazio
>

Thanks for replying, but ScsiHandler is never called. I use some LOGs in order to be sure it is called or not, but the code there is never executed.

I developed a driver to mount a Virtual CDDA from a BIN file and I can play the sound in WMPlayer, PowerDVD, and some other programs that send IOCTL_CDROM_RAW_READ to my driver, but when I try to play the songs in Winamp, there is no sound. So, I suppose Winamp connect with some SCSI device which sends SRB commands, and that is why I want to get them in my driver, but ScsiHandler is never called.

Is it actually possible to get them if my driver is not a SCSI miniport? I cannot do it.

The code is the following:


DriverObject->MajorFunction[IRP_MJ_CREATE] = VikingCDCreateClose;
DriverObject->MajorFunction[IRP_MJ_SCSI] = VikingCDScsiHandler;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = VikingCDDeviceControl;


NTSTATUS VikingCDScsiHandler(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
{
PVIKINGCD_EXTENSION diskExtension;
PIO_STACK_LOCATION Stack;
PSCSI_REQUEST_BLOCK Srb;
NTSTATUS Status;

PIO_STACK_LOCATION irpSp;
NTSTATUS ntStatus;

diskExtension = DeviceObject->DeviceExtension;

irpSp = IoGetCurrentIrpStackLocation( Irp );

Stack = IoGetCurrentIrpStackLocation(Irp);
Srb = Stack->Parameters.Scsi.Srb;

VikingCDLogS(“SCSI HERE”);

if (Srb->Function == SRB_FUNCTION_EXECUTE_SCSI)
{
PCDB Cdb = (PCDB)Srb->Cdb;

VikingCDLogS(“SCSI EXECUTE”);
switch (Cdb->CDB10.OperationCode)
{
case SCSIOP_READ:
VikingCDLogS(“READING SCSI”);
break;

case SCSIOP_WRITE:
VikingCDLogS(“WRITING SCSI”);
break;

default:
VikingCDLogSL("Cdb->CDB10.OperationCode = ", (ULONG) irpSp->Parameters.DeviceIoControl.IoControlCode);
//DPRINT(“Cdb->CDB10.OperationCode = %x”, Cdb->CDB10.OperationCode);
IoSkipCurrentIrpStackLocation(Irp);
Status = IoCallDriver(diskExtension->DeviceObject, Irp);
}
}

return Status;
}

Does anyone have some idea?

Thanks in advance,

Christian D’Orazio

You cannot take class driver, add IRP_MJ_SCSI handler and get fully functional SCSI port. There’s a long way to go…

Take a look at toaster sample from the DDK. This is the core driver you need to add IRP_MJ_SCSI processing and right
properties reporting thru the PnP handlers to get what you want.

-a

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com.ar
Sent: Saturday, August 04, 2007 11:09 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Gathering IRP_MJ_SCSI

Thanks for replying, but ScsiHandler is never called. I use some LOGs in order to be sure it is called or not, but the code there is never executed.

I developed a driver to mount a Virtual CDDA from a BIN file and I can play the sound in WMPlayer, PowerDVD, and some other programs that send IOCTL_CDROM_RAW_READ to my driver, but when I try to play the songs in Winamp, there is no sound. So, I suppose Winamp connect with some SCSI device which sends SRB commands, and that is why I want to get them in my driver, but ScsiHandler is never called.

Is it actually possible to get them if my driver is not a SCSI miniport? I cannot do it.

The code is the following:


DriverObject->MajorFunction[IRP_MJ_CREATE] = VikingCDCreateClose;
DriverObject->MajorFunction[IRP_MJ_SCSI] = VikingCDScsiHandler;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = VikingCDDeviceControl;


NTSTATUS VikingCDScsiHandler(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
{
PVIKINGCD_EXTENSION diskExtension;
PIO_STACK_LOCATION Stack;
PSCSI_REQUEST_BLOCK Srb;
NTSTATUS Status;

PIO_STACK_LOCATION irpSp;
NTSTATUS ntStatus;

diskExtension = DeviceObject->DeviceExtension;

irpSp = IoGetCurrentIrpStackLocation( Irp );

Stack = IoGetCurrentIrpStackLocation(Irp);
Srb = Stack->Parameters.Scsi.Srb;

VikingCDLogS(“SCSI HERE”);

if (Srb->Function == SRB_FUNCTION_EXECUTE_SCSI)
{
PCDB Cdb = (PCDB)Srb->Cdb;

VikingCDLogS(“SCSI EXECUTE”);
switch (Cdb->CDB10.OperationCode)
{
case SCSIOP_READ:
VikingCDLogS(“READING SCSI”);
break;

case SCSIOP_WRITE:
VikingCDLogS(“WRITING SCSI”);
break;

default:
VikingCDLogSL("Cdb->CDB10.OperationCode = ", (ULONG) irpSp->Parameters.DeviceIoControl.IoControlCode);
//DPRINT(“Cdb->CDB10.OperationCode = %x”, Cdb->CDB10.OperationCode);
IoSkipCurrentIrpStackLocation(Irp);
Status = IoCallDriver(diskExtension->DeviceObject, Irp);
}
}

return Status;
}

Does anyone have some idea?

Thanks in advance,

Christian D’Orazio


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Thanks Anton,

I took at look at Toaster, but it didn’t include IRP_MJ_SCSI handler, so I have no idea how to add this in order to dispach it in my driver. Is there any example which shows clearly how to support IRP_MJ_SCSI in a NOT miniport driver?

I’m taking a look on the Internet but all examples are miniport drivers.

Thanks in advance.

Christian D’Orazio

No. Monolithic SCSI ports are neither supported not blessed by Microsoft. You’ll
not find any samples of the full blown SCSI port in the Internet. Search this forum
archives and prepare do quite a lot of work.

-a

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com.ar
Sent: Sunday, August 05, 2007 10:17 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Gathering IRP_MJ_SCSI

Thanks Anton,

I took at look at Toaster, but it didn’t include IRP_MJ_SCSI handler, so I have no idea how to add this in order to dispach it in my driver. Is there any example which shows clearly how to support IRP_MJ_SCSI in a NOT miniport driver?

I’m taking a look on the Internet but all examples are miniport drivers.

Thanks in advance.

Christian D’Orazio


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

The problem is not in implementing a dispatch handler for IRP_MJ_SCSI the problem is getting other drivers to send IRP_MJ_SCSI IRPs to your device. I think you have already been told that, but you appear to have brushed this advice off. To receive these requests your device needs to appear to the system as some sort of scsi device.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-296428-
xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com.ar
Sent: Sunday, August 05, 2007 3:17 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Gathering IRP_MJ_SCSI

Thanks Anton,

I took at look at Toaster, but it didn’t include IRP_MJ_SCSI handler,
so I have no idea how to add this in order to dispach it in my driver.
Is there any example which shows clearly how to support IRP_MJ_SCSI in
a NOT miniport driver?

I’m taking a look on the Internet but all examples are miniport
drivers.

Thanks in advance.

Christian D’Orazio


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer