API for getting disk signature

Hi,

Is there an API or IOCTL which gives disk signature/guid or disk id (looking
for something unique) for any given disk, like USB, SAN, iSCSI, DAS?

Thanks,
Sunil

IOCTL_STORAGE_QUERY_PROPERTY


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

“Sunil Patil” wrote in message news:xxxxx@ntdev…
Hi,

Is there an API or IOCTL which gives disk signature/guid or disk id (looking for something unique) for any given disk, like USB, SAN, iSCSI, DAS?

Thanks,
Sunil

But only for some release levels. Earlier versions of Windows did not
provide the serial number and you have to go fetch the appropriate
page using scsi passthrough.

Mark Roddy

On Wed, Oct 20, 2010 at 6:38 AM, Maxim S. Shatskih
wrote:
> ? ?IOCTL_STORAGE_QUERY_PROPERTY
>
>
> –
> Maxim S. Shatskih
> Windows DDK MVP
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
> “Sunil Patil” wrote in message news:xxxxx@ntdev…
> Hi,
>
> Is there an API or IOCTL which gives disk signature/guid or disk id (looking for something unique) for any given disk, like USB, SAN, iSCSI, DAS?
>
> Thanks,
> Sunil
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>

Using IOCTL_STORAGE_QUERY_PROPERTY, I am getting desired information for
“query.PropertyId = StorageDeviceProperty” and “query.PropertyId =
StorageDeviceIdProperty”, but for “query.PropertyId =
StorageDeviceUniqueIdProperty”, the IOCTL is failing with error “err: 87:
The parameter is incorrect.”. I tried this on Win 7 and Win2k8 server where
it is supposed to work. Any idea whats the issue?

On Wed, Oct 20, 2010 at 4:08 PM, Maxim S. Shatskih
wrote:

> IOCTL_STORAGE_QUERY_PROPERTY
>
>
> –
> Maxim S. Shatskih
> Windows DDK MVP
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
> “Sunil Patil” wrote in message news:xxxxx@ntdev…
> Hi,
>
> Is there an API or IOCTL which gives disk signature/guid or disk id
> (looking for something unique) for any given disk, like USB, SAN, iSCSI,
> DAS?
>
> Thanks,
> Sunil
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

Hello,

I may be imprecise on this, as I was doing this long, long time ago.

What about getting mount points for the device and making some hash composed from mount points id? See http://msdn.microsoft.com/en-us/library/ff560474(VS.85).aspx ; more specifically for each mount point you can get it’s id: http://msdn.microsoft.com/en-us/library/ff562286(v=VS.85).aspx

Now, having set of ids per each device you can make your own pseudo id for the whole device.

HTH

> What about getting mount points for the device and making some hash composed from mount points

id?

For usual partitions, the mountdev ID contains the MBR signature. You can use it directly instead of hashing.

For GPT, you have GPT GUID.

Nevertheless, these IDs can be changed by re-creating the partition table. Hardware ID from the query property IOCTL - cannot.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

look in the sources in the WDK, specifically
src\storage\class\classpnp\utils.c. It would appear that if you want
the StorageDeviceUniqueIdProperty you have to supply some rather
undocumented AdditionalParameters values.

e.g:
//
// Check AdditionalParameters validity.
//

if (query->AdditionalParameters[0] == DUID_INCLUDE_SOFTWARE_IDS) {
includeOptionalIds = TRUE;
} else if (query->AdditionalParameters[0] == DUID_HARDWARE_IDS_ONLY) {
includeOptionalIds = FALSE;
} else {
status = STATUS_INVALID_PARAMETER;
goto FnExit;
}

Isn’t having access to the source really a nifty aid to answering all
of these silly questions? Too bad more of the actual sources, the ones
without the family jewels, whatever those are, aren’t available.

p.s. StorageDeviceIdProperty returns the page 83 VPD id number, and
that is likely good enough.

Mark Roddy

On Fri, Oct 22, 2010 at 8:01 AM, Sunil Patil wrote:
> Using IOCTL_STORAGE_QUERY_PROPERTY, I am getting desired information for
> “query.PropertyId = StorageDeviceProperty” and “query.PropertyId =
> StorageDeviceIdProperty”, but for “query.PropertyId =
> StorageDeviceUniqueIdProperty”, the IOCTL is failing with error “err: 87:
> The parameter is incorrect.”. I tried this on Win 7 and Win2k8 server where
> it is supposed to work. Any idea whats the issue?
>
> On Wed, Oct 20, 2010 at 4:08 PM, Maxim S. Shatskih
> wrote:
>>
>> ? ?IOCTL_STORAGE_QUERY_PROPERTY
>>
>>
>> –
>> Maxim S. Shatskih
>> Windows DDK MVP
>> xxxxx@storagecraft.com
>> http://www.storagecraft.com
>>
>> “Sunil Patil” wrote in message news:xxxxx@ntdev…
>> Hi,
>>
>> Is there an API or IOCTL which gives disk signature/guid or disk id
>> (looking for something unique) for any given disk, like USB, SAN, iSCSI,
>> DAS?
>>
>> Thanks,
>> Sunil
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> For our schedule of WDF, WDM, debugging and other seminars visit:
>> http://www.osr.com/seminars
>>
>> To unsubscribe, visit the List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>
> — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and
> other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the
> List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer