At 14:12 11/04/2011, xxxxx@Yahoo.com wrote:
I have a few more questions:
-
Is it absolutely necessary to have WMI related code as implemented
in diskperf? OR
-
Can i take out all the WMI related code/functions/callbacks and
simply pass the request on to the next lower driver in the handler
for IRP_MJ_SYSTEM_CONTROL?
DiskPerf is an example provided in the WDK, the WMI code is there to
show that the sample does something useful. Samples are there for
you to take what you need and to discard the rest. I do suggest that
you don’t delete huge chunks of code in case you delete something you
actually need. Proceed slowly.
>> In the upper filter, you should be able to retrieve ByteOffsets from
IRP_MJ_READ/IRP_MJ_WRITE.
Can you please explain this point further? Do you mean that in upper
filter, ByteOffsets represents/lead to LBA? Sorry i did not get this point.
That all depends on what type of filter it is. DiskPerf can be
installed as either a volume or a disk filter. Read and Write IRPs
have an offset value in bytes in the stack location. For a volume
filter this value is a logical offset in to the volume. As a disk
filter the value is a physical offset on the disk.
Mapping the offset value in a disk to an LBA is quite simple, just
divide by 512 since all reads and writes will be multiples of 512 bytes.
Mapping the volume offset to a disk and an LBA requires understanding
what disks and partitions the volume is located on, there are ioctls
you can use to discover this information.
>> I didn’t quite follow what you mean by “other necessary IRPs i
must handle”?
I was referring to providing handlers for major entry points (for
example IRP_MJ_CREATE,
IRP_MJ_DEVICE_CONTROL etc). I was not sure which one do i absolutely
need to have for a working class filter driver. I thought may be
there are some IRPs that are handled only to achieve diskperf
functionality and can be removed.
>> In that case you will have to write a handler for IRP_MJ_SCSI and then
decode the SRB to get the LBA.
I went throught the SCSI_REQUEST_BLOCK structure at the following link.
http://msdn.microsoft.com/en-us/library/ff565393(VS.85).aspx
Can you please point out what members do i need to decode to get LBA?
You need to read the CDB. The Windows SRB is simply Microsoft’s
wrapper for the SCSI CDB, which is the SCSI command block that
devices actually understand and decode. You’ll need to get the
latest version of the spec from T.10 - SCSI Block Commands (www.t10.org).
Specifically you’ll at least want to decode READ6, READ10, READ16,
WRITE6, WRITE10, WRITE16 and maybe some others (it’s a long time
since I played down here).
Mark