Re: CreateFile performance

Tech-Archive recommends: Fix windows errors by optimizing your registry



1) Is it a recommended practice to keep a handle referencing the device
and will be closed only after applications are closed. This way I have
oppurtunity to do clean up when application exits by sending
'CLEAN_UP_IOCTL' to driver.

When application exits, all its handles get closed, which means that
FILE_OBJECTs these handles refer to have to be deleted. Before it
happens, driver receives IRP_MJ_CLOSE (if there are no outstanding IO
requests on the file) or IRP_MJ_CLEANUP (if there are outstanding IO
requests on the file) from IO Manager. Therefore, there is no need for
'CLEAN_UP_IOCTL' , because IRP_MJ_CLOSE / IRP_MJ_CLEANUP handler is
supposed to do all clean-up that is needed upon closing the given
file...

2) Is caching CreateFile() handles practised in any standard drivers.

Drivers don't deal with handles that have been opened on their devices
as a result of CreateFile() call. Instead, they deal directly with
FILE_OBJECTs these handles refer to, so that they don't get passed to
drivers.

Anton Bassov


r_konjeti@xxxxxxxxxxxx wrote:
Thanks for the replies Don.

1) Is it a recommended practice to keep a handle referencing the device
and will be closed only after applications are closed. This way I have
oppurtunity to do clean up when application exits by sending
'CLEAN_UP_IOCTL' to driver.

2) Is caching CreateFile() handles practised in any standard drivers.
Is this just a non issue.

3) I always wonder how TCP/IP driver or support user mode software
working on windows efficiently. Few bytes sent in chat application are
handled as good as downloading 100MB movie. I see good driver code in
driver design books like Walter Oney or www.wd-3.com. I didnot find any
user mode code that will efficiently pull large and small chunks of
data from driver and distribute to many applications. I really
appreciate if any sample code or books referenced for part-2 of driver
support software.

Thanks,
Raj


Don Burn wrote:
Comments inline:
<r_konjeti@xxxxxxxxxxxx> wrote in message
news:1163082648.727755.307100@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
If many applications are calling driver, each application process
context need a separate handle or duplicate handle for CreateFile(). Is
it same to have a duplicate handle from other process in a given
application process. Or will it make a difference if we call
CreateFile() for each process context.

You want a handle for each process for security reasons. Otherwise an
unauthorized application can try to use you driver as an attack vector.

Will the driver unload if there is handle pending at the user mode for
a device. If the device is removed and handle not closed yet, will it
cause problems? If I implement this scheme, I want to close these file
handle lazy way.

The driver will not unload if there is a reference to it which a handle
owned by a process certainly is a reference so it will not be unloaded.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
http://www.windrvr.com
Remove StopSpam from the email to reply

.



Relevant Pages

  • Re: Cant print from Word 2008 (Excel prints OK)
    ... which can be found in the Utilities folder within the Applications folder. ... I am using the Gutenprint driver, because with the other driver none of ... Mac OS print preview, so I think my printer is printing me exactly what ... that it "couldn't communicate with the printer ... ...
    (microsoft.public.mac.office.word)
  • Re: WinXP SP2 very, very slow??
    ... The first thing I did was to look at the Admin Tools: Event Viewer ... Applications, Security are all information, but in Systems, every boot ... Seems like problem starts with bad driver, or nonexistent driver, ... support SCSI hard drives and also used for the more common SATA drives. ...
    (microsoft.public.windowsxp.general)
  • Re: CreateFile performance
    ... Is it a recommended practice to keep a handle referencing the device ... and will be closed only after applications are closed. ... 'CLEAN_UP_IOCTL' to driver. ... The driver will not unload if there is a reference to it which a handle ...
    (microsoft.public.development.device.drivers)
  • Re: Catch stack overflow in an application
    ... You should be able to use Dr. Watson or create and register your own debugger. ... Note you would not do this within a device driver. ... If the applications generate stack ... Usually stack overflow in a n application results in stuck device. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: CreateFile performance
    ... and will be closed only after applications are closed. ... 'CLEAN_UP_IOCTL' to driver. ... Is caching CreateFile() handles practised in any standard drivers. ... The driver will not unload if there is a reference to it which a handle ...
    (microsoft.public.development.device.drivers)