Function DosPathToSessionPath函数的用途是什么?

Function DosPathToSessionPath函数的用途是什么?,function,kernel,Function,Kernel,我正在内核dll中的文件函数中做一个小分析。我注意到这个函数叫做 DosPathToSessionPath。我在谷歌上搜索它。关于这方面没有太多的文档。有人能告诉我这个函数有什么用吗?DosPathToSessionPath没有文档记录。下面是一个使用DosPathToSessionPath的小C代码: using System; using System.Runtime.InteropServices; namespace DosPathToSessionPath { static

我正在内核dll中的文件函数中做一个小分析。我注意到这个函数叫做
DosPathToSessionPath。我在谷歌上搜索它。关于这方面没有太多的文档。有人能告诉我这个函数有什么用吗?

DosPathToSessionPath没有文档记录。下面是一个使用
DosPathToSessionPath
的小C代码:

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);
            }
        }
    }
}
不清楚该功能应在哪些情况下使用。会话路径是否类似于
\Sessions\1\DosDevices\C:\Program Files
或类似于
C:\Users\Oleg\AppData\Local\VirtualStore\Program Files


这段代码可以作为一些实验的起点。目前,
DosPathToSessionPath
ppOutPath
)的输出路径始终与输入路径相同。

这实际上是很久以前的事了,实际上是在我研究这个函数的时候。.注意到这个函数只识别路径的类型。.不管它定义的frm内核空间如何(例如:\Sessions\1\DosDevices\Drive\Program Files)或frm用户模式。