Re: About the settings in CreateFile
- From: "Doron Holan [MSFT]" <doronh@xxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 12 Sep 2008 10:46:06 -0700
sharing modes really apply to file systems, not device drivers. your CreateFile needs to return failure if you want to have exclusivity and there is alraedy an open handle
d
--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"Felix" <Felix@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:FE2756BE-19A1-4782-BAD5-474D9BE6B103@xxxxxxxxxxxxxxxx
Thanks for your replies.
But I still have confusion in sharing mode of CreateFile.
If the dispatch routine for IRP_MJ_CREATE in my driver always returns
NT_SUCCESS, any application can open the handle although I set non-sharing
mode in first application?
"Anand Choubey" wrote:
Read second point :
When you implement your dispatch routine for IRP_MJ_CREATE (in WDM) or
EvtDeviceFileCreate (in KMDF), you maintain a count of handles which
have been opened against your device and fail requests when the count
is > 1. Typically this count is maintained on a field in the device
extension using the InterlockedIncrement()/Decrement() functions and
is decremented in your IRP_MJ_CLOSE dispatch routine (in WDM) or
EvtFileClose (in KMDF). Note: in KMDF you don't need to do this at
all. During device initialization, if you call
WdfDeviceInitSetExclusive(), KMDF will maintain this count for you
automatically.
Regards,
Anand
On Sep 11, 5:43 pm, "Don Burn" <b...@xxxxxxxxxxxxxxxxxxxx> wrote:
> What are you talking about IOCTL? Sorry the create file DISPATCH > routine is
> called in the driver there is no IOCTL present here. As far as the > OP's
> problem, sharing of devices happens by default, > seehttp://blogs.msdn.com/doronh/archive/2006/05/25/607708.aspx
>
> --
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
> Website:http://www.windrvr.com
> Blog:http://msmvps.com/blogs/WinDrvr
> Remove StopSpam to reply
>
> "Anand Choubey" <anand.chou...@xxxxxxxxx> wrote in message
>
> news:5488095e-6ca3-405a-8ee8-e13acd4cfaf8@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> When you call createfile, MJ_CREATE IOCTL is hit in driver.
> If you do not want to open multiple handle of driver at a time.
>
> you should add reference counter mj_create ioctl.
>
> Regards,
> Anand
>
> On Sep 11, 2:24 pm, Felix <Fe...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> > Hi,
> > I write a DLL file which can open my device by calling CreateFIle
> > function.
> > The settings of CreateFile are like
>
> > CreateFile("\\\\.\\Device",
> > GENERIC_READ|GENERIC_WRITE,
> > 0,
> > NULL,
> > OPEN_EXISTING,
> > FILE_ATTRIBUTE_NORMAL,
> > NULL);
>
> > The sharing mode parameter is 0 !
> > Besides, I have two different applications which load the same DLL > > file
> > individually when startup.
> > I found they can get two handles at one time without closing handle!
> > Is this result against the rule of sharing mode 0 ?
> > Any suggestion is appreciated.
> > Thanks.
>
> > Felix
.
- Follow-Ups:
- Re: About the settings in CreateFile
- From: Felix
- Re: About the settings in CreateFile
- References:
- About the settings in CreateFile
- From: Felix
- Re: About the settings in CreateFile
- From: Anand Choubey
- Re: About the settings in CreateFile
- From: Don Burn
- Re: About the settings in CreateFile
- From: Anand Choubey
- Re: About the settings in CreateFile
- From: Felix
- About the settings in CreateFile
- Prev by Date: Re: kmdf usbsamp
- Next by Date: Re: KMDF DPC Synchronization
- Previous by thread: Re: About the settings in CreateFile
- Next by thread: Re: About the settings in CreateFile
- Index(es):
Relevant Pages
|
Loading