diff options
Diffstat (limited to '')
-rw-r--r-- | src/nt_path_converter/device.c | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/src/nt_path_converter/device.c b/src/nt_path_converter/device.c index fbffd27..5ee0d3e 100644 --- a/src/nt_path_converter/device.c +++ b/src/nt_path_converter/device.c @@ -22,15 +22,17 @@ static NTSTATUS device_open(DEVICE_OBJECT *device_object, IRP *irp) return status; } -typedef NTSTATUS (*ioctl_handler)(void *, unsigned long, - void *, unsigned long, - ULONG_PTR *); - -static NTSTATUS handle_convert_nt_path(void *in_buf, - unsigned long in_buf_size, - void *out_buf, - unsigned long out_buf_size, - ULONG_PTR *nbwritten) +typedef NTSTATUS (*ioctl_handler)( + void *, unsigned long, + void *, unsigned long, + ULONG_PTR *); + +static NTSTATUS handle_convert_nt_path( + void *in_buf, + unsigned long in_buf_size, + void *out_buf, + unsigned long out_buf_size, + ULONG_PTR *nbwritten) { UNICODE_STRING uUnresolved, uResolved; NTSTATUS status = STATUS_SUCCESS; @@ -52,13 +54,13 @@ static NTSTATUS handle_convert_nt_path(void *in_buf, if (out_buf_size < *nbwritten) { status = STATUS_BUFFER_OVERFLOW; - goto FREE_RESOLVED; + goto free_resolved; } RtlFillMemory(out_buf, *nbwritten, L'\0'); RtlCopyMemory(out_buf, uResolved.Buffer, uResolved.Length); -FREE_RESOLVED: +free_resolved: ExFreePool(uResolved.Buffer); return status; @@ -85,14 +87,16 @@ static NTSTATUS device_ioctl(DEVICE_OBJECT *device_object, IRP *irp) case CONVERT_NT_PATH: handler = handle_convert_nt_path; break; + default: status = irp->IoStatus.Status = STATUS_NOT_SUPPORTED; goto complete_request; } - status = irp->IoStatus.Status = handler(in_buf, in_buf_size, - out_buf, out_buf_size, - &irp->IoStatus.Information); + status = irp->IoStatus.Status = handler( + in_buf, in_buf_size, + out_buf, out_buf_size, + &irp->IoStatus.Information); complete_request: IoCompleteRequest(irp, IO_NO_INCREMENT); @@ -104,18 +108,20 @@ typedef struct { const wchar_t *path; const wchar_t *symlink; -} device_info; +} +DeviceInfo; typedef struct { DEVICE_OBJECT *object; UNICODE_STRING path; UNICODE_STRING symlink; -} device; +} +Device; #define NUMOF_DEVICES 1 -static device_info devices_info[NUMOF_DEVICES] = +static DeviceInfo devices_info[NUMOF_DEVICES] = { { L"\\Device\\nt_path_converter", @@ -123,7 +129,7 @@ static device_info devices_info[NUMOF_DEVICES] = }, }; -static device devices[NUMOF_DEVICES]; +static Device devices[NUMOF_DEVICES]; static void destroy_device(int i) { @@ -145,13 +151,14 @@ static NTSTATUS set_up_device(DRIVER_OBJECT *driver_object, int i) RtlInitUnicodeString(&devices[i].path, devices_info[i].path); RtlInitUnicodeString(&devices[i].symlink, devices_info[i].symlink); - status = IoCreateDevice(driver_object, - 0, - &devices[i].path, - FILE_DEVICE_UNKNOWN, - FILE_DEVICE_SECURE_OPEN, - FALSE, - &devices[i].object); + status = IoCreateDevice( + driver_object, + 0, + &devices[i].path, + FILE_DEVICE_UNKNOWN, + FILE_DEVICE_SECURE_OPEN, + FALSE, + &devices[i].object); if (!NT_SUCCESS(status)) return status; @@ -159,8 +166,8 @@ static NTSTATUS set_up_device(DRIVER_OBJECT *driver_object, int i) devices[i].object->Flags |= DO_BUFFERED_IO; devices[i].object->Flags &= ~DO_DEVICE_INITIALIZING; - if (!NT_SUCCESS(status = IoCreateSymbolicLink(&devices[i].symlink, - &devices[i].path))) + if (!NT_SUCCESS(status = IoCreateSymbolicLink( + &devices[i].symlink, &devices[i].path))) goto delete_device; return status; |