AFAIK, waiting in a IRP Completion Routine is illegal. The call contract is
that the routine runs at IRQL <= DISPATCH_LEVEL.
You should not assume that under all conditions (and other possible TDI
filters) that the completion process can ‘wait’ like this.
Would it not be better to:
- Issue the IRP with the query address.
- Return STATUS_MORE_PROCESSING_REQUIRED from the “connect” CRTN to stop
completion processing.
- In the CRTN for the “query address” call IoCompleteRequest() on the
“connect” IRP to continue the completion processing.
Or something like that?
Or if you don’t actually *need* the local address to decide how to complete
the connect IRP then just let the query IRP complete asynchronously and
cleanup the query IRP in its CRTN.
Since I don’t actually know that your driver needs to do, I am just
guessing. But it seems you wish to know the full IP address and port on
both ends of a TCP connection, perhaps to make some policy decision.
Good Luck,
Dave Cattley
Consulting Engineer
Systems Software Developement
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@yahoo.co.in
Sent: Monday, March 09, 2009 8:09 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] TDI Driver and BSOD on Windows 2008 Server
hello,
thanks David R. Cattley.
i took time to understand it and tried to come up with some solution.
here is the code that was in the DoCompletion() it does take care of Making
IRP pending if pending returned flag is true.
NTSTATUS DoCompletion(PDEVICE_OBJECT dev, PIRP irp, PVOID ctx)
{
LONG detaching, pending_io;
snoop_dev_ext_t *dx = (snoop_dev_ext_t *)dev->DeviceExtension;
if (irp->PendingReturned)
IoMarkIrpPending(irp);
return STATUS_SUCCESS;
}
so SL_PENDING_RETURNED issue is not present.
to resolve this. i created a KEVENT object and after passing the driver for
next lower level driver i wait upon that event if i get the STATUS_PENDING.
NTSTATUS status;
snoop_dev_ext_t *dx;
PIO_STACK_LOCATION irps;
KEVENT kEvent;
IO_STATUS_BLOCK io_status_block;
BOOLEAN bWait = FALSE;
ksnoop_event_t *evt = (ksnoop_event_t *)ctx;
PMDL mdl = NULL;
if (irp->IoStatus.Status != STATUS_SUCCESS)
goto done;
dx = (snoop_dev_ext_t*)dev->DeviceExtension;
InterlockedIncrement(&dx->open_addresses);
irps = IoGetCurrentIrpStackLocation(irp);
mdl = IoAllocateMdl(evt->tai, sizeof(evt->tai), FALSE, FALSE, NULL);
if (!mdl)
goto done;
if ( KeGetCurrentIrql() <= DISPATCH_LEVEL )
{
KeInitializeEvent ( &kEvent, NotificationEvent, FALSE );
evt->qirp->UserEvent = &kEvent;
evt->qirp->UserIosb = &io_status_block;
bWait = TRUE;
}
MmBuildMdlForNonPagedPool(mdl);
TdiBuildQueryInformation(evt->qirp, dx->dev_lower, irps->FileObject,
crQueryAddressInfo, evt, TDI_QUERY_ADDRESS_INFO, mdl);
status = IoCallDriver(dx->dev_lower, evt->qirp);
if(( bWait == TRUE) && status == STATUS_PENDING )
{
KeWaitForSingleObject( (PVOID)&kEvent, Executive,
KernelMode, TRUE, NULL );
status = io_status_block.Status;
return DoCompletion(dev, irp, NULL);
}
else if (status != STATUS_SUCCESS )
goto done;
mdl = NULL;
evt = NULL;
done:
if (mdl)
IoFreeMdl(mdl);
if (evt)
{
IoCompleteRequest(evt->qirp, IO_NO_INCREMENT);
snoop_event_free(evt);
}
return DoCompletion(dev, irp, NULL);
}
after adding this i did not get any blue screen. but as you told working
does’t mean correct. 
is there any thing wrong with respect to the guide-line?
sorry if i am wrong :0. i am trying my best.
regards
deep
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer