@@ -153,7 +153,7 @@ store_urb_get_intf_desc(PIRP irp, PURB urb, struct urb_req *urbr)
153
153
}
154
154
155
155
static NTSTATUS
156
- store_urb_class_vendor_partial (PIRP irp , PURB urb )
156
+ store_urb_class_vendor_partial (PPDO_DEVICE_DATA pdodata , PIRP irp , PURB urb )
157
157
{
158
158
struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST * urb_vc = & urb -> UrbControlVendorClassRequest ;
159
159
PVOID dst ;
@@ -164,6 +164,7 @@ store_urb_class_vendor_partial(PIRP irp, PURB urb)
164
164
165
165
RtlCopyMemory (dst , urb_vc -> TransferBuffer , urb_vc -> TransferBufferLength );
166
166
irp -> IoStatus .Information = urb_vc -> TransferBufferLength ;
167
+ pdodata -> len_sent_partial = 0 ;
167
168
168
169
return STATUS_SUCCESS ;
169
170
}
@@ -292,7 +293,7 @@ store_urb_select_interface(PIRP irp, PURB urb, struct urb_req *urbr)
292
293
}
293
294
294
295
static NTSTATUS
295
- store_urb_bulk_partial (PIRP irp , PURB urb )
296
+ store_urb_bulk_partial (PPDO_DEVICE_DATA pdodata , PIRP irp , PURB urb )
296
297
{
297
298
struct _URB_BULK_OR_INTERRUPT_TRANSFER * urb_bi = & urb -> UrbBulkOrInterruptTransfer ;
298
299
PVOID dst , src ;
@@ -306,6 +307,7 @@ store_urb_bulk_partial(PIRP irp, PURB urb)
306
307
return STATUS_INSUFFICIENT_RESOURCES ;
307
308
RtlCopyMemory (dst , src , urb_bi -> TransferBufferLength );
308
309
irp -> IoStatus .Information = urb_bi -> TransferBufferLength ;
310
+ pdodata -> len_sent_partial = 0 ;
309
311
310
312
return STATUS_SUCCESS ;
311
313
}
@@ -315,14 +317,17 @@ store_urb_bulk(PIRP irp, PURB urb, struct urb_req *urbr)
315
317
{
316
318
struct _URB_BULK_OR_INTERRUPT_TRANSFER * urb_bi = & urb -> UrbBulkOrInterruptTransfer ;
317
319
struct usbip_header * hdr ;
318
- int type ;
319
- int in = urb_bi -> TransferFlags & USBD_TRANSFER_DIRECTION_IN ? 1 : 0 ;
320
+ int in , type ;
320
321
321
322
hdr = get_usbip_hdr_from_read_irp (irp );
322
323
if (hdr == NULL ) {
323
324
return STATUS_BUFFER_TOO_SMALL ;
324
325
}
325
326
327
+ /* Sometimes, direction in TransferFlags of _URB_BULK_OR_INTERRUPT_TRANSFER is not consistent with PipeHandle.
328
+ * Use a direction flag in pipe handle.
329
+ */
330
+ in = PIPE2DIRECT (urb_bi -> PipeHandle );
326
331
type = PIPE2TYPE (urb_bi -> PipeHandle );
327
332
if (type != USB_ENDPOINT_TYPE_BULK && type != USB_ENDPOINT_TYPE_INTERRUPT ) {
328
333
DBGE (DBG_READ , "Error, not a bulk pipe\n" );
@@ -384,7 +389,7 @@ copy_iso_data(PVOID dst, struct _URB_ISOCH_TRANSFER *urb_iso)
384
389
}
385
390
386
391
static NTSTATUS
387
- store_urb_iso_partial (PIRP irp , PURB urb )
392
+ store_urb_iso_partial (PPDO_DEVICE_DATA pdodata , PIRP irp , PURB urb )
388
393
{
389
394
struct _URB_ISOCH_TRANSFER * urb_iso = & urb -> UrbIsochronousTransfer ;
390
395
ULONG len_iso = urb_iso -> TransferBufferLength + urb_iso -> NumberOfPackets * sizeof (struct usbip_iso_packet_descriptor );
@@ -396,6 +401,8 @@ store_urb_iso_partial(PIRP irp, PURB urb)
396
401
397
402
copy_iso_data (dst , urb_iso );
398
403
irp -> IoStatus .Information = len_iso ;
404
+ pdodata -> len_sent_partial = 0 ;
405
+
399
406
return STATUS_SUCCESS ;
400
407
}
401
408
@@ -517,10 +524,10 @@ store_urbr_partial(PIRP irp, struct urb_req *urbr)
517
524
518
525
switch (code_func ) {
519
526
case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER :
520
- status = store_urb_bulk_partial (irp , urb );
527
+ status = store_urb_bulk_partial (urbr -> pdodata , irp , urb );
521
528
break ;
522
529
case URB_FUNCTION_ISOCH_TRANSFER :
523
- status = store_urb_iso_partial (irp , urb );
530
+ status = store_urb_iso_partial (urbr -> pdodata , irp , urb );
524
531
break ;
525
532
case URB_FUNCTION_CLASS_DEVICE :
526
533
case URB_FUNCTION_CLASS_INTERFACE :
@@ -529,7 +536,7 @@ store_urbr_partial(PIRP irp, struct urb_req *urbr)
529
536
case URB_FUNCTION_VENDOR_DEVICE :
530
537
case URB_FUNCTION_VENDOR_INTERFACE :
531
538
case URB_FUNCTION_VENDOR_ENDPOINT :
532
- status = store_urb_class_vendor_partial (irp , urb );
539
+ status = store_urb_class_vendor_partial (urbr -> pdodata , irp , urb );
533
540
break ;
534
541
default :
535
542
irp -> IoStatus .Information = 0 ;
0 commit comments