DosPathToSessionPath函数有什么用?

时间:2010-05-31 05:49:38

标签: function kernel

我正在对内核DLL中的文件函数进行小分析。我注意到这个函数叫做了 DosPathToSessionPath。我用谷歌搜索了它。没有太多关于此的文档。谁能告诉我这个功能的用途是什么?

1 个答案:

答案 0 :(得分:0)

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的路径吗?

这段代码是您看到的一些实验的起点。目前,DosPathToSessionPathppOutPath)的输出路径始终与输入路径相同。

相关问题