Is there a tutorial on how to read data cd sectors using DeviceIoControl?  I understand I can open the drive using CreateFile, then I can issue a IOCTL_SCSI_PASS_THROUGH_DIRECT command using DeviceIoControl but I have to put the right data in the _SCSI_PASS_THROUGH_DIRECT structure.  My current reads are http://msdn.microsoft.com/en-us/library/ms810301.aspx  I don't really understand PVOID  DataBuffer.  Is this a relative pointer?  And what exactly is a "drive sense?"  I found a few audio cd ripper programs but they weren't using sptd and didn't explain too much.
Posted on 2009-09-30 17:44:14 by GoldStar611
Hello GoldStar611

Here's a simple example that shows you how to use SPTI to read a sector from a CDrom
Have fun with it.
Attachments:
Posted on 2009-10-01 08:31:05 by Siekmanski
Very interesting.  Looks a lot like the c++ tutorials I've been reading for audio disks.  Thank you for the code sample :)

In your code

push edi
lea edi,sptd
xor eax,eax
mov ecx,sizeof sptd
cld
rep stosb
pop edi

This is effectively zeroing out the SPTD buffer correct?
Posted on 2009-10-01 14:43:02 by GoldStar611
Yes, the key here is the 'rep stosb' opcode.
"Repeatedly Store a Series of Bytes" :)
Posted on 2009-10-01 17:40:12 by Homer

Is there a tutorial on how to read data cd sectors using DeviceIoControl?  I understand I can open the drive using CreateFile, then I can issue a IOCTL_SCSI_PASS_THROUGH_DIRECT command using DeviceIoControl but I have to put the right data in the _SCSI_PASS_THROUGH_DIRECT structure.  My current reads are http://msdn.microsoft.com/en-us/library/ms810301.aspx  I don't really understand PVOID  DataBuffer.  Is this a relative pointer?  And what exactly is a "drive sense?"  I found a few audio cd ripper programs but they weren't using sptd and didn't explain too much.


What is your need exactly? Read cooked (Yellow book Mode 1/Mode2 form 1 user data field, 2048 Bytes) sectors, do this using SPTD over DeviceIoControl(), or read them raw (2352+96 Bytes)?

Data can be read simply by CreateFile("\\.\CdRom#",…) and ReadFile() (I'm not sure whether drivers create symlinks to CD-ROM device objects sequentially, you can always resort to CreateFile("\\.\DriveLetter:",…)/GetDriveType() combo).

For SPTD/DeviceIoControl() method, look for SCSI-3 Multimedia commands reference (former ANSI X3.304, now NCITS.304). There you will find CDB and DataBuffer layouts for different commands. BTW, pick up NCITS.303 too, it's Reduced block commands used by Mass Storage class USB devices.

CDs are so much fun to play with!
Posted on 2009-10-14 04:45:09 by baldr