[ros-diffs] [janderwald] 47222: [PORTCLS] - Pass subdevice interface to PcNewRegistryKey - Fix multiple bugs in PcNewRegistryKey such as - If key type is GeneralRegistryKey, the function is supposed to create a new key - If key type is HwProfileRegistryKey, the type must be or'd with PLUGPLAY_REGKEY_DEVICE - Implement opening keys of type DeviceInterfaceRegistryKey - Free key handle if there is not enough memory to create a registry key object - Add more comments

janderwald at svn.reactos.org janderwald at svn.reactos.org
Sat May 15 19:17:06 CEST 2010


Author: janderwald
Date: Sat May 15 19:17:05 2010
New Revision: 47222

URL: http://svn.reactos.org/svn/reactos?rev=47222&view=rev
Log:
[PORTCLS]
- Pass subdevice interface to PcNewRegistryKey
- Fix multiple bugs in PcNewRegistryKey such as
- If key type is GeneralRegistryKey, the function is supposed to create a new key
- If key type is HwProfileRegistryKey, the type must be or'd with PLUGPLAY_REGKEY_DEVICE
- Implement opening keys of type DeviceInterfaceRegistryKey
- Free key handle if there is not enough memory to create a registry key object
- Add more comments

Modified:
    trunk/reactos/drivers/wdm/audio/backpln/portcls/port_dmus.cpp
    trunk/reactos/drivers/wdm/audio/backpln/portcls/port_topology.cpp
    trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavecyclic.cpp
    trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavepci.cpp
    trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavert.cpp
    trunk/reactos/drivers/wdm/audio/backpln/portcls/private.hpp
    trunk/reactos/drivers/wdm/audio/backpln/portcls/registry.cpp

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/port_dmus.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/port_dmus.cpp?rev=47222&r1=47221&r2=47222&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/port_dmus.cpp [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/port_dmus.cpp [iso-8859-1] Sat May 15 19:17:05 2010
@@ -340,7 +340,7 @@
                             RegistryKeyType,
                             DesiredAccess,
                             m_pDeviceObject,
-                            NULL,//FIXME
+                            (ISubdevice*)this,
                             ObjectAttributes,
                             CreateOptions,
                             Disposition);

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/port_topology.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/port_topology.cpp?rev=47222&r1=47221&r2=47222&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/port_topology.cpp [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/port_topology.cpp [iso-8859-1] Sat May 15 19:17:05 2010
@@ -299,7 +299,7 @@
                             RegistryKeyType,
                             DesiredAccess,
                             m_pDeviceObject,
-                            NULL,//FIXME
+                            (ISubdevice*)this,
                             ObjectAttributes,
                             CreateOptions,
                             Disposition);

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavecyclic.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavecyclic.cpp?rev=47222&r1=47221&r2=47222&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavecyclic.cpp [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavecyclic.cpp [iso-8859-1] Sat May 15 19:17:05 2010
@@ -340,7 +340,7 @@
         DPRINT("IPortWaveCyclic_fnNewRegistryKey called w/o initialized\n");
         return STATUS_UNSUCCESSFUL;
     }
-    return PcNewRegistryKey(OutRegistryKey, OuterUnknown, RegistryKeyType, DesiredAccess, m_pDeviceObject, NULL /*FIXME*/, ObjectAttributes, CreateOptions, Disposition);
+    return PcNewRegistryKey(OutRegistryKey, OuterUnknown, RegistryKeyType, DesiredAccess, m_pDeviceObject, (ISubdevice*)this, ObjectAttributes, CreateOptions, Disposition);
 }
 
 

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavepci.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavepci.cpp?rev=47222&r1=47221&r2=47222&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavepci.cpp [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavepci.cpp [iso-8859-1] Sat May 15 19:17:05 2010
@@ -359,7 +359,7 @@
                             RegistryKeyType,
                             DesiredAccess,
                             m_pDeviceObject,
-                            NULL,//FIXME
+                            (ISubdevice*)this,
                             ObjectAttributes,
                             CreateOptions,
                             Disposition);

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavert.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavert.cpp?rev=47222&r1=47221&r2=47222&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavert.cpp [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/port_wavert.cpp [iso-8859-1] Sat May 15 19:17:05 2010
@@ -329,7 +329,7 @@
         DPRINT("IPortWaveRT_fnNewRegistryKey called w/o initialized\n");
         return STATUS_UNSUCCESSFUL;
     }
-    return PcNewRegistryKey(OutRegistryKey, OuterUnknown, RegistryKeyType, DesiredAccess, m_pDeviceObject, NULL /*FIXME*/, ObjectAttributes, CreateOptions, Disposition);
+    return PcNewRegistryKey(OutRegistryKey, OuterUnknown, RegistryKeyType, DesiredAccess, m_pDeviceObject, (ISubdevice*)this, ObjectAttributes, CreateOptions, Disposition);
 }
 //---------------------------------------------------------------
 // ISubdevice interface

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/private.hpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/private.hpp?rev=47222&r1=47221&r2=47222&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/private.hpp [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/private.hpp [iso-8859-1] Sat May 15 19:17:05 2010
@@ -14,7 +14,7 @@
 
 #include <ntddk.h>
 #include <portcls.h>
-#define NDEBUG
+#define YDEBUG
 #include <debug.h>
 
 #include <dmusicks.h>

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/registry.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/registry.cpp?rev=47222&r1=47221&r2=47222&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/registry.cpp [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/registry.cpp [iso-8859-1] Sat May 15 19:17:05 2010
@@ -270,6 +270,9 @@
     NTSTATUS Status = STATUS_UNSUCCESSFUL;
     CRegistryKey * RegistryKey;
     PPCLASS_DEVICE_EXTENSION DeviceExt;
+    PSUBDEVICE_DESCRIPTOR SubDeviceDescriptor;
+    ISubdevice * Device;
+    PSYMBOLICLINK_ENTRY SymEntry;
 
     DPRINT("PcNewRegistryKey entered\n");
 
@@ -294,8 +297,8 @@
             // object attributes is mandatory
             return STATUS_INVALID_PARAMETER;
         }
-        // try to open the key
-        Status = ZwOpenKey(&hHandle, DesiredAccess, ObjectAttributes);
+        // try to create the key
+        Status = ZwCreateKey(&hHandle, DesiredAccess, ObjectAttributes, 0, NULL, CreateOptions, Disposition);
     }
     else if (RegistryKeyType == DeviceRegistryKey ||
              RegistryKeyType == DriverRegistryKey ||
@@ -305,7 +308,7 @@
         if (RegistryKeyType == HwProfileRegistryKey)
         {
              // IoOpenDeviceRegistryKey used different constant
-            RegistryKeyType = PLUGPLAY_REGKEY_CURRENT_HWPROFILE;
+            RegistryKeyType = PLUGPLAY_REGKEY_CURRENT_HWPROFILE | PLUGPLAY_REGKEY_DEVICE;
         }
 
         // obtain the new device extension
@@ -315,24 +318,71 @@
     }
     else if (RegistryKeyType == DeviceInterfaceRegistryKey)
     {
-        // FIXME
-        UNIMPLEMENTED
-        DbgBreakPoint();
-    }
-
+        if (SubDevice == NULL)
+        {
+            // invalid parameter
+            return STATUS_INVALID_PARAMETER;
+        }
+
+        // look up our undocumented interface
+        Status = ((PUNKNOWN)SubDevice)->QueryInterface(IID_ISubdevice, (LPVOID*)&Device);
+
+        if (!NT_SUCCESS(Status))
+        {
+            DPRINT("No ISubdevice interface\n");
+            // invalid parameter
+            return STATUS_INVALID_PARAMETER;
+        }
+
+        // get the subdevice descriptor
+        Status = Device->GetDescriptor(&SubDeviceDescriptor);
+        if (!NT_SUCCESS(Status))
+        {
+            DPRINT("Failed to get subdevice descriptor %x\n", Status);
+            ((PUNKNOWN)SubDevice)->Release();
+            return STATUS_UNSUCCESSFUL;
+        }
+
+        // is there an registered device interface
+        if (IsListEmpty(&SubDeviceDescriptor->SymbolicLinkList))
+        {
+            DPRINT("No device interface registered\n");
+            ((PUNKNOWN)SubDevice)->Release();
+            return STATUS_UNSUCCESSFUL;
+        }
+
+        // get the first symbolic link
+        SymEntry = (PSYMBOLICLINK_ENTRY)CONTAINING_RECORD(SubDeviceDescriptor->SymbolicLinkList.Flink, SYMBOLICLINK_ENTRY, Entry);
+
+        // open device interface
+        Status = IoOpenDeviceInterfaceRegistryKey(&SymEntry->SymbolicLink, DesiredAccess, &hHandle);
+
+        // release subdevice interface
+        ((PUNKNOWN)SubDevice)->Release();
+    }
+
+    // check for success
     if (!NT_SUCCESS(Status))
     {
+        DPRINT1("PcNewRegistryKey failed with %lx\n", Status);
         return Status;
     }
 
+    // allocate new registry key object
     RegistryKey = new(NonPagedPool, TAG_PORTCLASS)CRegistryKey(OuterUnknown, hHandle);
     if (!RegistryKey)
+    {
+        // not enough memory
+        ZwClose(hHandle);
         return STATUS_INSUFFICIENT_RESOURCES;
-
+    }
+
+    // query for interface
     Status = RegistryKey->QueryInterface(IID_IRegistryKey, (PVOID*)OutRegistryKey);
 
     if (!NT_SUCCESS(Status))
     {
+        // out of memory
         delete RegistryKey;
     }
 




More information about the Ros-diffs mailing list