views:

20

answers:

1

I am doing a small analysis in file functions in kernel dll..I noticed this funtion called DosPathToSessionPath..i googled for it..there is no much documentation about this.Can anybody tell me what is the use of this fucntion?

A: 

The DosPathToSessionPath is not documented. Here is a small C# code which use DosPathToSessionPath:

using System;
using System.Runtime.InteropServices;

namespace DosPathToSessionPath {
    static class NativeMethods {
        [DllImport ("kernel32.dll", CharSet = CharSet.Unicode)]
        [return: MarshalAs(UnmanagedType.Bool)]
        internal static extern bool DosPathToSessionPath (
            uint sessionId, String pInPath, out IntPtr ppOutPath);

        [DllImport ("kernel32.dll")]
        internal static extern uint WTSGetActiveConsoleSessionId ();

        [DllImport ("kernel32.dll", SetLastError = true, ExactSpelling = true)]
        internal static extern IntPtr LocalFree (IntPtr hMem);
    }
    class Program {
        static void Main (string[] args) {
            uint sessionId = NativeMethods.WTSGetActiveConsoleSessionId ();
            string filePath = @"C:\Program Files";
            IntPtr ppOutPath;
            bool statusCode = NativeMethods.DosPathToSessionPath (
                                    sessionId, filePath, out ppOutPath);
            if (statusCode) {
                string outPath = Marshal.PtrToStringAuto (ppOutPath);
                Console.WriteLine (outPath);
                ppOutPath = NativeMethods.LocalFree (ppOutPath);
            }
        }
    }
}

It is not clear in which situations the function should be used. Is the session path is a path like \Sessions\1\DosDevices\C:\Program Files or like C:\Users\Oleg\AppData\Local\VirtualStore\Program Files?

This code an you see as a starting point of some experiments. Currently the output path of DosPathToSessionPath (ppOutPath) is always the same as the input path.

Oleg
it was actually along time before,actually when I went throu' research of this function..Its been noticed that this function only identifies the type of path..wether its defined frm kernel space(ex:\Sessions\1\DosDevices\Drive\Program Files) or frm user mode.
kiddo