Search code examples
cwindowsapiiscsi

How to interface my iSCSIinitiator to scsi subsystem in windows


I'm studying on how to program a iSCSI initiator in Windows in C (like Open-iSCSI (Linux) or Starwind iSCSI initiator (Windows)). I've previously coded an iSCSI target and now I'm learning the opposite of it. I've already coded mostly initiator to target messages (login, read/write, etc.). My problem now is how to interface my iSCSI initiator to the SCSI subsystem in Windows, which takes care of sending which lba to read/write, send inquiry, modesense msgs. I've previously looked at other open source initiators like Open-iSCSI, and it is a kernel mode driver, which I'm guessing directly interfaces with SCSI subsystem in Linux, which I don't know how to do in windows.

Someone suggested SCSI Miniport driver, and I'm trying to look into that.

Can someone point me in the right direction? is there an API which hooks how the OS interfaces SCSI commands to a custom iSCSI initiator?

You might think I'm reinventing the wheel as there is already a built in iSCSI initiator on Windows, but there are some stripped down version of Windows which has the initiator removed, and also would like to learn how to create a custom iSCSI initiator on my own.


Solution

  • I'd suggest to push StarWind guys to give you away they iSCSI initiator for maintenance / expanding. It's written as a monolithic SCSI port (super-fast!), and isn't supported by Microsoft, so no way MSFT will accept it for production AS IS. Ping them here:

    https://forums.starwindsoftware.com/viewforum.php?f=4&sid=a76a36e594767d2d6e8cb0d97a9c2f91

    Alternatively you need to check what's called "Virtual StorPort miniport" as it's a design "blessed" by Microsoft for virtual storage drivers. See:

    https://code.msdn.microsoft.com/windowshardware/WDKStorPortVirtualMiniport-973650f6

    It should be a good start for you, porting iSCSI stack from Open-iSCSI isn't trivial but doable :)

    Good luck!