2010-05-31 43 views
0

我在內核DLL文件函數中做了一個小的分析。我注意到這個函數叫做 DosPathToSessionPath。我Google搜索了它。沒有太多關於這方面的文件。任何人都可以告訴我這個函數有什麼用處?函數DosPathToSessionPath的用法是什麼?

回答

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)的輸出路徑始終與輸入路徑相同。

+0

它實際上是沿着時間之前,其實我去的時候THROU」這function..Its的研究已經發現,此功能僅標識path..wether其定義的FRM內核空間的類型(例如:\會議\ 1 \ DosDevices \ Drive \ Program Files)或frm用戶模式。 – kiddo 2010-07-28 12:08:01