Re: How to convert "\Device\HarddiskVolume1\" to "C:\"

Tech-Archive recommends: Speed Up your PC by fixing your registry



If you need a generic solution that works in both kernel and user mode,
the whole things can be done like ZwOpenSymbolicLink() -
ZwQuerySymbolicLink() sequence for each drive letter (A;B;C;D,etc. If
the target volume is mounted on a partition of a basic disk, you will
get a string in the form "\Device\HarddiskVolumeX\...". If the target
volume is mounted on a partition of a removable USB disk, you will get
a string in the form "\Device\HarddiskX\DP(1)0-0+b\..." If the target
volume is a network drive, you will get a string in the form
"\Device\LanmanRedirector\ServerX\...". ). In other words, you have no
chance to miss your target string.


If you want a solution that works only in the kernel mode, you can
check IoVolumeDeviceToDosName() (or RtlVolumeDeviceToDosName(), if you
want your code to run on W2K as well ) documentation on MSDN....


Anton Bassov

Mario Beutler wrote:
Hello,

How to convert the following full file names into "normal" file names:
\Device\HarddiskVolume1\windows\system32\lsass.exe
\Device\Harddisk5\DP(1)0-0+b\test.exe
\Device\LanmanRedirector\Server007\TEMP\test.exe

I need the "normal" file names like:
C:\windows\system32\lsass.exe
J:\test.exe (<-This is a USB drive.)
\\Server007\TEMP\test.exe

I tried GetVolumePathNamesForVolumeName,
GetVolumeNameForVolumeMountPoint, GetFullPathName and QueryDosDevice -
but nothing seems to work for all cases (e.g. USB, network shares).
Any ideas? Thanks.

Mario

.



Relevant Pages

  • Re: SpinLock/Mutex : Difference ?
    ... You seem to think that a spinlock is is something that only the kernel can ... But anyone can write an equivalent API for user mode, all you need to do is ...
    (microsoft.public.win32.programmer.kernel)
  • Re: When to write as a device driver instead of just a library.
    ... > one write the code as a device driver as opposed to a plain simple ... In general if it can be done in user mode, ... or major advantages to a kernel mode implementation, ... If you communicate with a device that way, ...
    (comp.os.linux.development.system)
  • Re: USB performance bug since kernel 2.6.13 (CRITICAL???)
    ... user mode for this sort of thing. ... kernel mode drivers in this regard. ... Recall that each transaction ...
    (Linux-Kernel)
  • Re: SpinLock/Mutex : Difference ?
    ... I never once said that user mode code should in any way ... Even the OS kernel does not support read/write spinlocks, ... spinlock owner is guaranteed to never get preempted by another thread. ... as resetting the count of kernel level semaphores under some contitions. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Unexpected Error With CE.BIB file
    ... runs in kernel mode which corrupts the kernel ... in user mode can't access kernel mode space, ... Anything running in kernel mode can access both user and kernel space. ... Move the component that loads hidparse into kernel space, ...
    (microsoft.public.windowsce.platbuilder)