15#pragma alloc_text(PAGE, VfdSetLink)
16#pragma alloc_text(PAGE, VfdLoadLink)
17#pragma alloc_text(PAGE, VfdStoreLink)
32 VFDTRACE(VFDINFO, (
"[VFD] VfdSetLink - IN\n"));
36 if (DriveLetter >=
'a' && DriveLetter <=
'z') {
37 DriveLetter -= (
'a' -
'A');
42 if (DriveLetter != 0 &&
43 (DriveLetter <
'A' || DriveLetter >
'Z')) {
47 if (DeviceExtension->DriveLetter &&
48 DeviceExtension->DriveLetter != DriveLetter) {
59 L"\\??\\%wc:", DeviceExtension->DriveLetter);
67 (
"[VFD] Link %ws deleted\n", name_buf));
69 DeviceExtension->DriveLetter = 0;
75 (
"[VFD] Link %ws not found\n", name_buf));
77 DeviceExtension->DriveLetter = 0;
82 (
"[VFD] IoDeleteSymbolicLink %ws - %s\n",
83 name_buf, GetStatusName(
status)));
97 L"\\??\\Global\\%wc:" :
L"\\??\\%wc:",
104 L"\\??\\Global\\%wc:" :
L"\\??\\%wc:",
111 &unicode_name, &(DeviceExtension->DeviceName));
114 VFDTRACE(VFDINFO, (
"[VFD] Link %ws created\n", name_buf));
116 DeviceExtension->DriveLetter = DriveLetter;
120 (
"[VFD] IoCreateSymbolicLink %ws - %s\n",
121 name_buf, GetStatusName(
status)));
126 (
"[VFD] VfdSetLink - %s\n", GetStatusName(
status)));
145 VFDTRACE(VFDINFO, (
"[VFD] VfdLoadLink - IN\n"));
154 DeviceExtension->DeviceNumber);
160 DeviceExtension->DeviceNumber);
164 params[0].Name = name_buf;
165 params[0].EntryContext = &letter;
175 (
"[VFD] Drive letter '%wc' loaded from the registry\n",
176 letter ? letter :
' '));
178 DeviceExtension->DriveLetter = (
CHAR)letter;
181 (
"[VFD] VfdLoadLink - %s\n", GetStatusName(
status)));
198 VFDTRACE(VFDINFO, (
"[VFD] VfdStoreLink - IN\n"));
202 DeviceExtension->device_object->DriverObject,
203 VFD_DRIVER_EXTENSION_ID);
205 driver_extension = DeviceExtension->DriverExtension;
208 if (!driver_extension ||
211 VFDTRACE(VFDWARN, (
"[VFD] Registry Path not present.\n"));
212 VFDTRACE(VFDINFO, (
"[VFD] VfdStoreLinks - OUT\n"));
221 DeviceExtension->DeviceNumber);
227 DeviceExtension->DeviceNumber);
230 letter = DeviceExtension->DriveLetter;
242 (
"[VFD] RtlWriteRegistryValue - %s\n",
247 (
"[VFD] Drive letter '%wc' stored into the registry\n",
248 letter ? letter :
L' '));
252 (
"[VFD] VfdStoreLink - %s\n", GetStatusName(
status)));
#define NT_SUCCESS(StatCode)
GLenum const GLfloat * params
NTSYSAPI NTSTATUS WINAPI RtlWriteRegistryValue(ULONG, PCWSTR, PCWSTR, ULONG, PVOID, ULONG)
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format,...)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RTL_REGISTRY_ABSOLUTE
#define RTL_QUERY_REGISTRY_DIRECT
#define RTL_REGISTRY_OPTIONAL
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
NTSTATUS NTAPI IoCreateSymbolicLink(IN PUNICODE_STRING SymbolicLinkName, IN PUNICODE_STRING DeviceName)
NTSTATUS NTAPI IoDeleteSymbolicLink(IN PUNICODE_STRING SymbolicLinkName)
UNICODE_STRING RegistryPath
#define RtlZeroMemory(Destination, Length)
#define STATUS_DRIVER_INTERNAL_ERROR
#define STATUS_INVALID_PARAMETER
#define STATUS_OBJECT_NAME_NOT_FOUND
#define VFDTRACE(LEVEL, STRING)
#define VFD_REG_DRIVE_LETTER
NTSTATUS VfdLoadLink(IN PDEVICE_EXTENSION DeviceExtension, IN PWSTR RegistryPath)
NTSTATUS VfdStoreLink(IN PDEVICE_EXTENSION DeviceExtension)
NTSTATUS VfdSetLink(IN PDEVICE_EXTENSION DeviceExtension, IN CHAR DriveLetter)
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath