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:

ObDereferenceObject never returns

tony_zhutony_zhu Member Posts: 41

This is happening in my code.
under what condition, ObDereferenceObject never returns, and is there any way to check the reason?


  • Doron_HolanDoron_Holan Member - All Emails Posts: 10,525
    Call stack under the Ob call? What type of object are you dereferencing? For instance, a deref on a file object can lead to the MJ_CLOSE irp being sent to the underlying stack and it could be stuck in the driver.
  • Dejan_MaksimovicDejan_Maksimovic Member - All Emails Posts: 350
    via Email
    What is the stack trace?
    An invalid handle passed is the most common reason.
    Also, the ObMgr might need to wait on an event, that would never get
    satisfied in your case (e.g. you are holding the lock)

    > This is happening in my code.
    > under what condition, ObDereferenceObject never returns, and is there any
    > way to check the reason?
    > --
    > Reply to this email directly or follow the link below to check it out:
    > Check it out:
  • tony_zhutony_zhu Member Posts: 41

    Thanks @Dejan_Maksimovic and @Doron_Holan
    the type of object is FILE_OBJECT.
    for the call stack, as it is WDDM related and so
    dxgkrnl!DpiDxgkDdiUnload+0x33 [onecoreuap\windows\core\dxkernel\dxgkrnl\port\dpetw.cxx @ 447]
    dxgkrnl!DpiCleanup+0xaf [onecoreuap\windows\core\dxkernel\dxgkrnl\port\dpport.cxx @ 3193]
    dxgkrnl!DpiDriverUnload+0xb [onecoreuap\windows\core\dxkernel\dxgkrnl\port\dpport.cxx @ 3229]
    nt!IopUnloadDriver+0x20f [minkernel\ntos\io\iomgr\loadunld.c @ 571]
    nt!PnpUnloadAttachedDriver+0xa6 [minkernel\ntos\io\pnpmgr\remove.c @ 3724]
    nt!PnpRemoveLockedDeviceNode+0x240 [minkernel\ntos\io\pnpmgr\remove.c @ 1501]
    nt!PnpDeleteLockedDeviceNode+0x8b [minkernel\ntos\io\pnpmgr\remove.c @ 584]
    nt!PnpDeleteLockedDeviceNodes+0x76 [minkernel\ntos\io\pnpmgr\remove.c @ 1712]
    nt!PipRemoveDevicesInRelationList+0x8d [minkernel\ntos\io\pnpmgr\remove.c @ 474]
    nt!PnpDelayedRemoveWorker+0x114 [minkernel\ntos\io\pnpmgr\remove.c @ 363]
    nt!PnpChainDereferenceComplete+0xfd [minkernel\ntos\io\pnpmgr\remove.c @ 285]
    nt!PnpIsChainDereferenced+0xac [minkernel\ntos\io\pnpmgr\eventremove.c @ 1521]
    nt!PnpProcessQueryRemoveAndEject+0x2a2 [minkernel\ntos\io\pnpmgr\event.c @ 2896]
    nt!PnpProcessTargetDeviceEvent+0xea [minkernel\ntos\io\pnpmgr\event.c @ 3351]
    nt!PnpDeviceEventWorker+0x2d8 [minkernel\ntos\io\pnpmgr\event.c @ 1821]
    nt!ExpWorkerThread+0x105 [minkernel\ntos\ex\worker.c @ 4315]
    nt!PspSystemThreadStartup+0x55 [minkernel\ntos\ps\psexec.c @ 9310]
    nt!KiStartSystemThread+0x2a [minkernel\ntos\ke\amd64\threadbg.asm @ 83]

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

    Sooooo... you’re hanging in your WDDM driver’s unload entry point...


    Peter Viscarola

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