ReactOS  0.4.15-dev-4916-gd519b11
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 CUnknownImpl<IUnregisterSubdevice>
18 {
19 public:
21 
23 
24  CUnregisterSubdevice(IUnknown * OuterUnknown) {}
26 
27 };
28 
30 NTAPI
32  IN REFIID refiid,
33  OUT PVOID* Output)
34 {
36 
37  if (IsEqualGUIDAligned(refiid, IID_IUnregisterSubdevice) ||
39  {
41  PUNKNOWN(*Output)->AddRef();
42  return STATUS_SUCCESS;
43  }
44 
46  {
47  DPRINT1("IPortWaveCyclic_fnQueryInterface no interface!!! iface %S\n", GuidString.Buffer);
49  }
50 
51  return STATUS_UNSUCCESSFUL;
52 }
53 
55 NTAPI
56 CUnregisterSubdevice::UnregisterSubdevice(
59 {
60  PPCLASS_DEVICE_EXTENSION DeviceExtension;
62  PSYMBOLICLINK_ENTRY SymLinkEntry;
63  PSUBDEVICE_DESCRIPTOR SubDeviceDescriptor;
64  ISubdevice *SubDevice;
65  ULONG Index;
67 
69 
70  DeviceExtension = (PPCLASS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
71  PC_ASSERT(DeviceExtension);
72 
73  // look up our undocumented interface
74  Status = Unknown->QueryInterface(IID_ISubdevice, (LPVOID*)&SubDevice);
75  if (!NT_SUCCESS(Status))
76  {
77  DPRINT("No ISubdevice interface\n");
78  // the provided port driver doesnt support ISubdevice
80  }
81 
82  Status = SubDevice->GetDescriptor(&SubDeviceDescriptor);
83  if (!NT_SUCCESS(Status))
84  {
85  DPRINT("Failed to retrieve subdevice descriptor %x\n", Status);
86  // the provided port driver doesnt support ISubdevice
88  }
89 
90  // loop our create items and disable the create handler
91  for(Index = 0; Index < DeviceExtension->MaxSubDevices; Index++)
92  {
93  if (!RtlCompareUnicodeString(&SubDeviceDescriptor->RefString, &DeviceExtension->CreateItems[Index].ObjectClass, TRUE))
94  {
95  DeviceExtension->CreateItems[Index].Create = NULL;
96  RtlInitUnicodeString(&DeviceExtension->CreateItems[Index].ObjectClass, NULL);
97  break;
98  }
99  }
100 
101  // now unregister device interfaces
102  while(!IsListEmpty(&SubDeviceDescriptor->SymbolicLinkList))
103  {
104  // remove entry
105  Entry = RemoveHeadList(&SubDeviceDescriptor->SymbolicLinkList);
106  // get symlink entry
108 
109  // unregister device interface
111  // free symbolic link
112  RtlFreeUnicodeString(&SymLinkEntry->SymbolicLink);
113  // free sym entry
114  FreeItem(SymLinkEntry, TAG_PORTCLASS);
115  }
116 
117  return STATUS_SUCCESS;
118 }
119 
120 NTSTATUS
121 NTAPI
123  OUT PUNREGISTERSUBDEVICE *OutDevice)
124 {
127  if (!This)
129 
130  Status = This->QueryInterface(IID_IUnregisterSubdevice, (PVOID*)OutDevice);
131  if (!NT_SUCCESS(Status))
132  {
133  delete This;
134  return Status;
135  }
136 
137  *OutDevice = (PUNREGISTERSUBDEVICE)This;
138  return Status;
139 }
static PWSTR GuidString
Definition: apphelp.c:93
#define IN
Definition: typedefs.h:39
#define REFIID
Definition: guiddef.h:118
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct _Entry Entry
Definition: kefuncs.h:629
NTSTATUS NTAPI NewIUnregisterSubdevice(OUT PUNREGISTERSUBDEVICE *OutDevice)
Definition: unregister.cpp:122
struct PCLASS_DEVICE_EXTENSION * PPCLASS_DEVICE_EXTENSION
#define TRUE
Definition: types.h:120
#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:31
virtual ~CUnregisterSubdevice()
Definition: unregister.cpp:25
#define PC_ASSERT(exp)
Definition: private.hpp:26
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
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
#define FALSE
Definition: types.h:117
#define STDMETHODIMP
Definition: basetyps.h:43
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
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
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ WDFCOLLECTION _In_ ULONG Index
const GUID IID_IUnknown
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:24
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
Definition: arc.h:85
Definition: typedefs.h:119
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
KSOBJECT_CREATE_ITEM * CreateItems
Definition: private.hpp:408
UNICODE_STRING RefString
Definition: interfaces.hpp:221
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:361
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
UNICODE_STRING SymbolicLink
Definition: interfaces.hpp:176
#define OUT
Definition: typedefs.h:40
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
base of all file and directory entries
Definition: entries.h:82
LIST_ENTRY SymbolicLinkList
Definition: interfaces.hpp:219