I've been adding a few interesting SCSI calls to my sgio.d project, such as ReadCapacity (get the size of the volume) and Read16 (read some raw blocks), and it all works fine on Linux. Fantastic. But getting this working on Windows has been quite difficult.

So far only the SCSI inquiries work and I'm no expert in talking with the Windows kernel using DeviceIoControl. The Windows documentation is difficult to search so it has been a hassle to even begin writing code. A call to GetLastError() tells me it "failed with status 5", or sometimes status 1, but even that is different on other machines. Should I be using SCSI_PASS_THROUGH instead of SCSI_PASS_THROUGH_DIRECT? Maybe it's best to use SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER? What are the pros/cons of using those? I have no idea and it's hard to find the answers... this is deep down the rabbit hole. Linux is so much easier to research.

I have a few short-term goals to get this problem solved:

First, I'll find (and save!) the documentation on the Windows SPT vs SPTD vs SPTDWB and hopefully I'll be able to use one of those for all of my SCSI needs. I thought I had a good understanding since the IOCTL_SCSI_PASS_THROUGH_DIRECT documentation states that it "Allows an application to send almost any SCSI command to a target device".

For the second goal, I'll find some C++ examples of this ReadCapacity/native-read crap and verify those solutions work on my machine. These examples have been difficult to find and more difficult to really understand. Once I have working code it should be easy work to migrate it to D and hope for the best.

After this problem is solved I'd like to move on to playing with Docker/rkt app images to get a better understanding of the hype around those.