MmUnlockPagableImageSection

VOID
MmUnlockPagableImageSection(

IN PVOID ImageSectionHandle
);

MmUnlockPagableImageSection releases a section of driver code or driver data, previously locked into system space with MmLockPagableCodeSection, MmLockPagableDataSection or MmLockPagableSectionByHandle, so the section can be paged out again.

Parameters

ImageSectionHandle

Is the handle returned by a call to MmLockPagableCodeSection or MmLockPagableDataSection.

Comments

The handle for a driver's pageable section must not be released if the driver has any outstanding IRPs in its device queue(s) or internal queue(s). A call to MmUnlockPagableImageSection restores the pageability of that entire section when there are no more references to the handle for that section.

The memory manager maintains the reference count on the handle to a section. A pageable section is only available to be paged out when the reference count is zero. Every lock request increments the count; every unlock request decrements the count. A driver must unlock a section as many times as it locks a section to make the section available to be paged out.

A handle is always valid, no matter what the count. If the count on a handle is zero and a call is made to MmLockPagableSectionByHandle, the count is set to one, and if the section has been paged out, it will be paged in.

In most cases, MmUnlockPagableImageSection is called before a driver's Unload routine. That is, a driver with a pageable section is likely to have its DispatchClose and/or DispatchShutdown routine call MmUnlockPagableImageSection before its Unload routine is called. However, care should be taken in unloadable drivers to release any pageable section before the driver itself is unloaded from the system.

For more information on paging code and data, see The Programmer's Guide.

Callers of MmUnlockPagableImageSection must be running at IRQL PASSIVE_LEVEL.

See Also

MmPageEntireDriver, MmResetDriverPaging, MmLockPagableCodeSection, MmLockPagableDataSection, MmLockPagableSectionByHandle