ReactOS 0.4.15-dev-6069-g56a4501
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
17class CUnregisterSubdevice : public CUnknownImpl<IUnregisterSubdevice>
18{
19public:
21
23
24 CUnregisterSubdevice(IUnknown * OuterUnknown) {}
26
27};
28
32 IN REFIID refiid,
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
52}
53
56CUnregisterSubdevice::UnregisterSubdevice(
59{
60 PPCLASS_DEVICE_EXTENSION DeviceExtension;
62 PSYMBOLICLINK_ENTRY SymLinkEntry;
63 PSUBDEVICE_DESCRIPTOR SubDeviceDescriptor;
64 ISubdevice *SubDevice;
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
121NTAPI
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}
struct SYMBOLICLINK_ENTRY * PSYMBOLICLINK_ENTRY
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define STDMETHODIMP
Definition: basetyps.h:43
const GUID IID_IUnknown
virtual ~CUnregisterSubdevice()
Definition: unregister.cpp:25
CUnregisterSubdevice(IUnknown *OuterUnknown)
Definition: unregister.cpp:24
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
Definition: unregister.cpp:31
IUnknown * PUNKNOWN
Definition: com_apitest.h:45
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
#define NonPagedPool
Definition: env_spec_w32.h:307
Status
Definition: gdiplustypes.h:25
@ Unknown
Definition: i8042prt.h:114
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
ULONG AddRef()
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
static PWSTR GuidString
Definition: apphelp.c:93
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
Definition: deviface.c:1311
IUnregisterSubdevice * PUNREGISTERSUBDEVICE
Definition: portcls.h:635
#define PC_ASSERT_IRQL_EQUAL(x)
Definition: private.hpp:31
struct PCLASS_DEVICE_EXTENSION * PPCLASS_DEVICE_EXTENSION
#define TAG_PORTCLASS
Definition: private.hpp:24
#define PC_ASSERT(exp)
Definition: private.hpp:26
#define REFIID
Definition: guiddef.h:118
@ Output
Definition: arc.h:85
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
base of all file and directory entries
Definition: entries.h:83
KSOBJECT_CREATE_ITEM * CreateItems
Definition: private.hpp:408
UNICODE_STRING RefString
Definition: interfaces.hpp:221
LIST_ENTRY SymbolicLinkList
Definition: interfaces.hpp:219
Definition: interfaces.hpp:174
UNICODE_STRING SymbolicLink
Definition: interfaces.hpp:176
Definition: typedefs.h:120
#define NTAPI
Definition: typedefs.h:36
void * PVOID
Definition: typedefs.h:50
#define IN
Definition: typedefs.h:39
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTSTATUS NTAPI NewIUnregisterSubdevice(OUT PUNREGISTERSUBDEVICE *OutDevice)
Definition: unregister.cpp:122
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235