From 2ecd5a82ab9dbc2da8ec1c18bd117b566318f64e Mon Sep 17 00:00:00 2001 From: Daniel Kamil Kozar Date: Thu, 7 Dec 2023 21:12:52 +0100 Subject: [PATCH] Pass a pointer to the SPTD struct as the output parameter too (#5) --- cachex_win.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/cachex_win.h b/cachex_win.h index bb6bf8f..e173a3f 100644 --- a/cachex_win.h +++ b/cachex_win.h @@ -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