How can I change dos name to device name?

How can I change dos name to device name?

Post by keand » Fri, 10 Nov 2006 10:06:08


HI.

In kernel mode, when I know just a volume name(like C, D, E... Z), can
I get device name of it?
 
 
 

How can I change dos name to device name?

Post by soviet_blo » Fri, 10 Nov 2006 10:45:43

> In kernel mode, when I know just a volume name(like C, D, E... Z), can

Sure you can - ZwOpenSymbolicLinkObject()+ZwQuerySymbolicLinkObject()
sequence will do this job just fine.....

Anton Bassov

 
 
 

How can I change dos name to device name?

Post by keand » Fri, 10 Nov 2006 11:41:07

Thank you soviet.
hmm...

I'm sorry, but could you give a simple example code to me?
 
 
 

How can I change dos name to device name?

Post by Anatoly Gr » Sat, 11 Nov 2006 01:03:21


try this

struct
{
MOUNTMGR_MOUNT_POINT mp;
WCHAR res0[32];
} _mp;

struct
{
MOUNTMGR_MOUNT_POINTS mps;
WCHAR res0[300];
} _mps;

DWORD Returned;

HANDLE hManager = CreateFileW(
L"\\\\.\\MountPointManager",
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL
);
if (hManager != INVALID_HANDLE_VALUE)
{
for (int i = 'a'; i <= 'z'; i ++)
{
ZeroMemory(&_mp, sizeof(_mp));
swprintf(_mp.res0, L"\\DosDevices\\%c:", i);
_mp.mp.SymbolicLinkNameLength = wcslen(_mp.res0) * 2;
_mp.mp.SymbolicLinkNameOffset = sizeof(MOUNTMGR_MOUNT_POINT);

BOOL rc = DeviceIoControl(
hManager,
IOCTL_MOUNTMGR_QUERY_POINTS,
&_mp,
sizeof(_mp),
&_mps,
sizeof(_mps),
&Returned,
NULL
);
if (rc)
{
....
 
 
 

How can I change dos name to device name?

Post by keand » Tue, 14 Nov 2006 16:29:59

Thank you ver much.
Thank you ver much.
Thank you ver much.
Thank you ver much.
Thank you ver much.
 
 
 

How can I change dos name to device name?

Post by keand » Tue, 14 Nov 2006 16:45:29

And...


MOUNTMGR_MOUNT_POINT ... ?

Where is it?
 
 
 

How can I change dos name to device name?

Post by keand » Tue, 14 Nov 2006 17:38:23

Hi Anatoly.

I understood your reply and tested it.

Its result is "\DosDevices\C:'. (in case of 'c' )

I want to change "C" to "\\Device\\HarddiskVolume1"
(You know we could have many drives and name - c, d, e, ~ z)

Sometimes "Volume1" is not C drive.
So I need exact volume of C drive.
 
 
 

How can I change dos name to device name?

Post by Uwe Siebe » Tue, 14 Nov 2006 20:10:17


In user mode this works:

Call GetVolumeNameForVolumeMountPoint with the root path like "C:\\".
You get the volume name like \\?\Volume{GUID}\.
Then call QueryDosDevice with the Volume{GUID} part. That's all.


Uwe