Skip to content

Commit

Permalink
Pass a pointer to the SPTD struct as the output parameter too (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
lighterowl authored Dec 7, 2023
1 parent d747a0a commit 2ecd5a8
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions cachex_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,21 @@ void sptd_exec(HANDLE handle, SCSI_PASS_THROUGH_DIRECT &sptd, CommandResult &rv)

windows_detail::MP_QueryPerformanceCounter(&PerfCountStart);
auto io_ok = DeviceIoControl(handle, IOCTL_SCSI_PASS_THROUGH_DIRECT, &sptd,
sizeof(SCSI_PASS_THROUGH_DIRECT), NULL, 0,
sizeof(sptd), &sptd, sizeof(sptd),
&dwBytesReturned, NULL);
windows_detail::MP_QueryPerformanceCounter(&PerfCountEnd);

rv.Valid = io_ok ? true : false;
rv.Duration = (PerfCountEnd.QuadPart - PerfCountStart.QuadPart) / freq;
rv.Data.resize(sptd.DataTransferLength);
rv.ScsiStatus = sptd.ScsiStatus;
if (io_ok && dwBytesReturned == sizeof(sptd))
{
rv.Valid = true;
rv.Duration = (PerfCountEnd.QuadPart - PerfCountStart.QuadPart) / freq;
rv.Data.resize(sptd.DataTransferLength);
rv.ScsiStatus = sptd.ScsiStatus;
}
else
{
rv.Valid = false;
}
}

template <std::size_t CDBLength>
Expand Down

0 comments on commit 2ecd5a8

Please sign in to comment.