Microsoft KB Archive/280077

= PRB: The 1394DIAG Sample Does Not Function Correctly =

Article ID: 280077

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Win32 Device Driver Kit for Windows 2000
 * 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(&quot;t1394_BusReset&quot;);

TRACE(TL_TRACE, (&quot;fulFlags = 0x%x\n&quot;, 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, (&quot;Failed to allocate newIrp!\n&quot;)); TRAP; ntStatus = STATUS_INSUFFICIENT_RESOURCES; goto Exit_BusReset; }        allocNewIrp = TRUE; }   pIrb = ExAllocatePool(NonPagedPool, sizeof(IRB));

if (!pIrb) {

TRACE(TL_ERROR, (&quot;Failed to allocate pIrb!\n&quot;)); 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, (&quot;SubmitIrpSync failed = 0x%x\n&quot;, ntStatus)); TRAP; }

ExFreePool(pIrb);

Exit_BusReset:

if (allocNewIrp) Irp->IoStatus = ioStatus; EXIT(&quot;t1394_BusReset&quot;, ntStatus); return(ntStatus);



MORE INFORMATION
This problem is resolved in the latest Windows DDK 1394Diag sample. The latest Windows DDK is available for download at the following web site:

Microsoft Windows Driver Development Kits

http://www.microsoft.com/whdc/devtools/ddk/default.mspx/

Keywords: kbado260fix kbmm kbprb kbwdm KB280077

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.