Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Sept/Oct 2019 Issue of The NT Insider available


Download PDF here: http://insider.osr.com/2019/ntinsider_2019_01.pdf

It’s a particularly BIG issue, too: 40 pages of technical goodness, ranging from WDF to Minifilters. Check it out.
Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

How I can obtain type of WDFOBJECT

Alex_FunkyAlex_Funky Member - All Emails Posts: 137

Hello!
I have method :
WDFOBJECT
CreateMemoryObject()
{
WDFMEMORY memory;
...
return memory;
}
and then add this wdf object to collection.
How I can in other side (during getting item object from collection) obtain type of wdf object (that is WDFMEMORY) for work with appropriate wdf-methods on this object ?
Thnx!

Comments

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,444

    I don’t understand your question, so I’m going to guess at what you’re asking: You remove your object from the collection, using one of the methods in WDFCOLLECTION. Having done that, you cast the handle generic WDFOBJECT handle returned to you to the specific type of object (WDFMEMORY) that it in fact is.

    Or did I not understand your questions correctly?

    Peter

    Peter Viscarola
    OSR
    @OSRDrivers

  • Alex_FunkyAlex_Funky Member - All Emails Posts: 137

    Peter, I'm pretty about WDFCOLLECTION of mutlitypes objects (WDFMEMORY, WDFFILEOBJECT , etc.)

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,106

    Are you asking "how can I tell what type of object it is"? You can't. You have to know what object type you stored in the collection. In practice, this is not a problem. There are no compelling reasons to store different object types in a single collection.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Alex_FunkyAlex_Funky Member - All Emails Posts: 137

    Tim, I can solve this by WDF_DECLARE_CUSTOM_TYPE ?

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,444

    OK... so you have multiple object types in the collection.

    Still simple.

    Attach a context to each object that has a “Type” field at the same offset in every context. Remove the object, retrieve an arbitrary context, check the “Type” field... them cast the object and type to the correct one.

    Peter

    Peter Viscarola
    OSR
    @OSRDrivers

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Writing WDF Drivers 21 Oct 2019 OSR Seminar Space & ONLINE
Internals & Software Drivers 18 Nov 2019 Dulles, VA
Kernel Debugging 30 Mar 2020 OSR Seminar Space
Developing Minifilters 27 Apr 2020 OSR Seminar Space & ONLINE