Newbie USBFX2 question

Hello,

Complete drvier newbie here, forgive me. If this is too basic for ntdev, is there a more appropriate forum?

I just got my USBFX2 learning kit, and it is awesome. Now that I have built the driver and test app, I’m starting on my first modification, which is to change the bit order in the Set/GetBarGraphState ioctls so that it makes more sense. All I want to do for now is to rotate the state field to the right by 3 bits during sets and gets so that bit 0 represents light 1, and bit 7 represents light 8.

The Set operation is no problem. I just munge the first byte of Irp->AssociatedIrp.SystemBuffer in UsbFx2LkDeviceControl() in the handler for IOCTL_OSRUSBFX2_SET_BAR_GRAPH_DISPLAY.

However the Get operation is completely stumping me. It looks like the IOCTL_OSRUSBFX2_GET_BAR_GRAPH_DISPLAY Irp is completed by a low-level driver, and I have not been able to figure out how to modify the output buffer before it is returned to the client app.

I added the following code to AsynchronousUrbRequestCompletion() as an attempt at doing this, but it has no effect:

case URB_FUNCTION_VENDOR_DEVICE:
{
if (urb->UrbControlVendorClassRequest.Request == USBFX2LK_READ_BARGRAPH_DISPLAY)
{
// Try modifying
// urb->UrbControlVendorClassRequest.Transferbuffer,
// which should contain (I think) the output buffer.
BAR_GRAPH_STATE *pbarstate = (BAR_GRAPH_STATE *)urb->UrbControlVendorClassRequest.TransferBuffer;
UCHAR bars = ((pbarstate->BarsAsUChar>>3)&0x1f);
bars |= (pbarstate->BarsAsUChar<<5);
pbarstate->BarsAsUChar = bars;

// Try modifying Irp->AssociatedIrp.SystemBuffer, which
// contained the state during the Set operation.
BAR_GRAPH_STATE *pbarstate2 = (BAR_GRAPH_STATE *)Irp->AssociatedIrp.SystemBuffer;
UCHAR bars = ((pbarstate->BarsAsUChar>>3)&0x1f);
bars |= (pbarstate->BarsAsUChar<<5);
pbarstate2->BarsAsUChar = bars;
}
}

What I’m basically wondering is, what is the “right” way to modify the output buffer of an Irp that is completed by a lower-level driver. I assume this is a common operation for Filter Drivers, but for an FDO like the USBFX2 sample driver, I don’t know how common it is.

I’m wading through the DDK to find the right answer to this, but thought I’d see if a quick answer is available on ntdev while I’m at it.

Thanks in advance,
Kevin

What is the toplevel switch statement? Is your case statement even executing? When you are completing the request, what you setting Irp->IoStatus.Information to? For the values to be copied back, you need to set it to sizeof(BAR_GRAPH_STATE).

D