Device Extensions RRS feed

  • Question

  • Hello,
    I am having some trouble adding a KTIMER to the device extension. The problem is I am quite unsure of how to deal with the device extension. I did not find any help about how to use them in the website, only descriptive stuff. I appear to have added the data, but when I call KeInitialzeDpc(...) I get errors. So I am guessing the data is not being passed correctly through the code.
    So I will throw a couple of questions:
    First of all, what are the correct ways of adding data to the extension?
    struct Example {...};... pDeviceObject->DeviceExtension=ptrExample;?or pDeviceObject->DeviceExtension=Example;?? Or what? 
    When to use pointers and when to use the actual data?
    For instance if in my DriverEntry I create a structure and put it in the DeviceExtension by pointer, once the processor leaves the function, won´t my structure be deleted and my pointer be pointing to invalid memory?

    What about DPC? Should it be put in the device extension of a driver object or in the DPC of the driver object? What would be the differences?

    Thanks for the help, searched for similar posts but nothing showed up looking for "Device".

    Rodrigo Rutsatz

    Tuesday, August 5, 2014 9:54 PM


  • A device extension is an area of memory for your use associated with a DEVICE_OBJECT.  Typically you create a structure with all the device specific items you want as members.  So a KTIMER may be there, and same with a DPC, plus other data and control objects.   Just think of this as an area to create a structure you can you whenever you have access to the device.

    A bigger question is since this is obviously new to you, why are you writing a device driver in WDM?  Except for a very few special cases, any new driver should be in KMDF or a device class specific miniport.

    Don Burn Windows Filesystem and Driver Consulting Website:

    Tuesday, August 5, 2014 10:01 PM