Is it possible to access a ASCII file in Driver?

Hai everybody,

i am new to this driver field. i am developing my first WDM Driver for a data acquisition PCI Card. i am having a strange specification from user so that he wants an API to write the huge contents of ( nearly 100kb), data in a file. For an example, Acquire_data_contents_to_File(), this API should transfer the data from the buffer to file. It is possible to do any I/O operations in a file by having a valid file pointer in the driver. we can have a vaild file pointer by opening a file in an application and pass it to driver by using DeviceIOControl win32 API. please help me.

Regards,

bala.R

Yes you could do the write to file from the driver, but there is really
no advantage to doing so. As you are building an API for the driver
interface, the user mode side of the API should do the write.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of balasubramanian
Sent: Tuesday, August 02, 2005 8:52 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Is it possible to access a ASCII file in Driver?

Hai everybody,

i am new to this driver field. i am developing my first WDM Driver for a
data acquisition PCI Card. i am having a strange specification from user
so that he wants an API to write the huge contents of ( nearly 100kb),
data in a file. For an example, Acquire_data_contents_to_File(), this
API should transfer the data from the buffer to file. It is possible to
do any I/O operations in a file by having a valid file pointer in the
driver. we can have a vaild file pointer by opening a file in an
application and pass it to driver by using DeviceIOControl win32 API.
please help me.

Regards,

bala.R


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

You are currently subscribed to ntdev as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

You do not want to write the data with a handle from user space, the problem
here is that the handle is valid only in context of the application, and
much of the driver will not run in that context. You can do file operations
in a device driver, see ZwCreateFile.

Before you do this, please consider posting some more of your design needs
in this forum. Many drivers that use file IO fall far from the norms of
Windows drivers. While this is not illegal, it in many cases is not
nessecary, and creates a situation where the driver is hard to maintain
since it does not follow the pattern of most drivers.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply

“balasubramanian” wrote in message
news:xxxxx@ntdev…
Hai everybody,

i am new to this driver field. i am developing my first WDM Driver for a
data acquisition PCI Card. i am having a strange specification from user so
that he wants an API to write the huge contents of ( nearly 100kb), data in
a file. For an example, Acquire_data_contents_to_File(), this API should
transfer the data from the buffer to file. It is possible to do any I/O
operations in a file by having a valid file pointer in the driver. we can
have a vaild file pointer by opening a file in an application and pass it to
driver by using DeviceIOControl win32 API. please help me.

Regards,

bala.R

This is best handled by using NT I/O the way it was meant to be used. Your
device driver should transfer data from your hardware to clients by using
IRP_MJ_READ / ReadFile or IRP_MJ_DEVICE_CONTROL / DeviceIoControl. The
application should handle allocating memory for the buffers. After that,
the application is free to write the same data to a file, or do whatever
other processing is required.

If your user / customer wants this transfer (from hardware to file) to be
efficient, then the application should be built to use asynchronous I/O in
user-mode. You can achieve very high rates of throughput by simply using
the NT I/O system the way it was designed to be used.

Hard-coding application logic – which is what “transfer from hardware to a
file” really is – is the wrong way to do it. Even if you did this in
kernel mode, there would be little or no performance benefit whatsoever.

– arlie


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of balasubramanian
Sent: Tuesday, August 02, 2005 8:52 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Is it possible to access a ASCII file in Driver?

Hai everybody,

i am new to this driver field. i am developing my first WDM Driver for a
data acquisition PCI Card. i am having a strange specification from user so
that he wants an API to write the huge contents of ( nearly 100kb), data in
a file. For an example, Acquire_data_contents_to_File(), this API should
transfer the data from the buffer to file. It is possible to do any I/O
operations in a file by having a valid file pointer in the driver. we can
have a vaild file pointer by opening a file in an application and pass it to
driver by using DeviceIOControl win32 API. please help me.

Regards,

bala.R


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

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com