I am writing a virtual disk driver for Windows XP, but I missed something,
and although generally my driver works, there are problems with read
and write in my driver.
The pseudocode is listed below. Irps to the my virtual disk is placed
by DriverDispatch routine in the driver internal list of irps and
processed later in the system thread.
The thing I couldn’t understand is that nSectors in some Irps is 0…
Such Irps with nSector = 0 is sent just after Irp with nSectors 0x7f. As
temporarily workaround I do next thing:
if( nSectors == 0x7f ) nSectors = 0x80
But it is not a good code… Could you please point me to the correct way of
processing SCSIOP_READ/SCSIOP_WRITE ?..
MySystemThread:
pBuffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
switch (pIrpStack->MajorFunction)
{
case IRP_MJ_SCSI:
srb = pIrpStack->Parameters.Scsi.Srb
if( srb->Function == SRB_FUNCTION_EXECUTE_SCSI )
{
if( pCdb->CDB6GENERIC.OperationCode == SCSIOP_READ )
{
pCdb = (PCDB)pSrb->Cdb;
StartSector = MakeLong( Cdb->CDB10.LogicalBlockByte0 … );
nSectors = MakeWord(Cdb->CDB10.TransferBlocksLsb …);
MyDeviceReadData( pBuffer, StartSector, nSectors )
}
}
}
–
WBR,
Dmitriy mailto:xxxxx@mail.ru
I use this piece of code:
// Calculating StartSector
REVERSE_BYTES(&StartSector, &Cdb->CDB10.LogicalBlockByte0);
// Calculating SectorCount
SectorCount = ( Cdb->CDB10.TransferBlocksMsb << 8 )+
Cdb->CDB10.TransferBlocksLsb;
It works for me. It’s possible the OS will read sector 0 after 7f.
Zoltan
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
Are you using *signed* integer values?.. 
Miguel Monteiro
xxxxx@criticalsoftware.com
----- Original Message -----
From: “Zoltan Csizmadia”
To: “NT Developers Interest List”
Sent: Thursday, April 04, 2002 5:29 PM
Subject: [ntdev] RE: WinXP SCSIOP_READ/WRITE Question
I use this piece of code:
// Calculating StartSector
REVERSE_BYTES(&StartSector, &Cdb->CDB10.LogicalBlockByte0);
// Calculating SectorCount
SectorCount = ( Cdb->CDB10.TransferBlocksMsb << 8 )+
Cdb->CDB10.TransferBlocksLsb;
It works for me. It’s possible the OS will read sector 0 after 7f.
Zoltan
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
—
You are currently subscribed to ntdev as: xxxxx@criticalsoftware.com
To unsubscribe send a blank email to %%email.unsub%%
Hi,
Below are macros I use for the same. You’d better show what your MakeWord
and MakeLong does. Do you care about reversed SCSI byte order?
Anton Kolomyeytsev
#define StarPort_GetNumberOfLBs( cdb ) ( cdb[2]
<< 24 | cdb[3] << 16 | cdb[4] << 8 | cdb[5] )
#define StarPort_GetIoTransferLength( cdb ) ( cdb[7] << 8 | cdb[8] )
Hello Dmitriy,
DS> The thing I couldn’t understand is that nSectors in some Irps is 0…
DS> Such Irps with nSector = 0 is sent just after Irp with nSectors 0x7f. As
DS> temporarily workaround I do next thing:
DS> if( nSectors == 0x7f ) nSectors = 0x80
DS> But it is not a good code… Could you please point me to the correct way of
DS> processing SCSIOP_READ/SCSIOP_WRITE ?..
If the code to reverse the byte order is OK, are you sure that your
structure is correctly packed?
–
Best Regards
Pierre Duhem
Logiciels & Services Duhem, Paris (France)
xxxxx@macdisk.com
Reading zero sectors is a completely valid thing to do. Try to return
success with zero as the number of bytes read and see if that fixes your
problem.
Jamey Kirby
StorageCraft, inc.
xxxxx@storagecraft.com
www.storagecraft.com
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Pierre Duhem
Sent: Friday, April 05, 2002 12:36 AM
To: NT Developers Interest List
Subject: [ntdev] Re: WinXP SCSIOP_READ/WRITE Question
Hello Dmitriy,
DS> The thing I couldn’t understand is that nSectors in some Irps is 0…
DS> Such Irps with nSector = 0 is sent just after Irp with nSectors
0x7f. As
DS> temporarily workaround I do next thing:
DS> if( nSectors == 0x7f ) nSectors = 0x80
DS> But it is not a good code… Could you please point me to the correct
way of
DS> processing SCSIOP_READ/SCSIOP_WRITE ?..
If the code to reverse the byte order is OK, are you sure that your
structure is correctly packed?
–
Best Regards
Pierre Duhem
Logiciels & Services Duhem, Paris (France)
xxxxx@macdisk.com
You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to %%email.unsub%%