Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I convert a native (NT) pathname into a Win32 path name?
    primarykey
    data
    text
    <p>I'm working on reporting some information gleaned from native system APIs. (I know this is bad.... but I'm getting information that I can't get otherwise, and I have little issue with having to update my app if/when that time comes around.)</p> <p>The native API returns native pathnames, as seen by <code>ob</code>, i.e. <code>\SystemRoot\System32\Ntoskrnl.exe</code>, or <code>\??\C:\Program Files\VMWare Workstation\vstor-ws60.sys</code>.</p> <p>I can replace common prefixes, i.e.</p> <pre><code>std::wstring NtPathToWin32Path( std::wstring ntPath ) { if (boost::starts_with(ntPath, L"\\\\?\\")) { ntPath.erase(ntPath.begin(), ntPath.begin() + 4); return ntPath; } if (boost::starts_with(ntPath, L"\\??\\")) { ntPath.erase(ntPath.begin(), ntPath.begin() + 4); } if (boost::starts_with(ntPath, L"\\")) { ntPath.erase(ntPath.begin(), ntPath.begin() + 1); } if (boost::istarts_with(ntPath, L"globalroot\\")) { ntPath.erase(ntPath.begin(), ntPath.begin() + 11); } if (boost::istarts_with(ntPath, L"systemroot")) { ntPath.replace(ntPath.begin(), ntPath.begin() + 10, GetWindowsPath()); } if (boost::istarts_with(ntPath, L"windows")) { ntPath.replace(ntPath.begin(), ntPath.begin() + 7, GetWindowsPath()); } return ntPath; } TEST(Win32Path, NtPathDoubleQuestions) { ASSERT_EQ(L"C:\\Example", NtPathToWin32Path(L"\\??\\C:\\Example")); } TEST(Win32Path, NtPathUncBegin) { ASSERT_EQ(L"C:\\Example", NtPathToWin32Path(L"\\\\?\\C:\\Example")); } TEST(Win32Path, NtPathWindowsStart) { ASSERT_EQ(GetCombinedPath(GetWindowsPath(), L"Hello\\World"), NtPathToWin32Path(L"\\Windows\\Hello\\World")); } TEST(Win32Path, NtPathSystemrootStart) { ASSERT_EQ(GetCombinedPath(GetWindowsPath(), L"Hello\\World"), NtPathToWin32Path(L"\\SystemRoot\\Hello\\World")); } TEST(Win32Path, NtPathGlobalRootSystemRoot) { ASSERT_EQ(GetCombinedPath(GetWindowsPath(), L"Hello\\World"), NtPathToWin32Path(L"\\globalroot\\SystemRoot\\Hello\\World")); } </code></pre> <p>but I'd be strongly surprised if there's not some API, native or otherwise, which will convert these into Win32 path names. Does such an API exist?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload