ReactOS  0.4.14-dev-77-gd9e7c48
unregister.cpp
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Kernel Streaming
4  * FILE: drivers/wdm/audio/backpln/portcls/unregister.cpp
5  * PURPOSE: Unregisters a subdevice
6  * PROGRAMMER: Johannes Anderwald
7  */
8 
9 #include "private.hpp"
10 
11 #ifndef YDEBUG
12 #define NDEBUG
13 #endif
14 
15 #include <debug.h>
16 
17 class CUnregisterSubdevice : public IUnregisterSubdevice
18 {
19 public:
21 
23  {
25  return m_Ref;
26  }
28  {
30 
31  if (!m_Ref)
32  {
33  delete this;
34  return 0;
35  }
36  return m_Ref;
37  }
38 
39 
41 
42  CUnregisterSubdevice(IUnknown * OuterUnknown) : m_Ref(0) {}
44 
45 protected:
47 
48 };
49 
51 NTAPI
53  IN REFIID refiid,
54  OUT PVOID* Output)
55 {
57 
58  if (IsEqualGUIDAligned(refiid, IID_IUnregisterSubdevice) ||
60  {
62  PUNKNOWN(*Output)->AddRef();
63  return STATUS_SUCCESS;
64  }
65 
67  {
68  DPRINT1("IPortWaveCyclic_fnQueryInterface no interface!!! iface %S\n", GuidString.Buffer);
70  }
71 
72  return STATUS_UNSUCCESSFUL;
73 }
74 
76 NTAPI
77 CUnregisterSubdevice::UnregisterSubdevice(
80 {
81  PPCLASS_DEVICE_EXTENSION DeviceExtension;
83  PSYMBOLICLINK_ENTRY SymLinkEntry;
84  PSUBDEVICE_DESCRIPTOR SubDeviceDescriptor;
85  ISubdevice *SubDevice;
86  ULONG Index;
88 
90 
92  PC_ASSERT(DeviceExtension);
93 
94  // look up our undocumented interface
95  Status = Unknown->QueryInterface(IID_ISubdevice, (LPVOID*)&SubDevice);
96  if (!NT_SUCCESS(Status))
97  {
98  DPRINT("No ISubdevice interface\n");
99  // the provided port driver doesnt support ISubdevice
101  }
102 
103  Status = SubDevice->GetDescriptor(&SubDeviceDescriptor);
104  if (!NT_SUCCESS(Status))
105  {
106  DPRINT("Failed to retrieve subdevice descriptor %x\n", Status);
107  // the provided port driver doesnt support ISubdevice
109  }
110 
111  // loop our create items and disable the create handler
112  for(Index = 0; Index < DeviceExtension->MaxSubDevices; Index++)
113  {
114  if (!RtlCompareUnicodeString(&SubDeviceDescriptor->RefString, &DeviceExtension->CreateItems[Index].ObjectClass, TRUE))
115  {
116  DeviceExtension->CreateItems[Index].Create = NULL;
117  RtlInitUnicodeString(&DeviceExtension->CreateItems[Index].ObjectClass, NULL);
118  break;
119  }
120  }
121 
122  // now unregister device interfaces
123  while(!IsListEmpty(&SubDeviceDescriptor->SymbolicLinkList))
124  {
125  // remove entry
126  Entry = RemoveHeadList(&SubDeviceDescriptor->SymbolicLinkList);
127  // get symlink entry
129 
130  // unregister device interface
132  // free symbolic link
133  RtlFreeUnicodeString(&SymLinkEntry->SymbolicLink);
134  // free sym entry
135  FreeItem(SymLinkEntry, TAG_PORTCLASS);
136  }
137 
138  return STATUS_SUCCESS;
139 }
140 
141 NTSTATUS
142 NTAPI
144  OUT PUNREGISTERSUBDEVICE *OutDevice)
145 {
148  if (!This)
150 
151  Status = This->QueryInterface(IID_IUnregisterSubdevice, (PVOID*)OutDevice);
152  if (!NT_SUCCESS(Status))
153  {
154  delete This;
155  return Status;
156  }
157 
158  *OutDevice = (PUNREGISTERSUBDEVICE)This;
159  return Status;
160 }
static PWSTR GuidString
Definition: apphelp.c:91
#define IN
Definition: typedefs.h:38
#define REFIID
Definition: guiddef.h:118
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define PC_ASSERT(exp)
Definition: usbehci.h:17
struct _Entry Entry
Definition: kefuncs.h:640
_In_ BOOLEAN Release
Definition: classpnp.h:929
NTSTATUS NTAPI NewIUnregisterSubdevice(OUT PUNREGISTERSUBDEVICE *OutDevice)
Definition: unregister.cpp:143
struct PCLASS_DEVICE_EXTENSION * PPCLASS_DEVICE_EXTENSION
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
IUnknown * PUNKNOWN
Definition: com_apitest.h:45
#define TAG_PORTCLASS
Definition: private.hpp:24
LONG NTSTATUS
Definition: precomp.h:26
IUnregisterSubdevice * PUNREGISTERSUBDEVICE
Definition: portcls.h:633
struct SYMBOLICLINK_ENTRY * PSYMBOLICLINK_ENTRY
Definition: interfaces.hpp:173
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
Definition: unregister.cpp:52
virtual ~CUnregisterSubdevice()
Definition: unregister.cpp:43
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
long LONG
Definition: pedump.c:60
#define STDMETHODIMP
Definition: basetyps.h:43
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
Definition: deviface.c:1311
void * PVOID
Definition: retypes.h:9
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
const GUID IID_IUnknown
static const UCHAR Index[8]
Definition: usbohci.c:18
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define PC_ASSERT_IRQL_EQUAL(x)
Definition: private.hpp:31
ULONG AddRef()
CUnregisterSubdevice(IUnknown *OuterUnknown)
Definition: unregister.cpp:42
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
#define InterlockedDecrement
Definition: armddk.h:52
Definition: arc.h:85
Definition: typedefs.h:117
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
Status
Definition: gdiplustypes.h:24
KSOBJECT_CREATE_ITEM * CreateItems
Definition: private.hpp:408
UNICODE_STRING RefString
Definition: interfaces.hpp:221
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
STDMETHODIMP_(ULONG) Release()
Definition: unregister.cpp:27
#define InterlockedIncrement
Definition: armddk.h:53
static ULONG WINAPI AddRef(IStream *iface)
Definition: clist.c:90
#define DPRINT1
Definition: precomp.h:8
UNICODE_STRING SymbolicLink
Definition: interfaces.hpp:176
#define OUT
Definition: typedefs.h:39
unsigned int ULONG
Definition: retypes.h:1
STDMETHODIMP_(ULONG) AddRef()
Definition: unregister.cpp:22
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
return STATUS_SUCCESS
Definition: btrfs.c:2966
base of all file and directory entries
Definition: entries.h:82
LIST_ENTRY SymbolicLinkList
Definition: interfaces.hpp:219