Exception caught while calling MmMapLockedPagesSpecifyCache

Hi,
My driver in some instances catches STATUS_INVALID_ADDRESS
exception while calling the routine MmMapLockedPagesSpecifyCache. Does
anyone know when this can happen.

The driver allocates block of memory from nonpaged pool that needs to
be shared with the user mode process and the MDL code looks like this.

pMdl = IoAllocateMdl( pReceivedEventData->Ptr,<— Non
paged pool memory
pReceivedEventData->Size,
FALSE,
FALSE,
NULL );

//
// If the allocation failed, panic.
//

if ( pMdl == NULL )
{
KLogBugCheckEx( XXXXX,
0,
0,
0,
0 );
}

PVOID MemPtr;
MmBuildMdlForNonPagedPool( pMdl );

//
// Map the locked page into user space. This requires obtaining the
// base address of the page and then adding the offset for
the mapped
// buffer to correctly locate the starting point of the buffer.
//

__try
{

MemPtr = MmMapLockedPagesSpecifyCache( pMdl, UserMode,
MmNonCached, NULL, FALSE, HighPagePriority );

Does using “HighPagePriority” here causes any problem?

if(MemPtr == NULL)
{
KLogBugCheckEx( YYYY,
0,
0,
0,
0 );
}
}
__except ( EXCEPTION_EXECUTE_HANDLER )
{
Iam catching the STATUS_INVALID_ADDRESS exception here.
}

pSynchronousReceiveOutBuffer->Ptr =
(PVOID) ( ( (ULONG) PAGE_ALIGN( MemPtr ) ) +
MmGetMdlByteOffset( pMdl ) );

Thanks for your help

Regards,
Praveen

Unfortunately there appear to be several error paths in the user mode
version of MmMLPSC that will raise STATUS_INVALID_ADDRESS.

Here is a likely one: the nonpaged pool memory cannot be set to non-cached
as it is already mapped cached or some other conflicting cache mode by
somebody else.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Praveen Seela
Sent: Friday, October 15, 2004 5:39 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Exception caught while calling
MmMapLockedPagesSpecifyCache

Hi,
My driver in some instances catches
STATUS_INVALID_ADDRESS exception while calling the routine
MmMapLockedPagesSpecifyCache. Does anyone know when this can happen.

The driver allocates block of memory from nonpaged pool that
needs to be shared with the user mode process and the MDL
code looks like this.

pMdl = IoAllocateMdl(
pReceivedEventData->Ptr,<— Non paged pool memory
pReceivedEventData->Size,
FALSE,
FALSE,
NULL );

//
// If the allocation failed, panic.
//

if ( pMdl == NULL )
{
KLogBugCheckEx( XXXXX,
0,
0,
0,
0 );
}

PVOID MemPtr;
MmBuildMdlForNonPagedPool( pMdl );

//
// Map the locked page into user space. This
requires obtaining the
// base address of the page and then adding the
offset for the mapped
// buffer to correctly locate the starting point
of the buffer.
//

__try
{

MemPtr = MmMapLockedPagesSpecifyCache( pMdl,
UserMode, MmNonCached, NULL, FALSE, HighPagePriority );

Does using “HighPagePriority” here causes any problem?

if(MemPtr == NULL)
{
KLogBugCheckEx( YYYY,
0,
0,
0,
0 );
}
}
__except ( EXCEPTION_EXECUTE_HANDLER )
{
Iam catching the STATUS_INVALID_ADDRESS exception here.
}

pSynchronousReceiveOutBuffer->Ptr =
(PVOID) ( ( (ULONG) PAGE_ALIGN( MemPtr ) ) +
MmGetMdlByteOffset( pMdl ) );

Thanks for your help

Regards,
Praveen


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@hollistech.com To unsubscribe send a blank email to
xxxxx@lists.osr.com