Obtain symbolic link name from Device name

I am wondering if I can get the symbolic link if I know the device name.
I mean how can I find the symbolic name of \Device\Harddisk3\Partition2 for
example?
Thanks


Get Your Private, Free Email at http://www.hotmail.com

Use the following sequence:

ZwOpenSymbolicLinkObject
ZwQuerySymbolicLinkObject

Inaki.

-----Original Message-----
From: Jack Brown
Sent: viernes 14 de abril de 2000 17:23
To: File Systems Developers
Subject: [ntfsd] Obtain symbolic link name from Device name

I am wondering if I can get the symbolic link if I know the device name.
I mean how can I find the symbolic name of \Device\Harddisk3\Partition2
for
example?
Thanks


Get Your Private, Free Email at http://www.hotmail.com


You are currently subscribed to ntfsd as: xxxxx@pandasoftware.es
To unsubscribe send a blank email to $subst(‘Email.Unsub’)

Thanks Inaki!!!
Jack

From: Iñaki Castillo
>Reply-To: “File Systems Developers”
>To: “File Systems Developers”
>Subject: [ntfsd] RE: Obtain symbolic link name from Device name
>Date: Fri, 14 Apr 2000 17:32:38 +0200
>
>Use the following sequence:
>
> ZwOpenSymbolicLinkObject
> ZwQuerySymbolicLinkObject
>
>Inaki.
>
> > -----Original Message-----
> > From: Jack Brown
> > Sent: viernes 14 de abril de 2000 17:23
> > To: File Systems Developers
> > Subject: [ntfsd] Obtain symbolic link name from Device name
> >
> > I am wondering if I can get the symbolic link if I know the device name.
> > I mean how can I find the symbolic name of \Device\Harddisk3\Partition2
> > for
> > example?
> > Thanks
> >
> > Get Your Private, Free Email at http://www.hotmail.com
> >
> >
> > —
> > You are currently subscribed to ntfsd as: xxxxx@pandasoftware.es
> > To unsubscribe send a blank email to $subst(‘Email.Unsub’)
>
>—
>You are currently subscribed to ntfsd as: xxxxx@hotmail.com
>To unsubscribe send a blank email to $subst(‘Email.Unsub’)
>


Get Your Private, Free Email at http://www.hotmail.com

Hi,
I think this set of APIs do the reverse !! Given the Symbolic link
they return the Device name.

I am not aware if some comination of flags make it work otherwise.

regards
Sumtush

-----Original Message-----
Thanks Inaki!!!
Jack

>From: Iñaki Castillo
> >Use the following sequence:
> >
> > ZwOpenSymbolicLinkObject
> > ZwQuerySymbolicLinkObject
> >
> >Inaki.
> > > -----Original Message-----
> > > From: Jack Brown
> > > I am wondering if I can get the symbolic link if I know the device
>name.
> > > I mean how can I find the symbolic name of
>\Device\Harddisk3\Partition2
> > > for
> > > example?
> > > Thanks

> > > You are currently subscribed to ntfsd as: xxxxx@pandasoftware.es
> > > To unsubscribe send a blank email to $subst(‘Email.Unsub’)
> >
> >—
> >You are currently subscribed to ntfsd as: xxxxx@hotmail.com
> >To unsubscribe send a blank email to $subst(‘Email.Unsub’)

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

Hello,

Thats true. However one can enumerate all the symbolic
link objects under the ?? directory object using
ZwQueryDirectoryObject. For each symbolic link object
found, one can use ZwOpenSymbolicLinkObject and
ZwQuerySymbolicLinkObject to gather the contents of
the symbolic link and match it with the name you are
interested in such as ‘\Device\Harddisk3\Partition2’.
This way one can find out the symbolic link object
referring to a devicename. This assumes that the
symbolic link is created in ?? object directory. This
is typically the case with devices.

-Prasad

— Tushar Banerjee wrote:
> Hi,
> I think this set of APIs do the reverse !! Given the
> Symbolic link
> they return the Device name.
>
> I am not aware if some comination of flags make it
> work otherwise.
>
> regards
> Sumtush
>
> >-----Original Message-----
> >Thanks Inaki!!!
> >Jack
> >
> > >From: Iñaki Castillo
> > >Use the following sequence:
> > >
> > > ZwOpenSymbolicLinkObject
> > > ZwQuerySymbolicLinkObject
> > >
> > >Inaki.
> > > > -----Original Message-----
> > > > From: Jack Brown
> > > > I am wondering if I can get the symbolic link
> if I know the device
> >name.
> > > > I mean how can I find the symbolic name of
> >\Device\Harddisk3\Partition2
> > > > for
> > > > example?
> > > > Thanks
>
> > > > You are currently subscribed to ntfsd as:
> xxxxx@pandasoftware.es
> > > > To unsubscribe send a blank email to
> $subst(‘Email.Unsub’)
> > >
> > >—
> > >You are currently subscribed to ntfsd as:
> xxxxx@hotmail.com
> > >To unsubscribe send a blank email to
> $subst(‘Email.Unsub’)
>
>
____
> Get Your Private, Free Email at
> http://www.hotmail.com
>
>
> —
> You are currently subscribed to ntfsd as:
> xxxxx@yahoo.com
> To unsubscribe send a blank email to
> $subst(‘Email.Unsub’)
>
>

=====
Prasad S. Dabak
Director of Engineering, Windows NT/2000 Division
Cybermedia Software Private Limited
http://www.cybermedia.co.in
Co-author of the book “Undocumented Windows NT”
ISBN 0764545698


Do You Yahoo!?
Send online invitations with Yahoo! Invites.
http://invites.yahoo.com

Hello,
That solution is always there !! In that case the whole set of
APIs will be :

ZwOpenDirectoryObject -------> ??
ZwQueryDirectoryObject ------> the handle obtained from the previous
call and get all symbolic links

For Number of symbolic links:
ZwOpenSymbolicLinkObject ----> To each such symbolic link
ZwQuerySymbolicLinkObject —> Compare if the target matches to what
u want.

Does a API exist to do it without the comparison stuff ??

Regards
Sumtush

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Prasad Dabak
Sent: Monday, April 17, 2000 12:47 PM
To: File Systems Developers
Subject: [ntfsd] RE: Obtain symbolic link name from Device name

Hello,

Thats true. However one can enumerate all the symbolic
link objects under the ?? directory object using
ZwQueryDirectoryObject. For each symbolic link object
found, one can use ZwOpenSymbolicLinkObject and
ZwQuerySymbolicLinkObject to gather the contents of
the symbolic link and match it with the name you are
interested in such as ‘\Device\Harddisk3\Partition2’.
This way one can find out the symbolic link object
referring to a devicename. This assumes that the
symbolic link is created in ?? object directory. This
is typically the case with devices.

-Prasad


Get Your Private, Free Email at http://www.hotmail.com

Nope. Symbolic links are directed, and are not one-to-one. There can
be several links to the same target object. As far as I know, there are
no data structures binding link objects to the target objects by pointer,
handle or the like. They simply store a string which names the target
object. I don’t believe it is possible to have a symbolic link to an
unnamed device.

It is interesing to note that the string associated with a link object
can actually contain a multi-string, only the first of which is considered
in any particular invocation of the link. The Win32 subsystem utilizes
this feature to “push” a new target onto a link object, and later to “pop”
it off and restore the previous target. What actually happens is, during
a push, it prepends the new target string to the multi-string, but the
old target(s) are still maintained as the successive strings in the multi-
string. During a pop, the first string is stripped off.

The kernel-mode APIs for creating and using symbolic links are unaware of
this convention. If you’re ever going to mix kernel-mode operations with
user-mode Query/DefineDosDevice() functions, you need to do a little extra
work in the kernel code. For example, one might need to double-null
terminate the string provided when creating a link in kernel-mode. If you
provide only a single null, DefineDosDevice() tries to treat the garbage
that follows as the next target name in the stack. This can have bad and
unpredictable consequences. If you want to preserve the push/pop model,
and avoid causing surprise disappearance of users’ pushed target names,
you should *read* a symbolic link name before setting it – get the
existing string(s), prepend your own, then set target name to the resulting
multi-string.


Dave Cox
Hewlett-Packard Co.
HPSO/SSMO (Santa Barbara)
https://ecardfile.com/id/Dave+Cox

-----Original Message-----
From: Tushar Banerjee [mailto:xxxxx@hotmail.com]
Sent: Monday, April 17, 2000 12:38 AM
To: File Systems Developers
Subject: [ntfsd] RE: Obtain symbolic link name from Device name



Does a API exist to do it without the comparison stuff ??

Regards
Sumtush