我正在对内核DLL中的文件函数进行小分析。我注意到这个函数叫做了 DosPathToSessionPath。我用谷歌搜索了它。没有太多关于此的文档。谁能告诉我这个功能的用途是什么?
答案 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
的路径吗?
这段代码是您看到的一些实验的起点。目前,DosPathToSessionPath
(ppOutPath
)的输出路径始终与输入路径相同。