Hi All,
I am trying to query the IP address assigned to connection object while filtering TDI_CONNECT.During TDI_CONNECT i
Set a Completion routine to the IRP and when that completion routine is called i am trying to query for the address info of connection endpoint.But
The following code generates IRQL_NOT_LESS_OR_EQUAL .
TA_ADDRESS* pTA;
unsigned int dBufferSize = (sizeof ( TDI_ADDRESS_INFO) + sizeof (
TRANSPORT_ADDRESS ) + sizeof ( TA_IP_ADDRESS ));
pTdiAddressInfo = ExAllocatePool(NonPagedPool,dBufferSize);
if(!pTdiAddressInfo)
{
DbgPrint(" Allocation for TdiAddressInfo - Query Address Comp Conext
Failed\n");
}
// Build an Mdl for the virtual buffer
pMdlAddr = IoAllocateMdl(pTdiAddressInfo,dBufferSize, 0,FALSE ,NULL );
if(pMdlAddr)
{
MmProbeAndLockPages ( pMdlAddr, KernelMode, IoModifyAccess );
pDevObj = IoGetRelatedDeviceObject(pIrpStackLocation->FileObject);
DbgPrint(“[INFITCP.SYS]-TdiDispatchIoCompletionRoutine Building Query
Irp\n”);
TdiBuildQueryInformation(
pFilterContext->pQueryIrp ,
pDevObj,
pIrpStackLocation->FileObject ,
NULL,
NULL,
TDI_QUERY_ADDRESS_INFO ,
pMdlAddr
);
KeInitializeEvent ( &kEvent, NotificationEvent, FALSE );
pFilterContext->pQueryIrp->UserEvent = &kEvent;
pFilterContext->pQueryIrp->UserIosb = &iosb;
status = IoCallDriver( pTargetDeviceObject,
pFilterContext->pQueryIrp);
if(status == STATUS_PENDING )
{
(void)KeWaitForSingleObject (
(PVOID)&kEvent,// signaling
object
Executive, // wait reason
KernelMode,// wait mode
TRUE, // alertable
NULL ); // timeout
}
pTA = ((TDI_ADDRESS_INFO*)pTdiAddressInfo)->Address.Address ;
// THE STATEMENT BELOW GENERATES BUG CHECK IRQL_NOT_LESS_OR_EQUAL
DbgPrint((“[INFITCP.SYS]- TdiDispatchIoCompletionRoutine: address: %x :
%u\n”,
ntohl(((TDI_ADDRESS_IP *)(pTA->Address))->in_addr),
ntohs(((TDI_ADDRESS_IP *)(pTA->Address))->sin_port)));
}
The strange point is that the same piece of code works fine while filtering
IRP_MJ_CREATE where in the same style i query for ip address in the
completion routine. where i used ONLY MmBuildMdlForNonPagedPool (NOT
MmProbeAndLockPages)and it works fine …But i tried here both
MmBuildMdlForNonPagedPool and MmProbeAndLockPages…But no luck it crashes
all the ways…
It seems to me that MDL is having problems … But why? how it can be corrected…
pls shed some light on what is happening here…
The stack looks like this -
FramePtr RetAddr Param1 Param2 Param3 Function Name
ffffffffed41f430 ffffffff8042c487 0000000000000003 0000000000000406
ffffffff80461d64 NTOSKRNL!RtlpSetSecurityObject+0x9d (EBP)
ffffffffed41f7bc ffffffff8046856f 0000000000000000 0000000000000406
0000000000000002 NTOSKRNL!KeBugCheckEx+0x573 (EBP)
ffffffffed41f7d8 ffffffff81580b28 0000000000000000 ffffffff81580b28
ffffffffed41fa50 NTOSKRNL!MiAllocatePoolPages+0x312 (EBP)
0000000000000000 0000000000000000 0000000000000000 0000000000000000
0000000000000000 0xFFFFFFFF81580B28 (No FPO)
Regards…
Subodh