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

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging

The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.

Check out The OSR Learning Library at:

WdfDeviceCreate STATUS_INVALID_DEVICE_REQUEST when SynchronizationScope = WdfSynchronizationScopeDev

OneKneeToeOneKneeToe Member Posts: 42
edited December 2019 in NTDEV

Hello again OSR Community:

  • In my KMDF EvtDeviceAdd routine, my one and only WdfDeviceCreate fails with STATUS_INVALID_DEVICE_REQUEST when I set SynchronizationScope = WdfSynchronizationScopeDev. Leaving it default, which is InheritFromParent due to the WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE macro, the creation succeeds.

  • In the article "WDF File Object Callbacks and Properties Demystified",, it states"...Lastly, WdfSynchronizationScopeDevice is a valid choice only if the parent WDF Device Object has a PASSIVE_LEVEL execution constraint, otherwise the Framework fails the attempt to create the device...."

  • In the article, "Understanding Sync Scope in WDF Drivers",, which came out later that year, there is no mention of any such restriction.

  • The MS Documentation states that "The parent of each framework device object is the driver's framework driver object.". Which doesn't really tell me much as I don't know the synch scope setting, and if it's not set to Device, then what?

  • I realize I am missing some fundamental understanding, and the articles + documentation, although quite good, haven't been enough for me; I know, I am a bit thick headed, it takes me a while... :smile:

Thanks for any help.


  • Scott_Noone_(OSR)Scott_Noone_(OSR) Administrator Posts: 3,355

    Have you dumped the in flight recorder with !wdfkd.wdflogdump? There should be a message about the reason for the error. You can also just step into the source code:


  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,640

    Did you actually set ExecutionLevel to WdfExecutionLevelPassive, as the documentation you quoted suggests?

    Please note that WDF makes it very easy to over-synchronize yourself and cause deadlocks. Is there some legitimate reason you want device sync scope, or did you just choose it because it seems easier? As a rule, it isn't. Notice the following quotes from the page

    In general, we do not recommend using device-level synchronization.

    The default synchronization scope for driver objects is WdfSynchronizationScopeNone.
    The default synchronization scope for device and queue objects is WdfSynchronizationScopeInheritFromParent.

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

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 8,108

    And last, it certainly not least, and to emphasize what Mr. Roberts said: You almost certain don’t really want SyncScopeDevice. Almost always a bad idea for a real driver.


    Peter Viscarola

  • OneKneeToeOneKneeToe Member Posts: 42

    Good Afternoon Scott, Mr. Roberts and Peter:

    Regarding the execution level; Since the article was about FileObjects and the same restrictions was not in the second article, I was slightly leaning on that restriction applying to just the FileObject.

    Reason for SyncScopDevice: I wasn't sure if the SyncScopeQueue on the request queue I am using would be enough. I wanted to test using the Device level sync to see how the drive would run vs only using the queue sync.

    A few points:

    • HW sends data and then enqueues (on the HW) metadata. HW Interrupts tell the driver that the HW FIFO has metadata.
    • The driver will disable interrupts, and process all the metadata in the HW FIFO, until empty. Then re-enable interrupts.
    • SW File Reads can come at anytime, but request processing is serialized as the requests are enqueued in the WDFQUEUE, which is Sync'd.

    I did some testing and queue sync + interrupt enable/disable seems to be enough - but I suppose you all already suspected that.

    Thank you all for your patience and all the helpful information you have given freely. I really need to find a way to make it out to a seminar and learn the fundamentals; I can see a good foundation is important here.


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
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Writing WDF Drivers 7 Dec 2020 LIVE ONLINE
Internals & Software Drivers 25 Jan 2021 LIVE ONLINE
Developing Minifilters 8 March 2021 LIVE ONLINE