ReactOS  0.4.13-dev-544-gede3fdd
topology.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for topology.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI KspCreateObjectType (IN HANDLE ParentHandle, IN LPWSTR ObjectType, PVOID CreateParameters, UINT CreateParametersSize, IN ACCESS_MASK DesiredAccess, OUT PHANDLE NodeHandle)
 
KSDDKAPI NTSTATUS NTAPI KsCreateTopologyNode (IN HANDLE ParentHandle, IN PKSNODE_CREATE NodeCreate, IN ACCESS_MASK DesiredAccess, OUT PHANDLE NodeHandle)
 
KSDDKAPI NTSTATUS NTAPI KsValidateTopologyNodeCreateRequest (IN PIRP Irp, IN PKSTOPOLOGY Topology, OUT PKSNODE_CREATE *OutNodeCreate)
 
KSDDKAPI NTSTATUS NTAPI KsTopologyPropertyHandler (IN PIRP Irp, IN PKSPROPERTY Property, IN OUT PVOID Data, IN const KSTOPOLOGY *Topology)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file topology.c.

Function Documentation

◆ KsCreateTopologyNode()

KSDDKAPI NTSTATUS NTAPI KsCreateTopologyNode ( IN HANDLE  ParentHandle,
IN PKSNODE_CREATE  NodeCreate,
IN ACCESS_MASK  DesiredAccess,
OUT PHANDLE  NodeHandle 
)

Definition at line 80 of file topology.c.

85 {
86  return KspCreateObjectType(ParentHandle,
89  sizeof(KSNODE_CREATE),
91  NodeHandle);
92 }
NTSTATUS NTAPI KspCreateObjectType(IN HANDLE ParentHandle, IN LPWSTR ObjectType, PVOID CreateParameters, UINT CreateParametersSize, IN ACCESS_MASK DesiredAccess, OUT PHANDLE NodeHandle)
Definition: topology.c:16
_In_ PKSNODE_CREATE NodeCreate
Definition: ks.h:4575
_In_ PKSNODE_CREATE _In_ ACCESS_MASK _Out_ PHANDLE NodeHandle
Definition: ks.h:4575
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4157
#define KSSTRING_TopologyNode
Definition: ks.h:52

◆ KspCreateObjectType()

NTSTATUS NTAPI KspCreateObjectType ( IN HANDLE  ParentHandle,
IN LPWSTR  ObjectType,
PVOID  CreateParameters,
UINT  CreateParametersSize,
IN ACCESS_MASK  DesiredAccess,
OUT PHANDLE  NodeHandle 
)

Definition at line 16 of file topology.c.

23 {
28 
29  /* calculate request length */
30  Name.Length = 0;
31  Name.MaximumLength = (USHORT)(wcslen(ObjectType) * sizeof(WCHAR) + CreateParametersSize + 1 * sizeof(WCHAR));
32  Name.MaximumLength += sizeof(WCHAR);
33  /* acquire request buffer */
34  Name.Buffer = AllocateItem(NonPagedPool, Name.MaximumLength);
35  /* check for success */
36  if (!Name.Buffer)
37  {
38  /* insufficient resources */
40  }
41 
42  /* build a request which looks like {ObjectClass}\CreateParameters
43  * For pins the parent is the reference string used in registration
44  * For clocks it is full path for pin\{ClockGuid}\ClockCreateParams
45  */
48  /* append create parameters */
49  RtlMoveMemory(Name.Buffer + (Name.Length / sizeof(WCHAR)), CreateParameters, CreateParametersSize);
50  Name.Length += CreateParametersSize;
51  Name.Buffer[Name.Length / 2] = L'\0';
52 
54  /* create the instance */
59  NULL,
60  0,
61  0,
62  FILE_OPEN,
63  0,
64  NULL,
65  0,
67  NULL,
69 
70  /* free request buffer */
71  FreeItem(Name.Buffer);
72  return Status;
73 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
ObjectType
Definition: metafile.c:80
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define IO_FORCE_ACCESS_CHECK
Definition: iotypes.h:507
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:30
LONG NTSTATUS
Definition: precomp.h:26
_In_ PKSNODE_CREATE _In_ ACCESS_MASK _Out_ PHANDLE NodeHandle
Definition: ks.h:4575
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define OBJ_OPENIF
Definition: winternl.h:229
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
#define IO_NO_PARAMETER_CHECKING
Definition: iotypes.h:508
struct NameRec_ * Name
Definition: cdprocs.h:464
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
#define FILE_OPEN
Definition: from_kernel.h:54
unsigned short USHORT
Definition: pedump.c:61
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4157
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
NTSTATUS NTAPI IoCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG Disposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength, IN CREATE_FILE_TYPE CreateFileType, IN PVOID ExtraCreateParameters OPTIONAL, IN ULONG Options)
Definition: file.c:3009
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by KsCreateAllocator(), KsCreateClock(), KsCreatePin(), and KsCreateTopologyNode().

◆ KsTopologyPropertyHandler()

KSDDKAPI NTSTATUS NTAPI KsTopologyPropertyHandler ( IN PIRP  Irp,
IN PKSPROPERTY  Property,
IN OUT PVOID  Data,
IN const KSTOPOLOGY Topology 
)

Definition at line 144 of file topology.c.

149 {
150  KSP_NODE * Node;
151  PIO_STACK_LOCATION IoStack;
154  LPGUID Guid;
155 
157 
158  DPRINT("KsTopologyPropertyHandler Irp %p Property %p Data %p Topology %p OutputLength %lu PropertyId %lu\n", Irp, Property, Data, Topology, IoStack->Parameters.DeviceIoControl.OutputBufferLength, Property->Id);
159 
160  if (Property->Flags != KSPROPERTY_TYPE_GET)
161  {
162  Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
163  Irp->IoStatus.Information = 0;
164  return STATUS_NOT_IMPLEMENTED;
165  }
166 
167  switch(Property->Id)
168  {
170  return KsHandleSizedListQuery(Irp, Topology->CategoriesCount, sizeof(GUID), Topology->Categories);
171 
173  return KsHandleSizedListQuery(Irp, Topology->TopologyNodesCount, sizeof(GUID), Topology->TopologyNodes);
174 
176  return KsHandleSizedListQuery(Irp, Topology->TopologyConnectionsCount, sizeof(KSTOPOLOGY_CONNECTION), Topology->TopologyConnections);
177 
179  Node = (KSP_NODE*)Property;
180 
181  /* check for invalid node id */
182  if (Node->NodeId >= Topology->TopologyNodesCount)
183  {
184  /* invalid node id */
185  Irp->IoStatus.Information = 0;
187  break;
188  }
189 
190  /* check if there is a name supplied */
191  if (!IsEqualGUIDAligned(&Topology->TopologyNodesNames[Node->NodeId], &GUID_NULL))
192  {
193  /* node name has been supplied */
194  Guid = (LPGUID)&Topology->TopologyNodesNames[Node->NodeId];
195  }
196  else
197  {
198  /* fallback to topology node type */
199  Guid = (LPGUID)&Topology->TopologyNodes[Node->NodeId];
200  }
201 
202  /* read topology node name */
203  Status = KspReadMediaCategory(Guid, &KeyInfo);
204  if (!NT_SUCCESS(Status))
205  {
206  Irp->IoStatus.Information = 0;
207  break;
208  }
209 
210  /* store result size */
211  Irp->IoStatus.Information = KeyInfo->DataLength + sizeof(WCHAR);
212 
213  /* check for buffer overflow */
214  if (KeyInfo->DataLength + sizeof(WCHAR) > IoStack->Parameters.DeviceIoControl.OutputBufferLength)
215  {
216  /* buffer too small */
218  FreeItem(KeyInfo);
219  break;
220  }
221 
222  /* copy result buffer */
223  RtlMoveMemory(Irp->AssociatedIrp.SystemBuffer, &KeyInfo->Data, KeyInfo->DataLength);
224 
225  /* zero terminate it */
226  ((LPWSTR)Irp->AssociatedIrp.SystemBuffer)[KeyInfo->DataLength / sizeof(WCHAR)] = L'\0';
227 
228  /* free key info */
229  FreeItem(KeyInfo);
230 
231  break;
232  default:
233  Irp->IoStatus.Information = 0;
235  }
236 
237  Irp->IoStatus.Status = Status;
238  return Status;
239 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
KSDDKAPI NTSTATUS NTAPI KsHandleSizedListQuery(IN PIRP Irp, IN ULONG DataItemsCount, IN ULONG DataItemSize, IN const VOID *DataItems)
Definition: connectivity.c:774
NTSTATUS KspReadMediaCategory(IN LPGUID Category, PKEY_VALUE_PARTIAL_INFORMATION *OutInformation)
Definition: connectivity.c:232
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
union node Node
Definition: types.h:1255
static GUID * Guid
Definition: apphelp.c:93
Definition: ks.h:2104
void DPRINT(...)
Definition: polytest.cpp:61
#define STATUS_NOT_FOUND
Definition: shellext.h:67
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR L[]
Definition: oid.c:1250
#define GUID_NULL
Definition: ks.h:106
Status
Definition: gdiplustypes.h:24
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
WCHAR * LPWSTR
Definition: xmlstorage.h:184
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
Definition: dlist.c:348
GUID * LPGUID
Definition: guiddef.h:76

Referenced by FilterTopologyPropertyHandler(), and TopologyPropertyHandler().

◆ KsValidateTopologyNodeCreateRequest()

KSDDKAPI NTSTATUS NTAPI KsValidateTopologyNodeCreateRequest ( IN PIRP  Irp,
IN PKSTOPOLOGY  Topology,
OUT PKSNODE_CREATE OutNodeCreate 
)

Definition at line 100 of file topology.c.

104 {
106  ULONG Size;
108 
109  /* did the caller miss the topology */
110  if (!Topology)
112 
113  /* set create param size */
114  Size = sizeof(KSNODE_CREATE);
115 
116  /* fetch create parameters */
119  &Size,
120  (PVOID*)&NodeCreate);
121 
122  if (!NT_SUCCESS(Status))
123  return Status;
124 
125  if (NodeCreate->CreateFlags != 0 || (NodeCreate->Node >= Topology->TopologyNodesCount && NodeCreate->Node != MAXULONG))
126  {
127  /* invalid node create */
129  return STATUS_UNSUCCESSFUL;
130  }
131 
132  /* store result */
133  *OutNodeCreate = NodeCreate;
134 
135  return Status;
136 }
_In_ PKSNODE_CREATE NodeCreate
Definition: ks.h:4575
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS KspCopyCreateRequest(IN PIRP Irp, IN LPWSTR ObjectClass, IN OUT PULONG Size, OUT PVOID *Result)
Definition: misc.c:101
VOID FreeItem(IN PVOID Item)
Definition: misc.c:43
ULONG Node
Definition: ks.h:2124
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
#define MAXULONG
Definition: typedefs.h:250
#define KSSTRING_TopologyNode
Definition: ks.h:52
unsigned int ULONG
Definition: retypes.h:1
ULONG CreateFlags
Definition: ks.h:2123