From 5dc8dc829af667ab266c6150b9d43b18f991498e Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Fri, 29 Jan 2016 09:44:36 -0600 Subject: [PATCH] ntoskrnl.exe: Implement IoGetDeviceProperty for DevicePropertyPhysicalDeviceObjectName. Signed-off-by: Aric Stewart Signed-off-by: Alexandre Julliard --- dlls/ntoskrnl.exe/ntoskrnl.c | 39 ++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index 04f01985eaf..7e043be634f 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -1040,9 +1040,44 @@ PDEVICE_OBJECT WINAPI IoGetAttachedDevice( PDEVICE_OBJECT device ) NTSTATUS WINAPI IoGetDeviceProperty( DEVICE_OBJECT *device, DEVICE_REGISTRY_PROPERTY device_property, ULONG buffer_length, PVOID property_buffer, PULONG result_length ) { - FIXME( "%p %d %u %p %p: stub\n", device, device_property, buffer_length, + NTSTATUS status = STATUS_NOT_IMPLEMENTED; + TRACE( "%p %d %u %p %p\n", device, device_property, buffer_length, property_buffer, result_length ); - return STATUS_NOT_IMPLEMENTED; + switch (device_property) + { + case DevicePropertyPhysicalDeviceObjectName: + { + ULONG used_len, len = buffer_length + sizeof(OBJECT_NAME_INFORMATION); + OBJECT_NAME_INFORMATION *name = HeapAlloc(GetProcessHeap(), 0, len); + + status = NtQueryObject(device->Reserved, ObjectNameInformation, name, len, &used_len); + if (status == STATUS_SUCCESS) + { + /* Ensure room for NULL termination */ + if (buffer_length >= name->Name.MaximumLength) + memcpy(property_buffer, name->Name.Buffer, name->Name.MaximumLength); + else + status = STATUS_BUFFER_TOO_SMALL; + *result_length = name->Name.MaximumLength; + } + else + { + if (status == STATUS_INFO_LENGTH_MISMATCH || + status == STATUS_BUFFER_OVERFLOW) + { + status = STATUS_BUFFER_TOO_SMALL; + *result_length = used_len - sizeof(OBJECT_NAME_INFORMATION); + } + else + *result_length = 0; + } + HeapFree(GetProcessHeap(), 0, name); + break; + } + default: + FIXME("unhandled property %d\n", device_property); + } + return status; }