My device is not exclusive and can have multiple file handles open. I
would like to store an integer that is unique to each file handle.

It seems the recommended method is to store the data in the
WDFFILEOBJECT's device context. However, when new data arrives from
my device, the driver needs to examine and potentially update each
integer that is unique to each file handle. Therefore, I need some
way to enumerate all open WDFFILEOBJECTS. Is this possible?

If not, my alternative would be to store a hash map or linked list
containing all of the WDFFILEOBJECT handles and their corresponding
integers. This map/list would be stored in the device context of my
Device Object and updated in EvtDeviceFileCreate and EvtFileCleanup
callbacks. Are there some built in data structures for hash maps or
linked lists that would be helpful for implementing this?

I'd prefer the first approach (enumerating the WDFFILEOBJECTs) so that
I can let the framework manage the map between file objects and
integer data. Any other solutions are welcomed.

Thanks,
Jonah

Re: enumerating all open WDFFILEOBJECTs? by Doron

Doron
Thu Mar 20 18:38:42 CDT 2008

KMDF does not keep track of the WDFFILEOBJECTs so there is no enumeration
method. I assume that when you say "WDFFILEOBJECT's device context" you
mean the context on the WDFFILEOBJECT, not the context on the WDFDEVICE.

2 suggestions for keeping the list
1) use a WDFCOLLECTION and add/remove in the 2 callbacks you mention below
2) use LIST_ENTRYs. add a LIST_ENTRY FileObjectListHead to your device
context and initialize it with InitializeListHead after you created the
WDFDEVICE. Add a LIST_ENTRY Link; to your WDFFILEOBJECT's context. Use
InsertTailList to add it, RemoveEntryList to remove it.

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.


<jonah.peskin@gmail.com> wrote in message
news:cd7aae53-5538-48e2-83e1-e57ee4b0d550@s19g2000prg.googlegroups.com...
> My device is not exclusive and can have multiple file handles open. I
> would like to store an integer that is unique to each file handle.
>
> It seems the recommended method is to store the data in the
> WDFFILEOBJECT's device context. However, when new data arrives from
> my device, the driver needs to examine and potentially update each
> integer that is unique to each file handle. Therefore, I need some
> way to enumerate all open WDFFILEOBJECTS. Is this possible?
>
> If not, my alternative would be to store a hash map or linked list
> containing all of the WDFFILEOBJECT handles and their corresponding
> integers. This map/list would be stored in the device context of my
> Device Object and updated in EvtDeviceFileCreate and EvtFileCleanup
> callbacks. Are there some built in data structures for hash maps or
> linked lists that would be helpful for implementing this?
>
> I'd prefer the first approach (enumerating the WDFFILEOBJECTs) so that
> I can let the framework manage the map between file objects and
> integer data. Any other solutions are welcomed.
>
> Thanks,
> Jonah


Re: enumerating all open WDFFILEOBJECTs? by jonah

jonah
Thu Mar 20 18:57:47 CDT 2008

Thanks for the quick reply! Okay, I will look into the collection/
list options you suggest.

Yes, I meant to say the context on the WDFFILEOBJECT, not the device
context.

Thanks,
Jonah