| 59 | } |
| 60 | |
| 61 | void 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 |
nothing calls this directly
no outgoing calls
no test coverage detected