Recognizing drive letter of my Virtual Disk Drive

Hi All,

I’ve written a virtual scsi miniport driver, which I’m
using to virtualising a disk drive. After successfull
enumeration of the virtual adapter I can see the
virtual disk drive in the explorer. Now this
assignment of the drive letter to the new virtual
drive is done by Windows volume manager ( Hope I’m not
wrong ).

Now is there any way to know the drive letter assigned
to my virtual disk drive from my application without
any user interaction.

I’ve tried using ‘GetLogicalDrives()’ call to get all
the logical drives existing in the machine and then
used ‘QueryDosDevice()’ to know the device linked to
it. However it points to some device as /HardDisk/…
etc. And I can’t extract any information from that.

Can you guys suggest any method by which I can know
the drive letter assigned to my virtual disk drive ?

Thanks in Advance

Somsubhra Raj

If you think you can, you can.
If you think you can’t, you are right.


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Hi;

Try this, it works only on Windows 2003.

BOOL GetVolumePathNamesForVolumeName(
LPCTSTR lpszVolumeName,
LPTSTR lpszVolumePathNames,
DWORD cchBufferLength,
PDWORD lpcchReturnLength
);

Thanks & Regards

Faraz.

On 8/31/05, Somsubhra Raj wrote:
> Hi All,
>
> I’ve written a virtual scsi miniport driver, which I’m
> using to virtualising a disk drive. After successfull
> enumeration of the virtual adapter I can see the
> virtual disk drive in the explorer. Now this
> assignment of the drive letter to the new virtual
> drive is done by Windows volume manager ( Hope I’m not
> wrong ).
>
> Now is there any way to know the drive letter assigned
> to my virtual disk drive from my application without
> any user interaction.
>
> I’ve tried using ‘GetLogicalDrives()’ call to get all
> the logical drives existing in the machine and then
> used ‘QueryDosDevice()’ to know the device linked to
> it. However it points to some device as /HardDisk/…
> etc. And I can’t extract any information from that.
>
> Can you guys suggest any method by which I can know
> the drive letter assigned to my virtual disk drive ?
>
> Thanks in Advance
>
> Somsubhra Raj
>
> If you think you can, you can.
> If you think you can’t, you are right.
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@gmail.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

Hi,

Somsubhra Raj wrote:

I’ve written a virtual scsi miniport driver, which I’m
using to virtualising a disk drive. After successfull
enumeration of the virtual adapter I can see the
virtual disk drive in the explorer. Now this
assignment of the drive letter to the new virtual
drive is done by Windows volume manager ( Hope I’m not
wrong ).

Remember that volumes can be mounted also on paths like

c:\volumes\data

Regards,
Oliver

Support some “interesting” SCSI CDB in your virtual miniport. Then send
IOCTL_SCSI_PASS_THROUGH to this disk from the app, executing this CDB.

This will fail on usual disks and succeed on “your” disks.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Somsubhra Raj”
To: “Windows System Software Devs Interest List”
Sent: Thursday, September 01, 2005 9:43 AM
Subject: [ntdev] Recognizing drive letter of my Virtual Disk Drive

> Hi All,
>
> I’ve written a virtual scsi miniport driver, which I’m
> using to virtualising a disk drive. After successfull
> enumeration of the virtual adapter I can see the
> virtual disk drive in the explorer. Now this
> assignment of the drive letter to the new virtual
> drive is done by Windows volume manager ( Hope I’m not
> wrong ).
>
> Now is there any way to know the drive letter assigned
> to my virtual disk drive from my application without
> any user interaction.
>
> I’ve tried using ‘GetLogicalDrives()’ call to get all
> the logical drives existing in the machine and then
> used ‘QueryDosDevice()’ to know the device linked to
> it. However it points to some device as /HardDisk/…
> etc. And I can’t extract any information from that.
>
> Can you guys suggest any method by which I can know
> the drive letter assigned to my virtual disk drive ?
>
> Thanks in Advance
>
> Somsubhra Raj
>
> If you think you can, you can.
> If you think you can’t, you are right.
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

Better yet, first have your upper levels send the standard INQUIRY CDB
and check for your unique VENDORID/PRODUCTID/PRODUCTREVISION
combination(s).

From here, you now know it’s one of “your” disks. You can then either
use the vendor-specific area in the inquiry data (it’s about 20 bytes in
length), or you can use one fo the following Vendor-specific opcodes to
do anything you define:

Use only for 6-byte CDBs, may cause problems with other sizes:
0x02, 0x05, 0x06, 0x09, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x13, 0x14, 0x19

Use only for 10-byte CDBs, may cause problems with other sizes:
0x20, 0x21, 0x22, 0x23, 0x24, 0x26, 0x27, 0x29, 0x2C, 0x2D

Use for any CDB size (6,10,12,16) (opcode families 6,7 were always
vendor-unique):
0xC0 through 0xFF

So, please spend a little more time than just adding an “interesting”
CDB. Also, request an official VendorID if you haven’t already done so
– it’ll help prevent clashes with other software virtual disks.

Thanks,
.

-----Original Message-----
From: Maxim S. Shatskih [mailto:xxxxx@storagecraft.com]
Sent: Thursday, September 01, 2005 1:36 PM
Subject: Re: Recognizing drive letter of my Virtual Disk Drive

Support some “interesting” SCSI CDB in your virtual miniport. Then
send
IOCTL_SCSI_PASS_THROUGH to this disk from the app, executing this CDB.

This will fail on usual disks and succeed on “your” disks.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Somsubhra Raj”
To: “Windows System Software Devs Interest List”
Sent: Thursday, September 01, 2005 9:43 AM
Subject: [ntdev] Recognizing drive letter of my Virtual Disk Drive

> Hi All,
>
> I’ve written a virtual scsi miniport driver, which I’m
> using to virtualising a disk drive. After successfull
> enumeration of the virtual adapter I can see the
> virtual disk drive in the explorer. Now this
> assignment of the drive letter to the new virtual
> drive is done by Windows volume manager ( Hope I’m not
> wrong ).
>
> Now is there any way to know the drive letter assigned
> to my virtual disk drive from my application without
> any user interaction.
>
> I’ve tried using ‘GetLogicalDrives()’ call to get all
> the logical drives existing in the machine and then
> used ‘QueryDosDevice()’ to know the device linked to
> it. However it points to some device as /HardDisk/…
> etc. And I can’t extract any information from that.
>
> Can you guys suggest any method by which I can know
> the drive letter assigned to my virtual disk drive ?
>
> Thanks in Advance
>
> Somsubhra Raj
>
> If you think you can, you can.
> If you think you can’t, you are right.
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

You may be able to use SetupDi and the Mount Manager to do this. You
could enumerate drives of your class and check for your vendor/product
ID. Check SetupDiGetClassDevs(), SetupDiEnumDeviceInterfaces(),
SetupDiGetDeviceInterfaceDetail(), IOCTL_MOUNTDEV_QUERY_DEVICE_NAME, and
IOCTL_MOUNTMGR_QUERY_POINTS. I’ve used these with Windows 2000 and XP.

Chuck

----- Original Message -----
From: “Somsubhra Raj”
To: “Windows System Software Devs Interest List”
Sent: Thursday, September 01, 2005 12:43 AM
Subject: [ntdev] Recognizing drive letter of my Virtual Disk Drive

> Hi All,
>
> I’ve written a virtual scsi miniport driver, which I’m
> using to virtualising a disk drive. After successfull
> enumeration of the virtual adapter I can see the
> virtual disk drive in the explorer. Now this
> assignment of the drive letter to the new virtual
> drive is done by Windows volume manager ( Hope I’m not
> wrong ).
>
> Now is there any way to know the drive letter assigned
> to my virtual disk drive from my application without
> any user interaction.
>
> I’ve tried using ‘GetLogicalDrives()’ call to get all
> the logical drives existing in the machine and then
> used ‘QueryDosDevice()’ to know the device linked to
> it. However it points to some device as /HardDisk/…
> etc. And I can’t extract any information from that.
>
> Can you guys suggest any method by which I can know
> the drive letter assigned to my virtual disk drive ?
>
> Thanks in Advance
>
> Somsubhra Raj
>
> If you think you can, you can.
> If you think you can’t, you are right.

Use the technique Max defined. Just add a vendor unique CDB. Send that CDB
to all drives in the system. Each drive that it fails on is not your drive
and each drive it succeeds on is your drive.

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Chuck Batson
Sent: Friday, September 02, 2005 10:56 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Recognizing drive letter of my Virtual Disk Drive

You may be able to use SetupDi and the Mount Manager to do this. You
could enumerate drives of your class and check for your vendor/product
ID. Check SetupDiGetClassDevs(), SetupDiEnumDeviceInterfaces(),
SetupDiGetDeviceInterfaceDetail(), IOCTL_MOUNTDEV_QUERY_DEVICE_NAME, and
IOCTL_MOUNTMGR_QUERY_POINTS. I’ve used these with Windows 2000 and XP.

Chuck

----- Original Message -----
From: “Somsubhra Raj”
To: “Windows System Software Devs Interest List”
Sent: Thursday, September 01, 2005 12:43 AM
Subject: [ntdev] Recognizing drive letter of my Virtual Disk Drive

> Hi All,
>
> I’ve written a virtual scsi miniport driver, which I’m
> using to virtualising a disk drive. After successfull
> enumeration of the virtual adapter I can see the
> virtual disk drive in the explorer. Now this
> assignment of the drive letter to the new virtual
> drive is done by Windows volume manager ( Hope I’m not
> wrong ).
>
> Now is there any way to know the drive letter assigned
> to my virtual disk drive from my application without
> any user interaction.
>
> I’ve tried using ‘GetLogicalDrives()’ call to get all
> the logical drives existing in the machine and then
> used ‘QueryDosDevice()’ to know the device linked to
> it. However it points to some device as /HardDisk/…
> etc. And I can’t extract any information from that.
>
> Can you guys suggest any method by which I can know
> the drive letter assigned to my virtual disk drive ?
>
> Thanks in Advance
>
> Somsubhra Raj
>
> If you think you can, you can.
> If you think you can’t, you are right.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@rocketdivision.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Excuse my ignorance here, but what if by chance one chooses a “vendor
unique” CDB whose command code just happens to be implemented by another
vendor as “format device firmware”? (A contrived example I’ll admit.)
Would it not be better to use something noninvasive and benign like a
SCSI INQUIRY, at least before broadcasting some CDB?

Chuck

----- Original Message -----
From: “Jamey Kirby”
To: “Windows System Software Devs Interest List”
Sent: Friday, September 02, 2005 1:27 PM
Subject: RE: [ntdev] Recognizing drive letter of my Virtual Disk Drive

> Use the technique Max defined. Just add a vendor unique CDB. Send that
> CDB
> to all drives in the system. Each drive that it fails on is not your
> drive
> and each drive it succeeds on is your drive.
>
> Jamey
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Chuck Batson
> Sent: Friday, September 02, 2005 10:56 AM
> To: Windows System Software Devs Interest List
> Subject: Re: [ntdev] Recognizing drive letter of my Virtual Disk Drive
>
> You may be able to use SetupDi and the Mount Manager to do this. You
> could enumerate drives of your class and check for your vendor/product
> ID. Check SetupDiGetClassDevs(), SetupDiEnumDeviceInterfaces(),
> SetupDiGetDeviceInterfaceDetail(), IOCTL_MOUNTDEV_QUERY_DEVICE_NAME,
> and
> IOCTL_MOUNTMGR_QUERY_POINTS. I’ve used these with Windows 2000 and
> XP.
>
> Chuck
>
> ----- Original Message -----
> From: “Somsubhra Raj”
> To: “Windows System Software Devs Interest List”
> Sent: Thursday, September 01, 2005 12:43 AM
> Subject: [ntdev] Recognizing drive letter of my Virtual Disk Drive
>
>
>> Hi All,
>>
>> I’ve written a virtual scsi miniport driver, which I’m
>> using to virtualising a disk drive. After successfull
>> enumeration of the virtual adapter I can see the
>> virtual disk drive in the explorer. Now this
>> assignment of the drive letter to the new virtual
>> drive is done by Windows volume manager ( Hope I’m not
>> wrong ).
>>
>> Now is there any way to know the drive letter assigned
>> to my virtual disk drive from my application without
>> any user interaction.
>>
>> I’ve tried using ‘GetLogicalDrives()’ call to get all
>> the logical drives existing in the machine and then
>> used ‘QueryDosDevice()’ to know the device linked to
>> it. However it points to some device as /HardDisk/…
>> etc. And I can’t extract any information from that.
>>
>> Can you guys suggest any method by which I can know
>> the drive letter assigned to my virtual disk drive ?
>>
>> Thanks in Advance
>>
>> Somsubhra Raj
>>
>> If you think you can, you can.
>> If you think you can’t, you are right.

Any number of mechanisms can work to solve his problem.

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Chuck Batson
Sent: Friday, September 02, 2005 11:55 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Recognizing drive letter of my Virtual Disk Drive

Excuse my ignorance here, but what if by chance one chooses a “vendor
unique” CDB whose command code just happens to be implemented by another
vendor as “format device firmware”? (A contrived example I’ll admit.)
Would it not be better to use something noninvasive and benign like a
SCSI INQUIRY, at least before broadcasting some CDB?

Chuck

----- Original Message -----
From: “Jamey Kirby”
To: “Windows System Software Devs Interest List”
Sent: Friday, September 02, 2005 1:27 PM
Subject: RE: [ntdev] Recognizing drive letter of my Virtual Disk Drive

> Use the technique Max defined. Just add a vendor unique CDB. Send that
> CDB
> to all drives in the system. Each drive that it fails on is not your
> drive
> and each drive it succeeds on is your drive.
>
> Jamey
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Chuck Batson
> Sent: Friday, September 02, 2005 10:56 AM
> To: Windows System Software Devs Interest List
> Subject: Re: [ntdev] Recognizing drive letter of my Virtual Disk Drive
>
> You may be able to use SetupDi and the Mount Manager to do this. You
> could enumerate drives of your class and check for your vendor/product
> ID. Check SetupDiGetClassDevs(), SetupDiEnumDeviceInterfaces(),
> SetupDiGetDeviceInterfaceDetail(), IOCTL_MOUNTDEV_QUERY_DEVICE_NAME,
> and
> IOCTL_MOUNTMGR_QUERY_POINTS. I’ve used these with Windows 2000 and
> XP.
>
> Chuck
>
> ----- Original Message -----
> From: “Somsubhra Raj”
> To: “Windows System Software Devs Interest List”
> Sent: Thursday, September 01, 2005 12:43 AM
> Subject: [ntdev] Recognizing drive letter of my Virtual Disk Drive
>
>
>> Hi All,
>>
>> I’ve written a virtual scsi miniport driver, which I’m
>> using to virtualising a disk drive. After successfull
>> enumeration of the virtual adapter I can see the
>> virtual disk drive in the explorer. Now this
>> assignment of the drive letter to the new virtual
>> drive is done by Windows volume manager ( Hope I’m not
>> wrong ).
>>
>> Now is there any way to know the drive letter assigned
>> to my virtual disk drive from my application without
>> any user interaction.
>>
>> I’ve tried using ‘GetLogicalDrives()’ call to get all
>> the logical drives existing in the machine and then
>> used ‘QueryDosDevice()’ to know the device linked to
>> it. However it points to some device as /HardDisk/…
>> etc. And I can’t extract any information from that.
>>
>> Can you guys suggest any method by which I can know
>> the drive letter assigned to my virtual disk drive ?
>>
>> Thanks in Advance
>>
>> Somsubhra Raj
>>
>> If you think you can, you can.
>> If you think you can’t, you are right.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@rocketdivision.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

It’s not that simple. Blindly sending a vendor-unique to a device that you
don’t know is yours can be catastrophic, if you happen to accidentally find
a CDB definition that triggers something destructive on another vendor’s
hardware. Make sure you check the IDs in the INQUIRY data first, and only
send your CDB to the devices that look like yours. But you should be able
to rely on the VENDOR, MODEL NUMBER, and FIRMWARE REVISION fields to unique
identify your flavor of device.

You really want to avoid sending vendor-unique opcodes to other vendor’s
hardware.

Phil

Philip D. Barila
Seagate Technology LLC
(720) 684-1842

xxxxx@lists.osr.com wrote on 09/02/2005 12:27:32 PM:

Use the technique Max defined. Just add a vendor unique CDB. Send that
CDB
to all drives in the system. Each drive that it fails on is not your
drive
and each drive it succeeds on is your drive.

Use a fake LUN to avoid this. Name this LUN by something like “IO
Processor”.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Chuck Batson”
To: “Windows System Software Devs Interest List”
Sent: Friday, September 02, 2005 10:54 PM
Subject: Re: [ntdev] Recognizing drive letter of my Virtual Disk Drive

> Excuse my ignorance here, but what if by chance one chooses a “vendor
> unique” CDB whose command code just happens to be implemented by another
> vendor as “format device firmware”? (A contrived example I’ll admit.)
> Would it not be better to use something noninvasive and benign like a
> SCSI INQUIRY, at least before broadcasting some CDB?
>
> Chuck
>
> ----- Original Message -----
> From: “Jamey Kirby”
> To: “Windows System Software Devs Interest List”
> Sent: Friday, September 02, 2005 1:27 PM
> Subject: RE: [ntdev] Recognizing drive letter of my Virtual Disk Drive
>
>
> > Use the technique Max defined. Just add a vendor unique CDB. Send that
> > CDB
> > to all drives in the system. Each drive that it fails on is not your
> > drive
> > and each drive it succeeds on is your drive.
> >
> > Jamey
> >
> >
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com] On Behalf Of Chuck Batson
> > Sent: Friday, September 02, 2005 10:56 AM
> > To: Windows System Software Devs Interest List
> > Subject: Re: [ntdev] Recognizing drive letter of my Virtual Disk Drive
> >
> > You may be able to use SetupDi and the Mount Manager to do this. You
> > could enumerate drives of your class and check for your vendor/product
> > ID. Check SetupDiGetClassDevs(), SetupDiEnumDeviceInterfaces(),
> > SetupDiGetDeviceInterfaceDetail(), IOCTL_MOUNTDEV_QUERY_DEVICE_NAME,
> > and
> > IOCTL_MOUNTMGR_QUERY_POINTS. I’ve used these with Windows 2000 and
> > XP.
> >
> > Chuck
> >
> > ----- Original Message -----
> > From: “Somsubhra Raj”
> > To: “Windows System Software Devs Interest List”
> > Sent: Thursday, September 01, 2005 12:43 AM
> > Subject: [ntdev] Recognizing drive letter of my Virtual Disk Drive
> >
> >
> >> Hi All,
> >>
> >> I’ve written a virtual scsi miniport driver, which I’m
> >> using to virtualising a disk drive. After successfull
> >> enumeration of the virtual adapter I can see the
> >> virtual disk drive in the explorer. Now this
> >> assignment of the drive letter to the new virtual
> >> drive is done by Windows volume manager ( Hope I’m not
> >> wrong ).
> >>
> >> Now is there any way to know the drive letter assigned
> >> to my virtual disk drive from my application without
> >> any user interaction.
> >>
> >> I’ve tried using ‘GetLogicalDrives()’ call to get all
> >> the logical drives existing in the machine and then
> >> used ‘QueryDosDevice()’ to know the device linked to
> >> it. However it points to some device as /HardDisk/…
> >> etc. And I can’t extract any information from that.
> >>
> >> Can you guys suggest any method by which I can know
> >> the drive letter assigned to my virtual disk drive ?
> >>
> >> Thanks in Advance
> >>
> >> Somsubhra Raj
> >>
> >> If you think you can, you can.
> >> If you think you can’t, you are right.
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com