为什么当我呼唤RtlDosPathNameToNtPathName_U路径时\\?\C:,而不是回来
\??\C:
Run Code Online (Sandbox Code Playgroud)
我回来了
\??\C:\?\\?\C:
Run Code Online (Sandbox Code Playgroud)
哪个明显不正确?
代码段(在D中):
struct CurDir { UnicodeString DosPath; HANDLE Handle; }
extern (Windows) static bool RtlDosPathNameToNtPathName_U(
in const(wchar)* DosPathName, out UnicodeString NtPathName,
out const(wchar)* NtFileNamePart, out CurDir DirectoryInfo);
wchar[] toNtPath(const(wchar)[] path)
{
UnicodeString ntPath;
CurDir curDir;
const(wchar)* fileNamePart;
enforce(RtlDosPathNameToNtPathName_U(path.ptr, ntPath,
fileNamePart, curDir));
try
{ return ntPath.Buffer[0 .. ntPath.Length / ntPath.Buffer[0].sizeof].dup; }
finally { RtlFreeHeap(RtlGetProcessHeap(), 0, ntPath.Buffer); }
}
writeln(toNtPath(r"\\?\C:")); //Returns the weird string
Run Code Online (Sandbox Code Playgroud)
更新:
我想出了问题 - 看我的答案.
wj3*_*j32 10
RtlDosPathNameToNtPathName_U给你正确的输出.你看到在中间看起来怪怪的角色的原因是因为UNICODE_STRINGs的不为空值终止(我敢肯定,你已经知道)要求.文件名\??\C:\是完全有效的本机格式文件名.我怀疑你真正想要的是预先设置设备名称,而不是仅仅GLOBAL??像引用目录一样引用目录RtlDosPathNameToNtPathName_U.
要做到这一点,只需调用NtQuerySymbolicLinkObject上\??\x:,其中X是驱动器盘符路径被使用,且在前面加上结果.如果它是UNC路径,则前置\Device\Mup.等等其他类型的路径(如果有的话).
| 归档时间: |
|
| 查看次数: |
4930 次 |
| 最近记录: |