THIS_SCSI_PASS_THROUGH_DIRECT sptd; memset(&sptd, 0, sizeof(THIS_SCSI_PASS_THROUGH_DIRECT)); sptd.msptd.Length = sizeof(SCSI_PASS_THROUGH_DIRECT); ... sptd.msptd.DataTransferLength = cbData; // <<==== !!! sptd.msptd.DataBuffer = pData; // send receive command if ( !DeviceIoControl(hDevice, IOCTL_SCSI_PASS_THROUGH_DIRECT,&sptd, sizeof(THIS_SCSI_PASS_THROUGH_DIRECT), &sptd, sizeof(THIS_SCSI_PASS_THROUGH_DIRECT), &cbRecvData, NULL)) { // failed int nErrD= (int)wbs::SystemInfo::GetLastError();// error 87 (invalid parameter)
There is a known problem in Win8 builds before 8320,
where non-page aligned transfers fail for lengths falling
within the range [(64K - 4K), 64K].
The problem is fixed in builds 8320 or later.
I'm not sure when a newer build will be generally available.
In the meantime here are a few things to try.
The following per-device setting can be used to
increase the maximum transfer length from 64K to 128K,
enabling IOCTL_SCSI_PASS_THROUGH_DIRECT to transfer
more than 64K to the device.
As an added bonus it may also increase general I/O throughput to the device.
This setting is implemented on Windows Vista and above,
however use it with caution and thoroughly test with
a particular device to ensure the device can tolerate this change.
Some devices have been observed to have problems functioning properly
when this setting is modified.
With bit value 0x8 set on this DWORD registry value,
USBSTOR increases the maximum transfer length reported
for the specific device to 128KB. Otherwise the default value is 64KB.
HKLM\System\CurrentControlSet\Control\usbstor\VVVVPPPP DWORD: "DeviceHackFlags"
Where “VVVV” represents the 4-digit USB Vendor ID for the device
and “PPPP” represents the 4-digit Product ID.
Leading 0’s are required. Restart the device
(e.g. enable/disable or unplug/plug) for this setting to take effect.
To obtain Vendor/Product ID for the device open device manager
and select View -> Devices by connection.
Right click on “USB Mass Storage Device”
which is the parent of the recognized disk device.
Then select Propertiesfrom the pop-up menu to bring up the Properties dialog.
From the Properties dialog, select Details tab, then Hardware Idsproperty:
Also in Windows 8, a larger maximum transfer length value
is enabled by default for USB 3.0 mass storage devices.
The problem seems to be solved with Windows 8 Build 8400.