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