🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #4634

Re: Problem with DeviceIoControl() IOCTL_STORAGE_QUERY_PROPERTY

#4634
From: Andrue Cope [TeamB]
Date: Thu, 15 Dec 2005 13:50
99 lines
4224 bytes
You have my sympathy.

> DevicePath=\\?\ide#cdromhl-dt-st_dvd-rom_gdr8163b_______________0l23__
> __#5&3001a662&0&0.1.0#{53f56308-b6bf-11d0-94f2-00a0c91efb8b}

Good luck with that device path. It looks valid but each device has
several paths to get to it and not all of them work all the time. For
that device I would try:

  \\?\cdrom0

..and of course you'll need a readable CD-ROM in the drive :)

I have been through all this once so I'll try to help you.
Unfortunately it was a while back and it's very much the kind of thing
you want to forget about once you've got it working.

Somehow we've managed to avoid making that particular call. Would it be
enough to get SCSI inquiry data from the device (bearing in mind that
non-SCSI devices will have something made up for them)?

  MyFileHandle=CreateFile( SPTIDeviceID,
                           GENERIC_WRITE|GENERIC_READ,
                           FILE_SHARE_READ|FILE_SHARE_WRITE,
                           NULL,
                           OPEN_EXISTING,
                           0,
                           NULL );

  if( MyFileHandle!=INVALID_HANDLE_VALUE )
  {
    DWORD returned=0;

    if( !MyIAmDriveLetterF )
    {
      if( DeviceIoControl( MyFileHandle,
                           IOCTL_SCSI_GET_INQUIRY_DATA,
                           NULL,
                           0,
                           MyInfoBuffer,
                           sizeof( MyInfoBuffer ),
                           &returned,
                           FALSE ) )
      {
        MyIAmDriveLetterF=false;
        PSCSI_ADAPTER_BUS_INFO adapterInfo=(PSCSI_ADAPTER_BUS_INFO)
MyInfoBuffer;

        if( adapterInfo&&
            adapterInfo->NumberOfBuses&&
            adapterInfo->BusData[ 0 ].InquiryDataOffset )
        {
          PSCSI_INQUIRY_DATA inquiryData=
            (PSCSI_INQUIRY_DATA)( MyInfoBuffer+adapterInfo->BusData[ 0
].InquiryDataOffset );

//////////////

If you want to perform any I/O you'll also need the call to get
capabilities:

          // Now we have to determine the maximum transfer size
          IO_SCSI_CAPABILITIES scsiCaps;

          if( DeviceIoControl( MyFileHandle,
                               IOCTL_SCSI_GET_CAPABILITIES,
                               NULL,
                               0,
                               &scsiCaps,
                               sizeof( scsiCaps ),
                               &returned,
                               FALSE ) )
          {
            MyMaxTransfer=scsiCaps.MaximumPhysicalPages-1;

            SYSTEM_INFO si;
            GetSystemInfo( &si );

            MyMaxTransfer*=si.dwPageSize;

            if( MyMaxTransfer>scsiCaps.MaximumTransferLength )
              MyMaxTransfer=scsiCaps.MaximumTransferLength;

            IsReadyF=true;
            return;
          }

BTW the BusData[] structure is weird. Weird in layout and weird in
operation. If nothing else the Adaptor and Bus IDs do not neccessarily
match the hardware.
-- 
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html

-- 
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html
Technical Details
Message-ID: <43a17435$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <8b04q11n406hs1bonf8n9586mn3of3lqm3@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,f7af8c8a3ab6155a
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Andrue Cope [TeamB]" <no.spam@not.a.valid.address>
Subject: Re: Problem with DeviceIoControl() IOCTL_STORAGE_QUERY_PROPERTY
Newsgroups: borland.public.cppbuilder.nativeapi
References: <8b04q11n406hs1bonf8n9586mn3of3lqm3@4ax.com>
Date: Thu, 15 Dec 2005 13:50:09 +0000
User-Agent: XanaNews/1.17.6.6
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
NNTP-Posting-Host: 217.207.223.34
Message-ID: <43a17435$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1134654517 217.207.223.34 (15 Dec 2005 05:48:37 -0700)
Lines: 99
X-Authenticated-User: acope
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail