How can I get the available drive letter?

Hi , all!

I am writing a CD-ROM- simulation. Now I have a problem, how can I get the
available drive letter for my own simulated-CD ROM? That is , if the system
is using C: D: E: and I want to use F:, how can I know I should use F:?


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Use ::GetLogicalDrives() - it returns bitmask that represents currently
available drive letters.

-----Original Message-----
From: yuan3rd [mailto:xxxxx@21cn.com]
Sent: Friday, December 22, 2000 2:30 AM
To: NT Developers Interest List
Subject: [ntdev] How can I get the available drive letter?

Hi , all!

I am writing a CD-ROM- simulation. Now I have a problem, how
can I get the
available drive letter for my own simulated-CD ROM? That is ,
if the system
is using C: D: E: and I want to use F:, how can I know I
should use F:?


You are currently subscribed to ntdev as: xxxxx@previo.ee
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Sorry, I mean how to do it in kernel-mode?

----- Original Message -----
From: “Grigori Shpakov”
To: “NT Developers Interest List”
Sent: Thursday, January 24, 2002 12:38 AM
Subject: [ntdev] RE: How can I get the available drive letter?

> Use ::GetLogicalDrives() - it returns bitmask that represents currently
> available drive letters.
>
> > -----Original Message-----
> > From: yuan3rd [mailto:xxxxx@21cn.com]
> > Sent: Friday, December 22, 2000 2:30 AM
> > To: NT Developers Interest List
> > Subject: [ntdev] How can I get the available drive letter?
> >
> >
> > Hi , all!
> >
> > I am writing a CD-ROM- simulation. Now I have a problem, how
> > can I get the
> > available drive letter for my own simulated-CD ROM? That is ,
> > if the system
> > is using C: D: E: and I want to use F:, how can I know I
> > should use F:?
> >
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@previo.ee
> > To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
> >
>
> —
> You are currently subscribed to ntdev as: xxxxx@21cn.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hi , all!
I am writing a CD-ROM- simulation. Now I have a problem, how can I get the
available drive letter for my own simulated-CD ROM?
That is , if the system is using C: D: E: and I want to use F:, how can I
know I should use F:?

(sorry for repeating this message, it’s due to my wrong system clock)


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

I’m not sure if IoCreateSymbolicLink() fails when you specify the link name
that already exists. If it does - then just try to create link until
success.
But if IoCreateSymbolicLink() can recreate existing link, then you will have
to enumerate all drive letters.
I think this is possible via ZwOpenDirectoryObject() and
ZwQueryDirectoryObject(). Also may be possible via undocumented
ObOpenObjectByName() or ObReferenceObjectByName().

-----Original Message-----
From: yuan3rd [mailto:xxxxx@21cn.com]
Sent: Friday, December 22, 2000 3:03 AM
To: NT Developers Interest List
Subject: [ntdev] RE: How can I get the available drive letter?

Sorry, I mean how to do it in kernel-mode?

----- Original Message -----
From: “Grigori Shpakov”
> To: “NT Developers Interest List”
> Sent: Thursday, January 24, 2002 12:38 AM
> Subject: [ntdev] RE: How can I get the available drive letter?
>
>
> > Use ::GetLogicalDrives() - it returns bitmask that
> represents currently
> > available drive letters.
> >
> > > -----Original Message-----
> > > From: yuan3rd [mailto:xxxxx@21cn.com]
> > > Sent: Friday, December 22, 2000 2:30 AM
> > > To: NT Developers Interest List
> > > Subject: [ntdev] How can I get the available drive letter?
> > >
> > >
> > > Hi , all!
> > >
> > > I am writing a CD-ROM- simulation. Now I have a problem, how
> > > can I get the
> > > available drive letter for my own simulated-CD ROM? That is ,
> > > if the system
> > > is using C: D: E: and I want to use F:, how can I know I
> > > should use F:?
> > >
> > >
> > >
> > > —
> > > You are currently subscribed to ntdev as: xxxxx@previo.ee
> > > To unsubscribe send a blank email to
> leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
> > >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@21cn.com
> > To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
> >
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@previo.ee
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Try reading up on IoGetConfigurationInformation().

At 05:02 PM 12/21/2000 -0800, yuan3rd wrote:

Sorry, I mean how to do it in kernel-mode?

----- Original Message -----
From: “Grigori Shpakov”
>To: “NT Developers Interest List”
>Sent: Thursday, January 24, 2002 12:38 AM
>Subject: [ntdev] RE: How can I get the available drive letter?
>
>
> > Use ::GetLogicalDrives() - it returns bitmask that represents currently
> > available drive letters.
> >
> > > -----Original Message-----
> > > From: yuan3rd [mailto:xxxxx@21cn.com]
> > > Sent: Friday, December 22, 2000 2:30 AM
> > > To: NT Developers Interest List
> > > Subject: [ntdev] How can I get the available drive letter?
> > >
> > >
> > > Hi , all!
> > >
> > > I am writing a CD-ROM- simulation. Now I have a problem, how
> > > can I get the
> > > available drive letter for my own simulated-CD ROM? That is ,
> > > if the system
> > > is using C: D: E: and I want to use F:, how can I know I
> > > should use F:?


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

But you won’t get the letters - only drive count?

-----Original Message-----
From: Mark S. Edwards [mailto:xxxxx@muttsnuts.com]
Sent: Thursday, January 24, 2002 11:24 AM
To: NT Developers Interest List
Subject: [ntdev] RE: How can I get the available drive letter?

Try reading up on IoGetConfigurationInformation().

At 05:02 PM 12/21/2000 -0800, yuan3rd wrote:
>Sorry, I mean how to do it in kernel-mode?
>
>----- Original Message -----
>From: “Grigori Shpakov”
> >To: “NT Developers Interest List”
> >Sent: Thursday, January 24, 2002 12:38 AM
> >Subject: [ntdev] RE: How can I get the available drive letter?
> >
> >
> > > Use ::GetLogicalDrives() - it returns bitmask that
> represents currently
> > > available drive letters.
> > >
> > > > -----Original Message-----
> > > > From: yuan3rd [mailto:xxxxx@21cn.com]
> > > > Sent: Friday, December 22, 2000 2:30 AM
> > > > To: NT Developers Interest List
> > > > Subject: [ntdev] How can I get the available drive letter?
> > > >
> > > >
> > > > Hi , all!
> > > >
> > > > I am writing a CD-ROM- simulation. Now I have a problem, how
> > > > can I get the
> > > > available drive letter for my own simulated-CD ROM? That is ,
> > > > if the system
> > > > is using C: D: E: and I want to use F:, how can I know I
> > > > should use F:?
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@previo.ee
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Look at the IFS kit, the samples use this to determine the available drive
letter.

If DiskCount is 2 and CdRomCount is 1, then incrementing CdRomCount gives a
total of 4, using an offset starting from C:, this tells you that F: is
free to use. (assuming everyone in the system is playing by the rules)

At 11:38 AM 1/24/2002 +0200, Grigori Shpakov wrote:

But you won’t get the letters - only drive count?

> -----Original Message-----
> From: Mark S. Edwards [mailto:xxxxx@muttsnuts.com]
> Sent: Thursday, January 24, 2002 11:24 AM
> To: NT Developers Interest List
> Subject: [ntdev] RE: How can I get the available drive letter?
>
>
> Try reading up on IoGetConfigurationInformation().
>
>
> At 05:02 PM 12/21/2000 -0800, yuan3rd wrote:
> >Sorry, I mean how to do it in kernel-mode?
> >
> >----- Original Message -----
> >From: “Grigori Shpakov”
> > >To: “NT Developers Interest List”
> > >Sent: Thursday, January 24, 2002 12:38 AM
> > >Subject: [ntdev] RE: How can I get the available drive letter?
> > >
> > >
> > > > Use ::GetLogicalDrives() - it returns bitmask that
> > represents currently
> > > > available drive letters.
> > > >
> > > > > -----Original Message-----
> > > > > From: yuan3rd [mailto:xxxxx@21cn.com]
> > > > > Sent: Friday, December 22, 2000 2:30 AM
> > > > > To: NT Developers Interest List
> > > > > Subject: [ntdev] How can I get the available drive letter?
> > > > >
> > > > >
> > > > > Hi , all!
> > > > >
> > > > > I am writing a CD-ROM- simulation. Now I have a problem, how
> > > > > can I get the
> > > > > available drive letter for my own simulated-CD ROM? That is ,
> > > > > if the system
> > > > > is using C: D: E: and I want to use F:, how can I know I
> > > > > should use F:?


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> -----Original Message-----

From: Mark S. Edwards [mailto:xxxxx@muttsnuts.com]
Sent: Thursday, January 24, 2002 11:46 AM
To: NT Developers Interest List
Subject: [ntdev] RE: How can I get the available drive letter?

Look at the IFS kit, the samples use this to determine the
available drive
letter.

If DiskCount is 2 and CdRomCount is 1, then incrementing
CdRomCount gives a
total of 4, using an offset starting from C:, this tells you
that F: is
free to use. (assuming everyone in the system is playing by the rules)

I wouldn’t rely on that :slight_smile:
Besides this, letter assignments may not be sequential (i.e. C:, E:, N:,
etc…).

At 11:38 AM 1/24/2002 +0200, Grigori Shpakov wrote:
>But you won’t get the letters - only drive count?
>
> > -----Original Message-----
> > From: Mark S. Edwards [mailto:xxxxx@muttsnuts.com]
> > Sent: Thursday, January 24, 2002 11:24 AM
> > To: NT Developers Interest List
> > Subject: [ntdev] RE: How can I get the available drive letter?
> >
> >
> > Try reading up on IoGetConfigurationInformation().
> >
> >
> > At 05:02 PM 12/21/2000 -0800, yuan3rd wrote:
> > >Sorry, I mean how to do it in kernel-mode?
> > >
> > >----- Original Message -----
> > >From: “Grigori Shpakov”
> > > >To: “NT Developers Interest List”
> > > >Sent: Thursday, January 24, 2002 12:38 AM
> > > >Subject: [ntdev] RE: How can I get the available drive letter?
> > > >
> > > >
> > > > > Use ::GetLogicalDrives() - it returns bitmask that
> > > represents currently
> > > > > available drive letters.
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: yuan3rd [mailto:xxxxx@21cn.com]
> > > > > > Sent: Friday, December 22, 2000 2:30 AM
> > > > > > To: NT Developers Interest List
> > > > > > Subject: [ntdev] How can I get the available drive letter?
> > > > > >
> > > > > >
> > > > > > Hi , all!
> > > > > >
> > > > > > I am writing a CD-ROM- simulation. Now I have a problem, how
> > > > > > can I get the
> > > > > > available drive letter for my own simulated-CD ROM?
> That is ,
> > > > > > if the system
> > > > > > is using C: D: E: and I want to use F:, how can I know I
> > > > > > should use F:?
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@previo.ee
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hi,

Are you writing your driver as SCSI class driver? Maybe you’ll think about
implementing it as monolithic SCSI port driver and let the system manage
drive letter assigning for you? I did not experiment with CD/DVD, but with
hard disk driv letter apper/disappear works fine.

In any case you can try to open the drive letter until you’ll fail to do
this.
Do not know is there any equivalent for UserMode call to get drive map.

Regards,
Anton

On 01/24/02, ““yuan3rd” ” wrote:
> Hi , all!
>
> I am writing a CD-ROM- simulation. Now I have a problem, how can I get the
> available drive letter for my own simulated-CD ROM? That is , if the system
> is using C: D: E: and I want to use F:, how can I know I should use F:?
>
>
>
> —
> You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Not even close!

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mark S. Edwards
Sent: Thursday, January 24, 2002 1:46 AM
To: NT Developers Interest List
Subject: [ntdev] RE: How can I get the available drive letter?

Look at the IFS kit, the samples use this to determine the available
drive
letter.

If DiskCount is 2 and CdRomCount is 1, then incrementing CdRomCount
gives a
total of 4, using an offset starting from C:, this tells you that F: is
free to use. (assuming everyone in the system is playing by the rules)

At 11:38 AM 1/24/2002 +0200, Grigori Shpakov wrote:

But you won’t get the letters - only drive count?

> -----Original Message-----
> From: Mark S. Edwards [mailto:xxxxx@muttsnuts.com]
> Sent: Thursday, January 24, 2002 11:24 AM
> To: NT Developers Interest List
> Subject: [ntdev] RE: How can I get the available drive letter?
>
>
> Try reading up on IoGetConfigurationInformation().
>
>
> At 05:02 PM 12/21/2000 -0800, yuan3rd wrote:
> >Sorry, I mean how to do it in kernel-mode?
> >
> >----- Original Message -----
> >From: “Grigori Shpakov”
> > >To: “NT Developers Interest List”
> > >Sent: Thursday, January 24, 2002 12:38 AM
> > >Subject: [ntdev] RE: How can I get the available drive letter?
> > >
> > >
> > > > Use ::GetLogicalDrives() - it returns bitmask that
> > represents currently
> > > > available drive letters.
> > > >
> > > > > -----Original Message-----
> > > > > From: yuan3rd [mailto:xxxxx@21cn.com]
> > > > > Sent: Friday, December 22, 2000 2:30 AM
> > > > > To: NT Developers Interest List
> > > > > Subject: [ntdev] How can I get the available drive letter?
> > > > >
> > > > >
> > > > > Hi , all!
> > > > >
> > > > > I am writing a CD-ROM- simulation. Now I have a problem, how
> > > > > can I get the available drive letter for my own simulated-CD
> > > > > ROM? That is , if the system
> > > > > is using C: D: E: and I want to use F:, how can I know I
> > > > > should use F:?


You are currently subscribed to ntdev as: xxxxx@storagecraft.com To
unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

“yuan3rd” wrote in message news:xxxxx@ntdev…
> That is , if the system is using C: D: E: and I want to use F:, how can I
> know I should use F:?

You ask the mount manager.

Check the NTFSD archives, I believe this has been discussed there. If not,
those are the folks to ask…

Peter
OSR


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

This is not necessary for the driver to work.
Just create the device and let the user-mode stuff assign a letter for it.

Max

----- Original Message -----
From: “yuan3rd”
To: “NT Developers Interest List”
Sent: Friday, December 22, 2000 3:29 AM
Subject: [ntdev] How can I get the available drive letter?

> Hi , all!
>
> I am writing a CD-ROM- simulation. Now I have a problem, how can I get the
> available drive letter for my own simulated-CD ROM? That is , if the system
> is using C: D: E: and I want to use F:, how can I know I should use F:?
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

At 06.32 24/01/2002, you wrote:

Are you writing your driver as SCSI class driver? Maybe you’ll think about
implementing it as monolithic SCSI port driver and let the system manage
drive letter assigning for you? I did not experiment with CD/DVD, but with
hard disk driv letter apper/disappear works fine.
In any case you can try to open the drive letter until you’ll fail to do this.

Not a good suggestion. Multiple sessions in Terminal Services and Windows
XP complicate it further. In what object directory, exactly, would you
create the symlink? And what if the user doesn’t want drive letters? For
example, I don’t even have C:, on my system it’s accessible as D:\boot, or
D:\mnt\w98\c. Could I get rid of D: as well and use only absolute paths, I
would be really happy. But I need letters for the floppy and CD-ROM drives
anyway, because otherwise crappy apps won’t recognize them (normally I
access my CD-ROM drives as D:\mnt\cdrom and D:\mnt\cdrom1, E: and F: are
there just to make Starcraft and some CD-ROM based setups run correctly).
Now, a driver silently adding a drive letter would *really* drive me crazy

That’s what the Mount Manager device, the mountvol command and junction
points are for. If the driver is PnP there shouldn’t be problems at all:
the system should assign automatically a drive id and, if appropriate, a
drive letter and/or mount point to your device


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com