Writing a FileDisk Driver

Hi,

I am attempting to write a filedisk driver.
Reading from the list I understand that there are 2
approaches to do this.

One, is to write a port/miniport driver or write a
PnP bus driver that will create a PDO for the disk
driver(disk.sys) lying above.

Considering the second approach,
how can I create a PDO in my driver code and
how do I get the system to call AddDevice routine of
disk.sys with this PDO.

Any help on this would be highly appreciated.

Thanks,
-SP


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Look at the busenum driver in the toaster sample. You create a device
object and then report it via query device relations. You then report
various IDs, of which the hardware and/or compatible IDs will match the
generic disk and disk.sys will load. Writing a bus driver is not
trivial, in fact it can be quite hard. I strongly suggest that you use
KMDF for this if you choose to enumerate PDOs.

d

– I can spell, I just can’t type.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Shubhraprakash
Das
Sent: Wednesday, June 21, 2006 8:14 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Writing a FileDisk Driver

Hi,

I am attempting to write a filedisk driver.
Reading from the list I understand that there are 2 approaches to do
this.

One, is to write a port/miniport driver or write a PnP bus driver that
will create a PDO for the disk
driver(disk.sys) lying above.

Considering the second approach,
how can I create a PDO in my driver code and how do I get the system to
call AddDevice routine of disk.sys with this PDO.

Any help on this would be highly appreciated.

Thanks,
-SP


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

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

Hello Doron,

Thanks for your reply.

I looked at the toaster example and was able to follow
most of what went on there.

I am not familiar with KMDF model.

Is it very difficult to write the bus driver under the
WDM model or would I be better off studying the KMDF
model and then wrirting the driver under KMDF model.

In your opinion, which would be a faster approach?

Thanks,
-SP


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

KMDF.

Gary G. Little
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@yahoo.com
Sent: Thursday, June 22, 2006 12:27 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Writing a FileDisk Driver

Hello Doron,

Thanks for your reply.

I looked at the toaster example and was able to follow
most of what went on there.

I am not familiar with KMDF model.

Is it very difficult to write the bus driver under the
WDM model or would I be better off studying the KMDF
model and then wrirting the driver under KMDF model.

In your opinion, which would be a faster approach?

Thanks,
-SP


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

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

It is somewhat easy to attempt to write a bus driver using WDM, it is
very difficult to get it *right* using WDM though because there are many
many rules and behaviors that you must implement. You can get a fully
functional bus driver up and running much more quickly with KMDF because
KMDF implements these rules and behaviors for you.

d

– I can spell, I just can’t type.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Shubhraprakash
Das
Sent: Thursday, June 22, 2006 10:27 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Writing a FileDisk Driver

Hello Doron,

Thanks for your reply.

I looked at the toaster example and was able to follow most of what went
on there.

I am not familiar with KMDF model.

Is it very difficult to write the bus driver under the WDM model or
would I be better off studying the KMDF model and then wrirting the
driver under KMDF model.

In your opinion, which would be a faster approach?

Thanks,
-SP


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

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

> Look at the busenum driver in the toaster sample. You create a device

object and then report it via query device relations. You then report
various IDs, of which the hardware and/or compatible IDs will match the
generic disk and disk.sys will load. Writing a bus driver is not
trivial, in fact it can be quite hard. I strongly suggest that you use
KMDF for this if you choose to enumerate PDOs.

A couple quick ideas, which may or may not be viable after further
investigation…

Instead of writing a bus driver, it seems like you could just root enumerate
a PDO for disk.sys, and then specify a device lower filter driver to handle
the srb I/O irps? A user mode app could create and destroy new root
enumerations as needed.

It might be easier to implement a function driver that created a disk
object, and was layered on a root enumerated pdo. You could use the disk.sys
class driver sources as a starting place (and strip out all the code that
sends request down the stack).

  • Jan

That is also a viable option. The bus driver comes into play if you
want to control the presence of the disk in KM w/out relying on a UM app
to manipulate device stack state.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Jan Bottorff
Sent: Thursday, June 22, 2006 12:57 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Writing a FileDisk Driver

Look at the busenum driver in the toaster sample. You create a device

object and then report it via query device relations. You then report

various IDs, of which the hardware and/or compatible IDs will match
the generic disk and disk.sys will load. Writing a bus driver is not
trivial, in fact it can be quite hard. I strongly suggest that you
use KMDF for this if you choose to enumerate PDOs.

A couple quick ideas, which may or may not be viable after further
investigation…

Instead of writing a bus driver, it seems like you could just root
enumerate a PDO for disk.sys, and then specify a device lower filter
driver to handle the srb I/O irps? A user mode app could create and
destroy new root enumerations as needed.

It might be easier to implement a function driver that created a disk
object, and was layered on a root enumerated pdo. You could use the
disk.sys class driver sources as a starting place (and strip out all the
code that sends request down the stack).

  • Jan

Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

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

> Considering the second approach,

how can I create a PDO in my driver code

Read the docs on bus drivers. Try using KMDF.

how do I get the system to call AddDevice routine of
disk.sys with this PDO.

Return “GenDisk” in IRP_MN_QUERY_ID response, then be ready to handle
IRP_MJ_SCSI with SRBs.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com