Is this frowned upon?

Hello,

I am in the process of writing my first Windows driver and have a question:

  1. Is it frowned upon for WDM drivers to open and read files on disk? I
    have written a USB Function driver for a device to which I have to send 2
    binary images to initialize the firmware. I would ideally like to read the
    registry, get the name of the file that I have to send, read the contents
    of the file and then send it down to the device. (I did manage to setup
    WinDbg :slight_smile: )

  2. How would you solve the problem? Would you put it in the registry (the
    files are about 8K and 42K in size) and so, I am against putting them in
    the registry.

I am currently NOT reading files on disk. I used a little utility to
generate a Header file (from the HEX file) which defines the file as a
character array, and using that to dump it to the device. I don’t like that
approach either, because the driver building gets to be a bit tedious…

Thanks for your help!
Narayan


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Sure, you can read from the file in a driver. Use ZwCreatFile() and its
associated functions.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Narayan
Krishnamoorthy
Sent: Friday, January 11, 2002 1:49 PM
To: NT Developers Interest List
Subject: [ntdev] Is this frowned upon?

Hello,

I am in the process of writing my first Windows driver and have a
question:

  1. Is it frowned upon for WDM drivers to open and read files on disk? I
    have written a USB Function driver for a device to which I have to send
    2
    binary images to initialize the firmware. I would ideally like to read
    the
    registry, get the name of the file that I have to send, read the
    contents
    of the file and then send it down to the device. (I did manage to setup
    WinDbg :slight_smile: )

  2. How would you solve the problem? Would you put it in the registry
    (the
    files are about 8K and 42K in size) and so, I am against putting them in

the registry.

I am currently NOT reading files on disk. I used a little utility to
generate a Header file (from the HEX file) which defines the file as a
character array, and using that to dump it to the device. I don’t like
that
approach either, because the driver building gets to be a bit tedious…

Thanks for your help!
Narayan


You are currently subscribed to ntdev as: xxxxx@storagecraft.com To
unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

“Narayan Krishnamoorthy” wrote in message
news:xxxxx@ntdev…
>
> 1) Is it frowned upon for WDM drivers to open and read files on disk?
>

It’s not frowned upon by anyone that I know. Several devices I am
familiar with use this method to open microcode files or connection tables,
or… at driver initialization time.

Just remember to do all your I/O at IRQL PASSIVE_LEVEL only

Peter
OSR

—
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

“Narayan Krishnamoorthy” wrote in message
news:xxxxx@ntdev…
>
> 1) Is it frowned upon for WDM drivers to open and read files on disk?

xxxxx@osr.com said:
> It’s not frowned upon by anyone that I know.

I personally frown on it, but I grew up in the UNIX crowd, where
we would consider such behavior the work of the devil:-)

In the UNIX/Linux universe, device firmware is normally done by a
utility program that writes the file into the driver through an
ioctl. This utility program can be run in an rc script or a hotplug
demon, and the driver normally restricts access to the ioctl for
security reasons.

ZwCreateFile is less offensive to Windows driver writers, though
I personally use the utility program method simply for its greater
flexibility.

–
Steve Williams “The woods are lovely, dark and deep.
steve at icarus.com But I have promises to keep,
steve at picturel.com and lines to code before I sleep,
http://www.picturel.com And lines to code before I sleep.”

—
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hello:

Thanks for all the responses… I am under some pressure to get this done
using the non-ZwCreateFile() approach, and will change it for the next
release of the driver. (Mid-March)…

In the UNIX/Linux universe, device firmware is normally done by a
utility program that writes the file into the driver through an
ioctl. This utility program can be run in an rc script or a hotplug
demon, and the driver normally restricts access to the ioctl for
security reasons.

ZwCreateFile is less offensive to Windows driver writers, though
I personally use the utility program method simply for its greater
flexibility.

I also favoured this approach, but we are an input device supporting Idle
Wakeup, and so I have to initialize the device way before any user-mode
program can get access to the driver to send down IOCTL’s, to facilitate us
to allow wakeup.

Cheers!
Narayan


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> I am in the process of writing my first Windows driver and have a question:

  1. Is it frowned upon for WDM drivers to open and read files on disk? I
    have written a USB Function driver for a device to which I have to send 2
    binary images to initialize the firmware. I would ideally like to read the
    registry, get the name of the file that I have to send, read the contents
    of the file and then send it down to the device. (I did manage to setup
    WinDbg :slight_smile: )

  2. How would you solve the problem? Would you put it in the registry (the
    files are about 8K and 42K in size) and so, I am against putting them in
    the registry.

I am currently NOT reading files on disk. I used a little utility to
generate a Header file (from the HEX file) which defines the file as a
character array, and using that to dump it to the device. I don’t like that
approach either, because the driver building gets to be a bit tedious…

Considering that this is your first driver and the only reason you seem
to favor the “file” approach is that it is “tedious” to build the driver,
I would suggest you leave it “as is” and concentrate on finishing and
testing it. Otherwise you will have to spend hours to learn how to read
the registry, the file, to recover from situations when the file is
broken… Also, do you know in the top of your head how to specify
the path to %SystemRoot%\system32\drivers? I don’t. Also, once you have
signed your driver, the file and an inf, you will lose an ability to
substitute the file without signing everything again… Disadvantages
everywhere!


Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com