diff --git a/reactos/drivers/wdm/audio/backpln/portcls/port_dmus.cpp b/reactos/drivers/wdm/audio/backpln/portcls/port_dmus.cpp index 8c08b1f9c3d..3f4fb918259 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/port_dmus.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/port_dmus.cpp @@ -340,7 +340,7 @@ CPortDMus::NewRegistryKey( RegistryKeyType, DesiredAccess, m_pDeviceObject, - NULL,//FIXME + (ISubdevice*)this, ObjectAttributes, CreateOptions, Disposition); diff --git a/reactos/drivers/wdm/audio/backpln/portcls/port_topology.cpp b/reactos/drivers/wdm/audio/backpln/portcls/port_topology.cpp index 2c80a430f22..ab4322aa943 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/port_topology.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/port_topology.cpp @@ -299,7 +299,7 @@ CPortTopology::NewRegistryKey( RegistryKeyType, DesiredAccess, m_pDeviceObject, - NULL,//FIXME + (ISubdevice*)this, ObjectAttributes, CreateOptions, Disposition); diff --git a/reactos/drivers/wdm/audio/backpln/portcls/port_wavecyclic.cpp b/reactos/drivers/wdm/audio/backpln/portcls/port_wavecyclic.cpp index 23bfba91681..6566fe67299 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/port_wavecyclic.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/port_wavecyclic.cpp @@ -340,7 +340,7 @@ CPortWaveCyclic::NewRegistryKey( 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); } diff --git a/reactos/drivers/wdm/audio/backpln/portcls/port_wavepci.cpp b/reactos/drivers/wdm/audio/backpln/portcls/port_wavepci.cpp index 81d6ed9bfbf..986ffcf9d40 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/port_wavepci.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/port_wavepci.cpp @@ -359,7 +359,7 @@ CPortWavePci::NewRegistryKey( RegistryKeyType, DesiredAccess, m_pDeviceObject, - NULL,//FIXME + (ISubdevice*)this, ObjectAttributes, CreateOptions, Disposition); diff --git a/reactos/drivers/wdm/audio/backpln/portcls/port_wavert.cpp b/reactos/drivers/wdm/audio/backpln/portcls/port_wavert.cpp index 8910dc1cb19..305d097276c 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/port_wavert.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/port_wavert.cpp @@ -329,7 +329,7 @@ CPortWaveRT::NewRegistryKey( 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 diff --git a/reactos/drivers/wdm/audio/backpln/portcls/private.hpp b/reactos/drivers/wdm/audio/backpln/portcls/private.hpp index 17adc4c8af5..874d2266d20 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/private.hpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/private.hpp @@ -14,7 +14,7 @@ #include #include -#define NDEBUG +#define YDEBUG #include #include diff --git a/reactos/drivers/wdm/audio/backpln/portcls/registry.cpp b/reactos/drivers/wdm/audio/backpln/portcls/registry.cpp index eadcc89eaf3..86c2d3f8784 100644 --- a/reactos/drivers/wdm/audio/backpln/portcls/registry.cpp +++ b/reactos/drivers/wdm/audio/backpln/portcls/registry.cpp @@ -270,6 +270,9 @@ PcNewRegistryKey( 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 @@ PcNewRegistryKey( // 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 @@ PcNewRegistryKey( 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 @@ PcNewRegistryKey( } 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; }