MCPcopy Create free account
hub / github.com/MaaXYZ/MaaFramework / NtPathToDosPath

Function NtPathToDosPath

source/binding/NodeJS/src/utils/library.cpp:10–43  ·  view source on GitHub ↗

\Device\HarddiskVolume3\xxx -> C:\xxx

Source from the content-addressed store, hash-verified

8
9// \Device\HarddiskVolume3\xxx -> C:\xxx
10static std::wstring NtPathToDosPath(std::wstring nt_path)
11{
12 WCHAR drive_buffers[512];
13
14 DWORD len = GetLogicalDriveStringsW(512, drive_buffers);
15 if (!len) {
16 return L"";
17 }
18
19 std::vector<std::wstring> drives;
20 WCHAR* p = drive_buffers;
21 while (*p) {
22 drives.emplace_back(p);
23 p += wcslen(p) + 1;
24 }
25
26 WCHAR device_paths[512];
27 for (const auto& drive : drives) {
28 std::wstring drive_name = drive.substr(0, 2);
29
30 DWORD ret = QueryDosDeviceW(drive_name.c_str(), device_paths, 512);
31 if (!ret) {
32 continue;
33 }
34
35 std::wstring dev { device_paths };
36 if (nt_path.rfind(dev, 0) == 0) {
37 nt_path.replace(0, dev.size(), drive_name);
38 return nt_path;
39 }
40 }
41
42 return L"";
43}
44
45std::filesystem::path get_library_path(void* addr)
46{

Callers 1

get_library_pathFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected