Author: janderwald
Date: Sat Nov  8 20:58:57 2014
New Revision: 65330

URL: http://svn.reactos.org/svn/reactos?rev=65330&view=rev
Log:
[NTOS]
- implement PlugPlayControlGetInterfaceDeviceList class for NtPlugPlayControl

Modified:
    trunk/reactos/ntoskrnl/io/pnpmgr/plugplay.c

Modified: trunk/reactos/ntoskrnl/io/pnpmgr/plugplay.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr/plugplay.c?rev=65330&r1=65329&r2=65330&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/io/pnpmgr/plugplay.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/io/pnpmgr/plugplay.c [iso-8859-1] Sat Nov  8 
20:58:57 2014
@@ -206,6 +206,70 @@
     _SEH2_END;
 
     return Status;
+}
+
+static NTSTATUS
+IopGetInterfaceDeviceList(PPLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA 
DeviceList)
+{
+    NTSTATUS Status;
+    UNICODE_STRING DeviceInstance;
+    PDEVICE_OBJECT DeviceObject = NULL;
+    ULONG BufferSize = 0;
+    GUID FilterGuid;
+    PZZWSTR SymbolicLinkList = NULL, LinkList;
+    ULONG TotalLength = 0;
+
+    _SEH2_TRY
+    {
+        ProbeForRead(DeviceList->FilterGuid, sizeof(GUID), sizeof(UCHAR));
+        RtlCopyMemory(&FilterGuid, DeviceList->FilterGuid, sizeof(GUID));
+
+        if (DeviceList->Buffer != NULL && DeviceList->BufferSize != 0)
+        {
+            BufferSize = DeviceList->BufferSize;
+            ProbeForWrite(DeviceList->Buffer, BufferSize, sizeof(UCHAR));
+        }
+    }
+    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+    {
+        ExFreePool(DeviceInstance.Buffer);
+        _SEH2_YIELD(return _SEH2_GetExceptionCode());
+    }
+    _SEH2_END;
+
+
+    Status = IopCaptureUnicodeString(&DeviceInstance, 
&DeviceList->DeviceInstance);
+    if (NT_SUCCESS(Status))
+    {
+        /* Get the device object */
+        DeviceObject = IopGetDeviceObjectFromDeviceInstance(&DeviceInstance);
+        ExFreePool(DeviceInstance.Buffer);
+    }
+
+    Status = IoGetDeviceInterfaces(&FilterGuid, DeviceObject, 
DeviceList->Flags, &SymbolicLinkList);
+    ObDereferenceObject(DeviceObject);
+
+    if (!NT_SUCCESS(Status))
+    {
+        /* failed */
+        return Status;
+    }
+
+    LinkList = SymbolicLinkList;
+    while (*SymbolicLinkList != UNICODE_NULL)
+    {
+        TotalLength += (wcslen(SymbolicLinkList) + 1) * sizeof(WCHAR);
+        SymbolicLinkList += wcslen(SymbolicLinkList) + (sizeof(UNICODE_NULL) / 
sizeof(WCHAR));
+    }
+    TotalLength += sizeof(UNICODE_NULL);
+
+    if (BufferSize >= TotalLength)
+    {
+        RtlCopyMemory(DeviceList->Buffer, SymbolicLinkList, TotalLength * 
sizeof(WCHAR));
+    }
+    DeviceList->BufferSize = TotalLength;
+    ExFreePool(LinkList);
+    return STATUS_SUCCESS;
 }
 
 static NTSTATUS
@@ -865,6 +929,11 @@
                 return STATUS_INVALID_PARAMETER;
             return IopRemovePlugPlayEvent();
 
+        case PlugPlayControlGetInterfaceDeviceList:
+            if (!Buffer || BufferLength < 
sizeof(PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA))
+                return STATUS_INVALID_PARAMETER;
+            return 
IopGetInterfaceDeviceList((PPLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA)Buffer);
+
         case PlugPlayControlProperty:
             if (!Buffer || BufferLength < 
sizeof(PLUGPLAY_CONTROL_PROPERTY_DATA))
                 return STATUS_INVALID_PARAMETER;


Reply via email to