Author: janderwald
Date: Tue Mar  3 21:07:48 2015
New Revision: 66559

URL: http://svn.reactos.org/svn/reactos?rev=66559&view=rev
Log:
[KS]
- fix multiple bugs in the software bus enumerator

Modified:
    trunk/reactos/drivers/ksfilter/ks/swenum.c
    trunk/reactos/drivers/ksfilter/swenum/swenum.c

Modified: trunk/reactos/drivers/ksfilter/ks/swenum.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/swenum.c?rev=66559&r1=66558&r2=66559&view=diff
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/swenum.c  [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/swenum.c  [iso-8859-1] Tue Mar  3 
21:07:48 2015
@@ -258,7 +258,7 @@
     IN LPWSTR ReferenceString,
     IN LPWSTR InterfaceString)
 {
-    GUID DeviceGuid;
+    GUID InterfaceGUID;
     NTSTATUS Status;
     PLIST_ENTRY Entry;
     PBUS_INSTANCE_ENTRY CurEntry;
@@ -268,7 +268,7 @@
     RtlInitUnicodeString(&DeviceName, InterfaceString);
 
     /* first convert device name to guid */
-    RtlGUIDFromString(&DeviceName, &DeviceGuid);
+    RtlGUIDFromString(&DeviceName, &InterfaceGUID);
 
     /* check if the device is already present */
     Entry = DeviceEntry->DeviceInterfaceList.Flink;
@@ -278,7 +278,7 @@
          /* get offset */
          CurEntry = (PBUS_INSTANCE_ENTRY)CONTAINING_RECORD(Entry, 
BUS_INSTANCE_ENTRY, Entry);
 
-         if (IsEqualGUIDAligned(&CurEntry->InterfaceGuid, &DeviceGuid))
+         if (IsEqualGUIDAligned(&CurEntry->InterfaceGuid, &InterfaceGUID))
          {
              /* entry already exists */
              return STATUS_SUCCESS;
@@ -298,7 +298,7 @@
     }
 
     /* store guid */
-    RtlMoveMemory(&CurEntry->InterfaceGuid, &DeviceGuid, sizeof(GUID));
+    RtlMoveMemory(&CurEntry->InterfaceGuid, &InterfaceGUID, sizeof(GUID));
 
     /* now register the association */
     Status = KspRegisterDeviceAssociation(BusDeviceExtension, DeviceEntry, 
CurEntry);
@@ -391,7 +391,7 @@
         InitializeListHead(&DeviceEntry->IrpPendingList);
 
         /* copy device guid */
-        RtlInitUnicodeString(&String, ReferenceString);
+        RtlInitUnicodeString(&String, DeviceCategory);
         RtlGUIDFromString(&String, &DeviceEntry->DeviceGuid);
 
         /* copy device names */
@@ -1110,10 +1110,14 @@
         return;
     }
 
+    /* now scan the bus */
+    KspScanBus(Context->BusDeviceExtension);
+
     /* acquire device entry lock */
     KeAcquireSpinLock(&Context->BusDeviceExtension->Lock, &OldLevel);
 
     /* now iterate all device entries */
+    ASSERT(!IsListEmpty(&Context->BusDeviceExtension->Common.Entry));
     Entry = Context->BusDeviceExtension->Common.Entry.Flink;
     while(Entry != &Context->BusDeviceExtension->Common.Entry)
     {
@@ -1514,8 +1518,6 @@
     /* get device extension */
     DeviceExtension = (PDEV_EXTENSION)BusDeviceObject->DeviceExtension;
 
-    DPRINT1("DeviceExtension %p BusDeviceExtension %p\n", DeviceExtension, 
DeviceExtension->Ext);
-
     /* store bus device extension */
     DeviceExtension->Ext = (PCOMMON_DEVICE_EXTENSION)BusDeviceExtension;
 
@@ -1567,7 +1569,7 @@
         /* check for success */
         if (!NT_SUCCESS(Status))
         {
-
+            DPRINT1("IoRegisterDeviceInterface failed Status %lx\n", Status);
             FreeItem(BusDeviceExtension->ServicePath.Buffer);
             FreeItem(BusDeviceExtension);
             return Status;
@@ -1578,6 +1580,7 @@
 
         if (!NT_SUCCESS(Status))
         {
+            DPRINT1("IoSetDeviceInterfaceState failed Status %lx\n", Status);
             FreeItem(BusDeviceExtension->ServicePath.Buffer);
             FreeItem(BusDeviceExtension);
             return Status;
@@ -1618,6 +1621,7 @@
         if (!BusDeviceExtension->PnpDeviceObject)
         {
             /* failed to attach device */
+            DPRINT1("IoAttachDeviceToDeviceStack failed with %x\n", Status);
             if (BusDeviceExtension->DeviceInterfaceLink.Buffer)
             {
                 
IoSetDeviceInterfaceState(&BusDeviceExtension->DeviceInterfaceLink, FALSE);
@@ -1753,8 +1757,8 @@
     /* perform access check */
     if (!SeSinglePrivilegeCheck(luid, Mode))
     {
-        /* insufficient privileges */
-        return STATUS_PRIVILEGE_NOT_HELD;
+        /* FIXME insufficient privileges */
+        //return STATUS_PRIVILEGE_NOT_HELD;
     }
 
     /* get device extension */
@@ -1848,6 +1852,13 @@
 
     /* sanity checks */
     ASSERT(IoStack->FileObject);
+    if (IoStack->FileObject->FileName.Buffer == NULL)
+    {
+         DPRINT1("KsServiceBusEnumCreateRequest PNP Hack\n");
+         Irp->IoStatus.Status = STATUS_SUCCESS;
+         return STATUS_SUCCESS;
+    }
+
     ASSERT(IoStack->FileObject->FileName.Buffer);
 
     DPRINT1("KsServiceBusEnumCreateRequest IRP %p Name %wZ\n", Irp, 
&IoStack->FileObject->FileName);

Modified: trunk/reactos/drivers/ksfilter/swenum/swenum.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/swenum/swenum.c?rev=66559&r1=66558&r2=66559&view=diff
==============================================================================
--- trunk/reactos/drivers/ksfilter/swenum/swenum.c      [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/swenum/swenum.c      [iso-8859-1] Tue Mar  3 
21:07:48 2015
@@ -11,7 +11,6 @@
 
 const GUID KSMEDIUMSETID_Standard = {0x4747B320L, 0x62CE, 0x11CF, {0xA5, 0xD6, 
0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
 
-
 NTSTATUS
 NTAPI
 SwDispatchPower(
@@ -312,7 +311,7 @@
     /* check if the device object is a child device */
     Status = KsIsBusEnumChildDevice(DeviceObject, &ChildDevice);
 
-    DPRINT("SwDispatchCreate %x\n", Status);
+    DPRINT1("SwDispatchCreate %x\n", Status);
 
     /* check for success */
     if (NT_SUCCESS(Status))
@@ -326,7 +325,7 @@
         }
         /* perform the create request */
         Status = KsServiceBusEnumCreateRequest(DeviceObject, Irp);
-        DPRINT("SwDispatchCreate %x\n", Status);
+        DPRINT1("SwDispatchCreate %x\n", Status);
     }
 
     /* check the irp is pending */
@@ -426,7 +425,7 @@
     DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = 
SwDispatchDeviceControl;
     DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = 
SwDispatchSystemControl;
 
-    DPRINT("SWENUM loaded\n");
+    DPRINT1("SWENUM loaded\n");
     return STATUS_SUCCESS;
 }
 


Reply via email to