Re: CreateFile performance
- From: soviet_bloke@xxxxxxxxxxx
- Date: 9 Nov 2006 14:35:28 -0800
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
.
- Follow-Ups:
- Re: CreateFile performance
- From: r_konjeti
- Re: CreateFile performance
- References:
- CreateFile performance
- From: r_konjeti
- Re: CreateFile performance
- From: soviet_bloke
- Re: CreateFile performance
- From: r_konjeti
- Re: CreateFile performance
- From: Don Burn
- Re: CreateFile performance
- From: r_konjeti
- CreateFile performance
- Prev by Date: Re: CreateFile performance
- Next by Date: Re: CreateFile performance
- Previous by thread: Re: CreateFile performance
- Next by thread: Re: CreateFile performance
- Index(es):
Relevant Pages
|