- SEHify LockRequest

- Free everything and return if MmMapLockedPages fails

svn path=/branches/aicom-network-fixes/; revision=35454
This commit is contained in:
Cameron Gutman 2008-08-19 16:23:01 +00:00
parent ea2d464b14
commit 2a199d0cb2

View file

@ -15,6 +15,8 @@
/* Lock a method_neither request so it'll be available from DISPATCH_LEVEL */ /* Lock a method_neither request so it'll be available from DISPATCH_LEVEL */
PVOID LockRequest( PIRP Irp, PIO_STACK_LOCATION IrpSp ) { PVOID LockRequest( PIRP Irp, PIO_STACK_LOCATION IrpSp ) {
BOOLEAN LockFailed = FALSE;
Irp->MdlAddress = Irp->MdlAddress =
IoAllocateMdl( IrpSp->Parameters.DeviceIoControl.Type3InputBuffer, IoAllocateMdl( IrpSp->Parameters.DeviceIoControl.Type3InputBuffer,
IrpSp->Parameters.DeviceIoControl.InputBufferLength, IrpSp->Parameters.DeviceIoControl.InputBufferLength,
@ -22,9 +24,27 @@ PVOID LockRequest( PIRP Irp, PIO_STACK_LOCATION IrpSp ) {
FALSE, FALSE,
NULL ); NULL );
if( Irp->MdlAddress ) { if( Irp->MdlAddress ) {
MmProbeAndLockPages( Irp->MdlAddress, KernelMode, IoModifyAccess ); _SEH_TRY {
MmProbeAndLockPages( Irp->MdlAddress, KernelMode, IoModifyAccess );
} _SEH_HANDLE {
LockFailed = TRUE;
} _SEH_END;
if( LockFailed ) {
IoFreeMdl( Irp->MdlAddress );
Irp->MdlAddress = NULL;
return NULL;
}
IrpSp->Parameters.DeviceIoControl.Type3InputBuffer = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer =
MmMapLockedPages( Irp->MdlAddress, KernelMode ); MmMapLockedPages( Irp->MdlAddress, KernelMode );
if( !IrpSp->Parameters.DeviceIoControl.Type3InputBuffer ) {
IoFreeMdl( Irp->MdlAddress );
Irp->MdlAddress = NULL;
return NULL;
}
return IrpSp->Parameters.DeviceIoControl.Type3InputBuffer; return IrpSp->Parameters.DeviceIoControl.Type3InputBuffer;
} else return NULL; } else return NULL;
} }