PRB: The 1394DIAG Sample Does Not Function Correctly (280077)
The information in this article applies to:
- Microsoft Windows 2000 Driver Development Kit (DDK)
- Microsoft Windows 98 Driver Development Kit (DDK)
This article was previously published under Q280077 SYMPTOMS
After you successfully build and install the 1394Diag.sys file, and then you try to use the Win1394.exe program to call the driver, some of the calls fail. Error messages are displayed inside of the Win1394.exe application that indicate that the respective 1394 operation failed, and the OhcI1394.sys driver returns a STATUS_NOT_SUPPORTED error.
CAUSE
The 1394 host controller driver (OhcI1394.sys) does not allow I/O request packets (IRPs) and/or IOCTLs that the user mode generates because user mode-generated IRPs can corrupt the 1394 stack (for example, if an application passes bad data in).
RESOLUTION
Change each user mode generated IRP from Win1394.exe to a kernel mode generated IRP. To do this, use the following sample code:
NTSTATUS
t1394_BusReset(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN ULONG fulFlags
)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
PDEVICE_EXTENSION deviceExtension = DeviceObject->DeviceExtension;
PIRB pIrb;
PIRP newIrp;
BOOLEAN allocNewIrp = FALSE;
KEVENT Event;
IO_STATUS_BLOCK ioStatus;
ENTER("t1394_BusReset");
TRACE(TL_TRACE, ("fulFlags = 0x%x\n", fulFlags));
// If this is a UserMode request, create a newIrp so that the request
// is issued from KernelMode.
if (Irp->RequestorMode == UserMode) {
newIrp = IoBuildDeviceIoControlRequest (IOCTL_1394_CLASS,
deviceExtension->StackDeviceObject,
NULL, 0, NULL, 0, TRUE, &Event,
&ioStatus);
if (!newIrp) {
TRACE(TL_ERROR, ("Failed to allocate newIrp!\n"));
TRAP;
ntStatus = STATUS_INSUFFICIENT_RESOURCES;
goto Exit_BusReset;
}
allocNewIrp = TRUE;
}
pIrb = ExAllocatePool(NonPagedPool, sizeof(IRB));
if (!pIrb) {
TRACE(TL_ERROR, ("Failed to allocate pIrb!\n"));
TRAP;
ntStatus = STATUS_INSUFFICIENT_RESOURCES;
goto Exit_BusReset;
} // if
RtlZeroMemory (pIrb, sizeof (IRB));
pIrb->FunctionNumber = REQUEST_BUS_RESET;
pIrb->Flags = 0;
pIrb->u.BusReset.fulFlags = fulFlags;
//
// If you allocated this IRP, submit it asynchronously and wait for its
// completion event to be signaled, otherwise, submit it synchronously.
//
if (allocNewIrp) {
KeInitializeEvent (&Event, NotificationEvent, FALSE);
ntStatus = t1394_SubmitIrpAsync(deviceExtension->StackDeviceObject,
newIrp, pIrb);
if (ntStatus == STATUS_PENDING) {
KeWaitForSingleObject (&Event, Executive, KernelMode, FALSE,
NULL);
ntStatus = ioStatus.Status;
}
}
else {
ntStatus = t1394_SubmitIrpSynch(deviceExtension->StackDeviceObject,
Irp, pIrb);
}
if (!NT_SUCCESS(ntStatus)) {
TRACE(TL_ERROR, ("SubmitIrpSync failed = 0x%x\n", ntStatus));
TRAP;
}
ExFreePool(pIrb);
Exit_BusReset:
if (allocNewIrp)
Irp->IoStatus = ioStatus;
EXIT("t1394_BusReset", ntStatus);
return(ntStatus);
Modification Type: | Minor | Last Reviewed: | 11/23/2005 |
---|
Keywords: | kbADO260fix kbmm kbprb kbWDM KB280077 |
---|
|