IoSkipCurrentIrpStackLocation and IoCopyCurrentIrpStackLocationToNext.

Interesting question :

The documentation in MSDN describes that an
IoCopyCurrentIrpStackLocationToNext should be call only when setting a
completion routine for an IRP.

I understand that calling IoSkipCurrentIrpStackLocation is a good practice
if no completion routine is needed to be set but why is it a must ?

Any idea ?

Jim

You can also use IoCopyCurrentIrpStackLocationToNext instead of
IoSkipCurrentIrpStackLocation if you don’t set completion routine. But
it’s inefficient so nobody do that. But if you want to set completion in
one stack location, you have use IoCopyCurrentIrpStackLocationToNext , not
IoSkipCurrentIrpStackLocation . IO LOCATION has a field which record the
completion routine address. If you don’t copy it and just skip it, it means
you change the other stack’s completion routine address.
Marvin

On Wed, Feb 29, 2012 at 10:10 PM, Jim wrote:

> Interesting question :
>
> The documentation in MSDN describes that an
> IoCopyCurrentIrpStackLocationToNext should be call only when setting a
> completion routine for an IRP.
>
> I understand that calling IoSkipCurrentIrpStackLocation is a good practice
> if no completion routine is needed to be set but why is it a must ?
>
> Any idea ?
>
> Jim
> — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and
> other seminars visit: http://www.osr.com/seminars To unsubscribe, visit
> the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer

It’s not “a must”… it’s merely an optimization.

Remember: The documentation is there to provide guidance on the most common path to do things as well as (most of the time) best practices. The documentation rarely describes every possible option, or even the motivation behind certain practices. Doing so just makes things more difficult for learners who “just want to know which function to call.”

Peter
OSR

As far as I can tell, using IoSkipCurrentIrpStackLocation is an
optimization. It is not at all clear that it is “mandatory”, but it is
certainly “recommended”. It sounds like the documentation is overstating
the case.
joe

Interesting question :

The documentation in MSDN describes that an
IoCopyCurrentIrpStackLocationToNext should be call only when setting a
completion routine for an IRP.

I understand that calling IoSkipCurrentIrpStackLocation is a good practice
if no completion routine is needed to be set but why is it a must ?

Any idea ?

Jim


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Sometimes using ‘IoSkipCurrentIrpStackLocation’ can hide problems with your ‘StackSize’ where if you get ‘lucky’ you don’t see it until you ship your driver :slight_smile:

>Sometimes using ‘IoSkipCurrentIrpStackLocation’ can hide problems with your ‘StackSize’ where if you >get ‘lucky’ you don’t see it until you ship your driver :slight_smile:

The Driver Verifier should catch such error. It is a good practice to test a device driver by using the Driver Verifier before releasing it.

Igor Sharovar

It’s more than a good idea. If you release a driver without running
verifier, you can safely assume that you are releasing completely untested
code.

I have discovered this at a number of times at client sites, where they
say things like “Every time we install this driver, we start getting
bluescreens” or “Once we install this driver, power management no longer
works”. The driver verifier detects the failure reasons within seconds (I
think the longest delay was five seconds) proving that the driver writer
never, ever tested the driver.

In one case, the company had paid $50,000 to get a driver, but to compile
it required a modified NTDDK.H, and the Windows 95 version had to be built
first. Apparently, the contract did not state that the source had to be
compilable on a standard (at that time DKK) tool release. And since the
contract only called for a Windows driver, and did not cover the Windows
95 development, the company would not release the Win95 components that
had to be built first. Not only an incompetent driver company, but a
totally incompetent contract negotiator for the company that purchased the
driver.
joe

>Sometimes using ‘IoSkipCurrentIrpStackLocation’ can hide problems with
> your ‘StackSize’ where if you >get ‘lucky’ you don’t see it until you
> ship your driver :slight_smile:

The Driver Verifier should catch such error. It is a good practice to test
a device driver by using the Driver Verifier before releasing it.

Igor Sharovar


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer