https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4a7e89770eaefdd54b9f2…
commit 4a7e89770eaefdd54b9f2f3c20047c29cd52a19a
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Wed Oct 3 11:56:21 2018 +0200
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Wed Oct 3 11:56:21 2018 +0200
[NTOSKRNL] Implement IoQueryFileDosDeviceName()
---
ntoskrnl/io/iomgr/file.c | 54 +++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 51 insertions(+), 3 deletions(-)
diff --git a/ntoskrnl/io/iomgr/file.c b/ntoskrnl/io/iomgr/file.c
index 792376ca82..1fb691809c 100644
--- a/ntoskrnl/io/iomgr/file.c
+++ b/ntoskrnl/io/iomgr/file.c
@@ -3480,15 +3480,63 @@ IoCancelFileOpen(IN PDEVICE_OBJECT DeviceObject,
}
/*
- * @unimplemented
+ * @implemented
*/
NTSTATUS
NTAPI
IoQueryFileDosDeviceName(IN PFILE_OBJECT FileObject,
OUT POBJECT_NAME_INFORMATION *ObjectNameInformation)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ NTSTATUS Status;
+ ULONG Length, ReturnLength;
+ POBJECT_NAME_INFORMATION LocalInfo;
+
+ /* Start with a buffer length of 200 */
+ ReturnLength = 200;
+ /*
+ * We'll loop until query works.
+ * We will use returned length for next loop
+ * iteration, trying to have a big enough buffer.
+ */
+ for (Length = 200; ; Length = ReturnLength)
+ {
+ /* Allocate our work buffer */
+ LocalInfo = ExAllocatePoolWithTag(PagedPool, Length, 'nDoI');
+ if (LocalInfo == NULL)
+ {
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ /* Query the DOS name */
+ Status = IopQueryNameInternal(FileObject,
+ TRUE,
+ TRUE,
+ LocalInfo,
+ Length,
+ &ReturnLength,
+ KernelMode);
+ /* If it succeed, nothing more to do */
+ if (Status == STATUS_SUCCESS)
+ {
+ break;
+ }
+
+ /* Otherwise, prepare for re-allocation */
+ ExFreePoolWithTag(LocalInfo, 'nDoI');
+
+ /*
+ * If we failed because of something else
+ * than memory, simply stop and fail here
+ */
+ if (Status != STATUS_BUFFER_OVERFLOW)
+ {
+ return STATUS_BUFFER_OVERFLOW;
+ }
+ }
+
+ /* Success case here: return our buffer */
+ *ObjectNameInformation = LocalInfo;
+ return STATUS_SUCCESS;
}
/*