Calling REQUEST_GET_GENERATION_COUNT from 1394 BusResetRoutine

Hi everyone,

I’ve got what seems to be a trivial problem, however I am a bit stuck so any help would be appreciated.

I am porting a WDM 1394 driver to Win7 and I have trouble getting the new generation count from within the bus reset routine, which runs at DISPATCH_LEVEL IRQL. I use the code below and either get a STATUS_INVALID_PARAMETER or a STATUS_INVALID_DEVICE_REQUEST, depending on whether I use IRP_MJ_DEVICE_CONTROL or IRP_MJ_INTERNAL_DEVICE_CONTROL respectively.

The bus reset callback routine executes the following code (error handling removed):

// StackDeviceObject is what IoAttachDeviceToDeviceStack returned.
StackSize = pDeviceExtension->StackDeviceObject->StackSize + 1;

pIrp = IoAllocateIrp(StackSize, FALSE);
pIRB = ExAllocatePoolWithTag(NonPagedPool, sizeof(IRB), MY_ALLOCATION_TAG);
RtlZeroMemory(pIRB, sizeof(IRB));
pIRB->FunctionNumber = REQUEST_GET_GENERATION_COUNT;
pIRB->Flags = 0;

pIrp->RequestorMode = KernelMode;

IoSetNextIrpStackLocation(pIrp);
IoGetCurrentIrpStackLocation(pIrp)->DeviceObject = pDeviceObject;

// Now set up the stack location for the next driver.
pNextIrpStackLocation = IoGetNextIrpStackLocation(pIrp);
pNextIrpStackLocation->MajorFunction = IRP_MJ_DEVICE_CONTROL;
pNextIrpStackLocation->Parameters.DeviceIoControl.IoControlCode = IOCTL_1394_CLASS;
pNextIrpStackLocation->Parameters.Others.Argument1 = pIRB;

IoSetCompletionRoutine( pIrp, MyCompletionRoutine, pIRB, TRUE, TRUE, TRUE );
ntStatus = IoCallDriver(pDeviceObject, pIrp);

The completion routine looks like this:

NTSTATUS MyCompletionRoutine
(
PDEVICE_OBJECT a_pDeviceObject,
PIRP a_pIrp,
PVOID a_Context
)
{
PDEVICE_EXTENSION pDeviceExtension = a_pDeviceObject->DeviceExtension;
PIRB pIRB = (PIRB)a_Context;

if (NT_SUCCESS(a_pIrp->IoStatus.Status))
{
pDeviceExtension->GenerationCount = pIRB->u.GetGenerationCount.GenerationCount;
}

ExFreePoolWithTag(pIRB, MY_ALLOCATION_TAG);
IoFreeIrp(a_pIrp);

return STATUS_MORE_PROCESSING_REQUIRED;
}

In either case a_pIrp->IoStatus.Status contains the error codes mentioned above.
I first tried on Win7 x86 Checked Build with verifier on, then on Win7 x86 free build but the behavior was the same.
I tried to use 1394ohcitrace.cmd from https://blogs.msdn.com/b/usbcoreblog/archive/2010/02/10/how-to-generate-and-view-a-1394-debug-log.aspx but when I try to view or view_realtime the messages all I get is several “No Format Information found”.

Thanks in advance,
Dimitrios Staikos