DefineDosDevice on Windows 2003

I am going to ask a question that has been asked
before on this newsgroup in 2003 by someone but I have
not seen an answer for it. I am having a very similar
problem to the issue that was raised.

"…
Looks like WinXP is policy change w.r.t
DefineDosDevice().
The URL is -
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/defining_an_ms_dos_device_name.asp

According to the url “The visibility of an MS-DOS
device names is
categorized as Global or Local MS-DOS Device
Namespace. Note that only
processes running in the LocalSystem context can call
DefineDosDevice to
create an MS-DOS device in the Global MS-DOS device
namespace.”

My application uses DefineDosDevice() that does not
execute in the
LocalSystem context. Due to this on Win 2003, it
creates a device name in
Local MS-DOS device namespace. Now, when I try to
share this drive, the
NetShareAdd() API returns an error:"The device or
directory does not
exist. " My assumtion is that this error is returned
because NetShareAdd()
is searching for the device name in the Global MS-DOS
Device Namespace and
it does not exixt there.

My question is that how do I allocate MS-DOS drive
letters in the Global
MS-DOS Device namespace as I am not running in Local
System context? Can I
make the process change to LocalSystem context
temporarily ?
…"
In addition to the problem above I cannot even see the
drive letter in explorer after the call to
DefineDosDevice when my service does not run in local
system context.
When I switch to local system context everything gets
to work just fine.

Any help would be greatly appreciated.
-Jeff


Yahoo! Mail - PC Magazine Editors’ Choice 2005
http://mail.yahoo.com

That is correct the behavior of symbolic links has changed in Windows XP
as opposed to NT 4 and Windows 2000 (Actually, it changed between those
as well).

There actually is a way to revert the behavior of the mapping through a
registry value however I do not believe it is recommended. The new
method is through LUID mappings so per-user devices are mapped into a
LUID space and global mappings still occur in the ?? Space.
Previously, everyone would get their own copy of global (non-console
users, console users used global directly as far as I remember) and
could modify it without conflict. Now, everyone gets their own LUID
mapping and they can override or add new mappings to this area as it
will be checked first, then global.

You can view the different mapping locations using WINOBJ. To get
around not being able to map globally for all users on the system you
would either need a service that you could LPC to perform this on your
behalf, or a driver that could create symbolic links for you.

I have also noticed that “net share” would never work on subst drives in
XP when they would in 2000 and this is probably the reason. To get more
information though I would suggest that you debug these APIs and see why
the fail and how they are working. Perhaps they enumeration drives
using the global, perhaps they call GetDriveType(), or any number of
reasons. You could even debug DefineDosDevice and see how it’s working
but obviously the documentation states that you need to be running in
system to map to the global devices.

The problem with NetShareAdd() is perhaps that it may talk to a service
and that service (running in one particular session in SYSTEM context)
can’t see per-user configurations since it runs in system and as such
only sees the global.

This whole “luid” implementation is basically for fast user switching,
each user can map their own specific drives, I mean if one user does
“net use” you don’t want the other user to use it so it’s user specific.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of J Sukh
Sent: Tuesday, September 13, 2005 4:17 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] DefineDosDevice on Windows 2003

I am going to ask a question that has been asked
before on this newsgroup in 2003 by someone but I have
not seen an answer for it. I am having a very similar
problem to the issue that was raised.

"…
Looks like WinXP is policy change w.r.t
DefineDosDevice().
The URL is -
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/
base/defining_an_ms_dos_device_name.asp

According to the url “The visibility of an MS-DOS
device names is
categorized as Global or Local MS-DOS Device
Namespace. Note that only
processes running in the LocalSystem context can call
DefineDosDevice to
create an MS-DOS device in the Global MS-DOS device
namespace.”

My application uses DefineDosDevice() that does not
execute in the
LocalSystem context. Due to this on Win 2003, it
creates a device name in
Local MS-DOS device namespace. Now, when I try to
share this drive, the
NetShareAdd() API returns an error:"The device or
directory does not
exist. " My assumtion is that this error is returned
because NetShareAdd()
is searching for the device name in the Global MS-DOS
Device Namespace and
it does not exixt there.

My question is that how do I allocate MS-DOS drive
letters in the Global
MS-DOS Device namespace as I am not running in Local
System context? Can I
make the process change to LocalSystem context
temporarily ?
…"
In addition to the problem above I cannot even see the
drive letter in explorer after the call to
DefineDosDevice when my service does not run in local
system context.
When I switch to local system context everything gets
to work just fine.

Any help would be greatly appreciated.
-Jeff


Yahoo! Mail - PC Magazine Editors’ Choice 2005
http://mail.yahoo.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

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

I am trying to simulate DefineDosDevice in our
filesystem driver and I am running into problems.
I am using IOCTL calls to call into our driver.
So my call to IoCreateSymbolicLink succeeds and
I can see the Symbolic link (our drive letter) in the
global section (using WinObj) but it seems that our
drive is still invisible for the explorer.
I have tried using both L"\DosDevices\Y:" and
L"\DosDevices\Global\Y:" for usDosDeviceName (see
below)
Could someone tell what I am doing wrong?
What else is being done inside DefineDosDevice that I
am not doing?

Thank you very much.
-Jeff

— Toby Opferman wrote:

> The ?? Should work but you should also be able to
> use \DosDevices.
>
> RtlInitUnicodeString(&usDriverName,
> L"\Device\Example");
> RtlInitUnicodeString(&usDosDeviceName,
> L"\DosDevices\G:");
>
> IoCreateSymbolicLink(&usDosDeviceName,
> &usDriverName);
>
>
>
> -----Original Message-----
> From: J Sukh [mailto:xxxxx@yahoo.com]
> Sent: Tuesday, September 13, 2005 8:07 PM
> To: xxxxx@opferman.com
> Subject: RE: [ntfsd] DefineDosDevice on Windows 2003
>
> Thanks for your reply Toby,
> How would I be able to simulate DefineDosDevice in
> the
> filesystem driver (the driver letter that we want is
> a
> symbolic link to our filesystem drive)
>
> Should I try something like this:
> IoCreateSymbolicLink(SymbolicLinkName,
> DriverDeviceName)
>
> where SymbolicLinkName is our drive letter with
> ?? in front.
>
> Thanks,
> -Jeff
>
> — Toby Opferman wrote:
>
> > That is correct the behavior of symbolic links has
> > changed in Windows XP
> > as opposed to NT 4 and Windows 2000 (Actually, it
> > changed between those
> > as well).
> >
> > There actually is a way to revert the behavior of
> > the mapping through a
> > registry value however I do not believe it is
> > recommended. The new
> > method is through LUID mappings so per-user
> devices
> > are mapped into a
> > LUID space and global mappings still occur in the
> > ?? Space.
> > Previously, everyone would get their own copy of
> > global (non-console
> > users, console users used global directly as far
> as
> > I remember) and
> > could modify it without conflict. Now, everyone
> > gets their own LUID
> > mapping and they can override or add new mappings
> to
> > this area as it
> > will be checked first, then global.
> >
> > You can view the different mapping locations using
> > WINOBJ. To get
> > around not being able to map globally for all
> users
> > on the system you
> > would either need a service that you could LPC to
> > perform this on your
> > behalf, or a driver that could create symbolic
> links
> > for you.
> >
> > I have also noticed that “net share” would never
> > work on subst drives in
> > XP when they would in 2000 and this is probably
> the
> > reason. To get more
> > information though I would suggest that you debug
> > these APIs and see why
> > the fail and how they are working. Perhaps they
> > enumeration drives
> > using the global, perhaps they call
> GetDriveType(),
> > or any number of
> > reasons. You could even debug DefineDosDevice
> and
> > see how it’s working
> > but obviously the documentation states that you
> need
> > to be running in
> > system to map to the global devices.
> >
> > The problem with NetShareAdd() is perhaps that it
> > may talk to a service
> > and that service (running in one particular
> session
> > in SYSTEM context)
> > can’t see per-user configurations since it runs in
> > system and as such
> > only sees the global.
> >
> > This whole “luid” implementation is basically for
> > fast user switching,
> > each user can map their own specific drives, I
> mean
> > if one user does
> > “net use” you don’t want the other user to use it
> so
> > it’s user specific.
> >
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com] On
> Behalf
> > Of J Sukh
> > Sent: Tuesday, September 13, 2005 4:17 PM
> > To: Windows File Systems Devs Interest List
> > Subject: [ntfsd] DefineDosDevice on Windows 2003
> >
> > I am going to ask a question that has been asked
> > before on this newsgroup in 2003 by someone but I
> > have
> > not seen an answer for it. I am having a very
> > similar
> > problem to the issue that was raised.
> >
> > "…
> > Looks like WinXP is policy change w.r.t
> > DefineDosDevice().
> > The URL is -
> >
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/
> > base/defining_an_ms_dos_device_name.asp
> >
> >
> > According to the url “The visibility of an MS-DOS
> > device names is
> > categorized as Global or Local MS-DOS Device
> > Namespace. Note that only
> > processes running in the LocalSystem context can
> > call
> > DefineDosDevice to
> > create an MS-DOS device in the Global MS-DOS
> device
> > namespace.”
> >
> > My application uses DefineDosDevice() that does
> not
> > execute in the
> > LocalSystem context. Due to this on Win 2003, it
> > creates a device name in
> > Local MS-DOS device namespace. Now, when I try to
> > share this drive, the
> > NetShareAdd() API returns an error:“The device or
> > directory does not
> > exist. " My assumtion is that this error is
> returned
> > because NetShareAdd()
> > is searching for the device name in the Global
> > MS-DOS
> > Device Namespace and
> > it does not exixt there.
> >
> > My question is that how do I allocate MS-DOS drive
> > letters in the Global
> > MS-DOS Device namespace as I am not running in
> Local
> > System context? Can I
> > make the process change to LocalSystem context
> > temporarily ?
> > …”
> > In addition to the problem above I cannot even see
> > the
> > drive letter in explorer after the call to
> > DefineDosDevice when my service does not run in
> > local
> > system context.
> > When I switch to local system context everything
> > gets
> > to work just fine.
> >
> > Any help would be greatly appreciated.
> > -Jeff
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Mail - PC Magazine Editors’ Choice 2005
> > http://mail.yahoo.com
> >
> > —
> > Questions? First check the IFS FAQ at
> > https://www.osronline.com/article.cfm?id=17
> >
>
=== message truncated ===


Yahoo! Mail - PC Magazine Editors’ Choice 2005
http://mail.yahoo.com

Check NTDEV archives, it was discussed several times there, last time one or two weeks before. Basically, DefineDosDevice() sends an user mode broadcast to inform explorer about new drive arrival and removal.

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]


From: xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com] on behalf of J Sukh[SMTP:xxxxx@yahoo.com]
Reply To: Windows File Systems Devs Interest List
Sent: Friday, September 16, 2005 2:35 AM
To: Windows File Systems Devs Interest List
Cc: xxxxx@lists.osr.com
Subject: RE: [ntfsd] DefineDosDevice on Windows 2003

I am trying to simulate DefineDosDevice in our
filesystem driver and I am running into problems.
I am using IOCTL calls to call into our driver.
So my call to IoCreateSymbolicLink succeeds and
I can see the Symbolic link (our drive letter) in the
global section (using WinObj) but it seems that our
drive is still invisible for the explorer.
I have tried using both L"\DosDevices\Y:" and
L"\DosDevices\Global\Y:" for usDosDeviceName (see
below)
Could someone tell what I am doing wrong?
What else is being done inside DefineDosDevice that I
am not doing?

Thank you very much.
-Jeff

— Toby Opferman wrote:
>
> > The ?? Should work but you should also be able to
> > use \DosDevices.
> >
> > RtlInitUnicodeString(&usDriverName,
> > L"\Device\Example");
> > RtlInitUnicodeString(&usDosDeviceName,
> > L"\DosDevices\G:");
> >
> > IoCreateSymbolicLink(&usDosDeviceName,
> > &usDriverName);
> >
> >
> >
> > -----Original Message-----
> > From: J Sukh [mailto:xxxxx@yahoo.com]
> > Sent: Tuesday, September 13, 2005 8:07 PM
> > To: xxxxx@opferman.com
> > Subject: RE: [ntfsd] DefineDosDevice on Windows 2003
> >
> > Thanks for your reply Toby,
> > How would I be able to simulate DefineDosDevice in
> > the
> > filesystem driver (the driver letter that we want is
> > a
> > symbolic link to our filesystem drive)
> >
> > Should I try something like this:
> > IoCreateSymbolicLink(SymbolicLinkName,
> > DriverDeviceName)
> >
> > where SymbolicLinkName is our drive letter with
> > ?? in front.
> >
> > Thanks,
> > -Jeff
> >
> > — Toby Opferman wrote:
> >
> > > That is correct the behavior of symbolic links has
> > > changed in Windows XP
> > > as opposed to NT 4 and Windows 2000 (Actually, it
> > > changed between those
> > > as well).
> > >
> > > There actually is a way to revert the behavior of
> > > the mapping through a
> > > registry value however I do not believe it is
> > > recommended. The new
> > > method is through LUID mappings so per-user
> > devices
> > > are mapped into a
> > > LUID space and global mappings still occur in the
> > > ?? Space.
> > > Previously, everyone would get their own copy of
> > > global (non-console
> > > users, console users used global directly as far
> > as
> > > I remember) and
> > > could modify it without conflict. Now, everyone
> > > gets their own LUID
> > > mapping and they can override or add new mappings
> > to
> > > this area as it
> > > will be checked first, then global.
> > >
> > > You can view the different mapping locations using
> > > WINOBJ. To get
> > > around not being able to map globally for all
> > users
> > > on the system you
> > > would either need a service that you could LPC to
> > > perform this on your
> > > behalf, or a driver that could create symbolic
> > links
> > > for you.
> > >
> > > I have also noticed that “net share” would never
> > > work on subst drives in
> > > XP when they would in 2000 and this is probably
> > the
> > > reason. To get more
> > > information though I would suggest that you debug
> > > these APIs and see why
> > > the fail and how they are working. Perhaps they
> > > enumeration drives
> > > using the global, perhaps they call
> > GetDriveType(),>
> > > or any number of
> > > reasons. You could even debug DefineDosDevice
> > and
> > > see how it’s working
> > > but obviously the documentation states that you
> > need
> > > to be running in
> > > system to map to the global devices.
> > >
> > > The problem with NetShareAdd() is perhaps that it
> > > may talk to a service
> > > and that service (running in one particular
> > session
> > > in SYSTEM context)
> > > can’t see per-user configurations since it runs in
> > > system and as such
> > > only sees the global.
> > >
> > > This whole “luid” implementation is basically for
> > > fast user switching,
> > > each user can map their own specific drives, I
> > mean
> > > if one user does
> > > “net use” you don’t want the other user to use it
> > so
> > > it’s user specific.
> > >
> > > -----Original Message-----
> > > From: xxxxx@lists.osr.com
> > > [mailto:xxxxx@lists.osr.com] On
> > Behalf
> > > Of J Sukh
> > > Sent: Tuesday, September 13, 2005 4:17 PM
> > > To: Windows File Systems Devs Interest List
> > > Subject: [ntfsd] DefineDosDevice on Windows 2003
> > >
> > > I am going to ask a question that has been asked
> > > before on this newsgroup in 2003 by someone but I
> > > have
> > > not seen an answer for it. I am having a very
> > > similar
> > > problem to the issue that was raised.
> > >
> > > "…
> > > Looks like WinXP is policy change w.r.t
> > > DefineDosDevice().
> > > The URL is -
> > >
> >
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/
> > > base/defining_an_ms_dos_device_name.asp
> > >
> > >
> > > According to the url “The visibility of an MS-DOS
> > > device names is
> > > categorized as Global or Local MS-DOS Device
> > > Namespace. Note that only
> > > processes running in the LocalSystem context can
> > > call
> > > DefineDosDevice to
> > > create an MS-DOS device in the Global MS-DOS
> > device
> > > namespace.”
> > >
> > > My application uses DefineDosDevice() that does
> > not
> > > execute in the
> > > LocalSystem context. Due to this on Win 2003, it
> > > creates a device name in
> > > Local MS-DOS device namespace. Now, when I try to
> > > share this drive, the
> > > NetShareAdd() API returns an error:“The device or
> > > directory does not
> > > exist. " My assumtion is that this error is
> > returned
> > > because NetShareAdd()
> > > is searching for the device name in the Global
> > > MS-DOS
> > > Device Namespace and
> > > it does not exixt there.
> > >
> > > My question is that how do I allocate MS-DOS drive
> > > letters in the Global
> > > MS-DOS Device namespace as I am not running in
> > Local
> > > System context? Can I
> > > make the process change to LocalSystem context
> > > temporarily ?
> > > …”
> > > In addition to the problem above I cannot even see
> > > the
> > > drive letter in explorer after the call to
> > > DefineDosDevice when my service does not run in
> > > local
> > > system context.
> > > When I switch to local system context everything
> > > gets
> > > to work just fine.
> > >
> > > Any help would be greatly appreciated.
> > > -Jeff
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > Yahoo! Mail - PC Magazine Editors’ Choice 2005
> > > http://mail.yahoo.com
> > >
> > > —
> > > Questions? First check the IFS FAQ at
> > > https://www.osronline.com/article.cfm?id=17
> > >
> >
> === message truncated ===
>
>
>
>
>

> Yahoo! Mail - PC Magazine Editors’ Choice 2005
> http://mail.yahoo.com
>
> —
> Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@upek.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>