WdfUsbTargetDeviceFormatRequestForControlTransfer Fails with STATUS_INVALID_PARAMETER

Hi All,
I am developing a USB driver based on KMDF.
My driver communicate on default end point. I am using WdfUsbTargetDeviceFormatRequestForControlTransfer to send Vendor specific request to device, but it fails with status INVALID_PARAMETER. Why its so? Which parameter is Invalid?
Please help me to solve this problem.
Please look into the code and tell me is there some thing missing?
Is there any other way to communicate to device?

One more question:
presently i am not able to debug my driver as I don’t have a test system. I am developing on xp sp2. I have Windbg debug tool. Can i use it to debug my driver? Is to so how can i do that?

Code for reading fron device:

NTSTATUS EvtIoctlREAD(IN WDFQUEUE Queue,
IN WDFREQUEST Request,
IN size_t OutputBufferLength,
IN size_t InputBufferLength)
{
NTSTATUS status = STATUS_SUCCESS;
WDF_USB_CONTROL_SETUP_PACKET controlPacket;
WDF_MEMORY_DESCRIPTOR memDescriptor;
WDFREQUEST NewRequest;
PDEVICE_CONTEXT devCtx = NULL;
WDFMEMORY memHandle;
size_t length = 0;
PVOID buffer;
size_t bufSize;
PORT_RW_STRUCT *ub ;
WDF_OBJECT_ATTRIBUTES attributes;
UsbSamp_DbgPrint(3, (“entering IoctlREAD\n”));
devCtx = GetDeviceContext(WdfIoQueueGetDevice(Queue));
status = WdfRequestRetrieveOutputBuffer( Request, sizeof(PORT_RW_STRUCT),
&buffer,
&bufSize
);
if (!NT_SUCCESS(status))
{
UsbSamp_DbgPrint(3, (“IoctlREAD… WdfRequestRetrieveInputBuffer FAIL”));
return status;
}

ub = (PPORT_RW_STRUCT) buffer;
WDF_OBJECT_ATTRIBUTES_INIT(&attributes);

status = WdfRequestCreate(
&attributes,
WdfUsbTargetDeviceGetIoTarget(
devCtx->WdfUsbTargetDevice),
&NewRequest
);
if (!NT_SUCCESS(status)){
return status;
}

WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
attributes.ParentObject = NewRequest;
status = WdfMemoryCreate(
&attributes,
NonPagedPool,
0,
sizeof(PORT_RW_STRUCT),
&memHandle,
NULL
);
if (!NT_SUCCESS(status)){
return status;
}

WDF_USB_CONTROL_SETUP_PACKET_INIT_VENDOR(
&controlPacket,
BmRequestDeviceToHost,
BmRequestToDevice,
ub->bRequest,//0x05
0,
0);
status = WdfUsbTargetDeviceFormatRequestForControlTransfer(
devCtx->WdfUsbTargetDevice,
NewRequest,
&controlPacket,
memHandle,
NULL
);
if (!NT_SUCCESS(status)){
UsbSamp_DbgPrint(3, (“WdfUsbTargetDeviceFormatRequestForControlTransfer failed with status 0x%08x\n”,
status));

return status;
}
WdfRequestSetCompletionRoutine(
NewRequest,
DatGuardCompletionGetData,
NULL
);
if (WdfRequestSend(
NewRequest,
WdfUsbTargetDeviceGetIoTarget(devCtx->WdfUsbTargetDevice),
NULL
) == FALSE) {
status = WdfRequestGetStatus(NewRequest);
}

Thanks,
Abdul