2010-05-31 6 views
0

커널 dll에서 파일 기능에 대한 작은 분석을하고 있습니다. DosPathToSessionPath라는이 함수를 발견했습니다. 나는 그것을 봤다. 이에 대한 많은 문서는 없습니다. 아무도이 기능의 사용법을 말해 줄 수 있습니까?DosPathToSessionPath 함수는 무엇을 사용합니까?

답변

0

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); 
      } 
     } 
    } 
} 

함수가 사용되어야하는 상황에서 분명하지 않다 : 여기 DosPathToSessionPath을 사용하는 작은 C# 코드입니다. 세션 경로가 \Sessions\1\DosDevices\C:\Program Files 또는 C:\Users\Oleg\AppData\Local\VirtualStore\Program Files과 같은 경로입니까?

이 코드는 일부 실험의 출발점으로 간주됩니다. 현재 DosPathToSessionPath (ppOutPath)의 출력 경로는 항상 입력 경로와 같습니다.

+0

이 기능은 실제로이 기능이 경로 유형을 식별한다는 사실을 발견했습니다. 예를 들어, 정의 된 frm 커널 공간 (예 : \ Sessions \ 1 \ DosDevices \ Drive \ Program Files) 또는 frm 사용자 모드. – kiddo

관련 문제