about IoCallDriver for TDI lower driver in the TDI filter driver

I have a doubt about IoCallDriver for TDI lower driver in the TDI filter
driver.
The TDI filter dirver shut down the system when I try to connect the other
local networked computer.
But not shut down the system when I use Internet-Explore or other Internet
application using TCP/IP.
Sometime show me "NO_MORE_IRP_STACK_LOCATION:… " in blue screen.
Why? and How can I fix them???

How check whether I/O stack space of IRP is insufficient… and make new
IRP for next low driver?

//////////////////////////////////
NTSTATUS
TdimonHookRoutine(PDEVICE_OBJECT HookDevice, IN PIRP Irp)
{
PIO_STACK_LOCATION currentIrpStack = IoGetCurrentIrpStackLocation(Irp);
PIO_STACK_LOCATION nextIrpStack = IoGetNextIrpStackLocation(Irp);

// hook and process dispatch routine for monitoring

if (Irp->CurrentLocation <= 1) // If no more stack
location…allocate new IRP for next low driver…
{
PIRP newIrp;
PIO_STACK_LOCATION newNextIrpStack;
KEVENT event;
NTSTATUS ntRet;

//
// Initialize the event
//
KeInitializeEvent(&event, SynchronizationEvent, FALSE);

newIrp = IoAllocateIrp((CCHAR)(hookExt->FileSystem->StackSize + 1),
FALSE);

if (!newIrp)
{
DbgPrint((“!!! Error : IoAllocateIrp !!!\n”));
return STATUS_INSUFFICIENT_RESOURCES;
}

//
// Build the IRP’s main body
//
newIrp->AssociatedIrp.SystemBuffer =
Irp->AssociatedIrp.SystemBuffer;
newIrp->UserEvent = &event;
newIrp->UserIosb = Irp->UserIosb;
newIrp->Tail.Overlay.Thread = PsGetCurrentThread();
newIrp->Tail.Overlay.OriginalFileObject = FileObject;
newIrp->RequestorMode = KernelMode;
newIrp->Flags = Irp->Flags;
newIrp->MdlAddress = Irp->MdlAddress;

//
// Set up the I/O stack location.
//
newNextIrpStack = IoGetNextIrpStackLocation(newIrp);
*newNextIrpStack = *currentIrpStack;
IoSetNextIrpStackLocation( newIrp );

newNextIrpStack->MajorFunction = currentIrpStack->MajorFunction;
newNextIrpStack->MinorFunction = currentIrpStack->MinorFunction;
newNextIrpStack->Flags = currentIrpStack->Flags;
newNextIrpStack->Control = currentIrpStack->Control;
newNextIrpStack->DeviceObject = hookExt->FileSystem;
newNextIrpStack->FileObject = FileObject;
memcpy( &(newNextIrpStack->Parameters),
&(currentIrpStack->Parameters), sizeof(ULONG) * 4 );

IoSetCompletionRoutine( newIrp, TDIMonNewHookComplete, 0, TRUE,
TRUE, TRUE);

ntRet = IoCallDriver( hookExt->FileSystem, newIrp );

KeWaitForSingleObject(&event, Executive, KernelMode, TRUE, 0);

return ntRet;
}

return IoCallDriver( hookExt->FileSystem, Irp );
}
//////////////////////////////////


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

The bogus stack location is probably caused by NetBT. If NetBT opens the TCP
device before you attach your filter, then it determines the number of IRP
stack locations without taking your filter into account.

The solution is to attach your filter early enough to prevent this. One way
to accomplish this is to make NetBT depend on your filter.

A way to prevent the BSOD is to simply complete the “too small” IRP
immediately. Set Status to STATUS_INVALID_REQUEST, Information to 0 and call
IoCompleteRequest(). Of course, this isn’t a “fix”; just a way to get on
with your life for testing.

Regards,

Thomas F. Divine

PCAUSA - Toolkits & Resources For Network Software Developers
NDIS Protocol - NDIS Intermediate - TDI Client
http: - http:

----- Original Message -----
From: Hokyun Park
To: NT Developers Interest List
Sent: Friday, April 27, 2001 3:20 AM
Subject: [ntdev] about IoCallDriver for TDI lower driver in the TDI filter
driver

> I have a doubt about IoCallDriver for TDI lower driver in the TDI filter
> driver.
> The TDI filter dirver shut down the system when I try to connect the other
> local networked computer.
> But not shut down the system when I use Internet-Explore or other Internet
> application using TCP/IP.
> Sometime show me “NO_MORE_IRP_STACK_LOCATION:… " in blue screen.
> Why? and How can I fix them???
>
> How check whether I/O stack space of IRP is insufficient… and make new
> IRP for next low driver?
>
> //////////////////////////////////
> NTSTATUS
> TdimonHookRoutine(PDEVICE_OBJECT HookDevice, IN PIRP Irp)
> {
> PIO_STACK_LOCATION currentIrpStack =
IoGetCurrentIrpStackLocation(Irp);
> PIO_STACK_LOCATION nextIrpStack = IoGetNextIrpStackLocation(Irp);
>
> // hook and process dispatch routine for monitoring
>
> if (Irp->CurrentLocation <= 1) // If no more stack
> location…allocate new IRP for next low driver…
> {
> PIRP newIrp;
> PIO_STACK_LOCATION newNextIrpStack;
> KEVENT event;
> NTSTATUS ntRet;
>
> //
> // Initialize the event
> //
> KeInitializeEvent(&event, SynchronizationEvent, FALSE);
>
> newIrp = IoAllocateIrp((CCHAR)(hookExt->FileSystem->StackSize +
1),
> FALSE);
>
> if (!newIrp)
> {
> DbgPrint((”!!! Error : IoAllocateIrp !!!\n"));
> return STATUS_INSUFFICIENT_RESOURCES;
> }
>
> //
> // Build the IRP’s main body
> //
> newIrp->AssociatedIrp.SystemBuffer =
> Irp->AssociatedIrp.SystemBuffer;
> newIrp->UserEvent = &event;
> newIrp->UserIosb = Irp->UserIosb;
> newIrp->Tail.Overlay.Thread = PsGetCurrentThread();
> newIrp->Tail.Overlay.OriginalFileObject = FileObject;
> newIrp->RequestorMode = KernelMode;
> newIrp->Flags = Irp->Flags;
> newIrp->MdlAddress = Irp->MdlAddress;
>
> //
> // Set up the I/O stack location.
> //
> newNextIrpStack = IoGetNextIrpStackLocation(newIrp);
> *newNextIrpStack = *currentIrpStack;
> IoSetNextIrpStackLocation( newIrp );
>
> newNextIrpStack->MajorFunction = currentIrpStack->MajorFunction;
> newNextIrpStack->MinorFunction = currentIrpStack->MinorFunction;
> newNextIrpStack->Flags = currentIrpStack->Flags;
> newNextIrpStack->Control = currentIrpStack->Control;
> newNextIrpStack->DeviceObject = hookExt->FileSystem;
> newNextIrpStack->FileObject = FileObject;
> memcpy( &(newNextIrpStack->Parameters),
> &(currentIrpStack->Parameters), sizeof(ULONG) * 4 );
>
> IoSetCompletionRoutine( newIrp, TDIMonNewHookComplete, 0, TRUE,
> TRUE, TRUE);
>
> ntRet = IoCallDriver( hookExt->FileSystem, newIrp );
>
> KeWaitForSingleObject(&event, Executive, KernelMode, TRUE, 0);
>
> return ntRet;
> }
>
> return IoCallDriver( hookExt->FileSystem, Irp );
> }
> //////////////////////////////////
>


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com</http:></http:>