Cleaned up sizes and buffer usages
This commit is contained in:
parent
dd7061f728
commit
281fb7e2b8
@ -124,18 +124,23 @@ int wmain(int argc, wchar_t* argv[])
|
|||||||
ULONG length = 0, returned = 0;
|
ULONG length = 0, returned = 0;
|
||||||
SCSI_PASS_THROUGH_WITH_BUFFERS sptwb;
|
SCSI_PASS_THROUGH_WITH_BUFFERS sptwb;
|
||||||
|
|
||||||
|
BYTE cdb[] = { 0x12, 0x00, 0x00, 0x00, 0xFF, 0x00 }; // SCSI Inquiry CDB
|
||||||
|
|
||||||
ZeroMemory(&sptwb, sizeof(SCSI_PASS_THROUGH_WITH_BUFFERS));
|
ZeroMemory(&sptwb, sizeof(SCSI_PASS_THROUGH_WITH_BUFFERS));
|
||||||
sptwb.spt.Length = sizeof(SCSI_PASS_THROUGH);
|
sptwb.spt.Length = sizeof(SCSI_PASS_THROUGH);
|
||||||
sptwb.spt.PathId = 0;
|
sptwb.spt.PathId = 0;
|
||||||
sptwb.spt.TargetId = 0;
|
sptwb.spt.TargetId = 0;
|
||||||
sptwb.spt.Lun = 0;
|
sptwb.spt.Lun = 0;
|
||||||
sptwb.spt.CdbLength = 10;
|
sptwb.spt.CdbLength = ARRAYSIZE(cdb);
|
||||||
sptwb.spt.SenseInfoLength = SPT_SENSE_LENGTH;
|
sptwb.spt.SenseInfoLength = SPT_SENSE_LENGTH;
|
||||||
sptwb.spt.DataIn = SCSI_IOCTL_DATA_IN;
|
sptwb.spt.DataIn = SCSI_IOCTL_DATA_IN;
|
||||||
sptwb.spt.DataTransferLength = SPTWB_DATA_LENGTH;
|
sptwb.spt.DataTransferLength = SPTWB_DATA_LENGTH;
|
||||||
sptwb.spt.TimeOutValue = 120;
|
sptwb.spt.TimeOutValue = 120;
|
||||||
sptwb.spt.DataBufferOffset = offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS, ucDataBuf);
|
sptwb.spt.DataBufferOffset = offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS, ucDataBuf);
|
||||||
sptwb.spt.SenseInfoOffset = offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS, ucSenseBuf);
|
sptwb.spt.SenseInfoOffset = offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS, ucSenseBuf);
|
||||||
|
|
||||||
|
memcpy(sptwb.spt.Cdb, cdb, sizeof(cdb));
|
||||||
|
|
||||||
//sptwb.spt.Cdb[0] = 0x26; // SCSIOP_READ
|
//sptwb.spt.Cdb[0] = 0x26; // SCSIOP_READ
|
||||||
//sptwb.spt.Cdb[6] = 0x11;
|
//sptwb.spt.Cdb[6] = 0x11;
|
||||||
//
|
//
|
||||||
@ -144,11 +149,11 @@ int wmain(int argc, wchar_t* argv[])
|
|||||||
|
|
||||||
length = offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS, ucDataBuf) + sptwb.spt.DataTransferLength;
|
length = offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS, ucDataBuf) + sptwb.spt.DataTransferLength;
|
||||||
|
|
||||||
/*std::wcout << std::dec
|
std::wcout << std::dec
|
||||||
<< L"Total struct size: " << sizeof(SCSI_PASS_THROUGH_WITH_BUFFERS)
|
<< L"Total struct size: " << sizeof(SCSI_PASS_THROUGH_WITH_BUFFERS)
|
||||||
<< L", Calculated length: " << length
|
<< L", Calculated length: " << length
|
||||||
<< L", Header length: " << sptwb.spt.Length
|
<< L", Header length: " << sptwb.spt.Length
|
||||||
<< std::endl;*/
|
<< std::endl;
|
||||||
|
|
||||||
BOOL ret = DeviceIoControl(
|
BOOL ret = DeviceIoControl(
|
||||||
handle,
|
handle,
|
||||||
@ -163,10 +168,10 @@ int wmain(int argc, wchar_t* argv[])
|
|||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
std::wcout << L"Request succeeded" << std::endl;
|
std::wcout << L"Request succeeded (bytes returned: " << returned << L")" << std::endl;
|
||||||
std::wcout << std::endl;
|
std::wcout << std::endl;
|
||||||
|
|
||||||
const std::vector<char> buffer((PUCHAR)&sptwb + sptwb.spt.DataBufferOffset, (PUCHAR)&sptwb + sptwb.spt.DataBufferOffset + sptwb.spt.DataTransferLength);
|
const std::vector<char> buffer(sptwb.ucDataBuf, sptwb.ucDataBuf + length);
|
||||||
|
|
||||||
std::wostringstream ss;
|
std::wostringstream ss;
|
||||||
|
|
||||||
@ -279,4 +284,4 @@ int wmain(int argc, wchar_t* argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
CloseHandle(handle);
|
CloseHandle(handle);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user