Re: PreFast and NDISUIO

From: Arne Ludwig (arne_at_citde.net)
Date: 11/02/04


Date: 2 Nov 2004 04:40:43 -0800

I apparently misinterpreted what PreFast said. I found this in a
Microsoft document:

The following notes refer to the circled numbers in the sample code:
1. Remove the IRP from the pending structure before releasing the
cancel spin lock to prevent any other thread from trying to dequeue
it.
2. Release the cancel spin lock. The I/O Manager acquires the cancel
spin lock before it calls the Cancel routine; the Cancel routine must
release the lock.
3. Complete the IRP. A driver must never call IoCompleteRequest while
it holds the cancel spin lock.

and in another Microsoft document:

Calling IoCompleteRequest to complete an IRP constitutes a call
outside the driver. A deadlock could occur in the system if your
cancel routine completes the IRP while the kernel is holding the
cancel spinlock for you. So the cancel routine has to release the
global cancel spinlock first, then complete the cancelled IRP.

However, the original question still stands (slightly modified):

Why did Microsoft release the spinlock right at the beginning of the
cancel routine instead of after releasing the local lock and before
completing the IRP?

arne@citde.net (Arne Ludwig) wrote in message news:<84bdcc66.0411010055.49f5858b@posting.google.com>...
> We modified the DDK NDISUIO driver and I ran PreFast with driver
> enhancements from the Server 2003 Beta DDK on it. PreFast complained
> about some original Microsoft code that releases the cancel spinlock
> before the IRP was completed. I then moved the release down to after
> the complete and the driver still seems to work, but I wonder why
> Microsoft did it in the first place. Of course performancewise it is
> always best to release the spinlock as soon as possible.
>
> Was it allowed in this particular case and PreFast was wrong?



Relevant Pages

  • Re: Form_Open cancelled "delayed" !?
    ... I believe that this is due to the fact that Microsoft has tried to make the ... Private Sub Form_Open ... MsgBox "Can't use this form now - Open canceled" ... cancel is set to true. ...
    (microsoft.public.access.formscoding)
  • Re: Error Message- Ap has generated an excep- Help is Appreciated
    ... People who show unusual dedication to the newsgroup are recognized by Microsoft and given the title MVP, but no money. ... "Updnotif.exe is the Lacerte Internet Update notifier that runs in your system tray to notify you when Internet Updates are available. ... When I Click Cancel the following appears: UpNotif.Exe.-No Debugger found. ...
    (microsoft.public.windowsxp.perform_maintain)
  • RE: Removing assigned apps
    ... I understand that you want to cancel the ... installation prompt about delivery software by Assign Application wizard. ... Microsoft CSS Online Newsgroup Support ... | Thread-Topic: Removing assigned apps ...
    (microsoft.public.windows.server.sbs)
  • Re: Printer selection option in envelopes and labels within word.
    ... FWIW, when you have changed the printer selection, the button choices are ... > Envelopes or Labels to. ... > on the X to close the printer selection window, NOT OK OR CANCEL! ... > This post is a suggestion for Microsoft, ...
    (microsoft.public.word.docmanagement)
  • Re: license.cfg "credit card" "Microsoft Windows Licensing" "Register onlin
    ... The bit I especially detest is that by clicking cancel the system ... Microsoft enforcing some ... | "Microsoft Windows Licensing" ... | for the folks confronted. ...
    (microsoft.public.windowsxp.general)