ReactOS 0.4.15-dev-8100-g1887773
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#define NDEBUG
12#include <debug.h>
13
14class CUnregisterSubdevice : public CUnknownImpl<IUnregisterSubdevice>
15{
16public:
18
20
21 CUnregisterSubdevice(IUnknown * OuterUnknown) {}
23
24};
25
29 IN REFIID refiid,
31{
33
34 if (IsEqualGUIDAligned(refiid, IID_IUnregisterSubdevice) ||
36 {
38 PUNKNOWN(*Output)->AddRef();
39 return STATUS_SUCCESS;
40 }
41
43 {
44 DPRINT1("IPortWaveCyclic_fnQueryInterface no interface!!! iface %S\n", GuidString.Buffer);
46 }
47
49}
50
53CUnregisterSubdevice::UnregisterSubdevice(
56{
57 PPCLASS_DEVICE_EXTENSION DeviceExtension;
59 PSYMBOLICLINK_ENTRY SymLinkEntry;
60 PSUBDEVICE_DESCRIPTOR SubDeviceDescriptor;
61 ISubdevice *SubDevice;
64
66
67 DeviceExtension = (PPCLASS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
68 PC_ASSERT(DeviceExtension);
69
70 // look up our undocumented interface
71 Status = Unknown->QueryInterface(IID_ISubdevice, (LPVOID*)&SubDevice);
72 if (!NT_SUCCESS(Status))
73 {
74 DPRINT("No ISubdevice interface\n");
75 // the provided port driver doesnt support ISubdevice
77 }
78
79 Status = SubDevice->GetDescriptor(&SubDeviceDescriptor);
80 if (!NT_SUCCESS(Status))
81 {
82 DPRINT("Failed to retrieve subdevice descriptor %x\n", Status);
83 // the provided port driver doesnt support ISubdevice
85 }
86
87 // loop our create items and disable the create handler
88 for(Index = 0; Index < DeviceExtension->MaxSubDevices; Index++)
89 {
90 if (!RtlCompareUnicodeString(&SubDeviceDescriptor->RefString, &DeviceExtension->CreateItems[Index].ObjectClass, TRUE))
91 {
92 DeviceExtension->CreateItems[Index].Create = NULL;
93 RtlInitUnicodeString(&DeviceExtension->CreateItems[Index].ObjectClass, NULL);
94 break;
95 }
96 }
97
98 // now unregister device interfaces
99 while(!IsListEmpty(&SubDeviceDescriptor->SymbolicLinkList))
100 {
101 // remove entry
102 Entry = RemoveHeadList(&SubDeviceDescriptor->SymbolicLinkList);
103 // get symlink entry
105
106 // unregister device interface
108 // free symbolic link
109 RtlFreeUnicodeString(&SymLinkEntry->SymbolicLink);
110 // free sym entry
111 FreeItem(SymLinkEntry, TAG_PORTCLASS);
112 }
113
114 return STATUS_SUCCESS;
115}
116
118NTAPI
120 OUT PUNREGISTERSUBDEVICE *OutDevice)
121{
124 if (!This)
126
127 Status = This->QueryInterface(IID_IUnregisterSubdevice, (PVOID*)OutDevice);
128 if (!NT_SUCCESS(Status))
129 {
130 delete This;
131 return Status;
132 }
133
134 *OutDevice = (PUNREGISTERSUBDEVICE)This;
135 return Status;
136}
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:22
CUnregisterSubdevice(IUnknown *OuterUnknown)
Definition: unregister.cpp:21
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
Definition: unregister.cpp:28
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:37
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:73
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:119
_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