1
0

Found working setup

This commit is contained in:
Benjamin Höglinger-Stelzer 2023-06-26 10:20:57 +02:00
parent 3df30bbd04
commit dd7061f728

View File

@ -136,19 +136,19 @@ int wmain(int argc, wchar_t* argv[])
sptwb.spt.TimeOutValue = 120;
sptwb.spt.DataBufferOffset = offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS, ucDataBuf);
sptwb.spt.SenseInfoOffset = offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS, ucSenseBuf);
sptwb.spt.Cdb[0] = 0x26;
sptwb.spt.Cdb[6] = 0x11;
const unsigned short reqSize = htons(sizeof(id_ctlr));
memcpy(&sptwb.spt.Cdb[7], &reqSize, 2);
//sptwb.spt.Cdb[0] = 0x26; // SCSIOP_READ
//sptwb.spt.Cdb[6] = 0x11;
//
//const unsigned short reqSize = htons(sizeof(id_ctlr));
//memcpy(&sptwb.spt.Cdb[7], &reqSize, 2);
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", Calculated length: " << length
<< L", Header length: " << sptwb.spt.Length
<< std::endl;
<< std::endl;*/
BOOL ret = DeviceIoControl(
handle,
@ -165,6 +165,18 @@ int wmain(int argc, wchar_t* argv[])
{
std::wcout << L"Request succeeded" << std::endl;
std::wcout << std::endl;
const std::vector<char> buffer((PUCHAR)&sptwb + sptwb.spt.DataBufferOffset, (PUCHAR)&sptwb + sptwb.spt.DataBufferOffset + sptwb.spt.DataTransferLength);
std::wostringstream ss;
ss << std::hex << std::uppercase << std::setfill(L'0');
std::for_each(buffer.cbegin(), buffer.cend(), [&](int c) { ss << std::setw(2) << (unsigned char)c << L" "; });
const std::wstring hexString = ss.str();
std::wcout << L"Result buffer: " << hexString << std::endl;
std::wcout << std::endl;
}
else
{
@ -267,4 +279,4 @@ int wmain(int argc, wchar_t* argv[])
#endif
CloseHandle(handle);
}
}