ReactOS 0.4.16-dev-336-gb667d82
connection.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/connection.c
5 * PURPOSE: portcls physical connection registration
6 * PROGRAMMER: Johannes Anderwald
7 */
8
9#include "private.hpp"
10
11#define NDEBUG
12#include <debug.h>
13
14extern
15"C"
22);
23
24class CUnregisterPhysicalConnection : public CUnknownImpl<IUnregisterPhysicalConnection>
25{
26public:
28
30
32
34};
35
39 IN REFIID refiid,
41{
43
44 if (IsEqualGUIDAligned(refiid, IID_IUnregisterPhysicalConnection) ||
46 {
47 *Output = PVOID(PUNKNOWN(this));
48
49 PUNKNOWN(*Output)->AddRef();
50 return STATUS_SUCCESS;
51 }
52
54 {
55 DPRINT1("CUnregisterPhysicalConnection::QueryInterface no interface!!! iface %S\n", GuidString.Buffer);
57 }
58
60}
61
62static
66 IN PUNKNOWN FromUnknown,
67 IN PUNICODE_STRING FromString,
68 IN ULONG FromPin,
69 IN PUNKNOWN ToUnknown,
71 IN ULONG ToPin)
72{
75}
76
79CUnregisterPhysicalConnection::UnregisterPhysicalConnection(
81 IN PUNKNOWN FromUnknown,
82 IN ULONG FromPin,
83 IN PUNKNOWN ToUnknown,
84 IN ULONG ToPin)
85{
86 if (!DeviceObject || !FromUnknown || !ToUnknown)
88
89 return UnRegisterConnection(DeviceObject, FromUnknown, NULL, FromPin, ToUnknown, NULL, ToPin);
90}
91
94CUnregisterPhysicalConnection::UnregisterPhysicalConnectionToExternal(
96 IN PUNKNOWN FromUnknown,
97 IN ULONG FromPin,
99 IN ULONG ToPin)
100{
101 if (!DeviceObject || !FromUnknown || !ToString)
103
104 return UnRegisterConnection(DeviceObject, FromUnknown, NULL, FromPin, NULL, ToString, ToPin);
105}
106
108NTAPI
109CUnregisterPhysicalConnection::UnregisterPhysicalConnectionFromExternal(
111 IN PUNICODE_STRING FromString,
112 IN ULONG FromPin,
113 IN PUNKNOWN ToUnknown,
114 IN ULONG ToPin)
115{
116 if (!DeviceObject || !FromString || !ToUnknown)
118
119 return UnRegisterConnection(DeviceObject, NULL, FromString, FromPin, ToUnknown, NULL, ToPin);
120}
121
123NTAPI
125 OUT PUNREGISTERPHYSICALCONNECTION *OutConnection)
126{
127
129
130 if (!new_ptr)
132
133 new_ptr->AddRef();
134 *OutConnection = (PUNREGISTERPHYSICALCONNECTION)new_ptr;
135 return STATUS_SUCCESS;
136}
137
141 IN PUNKNOWN FromUnknown,
142 IN PUNICODE_STRING FromString,
143 IN ULONG FromPin,
144 IN PUNKNOWN ToUnknown,
146 IN ULONG ToPin)
147{
148 PSUBDEVICE_DESCRIPTOR FromSubDeviceDescriptor = NULL, ToSubDeviceDescriptor = NULL;
149 PSYMBOLICLINK_ENTRY SymEntry;
150 ISubdevice * FromSubDevice = NULL, *ToSubDevice = NULL;
152 PPHYSICAL_CONNECTION_ENTRY FromEntry = NULL, ToEntry = NULL;
153
154 if (FromUnknown)
155 {
156 Status = FromUnknown->QueryInterface(IID_ISubdevice, (PVOID*)&FromSubDevice);
157 if (!NT_SUCCESS(Status))
158 goto cleanup;
159
160 Status = FromSubDevice->GetDescriptor(&FromSubDeviceDescriptor);
161 if (!NT_SUCCESS(Status))
162 goto cleanup;
163
164 if (IsListEmpty(&FromSubDeviceDescriptor->SymbolicLinkList))
165 {
167 goto cleanup;
168 }
169
171 FromString = &SymEntry->SymbolicLink;
172 }
173
174 if (ToUnknown)
175 {
176 Status = ToUnknown->QueryInterface(IID_ISubdevice, (PVOID*)&ToSubDevice);
177 if (!NT_SUCCESS(Status))
178 goto cleanup;
179
180 Status = ToSubDevice->GetDescriptor(&ToSubDeviceDescriptor);
181 if (!NT_SUCCESS(Status))
182 goto cleanup;
183
184 if (IsListEmpty(&ToSubDeviceDescriptor->SymbolicLinkList))
185 {
187 goto cleanup;
188 }
189
190 SymEntry = (PSYMBOLICLINK_ENTRY)CONTAINING_RECORD(ToSubDeviceDescriptor->SymbolicLinkList.Flink, SYMBOLICLINK_ENTRY, Entry);
191 ToString = &SymEntry->SymbolicLink;
192
193 }
194
195 if (FromSubDeviceDescriptor)
196 {
198 if (!FromEntry)
199 {
201 goto cleanup;
202 }
203 }
204
205 if (ToSubDeviceDescriptor)
206 {
207 ToEntry = (PPHYSICAL_CONNECTION_ENTRY)AllocateItem(NonPagedPool, sizeof(PHYSICAL_CONNECTION_ENTRY) + FromString->MaximumLength + sizeof(WCHAR), TAG_PORTCLASS);
208 if (!ToEntry)
209 {
211 goto cleanup;
212 }
213 }
214
215 if (FromSubDeviceDescriptor)
216 {
217 FromEntry->FromPin = FromPin;
218 FromEntry->Connection.Pin = ToPin;
219 FromEntry->Connection.Size = sizeof(KSPIN_PHYSICALCONNECTION) + ToString->MaximumLength + sizeof(WCHAR);
220 RtlMoveMemory(&FromEntry->Connection.SymbolicLinkName, ToString->Buffer, ToString->MaximumLength);
221 FromEntry->Connection.SymbolicLinkName[ToString->Length / sizeof(WCHAR)] = UNICODE_NULL;
222
223 InsertTailList(&FromSubDeviceDescriptor->PhysicalConnectionList, &FromEntry->Entry);
224 }
225
226 if (ToSubDeviceDescriptor)
227 {
228 ToEntry->FromPin = ToPin;
229 ToEntry->Connection.Pin = FromPin;
230 ToEntry->Connection.Size = sizeof(KSPIN_PHYSICALCONNECTION) + FromString->MaximumLength + sizeof(WCHAR);
231 RtlMoveMemory(&ToEntry->Connection.SymbolicLinkName, FromString->Buffer, FromString->MaximumLength);
232 ToEntry->Connection.SymbolicLinkName[FromString->Length / sizeof(WCHAR)] = UNICODE_NULL;
233
234 InsertTailList(&ToSubDeviceDescriptor->PhysicalConnectionList, &ToEntry->Entry);
235
236 }
237
238 return STATUS_SUCCESS;
239
240cleanup:
241
242 if (FromSubDevice)
243 FromSubDevice->Release();
244
245 if (ToSubDevice)
246 ToSubDevice->Release();
247
248 if (FromEntry)
249 FreeItem(FromEntry, TAG_PORTCLASS);
250
251 if (ToEntry)
252 FreeItem(ToEntry, TAG_PORTCLASS);
253
254 return Status;
255}
256
258NTAPI
261 IN PUNKNOWN FromUnknown,
262 IN ULONG FromPin,
263 IN PUNKNOWN ToUnknown,
264 IN ULONG ToPin)
265{
266 DPRINT("PcRegisterPhysicalConnection\n");
268
269 if (!DeviceObject || !FromUnknown || !ToUnknown)
271
272 return RegisterConnection(DeviceObject, FromUnknown, NULL, FromPin, ToUnknown, NULL, ToPin);
273}
274
276NTAPI
279 IN PUNICODE_STRING FromString,
280 IN ULONG FromPin,
281 IN PUNKNOWN ToUnknown,
282 IN ULONG ToPin)
283{
285
286 if (!DeviceObject || !FromString || !ToUnknown)
288
289 return RegisterConnection(DeviceObject, NULL, FromString, FromPin, ToUnknown, NULL, ToPin);
290}
291
293NTAPI
296 IN PUNKNOWN FromUnknown,
297 IN ULONG FromPin,
299 IN ULONG ToPin)
300{
302
303 if (!DeviceObject || !FromUnknown || !ToString)
305
306 return RegisterConnection(DeviceObject, FromUnknown, NULL, FromPin, NULL, ToString, ToPin);
307}
unsigned char BOOLEAN
struct PHYSICAL_CONNECTION_ENTRY * PPHYSICAL_CONNECTION_ENTRY
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
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
#define NTSYSAPI
Definition: ntoskrnl.h:12
CUnregisterPhysicalConnection(IUnknown *OuterUnknown)
Definition: connection.cpp:31
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
Definition: connection.cpp:38
virtual ~CUnregisterPhysicalConnection()
Definition: connection.cpp:33
IUnknown * PUNKNOWN
Definition: com_apitest.h:45
NTSTATUS NTAPI PcRegisterPhysicalConnection(IN PDEVICE_OBJECT DeviceObject, IN PUNKNOWN FromUnknown, IN ULONG FromPin, IN PUNKNOWN ToUnknown, IN ULONG ToPin)
Definition: connection.cpp:259
NTSTATUS NTAPI PcRegisterPhysicalConnectionFromExternal(IN PDEVICE_OBJECT DeviceObject, IN PUNICODE_STRING FromString, IN ULONG FromPin, IN PUNKNOWN ToUnknown, IN ULONG ToPin)
Definition: connection.cpp:277
NTSTATUS NTAPI PcRegisterPhysicalConnectionToExternal(IN PDEVICE_OBJECT DeviceObject, IN PUNKNOWN FromUnknown, IN ULONG FromPin, IN PUNICODE_STRING ToString, IN ULONG ToPin)
Definition: connection.cpp:294
NTSTATUS NTAPI NewIUnregisterPhysicalConnection(OUT PUNREGISTERPHYSICALCONNECTION *OutConnection)
Definition: connection.cpp:124
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
static NTSTATUS UnRegisterConnection(IN OUT PDEVICE_OBJECT DeviceObject, IN PUNKNOWN FromUnknown, IN PUNICODE_STRING FromString, IN ULONG FromPin, IN PUNKNOWN ToUnknown, IN PUNICODE_STRING ToString, IN ULONG ToPin)
Definition: connection.cpp:64
NTSTATUS RegisterConnection(IN OUT PDEVICE_OBJECT DeviceObject, IN PUNKNOWN FromUnknown, IN PUNICODE_STRING FromString, IN ULONG FromPin, IN PUNKNOWN ToUnknown, IN PUNICODE_STRING ToString, IN ULONG ToPin)
Definition: connection.cpp:139
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
static void cleanup(void)
Definition: main.c:1335
#define InsertTailList(ListHead, Entry)
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define NonPagedPool
Definition: env_spec_w32.h:307
Status
Definition: gdiplustypes.h:25
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
ULONG AddRef()
nsrefcnt Release()
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:29
VOID FreeItem(IN PVOID Item)
Definition: misc.c:37
static PWSTR GuidString
Definition: apphelp.c:93
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1922
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1921
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define UNICODE_NULL
IUnregisterPhysicalConnection * PUNREGISTERPHYSICALCONNECTION
Definition: portcls.h:677
#define PC_ASSERT_IRQL_EQUAL(x)
Definition: private.hpp:31
#define TAG_PORTCLASS
Definition: private.hpp:24
#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
WCHAR SymbolicLinkName[1]
Definition: ks.h:658
Definition: interfaces.hpp:180
KSPIN_PHYSICALCONNECTION Connection
Definition: interfaces.hpp:183
LIST_ENTRY Entry
Definition: interfaces.hpp:181
ULONG FromPin
Definition: interfaces.hpp:182
LIST_ENTRY PhysicalConnectionList
Definition: interfaces.hpp:220
LIST_ENTRY SymbolicLinkList
Definition: interfaces.hpp:219
Definition: interfaces.hpp:174
UNICODE_STRING SymbolicLink
Definition: interfaces.hpp:176
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define NTAPI
Definition: typedefs.h:36
void * PVOID
Definition: typedefs.h:50
#define IN
Definition: typedefs.h:39
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#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
_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
std::string ToString(XMLHandle node)
Definition: xml2sdb.cpp:59
__wchar_t WCHAR
Definition: xmlstorage.h:180