Hi,
In my Tdi filter driver i need to call TdiBuildQueryInformation in order to ectract address information from FileObject Associated with the IRP.When I try to do this the call to TdiBuildQueryInformation Generates a bug check always with different bug codes.
1-ATTEMPTED_SWITCH_FROM_DPC
2-PFN_LIST_CORRUPT
3-Access Violation
I guess from the above that there is some problem with calling this functions from within the Completion Routine which is being called in arbitary thread context and at probably DISPATCH_LEVEL .Or it is something else ??
Do i need to put the code and allocate a WorkQueue item in order to get this info.
But the question is when the worker thread will get a chance to execute this code at that point of time will this FileObject and Irp be Valid ???
What is the correct way to do this???
Any Help is appreciated…
The Code is here –
PIRP pQueryIrp;
IO_STATUS_BLOCK IoStatusBlock;
PMDL pMdlForAddressInfo;
PVOID TdiAddressInfo;
TRANSPORT_ADDRESS TransportAddress;
TA_ADDRESS AddressArray;
PTDI_ADDRESS_IP pOneIPAddress;
TdiAddressInfo = ExAllocatePoolWithTag(NonPagedPool,
sizeof(TDI_ADDRESS_INFO),
‘QADR’);
if(!TdiAddressInfo )
{
DbgPrint(“Allocation Failed \n”);
return status;
}
pMdlForAddressInfo = IoAllocateMdl(TdiAddressInfo,
sizeof(TDI_ADDRESS_INFO),
FALSE,
FALSE,NULL);
if(pMdlForAddressInfo == NULL)
{
DbgPrint(“Mdl Allocation Failed…\n”);
ExFreePool(TdiAddressInfo);
return status;
}
__try
{
MmProbeAndLockPages(pMdlForAddressInfo,
KernelMode ,
IoModifyAccess);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
IoFreeMdl(pMdlForAddressInfo);
pMdlForAddressInfo = NULL;
}
pQueryIrp = TdiBuildInternalDeviceControlIrp (
TDI_QUERY_INFORMATION ,
pDeviceObject,
pIrpStackLocation->FileObject ,
NULL,
&IoStatusBlock
);
if(pQueryIrp == NULL)
{
DbgPrint(“Building Internal DeviceControlIrp Failed \n”);
return status;
}
MmBuildMdlForNonPagedPool(pMdlForAddressInfo);
TdiBuildQueryInformation ( pQueryIrp,
pTCPDevObj,
pIrpStackLocation->FileObject,
NULL, // No Comp Routine
NULL, // No Context
TDI_QUERY_ADDRESS_INFO,
pMdlForAddressInfo
);
DbgPrint(“Calling TCP \n”);
status = IoCallDriver(pTCPDevObj,pQueryIrp);
–Subodh