ReactOS 0.4.15-dev-7958-gcd0bb1a
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),
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:4546
_In_ PKSNODE_CREATE _In_ ACCESS_MASK _Out_ PHANDLE NodeHandle
Definition: ks.h:4548
#define KSSTRING_TopologyNode
Definition: ks.h:52
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658

◆ 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,
63 0,
64 NULL,
65 0,
67 NULL,
69
70 /* free request buffer */
71 FreeItem(Name.Buffer);
72 return Status;
73}
struct NameRec_ * Name
Definition: cdprocs.h:460
LONG NTSTATUS
Definition: precomp.h:26
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
#define NonPagedPool
Definition: env_spec_w32.h:307
#define FILE_OPEN
Definition: from_kernel.h:54
Status
Definition: gdiplustypes.h:25
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_OPENIF
Definition: winternl.h:229
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:29
VOID FreeItem(IN PVOID Item)
Definition: misc.c:37
ObjectType
Definition: metafile.c:81
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
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:3010
#define L(x)
Definition: ntvdm.h:50
unsigned short USHORT
Definition: pedump.c:61
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define IO_FORCE_ACCESS_CHECK
Definition: iotypes.h:540
#define IO_NO_PARAMETER_CHECKING
Definition: iotypes.h:541
@ CreateFileTypeNone
Definition: iotypes.h:535
__wchar_t WCHAR
Definition: xmlstorage.h:180

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;
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
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}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
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
_In_ PIRP Irp
Definition: csq.h:116
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
union node Node
Definition: types.h:1255
#define KSPROPERTY_TYPE_GET
Definition: dmksctrl.h:42
#define GUID_NULL
Definition: ks.h:106
@ KSPROPERTY_TOPOLOGY_CATEGORIES
Definition: ks.h:845
@ KSPROPERTY_TOPOLOGY_NAME
Definition: ks.h:848
@ KSPROPERTY_TOPOLOGY_NODES
Definition: ks.h:846
@ KSPROPERTY_TOPOLOGY_CONNECTIONS
Definition: ks.h:847
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
GUID * LPGUID
Definition: guiddef.h:81
#define STATUS_NOT_FOUND
Definition: shellext.h:72
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define DPRINT
Definition: sndvol32.h:71
Definition: ks.h:2074
struct _IO_STACK_LOCATION::@1564::@1565 DeviceIoControl
union _IO_STACK_LOCATION::@1564 Parameters
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
Definition: dlist.c:348
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:762
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235
WCHAR * LPWSTR
Definition: xmlstorage.h:184

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}
NTSTATUS KspCopyCreateRequest(IN PIRP Irp, IN LPWSTR ObjectClass, IN OUT PULONG Size, OUT PVOID *Result)
Definition: misc.c:44
ULONG Node
Definition: ks.h:2094
ULONG CreateFlags
Definition: ks.h:2093
#define MAXULONG
Definition: typedefs.h:251
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533