ReactOS  0.4.15-dev-5499-g1341c38
connection.cpp File Reference
#include "private.hpp"
#include <debug.h>
Include dependency graph for connection.cpp:

Go to the source code of this file.

Classes

class  CUnregisterPhysicalConnection
 

Macros

#define NDEBUG
 

Functions

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)
 
NTSTATUS NTAPI NewIUnregisterPhysicalConnection (OUT PUNREGISTERPHYSICALCONNECTION *OutConnection)
 
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)
 
NTSTATUS NTAPI PcRegisterPhysicalConnection (IN PDEVICE_OBJECT DeviceObject, IN PUNKNOWN FromUnknown, IN ULONG FromPin, IN PUNKNOWN ToUnknown, IN ULONG ToPin)
 
NTSTATUS NTAPI PcRegisterPhysicalConnectionFromExternal (IN PDEVICE_OBJECT DeviceObject, IN PUNICODE_STRING FromString, IN ULONG FromPin, IN PUNKNOWN ToUnknown, IN ULONG ToPin)
 
NTSTATUS NTAPI PcRegisterPhysicalConnectionToExternal (IN PDEVICE_OBJECT DeviceObject, IN PUNKNOWN FromUnknown, IN ULONG FromPin, IN PUNICODE_STRING ToString, IN ULONG ToPin)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file connection.cpp.

Function Documentation

◆ NewIUnregisterPhysicalConnection()

NTSTATUS NTAPI NewIUnregisterPhysicalConnection ( OUT PUNREGISTERPHYSICALCONNECTION OutConnection)

Definition at line 128 of file connection.cpp.

130 {
131 
133 
134  if (!new_ptr)
136 
137  new_ptr->AddRef();
138  *OutConnection = (PUNREGISTERPHYSICALCONNECTION)new_ptr;
139  return STATUS_SUCCESS;
140 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TAG_PORTCLASS
Definition: private.hpp:24
IUnregisterPhysicalConnection * PUNREGISTERPHYSICALCONNECTION
Definition: portcls.h:675
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by CPortDMus::QueryInterface(), CPortWaveRT::QueryInterface(), CPortWavePci::QueryInterface(), CPortTopology::QueryInterface(), and CPortWaveCyclic::QueryInterface().

◆ PcRegisterPhysicalConnection()

NTSTATUS NTAPI PcRegisterPhysicalConnection ( IN PDEVICE_OBJECT  DeviceObject,
IN PUNKNOWN  FromUnknown,
IN ULONG  FromPin,
IN PUNKNOWN  ToUnknown,
IN ULONG  ToPin 
)

Definition at line 266 of file connection.cpp.

272 {
273  DPRINT("PcRegisterPhysicalConnection\n");
275 
276  if (!DeviceObject || !FromUnknown || !ToUnknown)
278 
279  return RegisterConnection(DeviceObject, FromUnknown, NULL, FromPin, ToUnknown, NULL, ToPin);
280 }
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:143
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define PC_ASSERT_IRQL_EQUAL(x)
Definition: private.hpp:31
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define NULL
Definition: types.h:112
#define DPRINT
Definition: sndvol32.h:71

Referenced by StartDevice().

◆ PcRegisterPhysicalConnectionFromExternal()

NTSTATUS NTAPI PcRegisterPhysicalConnectionFromExternal ( IN PDEVICE_OBJECT  DeviceObject,
IN PUNICODE_STRING  FromString,
IN ULONG  FromPin,
IN PUNKNOWN  ToUnknown,
IN ULONG  ToPin 
)

Definition at line 284 of file connection.cpp.

290 {
292 
293  if (!DeviceObject || !FromString || !ToUnknown)
295 
296  return RegisterConnection(DeviceObject, NULL, FromString, FromPin, ToUnknown, NULL, ToPin);
297 }
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:143
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define PC_ASSERT_IRQL_EQUAL(x)
Definition: private.hpp:31
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define NULL
Definition: types.h:112

◆ PcRegisterPhysicalConnectionToExternal()

NTSTATUS NTAPI PcRegisterPhysicalConnectionToExternal ( IN PDEVICE_OBJECT  DeviceObject,
IN PUNKNOWN  FromUnknown,
IN ULONG  FromPin,
IN PUNICODE_STRING  ToString,
IN ULONG  ToPin 
)

Definition at line 301 of file connection.cpp.

307 {
309 
310  if (!DeviceObject || !FromUnknown || !ToString)
312 
313  return RegisterConnection(DeviceObject, FromUnknown, NULL, FromPin, NULL, ToString, ToPin);
314 }
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:143
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define PC_ASSERT_IRQL_EQUAL(x)
Definition: private.hpp:31
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define NULL
Definition: types.h:112
std::string ToString(XMLHandle node)
Definition: xml2sdb.cpp:59

◆ RegisterConnection()

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 at line 143 of file connection.cpp.

151 {
152  PSUBDEVICE_DESCRIPTOR FromSubDeviceDescriptor = NULL, ToSubDeviceDescriptor = NULL;
153  PSYMBOLICLINK_ENTRY SymEntry;
154  ISubdevice * FromSubDevice = NULL, *ToSubDevice = NULL;
156  PPHYSICAL_CONNECTION_ENTRY FromEntry = NULL, ToEntry = NULL;
157 
158  if (FromUnknown)
159  {
160  Status = FromUnknown->QueryInterface(IID_ISubdevice, (PVOID*)&FromSubDevice);
161  if (!NT_SUCCESS(Status))
162  goto cleanup;
163 
164  Status = FromSubDevice->GetDescriptor(&FromSubDeviceDescriptor);
165  if (!NT_SUCCESS(Status))
166  goto cleanup;
167 
168  if (IsListEmpty(&FromSubDeviceDescriptor->SymbolicLinkList))
169  {
171  goto cleanup;
172  }
173 
175  FromString = &SymEntry->SymbolicLink;
176  }
177 
178 
179  if (ToUnknown)
180  {
181  Status = ToUnknown->QueryInterface(IID_ISubdevice, (PVOID*)&ToSubDevice);
182  if (!NT_SUCCESS(Status))
183  goto cleanup;
184 
185  Status = ToSubDevice->GetDescriptor(&ToSubDeviceDescriptor);
186  if (!NT_SUCCESS(Status))
187  goto cleanup;
188 
189  if (IsListEmpty(&ToSubDeviceDescriptor->SymbolicLinkList))
190  {
192  goto cleanup;
193  }
194 
195 
196  SymEntry = (PSYMBOLICLINK_ENTRY)CONTAINING_RECORD(ToSubDeviceDescriptor->SymbolicLinkList.Flink, SYMBOLICLINK_ENTRY, Entry);
197  ToString = &SymEntry->SymbolicLink;
198 
199  }
200 
201  if (FromSubDeviceDescriptor)
202  {
204  if (!FromEntry)
205  {
207  goto cleanup;
208  }
209  }
210 
211  if (ToSubDeviceDescriptor)
212  {
213  ToEntry = (PPHYSICAL_CONNECTION_ENTRY)AllocateItem(NonPagedPool, sizeof(PHYSICAL_CONNECTION_ENTRY) + FromString->MaximumLength + sizeof(WCHAR), TAG_PORTCLASS);
214  if (!ToEntry)
215  {
217  goto cleanup;
218  }
219  }
220 
221  if (FromSubDeviceDescriptor)
222  {
223  FromEntry->FromPin = FromPin;
224  FromEntry->Connection.Pin = ToPin;
225  FromEntry->Connection.Size = sizeof(KSPIN_PHYSICALCONNECTION) + ToString->MaximumLength + sizeof(WCHAR);
226  RtlMoveMemory(&FromEntry->Connection.SymbolicLinkName, ToString->Buffer, ToString->MaximumLength);
227  FromEntry->Connection.SymbolicLinkName[ToString->Length / sizeof(WCHAR)] = UNICODE_NULL;
228 
229  InsertTailList(&FromSubDeviceDescriptor->PhysicalConnectionList, &FromEntry->Entry);
230  }
231 
232 
233  if (ToSubDeviceDescriptor)
234  {
235  ToEntry->FromPin = ToPin;
236  ToEntry->Connection.Pin = FromPin;
237  ToEntry->Connection.Size = sizeof(KSPIN_PHYSICALCONNECTION) + FromString->MaximumLength + sizeof(WCHAR);
238  RtlMoveMemory(&ToEntry->Connection.SymbolicLinkName, FromString->Buffer, FromString->MaximumLength);
239  ToEntry->Connection.SymbolicLinkName[FromString->Length / sizeof(WCHAR)] = UNICODE_NULL;
240 
241  InsertTailList(&ToSubDeviceDescriptor->PhysicalConnectionList, &ToEntry->Entry);
242 
243  }
244 
245  return STATUS_SUCCESS;
246 
247 cleanup:
248 
249  if (FromSubDevice)
250  FromSubDevice->Release();
251 
252  if (ToSubDevice)
253  ToSubDevice->Release();
254 
255  if (FromEntry)
256  FreeItem(FromEntry, TAG_PORTCLASS);
257 
258  if (ToEntry)
259  FreeItem(ToEntry, TAG_PORTCLASS);
260 
261  return Status;
262 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TAG_PORTCLASS
Definition: private.hpp:24
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
#define InsertTailList(ListHead, Entry)
WCHAR SymbolicLinkName[1]
Definition: ks.h:658
struct SYMBOLICLINK_ENTRY * PSYMBOLICLINK_ENTRY
Definition: interfaces.hpp:173
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
#define UNICODE_NULL
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
KSPIN_PHYSICALCONNECTION Connection
Definition: interfaces.hpp:183
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
nsrefcnt Release()
struct PHYSICAL_CONNECTION_ENTRY * PPHYSICAL_CONNECTION_ENTRY
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
ULONG FromPin
Definition: interfaces.hpp:182
LIST_ENTRY PhysicalConnectionList
Definition: interfaces.hpp:220
Definition: interfaces.hpp:179
#define NULL
Definition: types.h:112
LIST_ENTRY Entry
Definition: interfaces.hpp:181
UNICODE_STRING SymbolicLink
Definition: interfaces.hpp:176
char * cleanup(char *str)
Definition: wpickclick.c:99
#define STATUS_SUCCESS
Definition: shellext.h:65
std::string ToString(XMLHandle node)
Definition: xml2sdb.cpp:59
base of all file and directory entries
Definition: entries.h:82
LIST_ENTRY SymbolicLinkList
Definition: interfaces.hpp:219

Referenced by PcRegisterPhysicalConnection(), PcRegisterPhysicalConnectionFromExternal(), and PcRegisterPhysicalConnectionToExternal().

◆ RtlCreateUnicodeString()

◆ UnRegisterConnection()

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 
)
static

Definition at line 68 of file connection.cpp.

76 {
79 }
return STATUS_NOT_IMPLEMENTED
#define UNIMPLEMENTED
Definition: debug.h:115