Storage lower filter create new SRB and IRP

Hi All,

I have a special requirement, where one of my application as the User Mode level keep writing files to my USB device.

While the above file copy is in progress, in between a single file copy at the scsi commands level, I would like to send additional diagnostic/vendor specific scsi command (at the scsi command level) using a lower Filter Driver.

I am totally a beginner to Windows Driver Development and The help from the community will be highly appreciated.

I would also request help from MR Yassir M who has already posted in another thread the similar kind of development.

My email id is xxxxx@gmail.com and any help on this topic will be highly appreciated.

Thanks,
Thilak

Are you sure you need a filter driver to do this?

Have you considered what you can achieve using DeviceIoControl() from an application with control codes IOCTL_SCSI_PASS_THROUGH or IOCTL_SCSI_PASS_THROUGH_DIRECT?

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: 13 November 2017 11:55
To: Windows System Software Devs Interest List
Subject: [ntdev] Storage lower filter create new SRB and IRP

Hi All,

I have a special requirement, where one of my application as the User Mode level keep writing files to my USB device.

While the above file copy is in progress, in between a single file copy at the scsi commands level, I would like to send additional diagnostic/vendor specific scsi command (at the scsi command level) using a lower Filter Driver.

I am totally a beginner to Windows Driver Development and The help from the community will be highly appreciated.

I would also request help from MR Yassir M who has already posted in another thread the similar kind of development.

My email id is xxxxx@gmail.com and any help on this topic will be highly appreciated.

Thanks,
Thilak

Hi,

Thanks for your response. The reason for going ahead with lower filter
driver is my windows application is dealing at file system level and I
don’t have the source code for the same.

my WIndows application is keep on writing files to my USB device. When a
single file write is happening it is split by driver in to multiple scsi
Write(10) commands before sending to the device.

For example suppose file x write is being done using 10 Scsi (write 10)
commands. I want to send the diagnostic in between after 5th scsi command
for this file.

Do you think that this can be done by using DeviceIoControl() from an
application with control codes IOCTL_SCSI_PASS_THROUGH or
IOCTL_SCSI_PASS_THROUGH_DIRECT?

Please provide more inputs on the same. Really appreciate your help.

Thanks

On Mon, Nov 13, 2017 at 8:09 PM, xxxxx@becrypt.com
wrote:

> Are you sure you need a filter driver to do this?
>
> Have you considered what you can achieve using DeviceIoControl() from an
> application with control codes IOCTL_SCSI_PASS_THROUGH or
> IOCTL_SCSI_PASS_THROUGH_DIRECT?
>
> -----Original Message-----
> From: xxxxx@lists.osr.com [mailto:bounce-641554-159614@
> lists.osr.com] On Behalf Of xxxxx@gmail.com
> Sent: 13 November 2017 11:55
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Storage lower filter create new SRB and IRP
>
> Hi All,
>
> I have a special requirement, where one of my application as the User Mode
> level keep writing files to my USB device.
>
> While the above file copy is in progress, in between a single file copy at
> the scsi commands level, I would like to send additional diagnostic/vendor
> specific scsi command (at the scsi command level) using a lower Filter
> Driver.
>
> I am totally a beginner to Windows Driver Development and The help from
> the community will be highly appreciated.
>
> I would also request help from MR Yassir M who has already posted in
> another thread the similar kind of development.
>
> My email id is xxxxx@gmail.com and any help on this topic will be
> highly appreciated.
>
> Thanks,
> Thilak
>
>
> ------------------------------
> This email message has been delivered safely and archived online by
> Mimecast.
> For more information please visit http://www.mimecast.com
> ------------------------------
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:> showlists.cfm?list=ntdev>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
></http:></http:>

With all due respect, your requirement sounds crazy.

On Nov 13, 2017, at 6:46 PM, xxxxx@gmail.com wrote:
>
> Thanks for your response. The reason for going ahead with lower filter driver is my windows application is dealing at file system level and I don’t have the source code for the same.

The same what? You’re trying to interfere with an application that you don’t own?

> my WIndows application is keep on writing files to my USB device. When a single file write is happening it is split by driver in to multiple scsi Write(10) commands before sending to the device.

Right, as required by the spec.

> For example suppose file x write is being done using 10 Scsi (write 10) commands. I want to send the diagnostic in between after 5th scsi command for this file.

Why? What do you hope to learn? This is is the part that seems crazy. What do you hope to accomplish? For performance reasons, those write commands are all stacked up and submitted at once. If you require the device to block after every 5 block writes, your performance will go into the toilet.

> Do you think that this can be done by using DeviceIoControl() from an application with control codes IOCTL_SCSI_PASS_THROUGH or IOCTL_SCSI_PASS_THROUGH_DIRECT?

The application that is doing the writing certainly could. Write a chunk, submit an ioctl, write a chunk, submit an ioctl. However, if you can’t modify the application, then it can’t be done at a user-mode level.

> Please provide more inputs on the same.

The same what?

Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Tim Roberts wrote:

> Please provide more inputs on the same.

The same what?

I believe this is a “subcontinental” figure of speech, as in, “please guide me in the same”…

> With all due respect, your requirement sounds crazy.

Well, we were all inexperienced once,right…

Anton Bassov

> For example suppose file x write is being done using 10 Scsi (write = 10) commands. I want to send the diagnostic in between after 5th scsi = command for this file.

Tom -> Why? What do you hope to learn? This is is the part that seems crazy. = What do you hope to accomplish? For performance reasons, those write = commands are all stacked up and submitted at once. If you require the = device to block after every 5 block writes, your performance will go = into the toilet.

Hi Tom,

This requirement is mainly for testing/debug purpose and performance degradation is not an issue and it is already considered.

The main use of this requirement is, for example due to some device firmware issue file write got stuck after transferring 5 scsi write(10) blocks and file write is not completed. In this case if we would have sent Diagnostic, the reply from Diagnostic (device data) will help FW engineers to debug device issue. Main idea behind this requirement is for USB FW debugging purpose in case if some read/write operation got stuck in between.

Thanks,
Thilak

On Nov 14, 2017, at 7:09 PM, xxxxx@gmail.com wrote:
>
>> For example suppose file x write is being done using 10 Scsi (write = 10) commands. I want to send the diagnostic in between after 5th scsi = command for this file.
>
> Hi Tom,

Tim.

> This requirement is mainly for testing/debug purpose and performance degradation is not an issue and it is already considered.
>
> The main use of this requirement is, for example due to some device firmware issue file write got stuck after transferring 5 scsi write(10) blocks and file write is not completed. In this case if we would have sent Diagnostic, the reply from Diagnostic (device data) will help FW engineers to debug device issue. Main idea behind this requirement is for USB FW debugging purpose in case if some read/write operation got stuck in between.

If the write stalls, couldn’t you submit the diagnostic request from a user-mode app at any time after the stall?

Alternatively, couldn’t you write a short app to simulate the failing transaction and then request the diagnostic?

Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

If you don’t care about which file is doing the write, then yes you can
create an SRB IRP in your filter driver to emit the diagnostic SRB for
every 5th SRB Write operation your filter observes. Use the disk driver
sample code to learn how to construct an SRB IRP.

Mark Roddy

On Tue, Nov 14, 2017 at 10:09 PM, xxxxx@gmail.com
wrote:

> > For example suppose file x write is being done using 10 Scsi (write =
> 10) commands. I want to send the diagnostic in between after 5th scsi =
> command for this file.
>
> Tom -> Why? What do you hope to learn? This is is the part that seems
> crazy. = What do you hope to accomplish? For performance reasons, those
> write = commands are all stacked up and submitted at once. If you require
> the = device to block after every 5 block writes, your performance will go
> = into the toilet.
>
> Hi Tom,
>
> This requirement is mainly for testing/debug purpose and performance
> degradation is not an issue and it is already considered.
>
> The main use of this requirement is, for example due to some device
> firmware issue file write got stuck after transferring 5 scsi write(10)
> blocks and file write is not completed. In this case if we would have sent
> Diagnostic, the reply from Diagnostic (device data) will help FW engineers
> to debug device issue. Main idea behind this requirement is for USB FW
> debugging purpose in case if some read/write operation got stuck in between.
>
> Thanks,
> Thilak
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:> showlists.cfm?list=ntdev>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
></http:></http:>

Hi Mark Roddy,

Thanks a lot for the information. Yes we don’t care about which file is
doing write. Could you please guide me on where to get disk driver sample
code and how to build the driver code and constructing an SRB IRP… I am
sorry for asking upto this level. Because I am totally new to Driver
development.

My email id is thilakcitatgmailcom. I have used at for @.

Thanks,
Thilak

On Wed, Nov 15, 2017 at 9:30 PM, xxxxx@gmail.com > wrote:

> If you don’t care about which file is doing the write, then yes you can
> create an SRB IRP in your filter driver to emit the diagnostic SRB for
> every 5th SRB Write operation your filter observes. Use the disk driver
> sample code to learn how to construct an SRB IRP.
>
> Mark Roddy
>
> On Tue, Nov 14, 2017 at 10:09 PM, xxxxx@gmail.com > > wrote:
>
>> > For example suppose file x write is being done using 10 Scsi (write =
>> 10) commands. I want to send the diagnostic in between after 5th scsi =
>> command for this file.
>>
>> Tom -> Why? What do you hope to learn? This is is the part that seems
>> crazy. = What do you hope to accomplish? For performance reasons, those
>> write = commands are all stacked up and submitted at once. If you require
>> the = device to block after every 5 block writes, your performance will go
>> = into the toilet.
>>
>> Hi Tom,
>>
>> This requirement is mainly for testing/debug purpose and performance
>> degradation is not an issue and it is already considered.
>>
>> The main use of this requirement is, for example due to some device
>> firmware issue file write got stuck after transferring 5 scsi write(10)
>> blocks and file write is not completed. In this case if we would have sent
>> Diagnostic, the reply from Diagnostic (device data) will help FW engineers
>> to debug device issue. Main idea behind this requirement is for USB FW
>> debugging purpose in case if some read/write operation got stuck in between.
>>
>> Thanks,
>> Thilak
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> Visit the list online at: http:>> lists.cfm?list=ntdev>
>>
>> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
>> software drivers!
>> Details at http:
>>
>> To unsubscribe, visit the List Server section of OSR Online at <
>> http://www.osronline.com/page.cfm?name=ListServer&gt;
>>
>
> — NTDEV is sponsored by OSR Visit the list online at: MONTHLY seminars
> on crash dump analysis, WDF, Windows internals and software drivers!
> Details at To unsubscribe, visit the List Server section of OSR Online at</http:></http:>

On github here:
https://github.com/Microsoft/Windows-driver-samples/tree/master/storage/class

Mark Roddy

On Wed, Nov 15, 2017 at 9:33 PM, xxxxx@gmail.com
wrote:

> Hi Mark Roddy,
>
> Thanks a lot for the information. Yes we don’t care about which file is
> doing write. Could you please guide me on where to get disk driver sample
> code and how to build the driver code and constructing an SRB IRP… I am
> sorry for asking upto this level. Because I am totally new to Driver
> development.
>
> My email id is thilakcitatgmailcom. I have used at for @.
>
> Thanks,
> Thilak
>
> On Wed, Nov 15, 2017 at 9:30 PM, xxxxx@gmail.com <
> xxxxx@lists.osr.com> wrote:
>
>> If you don’t care about which file is doing the write, then yes you can
>> create an SRB IRP in your filter driver to emit the diagnostic SRB for
>> every 5th SRB Write operation your filter observes. Use the disk driver
>> sample code to learn how to construct an SRB IRP.
>>
>> Mark Roddy
>>
>> On Tue, Nov 14, 2017 at 10:09 PM, xxxxx@gmail.com <
>> xxxxx@lists.osr.com> wrote:
>>
>>> > For example suppose file x write is being done using 10 Scsi (write =
>>> 10) commands. I want to send the diagnostic in between after 5th scsi =
>>> command for this file.
>>>
>>> Tom -> Why? What do you hope to learn? This is is the part that seems
>>> crazy. = What do you hope to accomplish? For performance reasons, those
>>> write = commands are all stacked up and submitted at once. If you require
>>> the = device to block after every 5 block writes, your performance will go
>>> = into the toilet.
>>>
>>> Hi Tom,
>>>
>>> This requirement is mainly for testing/debug purpose and performance
>>> degradation is not an issue and it is already considered.
>>>
>>> The main use of this requirement is, for example due to some device
>>> firmware issue file write got stuck after transferring 5 scsi write(10)
>>> blocks and file write is not completed. In this case if we would have sent
>>> Diagnostic, the reply from Diagnostic (device data) will help FW engineers
>>> to debug device issue. Main idea behind this requirement is for USB FW
>>> debugging purpose in case if some read/write operation got stuck in between.
>>>
>>> Thanks,
>>> Thilak
>>>
>>> —
>>> NTDEV is sponsored by OSR
>>>
>>> Visit the list online at: http:>>> lists.cfm?list=ntdev>
>>>
>>> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
>>> software drivers!
>>> Details at http:
>>>
>>> To unsubscribe, visit the List Server section of OSR Online at <
>>> http://www.osronline.com/page.cfm?name=ListServer&gt;
>>>
>>
>> — NTDEV is sponsored by OSR Visit the list online at: MONTHLY seminars
>> on crash dump analysis, WDF, Windows internals and software drivers!
>> Details at To unsubscribe, visit the List Server section of OSR Online
>> at
>
>
> — NTDEV is sponsored by OSR Visit the list online at: MONTHLY seminars
> on crash dump analysis, WDF, Windows internals and software drivers!
> Details at To unsubscribe, visit the List Server section of OSR Online at</http:></http:>

Hi,

Thanks a lot Mark Roddy… I want to build this sample driver in Windows 7
OS 64 bit systems with WDK 7.1. Whatever has been explained in the github
Readme page is for Windows 10, WDK 10 etc.

Kindly help me on how to build this driver sample code in Windows 7 Os 64
bit System, with WDK 7.1

Thanks,
Thilak

On Thu, Nov 16, 2017 at 7:59 PM, xxxxx@gmail.com > wrote:

> On github here: https://github.com/Microsoft/Windows-driver-
> samples/tree/master/storage/class
>
>
> Mark Roddy
>
> On Wed, Nov 15, 2017 at 9:33 PM, xxxxx@gmail.com
> wrote:
>
>> Hi Mark Roddy,
>>
>> Thanks a lot for the information. Yes we don’t care about which file
>> is doing write. Could you please guide me on where to get disk driver
>> sample code and how to build the driver code and constructing an SRB IRP…
>> I am sorry for asking upto this level. Because I am totally new to Driver
>> development.
>>
>> My email id is thilakcitatgmailcom. I have used at for @.
>>
>> Thanks,
>> Thilak
>>
>> On Wed, Nov 15, 2017 at 9:30 PM, xxxxx@gmail.com <
>> xxxxx@lists.osr.com> wrote:
>>
>>> If you don’t care about which file is doing the write, then yes you can
>>> create an SRB IRP in your filter driver to emit the diagnostic SRB for
>>> every 5th SRB Write operation your filter observes. Use the disk driver
>>> sample code to learn how to construct an SRB IRP.
>>>
>>> Mark Roddy
>>>
>>> On Tue, Nov 14, 2017 at 10:09 PM, xxxxx@gmail.com <
>>> xxxxx@lists.osr.com> wrote:
>>>
>>>> > For example suppose file x write is being done using 10 Scsi (write =
>>>> 10) commands. I want to send the diagnostic in between after 5th scsi =
>>>> command for this file.
>>>>
>>>> Tom -> Why? What do you hope to learn? This is is the part that seems
>>>> crazy. = What do you hope to accomplish? For performance reasons, those
>>>> write = commands are all stacked up and submitted at once. If you require
>>>> the = device to block after every 5 block writes, your performance will go
>>>> = into the toilet.
>>>>
>>>> Hi Tom,
>>>>
>>>> This requirement is mainly for testing/debug purpose and performance
>>>> degradation is not an issue and it is already considered.
>>>>
>>>> The main use of this requirement is, for example due to some device
>>>> firmware issue file write got stuck after transferring 5 scsi write(10)
>>>> blocks and file write is not completed. In this case if we would have sent
>>>> Diagnostic, the reply from Diagnostic (device data) will help FW engineers
>>>> to debug device issue. Main idea behind this requirement is for USB FW
>>>> debugging purpose in case if some read/write operation got stuck in between.
>>>>
>>>> Thanks,
>>>> Thilak
>>>>
>>>> —
>>>> NTDEV is sponsored by OSR
>>>>
>>>> Visit the list online at: http:>>>> lists.cfm?list=ntdev>
>>>>
>>>> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
>>>> software drivers!
>>>> Details at http:
>>>>
>>>> To unsubscribe, visit the List Server section of OSR Online at <
>>>> http://www.osronline.com/page.cfm?name=ListServer&gt;
>>>>
>>>
>>> — NTDEV is sponsored by OSR Visit the list online at: MONTHLY
>>> seminars on crash dump analysis, WDF, Windows internals and software
>>> drivers! Details at To unsubscribe, visit the List Server section of
>>> OSR Online at
>>
>>
>> — NTDEV is sponsored by OSR Visit the list online at: MONTHLY seminars
>> on crash dump analysis, WDF, Windows internals and software drivers!
>> Details at To unsubscribe, visit the List Server section of OSR Online
>> at
>
>
> — NTDEV is sponsored by OSR Visit the list online at: MONTHLY seminars
> on crash dump analysis, WDF, Windows internals and software drivers!
> Details at To unsubscribe, visit the List Server section of OSR Online at
></http:></http:>

xxxxx@gmail.com wrote:

Thanks a lot Mark Roddy… I want to build this sample driver in
Windows 7 OS 64 bit systems with WDK 7.1.  Whatever has been explained
in the github Readme page is for Windows 10, WDK 10 etc.

Kindly help me on how to build this driver sample code in Windows 7 Os
64 bit System, with WDK 7.1

This post annoys me, because it tells me you have not even tried one
little bit to solve your problem on your own.

The storage\class sample is INCLUDED in the 7.1 WDK.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Hi Thilak,

With every WDK there are sample given by Microsoft when you install WDK 7.1
(https://www.microsoft.com/en-in/download/details.aspx?id=11800) here is
ISO.
Before sending basic question you should atleast try by yourself.

If you are so new ask your management to take training on Windows device
Driver (however scope is getting very limited), otherwise switch the job to
new (machine Learning, NLP or something)

Regards,
Rabish

On Fri, Nov 17, 2017 at 12:13 PM, xxxxx@gmail.com
wrote:

> Hi,
>
> Thanks a lot Mark Roddy… I want to build this sample driver in Windows 7
> OS 64 bit systems with WDK 7.1. Whatever has been explained in the github
> Readme page is for Windows 10, WDK 10 etc.
>
> Kindly help me on how to build this driver sample code in Windows 7 Os 64
> bit System, with WDK 7.1
>
> Thanks,
> Thilak
>
> On Thu, Nov 16, 2017 at 7:59 PM, xxxxx@gmail.com <
> xxxxx@lists.osr.com> wrote:
>
>> On github here: https://github.com/Microsoft/Windows-driver-samples/
>> tree/master/storage/class
>>
>>
>> Mark Roddy
>>
>> On Wed, Nov 15, 2017 at 9:33 PM, xxxxx@gmail.com >> > wrote:
>>
>>> Hi Mark Roddy,
>>>
>>> Thanks a lot for the information. Yes we don’t care about which file
>>> is doing write. Could you please guide me on where to get disk driver
>>> sample code and how to build the driver code and constructing an SRB IRP…
>>> I am sorry for asking upto this level. Because I am totally new to Driver
>>> development.
>>>
>>> My email id is thilakcitatgmailcom. I have used at for @.
>>>
>>> Thanks,
>>> Thilak
>>>
>>> On Wed, Nov 15, 2017 at 9:30 PM, xxxxx@gmail.com <
>>> xxxxx@lists.osr.com> wrote:
>>>
>>>> If you don’t care about which file is doing the write, then yes you can
>>>> create an SRB IRP in your filter driver to emit the diagnostic SRB for
>>>> every 5th SRB Write operation your filter observes. Use the disk driver
>>>> sample code to learn how to construct an SRB IRP.
>>>>
>>>> Mark Roddy
>>>>
>>>> On Tue, Nov 14, 2017 at 10:09 PM, xxxxx@gmail.com <
>>>> xxxxx@lists.osr.com> wrote:
>>>>
>>>>> > For example suppose file x write is being done using 10 Scsi (write
>>>>> = 10) commands. I want to send the diagnostic in between after 5th scsi =
>>>>> command for this file.
>>>>>
>>>>> Tom -> Why? What do you hope to learn? This is is the part that seems
>>>>> crazy. = What do you hope to accomplish? For performance reasons, those
>>>>> write = commands are all stacked up and submitted at once. If you require
>>>>> the = device to block after every 5 block writes, your performance will go
>>>>> = into the toilet.
>>>>>
>>>>> Hi Tom,
>>>>>
>>>>> This requirement is mainly for testing/debug purpose and
>>>>> performance degradation is not an issue and it is already considered.
>>>>>
>>>>> The main use of this requirement is, for example due to some device
>>>>> firmware issue file write got stuck after transferring 5 scsi write(10)
>>>>> blocks and file write is not completed. In this case if we would have sent
>>>>> Diagnostic, the reply from Diagnostic (device data) will help FW engineers
>>>>> to debug device issue. Main idea behind this requirement is for USB FW
>>>>> debugging purpose in case if some read/write operation got stuck in between.
>>>>>
>>>>> Thanks,
>>>>> Thilak
>>>>>
>>>>> —
>>>>> NTDEV is sponsored by OSR
>>>>>
>>>>> Visit the list online at: http:>>>>> lists.cfm?list=ntdev>
>>>>>
>>>>> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
>>>>> software drivers!
>>>>> Details at http:
>>>>>
>>>>> To unsubscribe, visit the List Server section of OSR Online at <
>>>>> http://www.osronline.com/page.cfm?name=ListServer&gt;
>>>>>
>>>>
>>>> — NTDEV is sponsored by OSR Visit the list online at: MONTHLY
>>>> seminars on crash dump analysis, WDF, Windows internals and software
>>>> drivers! Details at To unsubscribe, visit the List Server section of
>>>> OSR Online at
>>>
>>>
>>> — NTDEV is sponsored by OSR Visit the list online at: MONTHLY
>>> seminars on crash dump analysis, WDF, Windows internals and software
>>> drivers! Details at To unsubscribe, visit the List Server section of
>>> OSR Online at
>>
>>
>> — NTDEV is sponsored by OSR Visit the list online at: MONTHLY seminars
>> on crash dump analysis, WDF, Windows internals and software drivers!
>> Details at To unsubscribe, visit the List Server section of OSR Online
>> at
>>
>
> — NTDEV is sponsored by OSR Visit the list online at: MONTHLY seminars
> on crash dump analysis, WDF, Windows internals and software drivers!
> Details at To unsubscribe, visit the List Server section of OSR Online at
></http:></http:>

1 Like