Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to create a \device\LanmanRedirector session without using WNetAddConnection

2 views
Skip to first unread message

Daniel Lohmann

unread,
Jun 3, 2003, 7:12:30 AM6/3/03
to
F'-up to microsoft.public.win32.programmer.networks

Hi all,

I need to create lanmanager drive connections without going over
WNetAddConnectionX, but creating the link in the appropriate
DosDevices kernel namespace directly.

Drive mappings to UNC resources seem to have the following format:

<DriveLetter>: -->
\Device\LanmanRedirector\;<DriveLetter>:<id>\<SERVER>\<SHARE>

My question is about the <id> part of the link target. I assume it is
the lanmanager session id. However, on my Windows 2000 box it seems to
be always 0. On Windows XP it seems to contain always the *tokens*
login session id. Even if I create a connection as another user.

Is there any situation (on Windows 2000) where <id> is different from
0?
Or, in other words: When do I need a Lanmanager session and how could
I establish it without going through WNetAddConnectionX?

Thanks a lot

Daniel

Daniel Lohmann

unread,
Jun 3, 2003, 7:16:04 AM6/3/03
to

Daniel Lohmann

unread,
Jun 3, 2003, 7:53:28 AM6/3/03
to

Slava M. Usov

unread,
Jun 3, 2003, 11:04:17 AM6/3/03
to
"Daniel Lohmann" <dan...@uni-koblenz.de> wrote in message
news:r13pdvkfv8nf79uf5...@4ax.com...

> I need to create lanmanager drive connections without going over
> WNetAddConnectionX, but creating the link in the appropriate
> DosDevices kernel namespace directly.
>
> Drive mappings to UNC resources seem to have the following format:
>
> <DriveLetter>: -->
> \Device\LanmanRedirector\;<DriveLetter>:<id>\<SERVER>\<SHARE>
>
> My question is about the <id> part of the link target. I assume it is
> the lanmanager session id. However, on my Windows 2000 box it seems to
> be always 0. On Windows XP it seems to contain always the *tokens*
> login session id. Even if I create a connection as another user.

Let's assume that you can create a properly named object. So what's gonna
happen next? The IO manager will open that object and will issue IO IRPs to
it. Since you're the creator of the object, you can specify the driver that
will handle them; it can be one of the two things: a driver of yours or the
redirector. If that's a driver of yours, you will have to handle all that IO
somehow, and if it is the redirector, it will most likely just crash
horribly, because its internal state will be completely inconsistent.

So, are you really going to handle network IO on your own? Then there are
better and cleaner ways to be a redirector.

S


Duke Sun

unread,
Jun 4, 2003, 9:46:00 AM6/4/03
to
This post is the same as another post in the group.

Duke Sun

unread,
Jun 4, 2003, 9:47:31 AM6/4/03
to
This post is identical to another post in the same queue.

Duke Sun

unread,
Jun 4, 2003, 10:01:27 AM6/4/03
to
Could you provide more details regarding

Daniel Lohmann

unread,
Jun 4, 2003, 3:05:05 PM6/4/03
to
On Wed, 04 Jun 2003 14:01:27 GMT, qua...@microsoft.com (Duke Sun)
wrote:

>Could you provide more details regarding
>
><DriveLetter>: -->
> \Device\LanmanRedirector\;<DriveLetter>:<id>\<SERVER>\<SHARE>
>

It explains the format of a link in the "\??" kernel namespace
directory that represents a network connection (aka created by
WNetAddConnectionX). You can look them up with the WinObj tool from
http://www.sysinternals.com

"<DriveLetter>:" is the link name. It could be "A:" - "Z:"

"\Device\LanmanRedirector\;<DriveLetter>:<id>\<SERVER>\<SHARE>" is the
link target, where

"<DriveLetter>:" is same as above
"<id>" seems to be a 64 bit hex session id (but I don't know exactly)
"<SERVER>" is the NetBios server name
"<SHARE>" is the network share on "<SERVER">

Example:

net use X: \\BIGTOWER\CoolApps

would create a link as follows:

X: -> \Device\LanmanRedirector\;X:0\BIGTOWER\CoolApps


What I want to do is create this LanManager network connections in
another kernel directory than "\??". I know how to create links in
other directories, but I am wondering about the session state the
LanmanRedirector device may need.


Thanks

Daniel

Wei Mao [MSFT]

unread,
Jun 6, 2003, 3:58:50 AM6/6/03
to
>> Is there any situation (on Windows 2000) where <id> is different from 0?
how about a windows 2000 terminal server environment?

>> (how could I establish) a Lanmanager session ... without going through
WNetAddConnectionX?
you can try it, but you cannot gruantee that it really works, all the time.

let's take another sample here: with DFS (distributed file system),
net use y: \\server\share
it creates a symbolic link: \Sessions\0\DosDevices\00000000-0000caa4\Y:
and a brand new device object: \Device\WinDfs\Y:000000000000caa4

It is clear here that DFS does something internal / invisible to you. The
same should apply to LanManager too. Unless explicitely documented you
should not expect to create a symbolic name and then get a new shared drive.

thanks
wei

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Hardware & Driver portal: http://www.microsoft.com/whdc/

Daniel Lohmann

unread,
Jun 6, 2003, 5:21:01 AM6/6/03
to
On Fri, 06 Jun 2003 07:58:50 GMT, wei...@online.microsoft.com (Wei Mao
[MSFT]) wrote:

>>> Is there any situation (on Windows 2000) where <id> is different from 0?
>how about a windows 2000 terminal server environment?
>
>>> (how could I establish) a Lanmanager session ... without going through
>WNetAddConnectionX?
>you can try it, but you cannot gruantee that it really works, all the time.
>
>let's take another sample here: with DFS (distributed file system),
> net use y: \\server\share
>it creates a symbolic link: \Sessions\0\DosDevices\00000000-0000caa4\Y:
>and a brand new device object: \Device\WinDfs\Y:000000000000caa4

You are using WinXP or Windows 2003, right?
On these systems the id (numeric part) seems to be the tokens logon
session id. I am assuming on Win2k it is the terminal server session
id, that's why it is always 0 on my system.


>It is clear here that DFS does something internal / invisible to you. The
>same should apply to LanManager too. Unless explicitely documented you
>should not expect to create a symbolic name and then get a new shared drive.

Yes, I know...

And WinDFS is an important point, you are right.

Windows XP introduced a big improvement by providing an own DosDevices
namespace for each login session (and therefore seems to add the logon
session id instead of the TS session id to the link/device names). I
am implementing something similar for Windows 2000. It works fairly
well so far: I set a different DosDevices root directory the new
process and it resolves all drive letters using my own directory. For
network connections I currently create a "proxy" drive letter in the
global DosDevices directory (using WNetAddConnectionX) and put a link
to it in the session-specific dir. However, this limits the total
amount of network connections to < 26.

If the connection is an DFS connection, the link is (surprisingly) not
created in the global DosDevices directory, but in the one of the
calling process. However, this does still not help because as you
wrote a new device <DriveLetter>:0 is also created in the global
Devices directory. Therefore it is still not possible to connect the
same drive letter from two different sessions :-(


Thanks!

Daniel

Wei Mao [MSFT]

unread,
Jun 9, 2003, 10:09:59 PM6/9/03
to
Slava posted a msg on Jun 3 which explains the situation pretty well.

http://groups.google.com/groups?selm=
ODd0oFeK...@TK2MSFTNGP11.phx.gbl

0 new messages