Trim = Irp->AssociatedIrp.SystemBuffer;
- Trim->Version = 0;
+ Trim->Version = sizeof(DEVICE_TRIM_DESCRIPTOR);
Trim->Size = sizeof(DEVICE_TRIM_DESCRIPTOR);
Trim->TrimEnabled = TRUE;
Cdb->UNMAP.OperationCode = SCSIOP_UNMAP;
*(PUSHORT)Cdb->UNMAP.AllocationLength = _byteswap_ushort((USHORT)Length);
- *(PUSHORT)Unmap->DataLength = _byteswap_ushort((USHORT)Length);
- *(PUSHORT)Unmap->BlockDescrDataLength = _byteswap_ushort((USHORT)sizeof(UNMAP_BLOCK_DESCRIPTOR));
+ *(PUSHORT)Unmap->DataLength = _byteswap_ushort((USHORT)(Length - FIELD_OFFSET(UNMAP_LIST_HEADER, BlockDescrDataLength)));
+ *(PUSHORT)Unmap->BlockDescrDataLength = _byteswap_ushort((USHORT)(Length - FIELD_OFFSET(UNMAP_LIST_HEADER, Descriptors[0])));
for (Index = 0; Index < Count; ++Index) {
PUNMAP_BLOCK_DESCRIPTOR Block = &Unmap->Descriptors[Index];
{
PXENVBD_SRBEXT SrbExt = GetSrbExt(Srb);
PUNMAP_LIST_HEADER Unmap = Srb->DataBuffer;
- ULONG Count = _byteswap_ushort(*(PUSHORT)Unmap->DataLength) /
- _byteswap_ushort(*(PUSHORT)Unmap->BlockDescrDataLength);
+ ULONG Count = _byteswap_ushort(*(PUSHORT)Unmap->BlockDescrDataLength) / sizeof(UNMAP_BLOCK_DESCRIPTOR);
ULONG Index;
LIST_ENTRY List;