MCPcopy Create free account
hub / github.com/NtQuery/Scylla / fixVirtualDevices

Method fixVirtualDevices

Scylla/DeviceNameResolver.cpp:61–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61void DeviceNameResolver::fixVirtualDevices()
62{
63 const USHORT BufferSize = MAX_PATH * 2 * sizeof(WCHAR);
64 WCHAR longCopy[MAX_PATH] = {0};
65 OBJECT_ATTRIBUTES oa = {0};
66 UNICODE_STRING unicodeInput = {0};
67 UNICODE_STRING unicodeOutput = {0};
68 HANDLE hFile = 0;
69 ULONG retLen = 0;
70 HardDisk hardDisk;
71
72 unicodeOutput.Buffer = (PWSTR)malloc(BufferSize);
73 if (!unicodeOutput.Buffer)
74 return;
75
76 for (unsigned int i = 0; i < deviceNameList.size(); i++)
77 {
78 wcscpy_s(longCopy, deviceNameList[i].longName);
79
80 NativeWinApi::RtlInitUnicodeString(&unicodeInput, longCopy);
81 InitializeObjectAttributes(&oa, &unicodeInput, 0, 0, 0);
82
83 if(NT_SUCCESS(NativeWinApi::NtOpenSymbolicLinkObject(&hFile, SYMBOLIC_LINK_QUERY, &oa)))
84 {
85 unicodeOutput.Length = BufferSize;
86 unicodeOutput.MaximumLength = unicodeOutput.Length;
87 ZeroMemory(unicodeOutput.Buffer, unicodeOutput.Length);
88
89 if (NT_SUCCESS(NativeWinApi::NtQuerySymbolicLinkObject(hFile, &unicodeOutput, &retLen)))
90 {
91 hardDisk.longNameLength = wcslen(unicodeOutput.Buffer);
92 wcscpy_s(hardDisk.shortName, deviceNameList[i].shortName);
93 wcscpy_s(hardDisk.longName, unicodeOutput.Buffer);
94 deviceNameList.push_back(hardDisk);
95 }
96
97 NativeWinApi::NtClose(hFile);
98 }
99 }
100
101 free(unicodeOutput.Buffer);
102}
103

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected