🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Problem with DeviceIoControl() IOCTL_STORAGE_QUERY_PROPERTY

#4667
From: Kris
Date: Sat, 17 Dec 2005 15:33
142 lines
5812 bytes
Mike.

I tried your suggestion. Initially I was a bit confused by what you
asked...

>STORAGE_DEVICE_DESCRIPTOR StDescript = { 0 };
>
>status = DeviceIoControl( hHandle,
>                 IOCTL_STORAGE_QUERY_PROPERTY,
>                 &StDescript,
>                 sizeof(STORAGE_DEVICE_DESCRIPTOR),
>                 &buffer,
>                 512,
>                 &dwBytsReturned,
>                 NULL );
>
>

The reason of my confusion is because the first parameter after
IOCTL_STORAGE_QUERY_PROPERTY still needs to be the query parameter.
But once I realized you were suggesting getting the
STORAGE_DEVICE_DESCRIPTOR  instead of the STORAGE_ADAPTER_DESCRIPTOR
that I was retrieving I changed it into following code :

STORAGE_PROPERTY_QUERY StoragePropertyQuery;
STORAGE_DEVICE_DESCRIPTOR StDescript = { 0 };

StoragePropertyQuery.PropertyId = StorageDeviceProperty;
StoragePropertyQuery.QueryType = PropertyStandardQuery;

Status = DeviceIoControl( Handle,
              IOCTL_STORAGE_QUERY_PROPERTY,
              &StoragePropertyQuery,
              sizeof(STORAGE_PROPERTY_QUERY),
              &StDescript,
              sizeof(STORAGE_DEVICE_DESCRIPTOR),
              &NumberOfBytesReturned,
              NULL );
if (Status)
{
   Text("BusType %X",(BYTE)StDescript.BusType);
}


And this turned out to produce VERY interesting results....

E.g. enumerating GUID_DEVINTERFACE_CDROM gave me this :

DEVICE01::DevicePath  =
\\?\ide#cdromphilips_dvdr885p________________________p1.9____#5&8873354&0&0.1.0#{53f56308-b6bf-11d0-94f2-00a0c91efb8b}
DEVICE01::SptiHandle  = 0x06F4
DEVICE01::DriveLetter = [F:]
DEVICE01::BusType     = ATAPI (2)
 
DEVICE02::DevicePath  =
\\?\ide#cdromricoh_dvd+rw_mp5125_____________________1.72____#5&1b40e3f9&0&0.0.0#{53f56308-b6bf-11d0-94f2-00a0c91efb8b}
DEVICE02::SptiHandle  = 0x06DC
DEVICE02::DriveLetter = [G:]
DEVICE02::BusType     = ATAPI (2)

So, instead of just reporting ATA for my CDROM devices like it did
with  STORAGE_ADAPTER_DESCRIPTOR I now get ATAPI when using
STORAGE_DEVICE_DESCRIPTOR.

A result which is definitely more accurate !

When dealing with hard discs (GUID_DEVINTERFACE_DISK) I get this...

DEVICE01::DevicePath  =
\\?\ide#diskst3250823as_____________________________3.01____#5&2bc19e55&0&0.0.0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
DEVICE01::SptiHandle  = 0x070C
DEVICE01::DriveLetter = [?:]
DEVICE01::BusType     = ATA (3)

So your suggested STORAGE_DEVICE_DESCRIPTOR approach is able to
distinguish between ATAPI (CDROM) and ATA (HARD DISC).

The inability to report that the hard disc is actually a SATA is most
likely due to what Andrue Mentioned : 

On Fri, 16 Dec 2005 10:13:23 +0000, "Andrue Cope [TeamB]"
<no.spam@not.a.valid.address> wrote:

>Maybe the SATA disks are being accessed in legacy mode? Does device
>manager list any SATA controllers or drivers on your system? I've been
>looking at SATA for a month or so and unless you need the particular
>benefits of SATA (built in RAID, scatter/gather in command set, command
>chaining) you might as well stick with legacy mode and save yourself a
>lot of bother.
 
I'll still have too look into Andrue's remark in more detail but my
Device Manager indeed has no SATA devices listed. So, it's very likely
that my SATA discs are being accessed in legacy mode. Later on, when I
have some more time, I'll have a go at actually getting my SATA
controllers being recognized as SATA devices by the device manager
(I'm assuming/hoping that installing the correct nforce4 drivers would
do the trick). Hopefully, I'm then able to get a SATA bus type
reported back to me so that I know that all of this even works ok for
real SATA configurations.

Thank you very much for your feedback. It was very helpful indeed.

---
Kris Schoofs
** Don't forget to visit http://dvd.identifier.cdfreaks.com/ ** 





On Fri, 16 Dec 2005 19:35:50 -0600, "Mike Harris" <nospam@nospam.com>
wrote:

>Kris.
>    in your call to
>Status = DeviceIoControl(
>            Handle,
>            IOCTL_STORAGE_QUERY_PROPERTY,
>            &query,
>            sizeof(STORAGE_PROPERTY_QUERY),
>            &outBuf,
>            sizeof(outBuf),
>            &returnedLength,
>            NULL
>            );
>just to humor me.. try following changes
>
>STORAGE_DEVICE_DESCRIPTOR StDescript = { 0 };
>
>status = DeviceIoControl( hHandle,
>                 IOCTL_STORAGE_QUERY_PROPERTY,
>                 &StDescript,
>                 sizeof(STORAGE_DEVICE_DESCRIPTOR),
>                 &buffer,
>                 512,
>                 &dwBytsReturned,
>                 NULL );
>
>
>if (status)
>
>let me know if that makes any diff ...
Technical Details
Message-ID: <j9b8q1lmtetu9pc1mg43s0b6ur7pjdh60h@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!feed5.newsreader.com!newsreader.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <8b04q11n406hs1bonf8n9586mn3of3lqm3@4ax.com> <ou86q1tiik2rplgfs7gdoo6itfdd6e9c3d@4ax.com> <43a36b0d$1@newsgroups.borland.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: Kris <x.y@xyz.xx>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Problem with DeviceIoControl() IOCTL_STORAGE_QUERY_PROPERTY
Date: Sat, 17 Dec 2005 16:33:54 +0100
Message-ID: <j9b8q1lmtetu9pc1mg43s0b6ur7pjdh60h@4ax.com>
References: <8b04q11n406hs1bonf8n9586mn3of3lqm3@4ax.com> <ou86q1tiik2rplgfs7gdoo6itfdd6e9c3d@4ax.com> <43a36b0d$1@newsgroups.borland.com>
X-Newsreader: Forte Free Agent 3.1/32.783
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 81.11.246.252
X-Trace: newsgroups.borland.com 1134833551 81.11.246.252 (17 Dec 2005 07:32:31 -0700)
Lines: 142
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!feed5.newsreader.com!newsreader.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail