Jump to content

[SPTI Programming] Always getting errcode 87


donmor3000
 Share

Recommended Posts

I'm trying to read data from a hybrid CD (including iso9660, CDDA and mode 1 raw data) on windows. I can get toc data using IOCTL_CDROM_READ_TOC, but neither IOCTL_CDROM_RAW_READ nor IOCTL_SCSI_PASS_THROUGH_DIRECT can get any data. The buffer is untouched and everytime an error code 87 is generated.

Here's the SPTI part of my code:
 

const UCHAR cdb[12] = {0xBE, 0, 0, 7, 42, 15, 0, 0, 1, 0x10, 0, 0};
UCHAR bufx[2352 * 1];
memset(&bufx, 0, 1 * 2352);
struct sptd_with_sense {
  SCSI_PASS_THROUGH_DIRECT s;
  UCHAR sense[20];
} sptd;
memset(&sptd, 0, sizeof(sptd));
sptd.s.Length = sizeof(sptd.s);
sptd.s.CdbLength = sizeof(cdb);
sptd.s.DataIn = SCSI_IOCTL_DATA_IN;
sptd.s.TimeOutValue = 30;
sptd.s.DataBuffer = bufx;
sptd.s.DataTransferLength = sizeof(bufx);
sptd.s.SenseInfoOffset = offsetof(struct sptd_with_sense, sense);
sptd.s.SenseInfoLength = sizeof(sptd.sense);
memcpy(sptd.s.Cdb, cdb, sizeof(cdb));
BOOL rx = DeviceIoControl(handle, IOCTL_SCSI_PASS_THROUGH_DIRECT, &sptd, sizeof(sptd), &sptd, sizeof(sptd), &dummy, NULL);
DWORD ex = GetLastError();

I want to know what is missing in my code. One more thing is that I wonder how could the raw data be "cooked", as I want to get mode1/2048 sector data.

Edited by donmor3000
formatting
Link to comment
Share on other sites

There's nothing obviously wrong with what you've done.

As 'invalid parameter' is often to do with memory alignment, I'd guess you just need to tweak things a little so everything is happy.

I have a 'DWORD filler'  between your 's' and 'sense' to realign on dword boundaries - going by the comment next to it anyway ;)

 

 

Link to comment
Share on other sites

  • 3 weeks later...
On 10/12/2022 at 1:10 AM, LIGHTNING UK! said:

There's nothing obviously wrong with what you've done.

As 'invalid parameter' is often to do with memory alignment, I'd guess you just need to tweak things a little so everything is happy.

I have a 'DWORD filler'  between your 's' and 'sense' to realign on dword boundaries - going by the comment next to it anyway ;)

 

It did'nt resolve my issue, any guesses?

 

Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.