OSR Dev Blog

Watch that return from IoSetCompletionRoutineEx
(By: Hector J. Rodriguez | Published: 18-Apr-05| Modified: 25-Apr-05)

Some of you may already know that there's a new Ex version of IoSetCompletionRoutine that is meant to prevent non-PnP drivers from unloading prematurely. What you might not realize though is that this routine actually returns an NTSTATUS value, which means that you?re going to have to handle the possible error condition.

Another "gotcha" is that IoSetCompletionRoutineEx allocates memory to be used as a context block and this context is not freed until completion processing occurs for the stack location. Therefore, once your driver calls IoSetCompletionRoutineEx the IRP must be passed on to another driver. Otherwise, your completion routine never runs and your driver will leak the pool the I/O Manager allocated.

This article was printed from OSR Online http://www.osronline.com

Copyright 2017 OSR Open Systems Resources, Inc.