Driver Problems? Questions? Issues?
Put OSR's experience to work for you! Contact us for assistance with:
  • Creating the right design for your requirements
  • Reviewing your existing driver code
  • Analyzing driver reliability/performance issues
  • Custom training mixed with consulting and focused directly on your specific areas of interest/concern.
Check us out. OSR, the Windows driver experts.

Monthly Seminars at OSR Headquarters

East Coast USA
Windows Internals and SW Drivers, Dulles (Sterling) VA, 9 April 2018

Writing WDF Drivers I: Core Concepts, Manchester, NH, 7 May 2018

Kernel Debugging & Crash Analysis for Windows, Dulles (Sterling), VA, 21 May 2018


Go Back   OSR Online Lists > ntdev
Welcome, Guest
You must login to post to this list
  Message 1 of 6  
12 Feb 18 01:00
Michael Rolle
xxxxxx@rolle.name
Join Date: 27 Dec 2017
Posts To This List: 24
Can I have a KDPC object on the stack? When can I destroy or alter a KDPC?

AMD's CodeXL driver implements DPCs by declaring a local KDPC variable, initializing it, queueing it, creating an event, and waiting for the deferred routine to post to the event. The data passed to the deferred routine is also in a local variable. I assume this is safe, because AMD's product is out there. But it doesn't follow the documented requirement that it be in a device/controller extension or somewhere allocated from a nonpaged pool. Is the kernel stack in nonpaged memory, too? I made the mistake recently of creating my KDPC on the stack, but not waiting for the deferred routine to finish, so that the KDPC would have quickly been overwritten. This resulted in a bugcheck. So I'm putting my KDPC in the device extension. But that raises the question of reusing the KDPC, and synchronizing usage between threads. Assuming that I've handled the issue of access by different threads, I need to know how long a thread that is using the KDPC needs hold onto it, after queueing it. Even when the device is only being used by one user File, there may be multiple IRPs coming from different user threads at the same time.
  Message 2 of 6  
12 Feb 18 01:36
Tim Roberts
xxxxxx@probo.com
Join Date: 28 Jan 2005
Posts To This List: 11800
Can I have a KDPC object on the stack? When can I destroy or alter a KDPC?

On Feb 11, 2018, at 10:00 PM, xxxxx@rolle.name <xxxxx@lists.osr.com> wrote: > > AMD's CodeXL driver implements DPCs by declaring a local KDPC variable, initializing it, queueing it, creating an event, and waiting for the deferred routine to post to the event. The data passed to the deferred routine is also in a local variable. > > I assume this is safe, because AMD's product is out there. But it doesn't follow the documented requirement that it be in a device/controller extension or somewhere allocated from a nonpaged pool. > > Is the kernel stack in nonpaged memory, too? As long as the thread is running, or in a "kernel mode" wait, the stack is locked into memory. The kernel stack can only be paged out if you do a wait that specifies "user mode". ??? Tim Roberts, xxxxx@probo.com Providenza & Boekelheide, Inc.
  Message 3 of 6  
17 Feb 18 13:09
matt sykes
xxxxxx@hotmail.com
Join Date:
Posts To This List: 208
Can I have a KDPC object on the stack? When can I destroy or alter a KDPC?

If the KDPC is on the stack it gets destroyed when the function exits. Trying to access it after wards is a recipe for disaster. Just wait for the DPC routine to finish.
  Message 4 of 6  
20 Feb 18 12:19
Peter Viscarola (OSR)
xxxxxx@osr.com
Join Date:
Posts To This List: 5989
List Moderator
Can I have a KDPC object on the stack? When can I destroy or alter a KDPC?

<quote> Just wait for the DPC routine to finish. </quote> Just don't put the DPC object on the stack! Kinda of a dumb practice. Peter OSR @OSRDrivers
  Message 5 of 6  
Yesterday 10:10
matt sykes
xxxxxx@hotmail.com
Join Date:
Posts To This List: 208
Can I have a KDPC object on the stack? When can I destroy or alter a KDPC?

Why tell me Peter? I am quite aware of that. Why not tell the OP?
  Message 6 of 6  
Yesterday 17:01
Peter Viscarola (OSR)
xxxxxx@osr.com
Join Date:
Posts To This List: 5989
List Moderator
Can I have a KDPC object on the stack? When can I destroy or alter a KDPC?

>Why tell me Peter? I wasn't speaking directly to you, Mr. Sykes. I was simply adding a "better alternative" to waiting for the DPC routine to finish. Turns out, ANYbody can read the threads on this forum. Peter OSR @OSRDrivers
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntdev list to be able to post.

All times are GMT -5. The time now is 02:03.


Copyright ©2015, OSR Open Systems Resources, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license