allocators.c
- Implement IKsAllocator interface and use it in new implemented KsCreateAllocator, KsCreateDefaultAllocatorEx, KsValidateAllocatorFramingEx
api.c
- Implement KsSetDevicePnpAndBaseObject, KsQueryDevicePnpObject, KsSetTargetState, KsSetTargetDeviceObject, KsSetPowerDispatch, KsFreeDeviceHeader, KsFreeObjectHeader, KsAllocateObjectCreateItem, KsFreeObjectCreateItem, KsFreeObjectCreateItemsByContext, KsCreateDefaultSecurity
clocks.c
- Implement KsCreateClock, KsCreateDefaultClock, partly implement KsAllocateDefaultClockEx, KsFreeDefaultClock, KsGetDefaultClockState, KsSetDefaultClockState, KsGetDefaultClockTime, KsSetDefaultClockTime
device.c
- Partly implement IKsDevice interface in order to let AVStream client devices initialize
- Implement KsInitializeDevice
- Implement registering of device interface for AVStream drivers
driver.c
- Implement KsGetDeviceForDeviceObject
- Set device flags for ks
- Store Address for client drivers device extension
filter.c
- Implement IKsFilter & IKsControl interface
- Handle KSPROPERTY requests
filterfactory.c
- Implement IKsFilterFactory interface
- Implement KsCreateFilterFactory, KsFilterFactorySetDeviceClassesState, KsFilterFactoryGetSymbolicLink, KsFilterFactoryAddCreateItem
- Add KsFilterFactoryUpdateCacheData
image.c
- Implement KsLoadResource
irp.c
- Implement KsDispatchQuerySecurity, KsDispatchSetSecurity, KsWriteFile, KsDefaultIoCompletion
svn path=/trunk/; revision=42109
2009-07-20 23:26:57 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS Kernel Streaming
|
|
|
|
* FILE: drivers/ksfilter/ks/topoology.c
|
|
|
|
* PURPOSE: KS Allocator functions
|
|
|
|
* PROGRAMMER: Johannes Anderwald
|
|
|
|
*/
|
|
|
|
|
2014-01-29 10:59:06 +00:00
|
|
|
#include "precomp.h"
|
2006-12-10 05:43:49 +00:00
|
|
|
|
2014-01-02 11:34:12 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
2006-12-10 05:43:49 +00:00
|
|
|
|
2009-02-11 09:34:32 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
KspCreateObjectType(
|
|
|
|
IN HANDLE ParentHandle,
|
|
|
|
IN LPWSTR ObjectType,
|
|
|
|
PVOID CreateParameters,
|
|
|
|
UINT CreateParametersSize,
|
|
|
|
IN ACCESS_MASK DesiredAccess,
|
|
|
|
OUT PHANDLE NodeHandle)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
IO_STATUS_BLOCK IoStatusBlock;
|
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
UNICODE_STRING Name;
|
2009-07-10 15:14:56 +00:00
|
|
|
|
|
|
|
/* calculate request length */
|
|
|
|
Name.Length = 0;
|
2014-05-10 14:33:37 +00:00
|
|
|
Name.MaximumLength = (USHORT)(wcslen(ObjectType) * sizeof(WCHAR) + CreateParametersSize + 1 * sizeof(WCHAR));
|
2009-02-11 09:34:32 +00:00
|
|
|
Name.MaximumLength += sizeof(WCHAR);
|
2009-07-10 15:14:56 +00:00
|
|
|
/* acquire request buffer */
|
2010-06-09 14:44:46 +00:00
|
|
|
Name.Buffer = AllocateItem(NonPagedPool, Name.MaximumLength);
|
2009-07-10 15:14:56 +00:00
|
|
|
/* check for success */
|
2009-02-11 09:34:32 +00:00
|
|
|
if (!Name.Buffer)
|
|
|
|
{
|
2009-07-10 15:14:56 +00:00
|
|
|
/* insufficient resources */
|
2009-02-11 09:34:32 +00:00
|
|
|
return STATUS_INSUFFICIENT_RESOURCES;
|
|
|
|
}
|
|
|
|
|
2014-05-10 14:33:37 +00:00
|
|
|
/* build a request which looks like {ObjectClass}\CreateParameters
|
2009-07-10 15:14:56 +00:00
|
|
|
* For pins the parent is the reference string used in registration
|
|
|
|
* For clocks it is full path for pin\{ClockGuid}\ClockCreateParams
|
|
|
|
*/
|
|
|
|
RtlAppendUnicodeToString(&Name, ObjectType);
|
|
|
|
RtlAppendUnicodeToString(&Name, L"\\");
|
|
|
|
/* append create parameters */
|
|
|
|
RtlMoveMemory(Name.Buffer + (Name.Length / sizeof(WCHAR)), CreateParameters, CreateParametersSize);
|
|
|
|
Name.Length += CreateParametersSize;
|
2009-02-11 09:34:32 +00:00
|
|
|
Name.Buffer[Name.Length / 2] = L'\0';
|
|
|
|
|
2009-07-10 15:14:56 +00:00
|
|
|
InitializeObjectAttributes(&ObjectAttributes, &Name, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE | OBJ_OPENIF, ParentHandle, NULL);
|
|
|
|
/* create the instance */
|
2009-02-11 09:34:32 +00:00
|
|
|
Status = IoCreateFile(NodeHandle,
|
|
|
|
DesiredAccess,
|
|
|
|
&ObjectAttributes,
|
2009-02-19 01:11:59 +00:00
|
|
|
&IoStatusBlock,
|
2009-02-11 09:34:32 +00:00
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
FILE_OPEN,
|
2009-07-22 14:42:51 +00:00
|
|
|
0,
|
2009-02-11 09:34:32 +00:00
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
CreateFileTypeNone,
|
|
|
|
NULL,
|
|
|
|
IO_NO_PARAMETER_CHECKING | IO_FORCE_ACCESS_CHECK);
|
|
|
|
|
2009-07-10 15:14:56 +00:00
|
|
|
/* free request buffer */
|
2010-06-09 14:44:46 +00:00
|
|
|
FreeItem(Name.Buffer);
|
2009-02-11 09:34:32 +00:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-10 05:43:49 +00:00
|
|
|
/*
|
2009-02-11 09:34:32 +00:00
|
|
|
@implemented
|
2006-12-10 05:43:49 +00:00
|
|
|
*/
|
|
|
|
KSDDKAPI NTSTATUS NTAPI
|
|
|
|
KsCreateTopologyNode(
|
|
|
|
IN HANDLE ParentHandle,
|
|
|
|
IN PKSNODE_CREATE NodeCreate,
|
|
|
|
IN ACCESS_MASK DesiredAccess,
|
|
|
|
OUT PHANDLE NodeHandle)
|
|
|
|
{
|
2009-02-11 09:34:32 +00:00
|
|
|
return KspCreateObjectType(ParentHandle,
|
2009-07-22 19:08:57 +00:00
|
|
|
KSSTRING_TopologyNode,
|
2009-02-11 09:34:32 +00:00
|
|
|
(PVOID)NodeCreate,
|
|
|
|
sizeof(KSNODE_CREATE),
|
|
|
|
DesiredAccess,
|
|
|
|
NodeHandle);
|
2006-12-10 05:43:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2009-07-22 19:08:57 +00:00
|
|
|
@implemented
|
2006-12-10 05:43:49 +00:00
|
|
|
*/
|
2009-07-22 19:08:57 +00:00
|
|
|
KSDDKAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2006-12-10 05:43:49 +00:00
|
|
|
KsValidateTopologyNodeCreateRequest(
|
|
|
|
IN PIRP Irp,
|
|
|
|
IN PKSTOPOLOGY Topology,
|
2009-07-22 19:08:57 +00:00
|
|
|
OUT PKSNODE_CREATE* OutNodeCreate)
|
2006-12-10 05:43:49 +00:00
|
|
|
{
|
2009-07-22 19:08:57 +00:00
|
|
|
PKSNODE_CREATE NodeCreate;
|
|
|
|
ULONG Size;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
/* did the caller miss the topology */
|
|
|
|
if (!Topology)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
/* set create param size */
|
|
|
|
Size = sizeof(KSNODE_CREATE);
|
|
|
|
|
|
|
|
/* fetch create parameters */
|
|
|
|
Status = KspCopyCreateRequest(Irp,
|
|
|
|
KSSTRING_TopologyNode,
|
|
|
|
&Size,
|
|
|
|
(PVOID*)&NodeCreate);
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
return Status;
|
|
|
|
|
2009-09-27 20:07:43 +00:00
|
|
|
if (NodeCreate->CreateFlags != 0 || (NodeCreate->Node >= Topology->TopologyNodesCount && NodeCreate->Node != MAXULONG))
|
2009-07-22 19:08:57 +00:00
|
|
|
{
|
|
|
|
/* invalid node create */
|
|
|
|
FreeItem(NodeCreate);
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* store result */
|
|
|
|
*OutNodeCreate = NodeCreate;
|
|
|
|
|
|
|
|
return Status;
|
2006-12-10 05:43:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2009-02-17 04:52:11 +00:00
|
|
|
@implemented
|
2006-12-10 05:43:49 +00:00
|
|
|
*/
|
2009-02-17 04:52:11 +00:00
|
|
|
KSDDKAPI
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2006-12-10 05:43:49 +00:00
|
|
|
KsTopologyPropertyHandler(
|
|
|
|
IN PIRP Irp,
|
|
|
|
IN PKSPROPERTY Property,
|
|
|
|
IN OUT PVOID Data,
|
|
|
|
IN const KSTOPOLOGY* Topology)
|
|
|
|
{
|
2009-02-17 04:52:11 +00:00
|
|
|
KSP_NODE * Node;
|
|
|
|
PIO_STACK_LOCATION IoStack;
|
|
|
|
NTSTATUS Status;
|
|
|
|
PKEY_VALUE_PARTIAL_INFORMATION KeyInfo;
|
2010-10-18 22:21:00 +00:00
|
|
|
LPGUID Guid;
|
2009-02-17 04:52:11 +00:00
|
|
|
|
2009-12-25 01:17:39 +00:00
|
|
|
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
|
|
|
|
|
|
|
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);
|
2009-09-12 14:35:27 +00:00
|
|
|
|
2009-02-17 04:52:11 +00:00
|
|
|
if (Property->Flags != KSPROPERTY_TYPE_GET)
|
|
|
|
{
|
|
|
|
Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
|
|
|
|
Irp->IoStatus.Information = 0;
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(Property->Id)
|
|
|
|
{
|
|
|
|
case KSPROPERTY_TOPOLOGY_CATEGORIES:
|
2009-12-20 11:17:02 +00:00
|
|
|
return KsHandleSizedListQuery(Irp, Topology->CategoriesCount, sizeof(GUID), Topology->Categories);
|
2009-02-17 04:52:11 +00:00
|
|
|
|
|
|
|
case KSPROPERTY_TOPOLOGY_NODES:
|
2009-12-20 11:17:02 +00:00
|
|
|
return KsHandleSizedListQuery(Irp, Topology->TopologyNodesCount, sizeof(GUID), Topology->TopologyNodes);
|
2009-02-17 04:52:11 +00:00
|
|
|
|
|
|
|
case KSPROPERTY_TOPOLOGY_CONNECTIONS:
|
2009-12-20 11:17:02 +00:00
|
|
|
return KsHandleSizedListQuery(Irp, Topology->TopologyConnectionsCount, sizeof(KSTOPOLOGY_CONNECTION), Topology->TopologyConnections);
|
2009-02-17 04:52:11 +00:00
|
|
|
|
|
|
|
case KSPROPERTY_TOPOLOGY_NAME:
|
|
|
|
Node = (KSP_NODE*)Property;
|
|
|
|
|
2010-10-18 22:21:00 +00:00
|
|
|
/* check for invalid node id */
|
2009-10-02 10:53:36 +00:00
|
|
|
if (Node->NodeId >= Topology->TopologyNodesCount)
|
|
|
|
{
|
2010-10-18 22:21:00 +00:00
|
|
|
/* invalid node id */
|
2009-10-02 10:53:36 +00:00
|
|
|
Irp->IoStatus.Information = 0;
|
|
|
|
Status = STATUS_INVALID_PARAMETER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-10-18 22:21:00 +00:00
|
|
|
/* check if there is a name supplied */
|
|
|
|
if (!IsEqualGUIDAligned(&Topology->TopologyNodesNames[Node->NodeId], &GUID_NULL))
|
|
|
|
{
|
|
|
|
/* node name has been supplied */
|
|
|
|
Guid = (LPGUID)&Topology->TopologyNodesNames[Node->NodeId];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* fallback to topology node type */
|
|
|
|
Guid = (LPGUID)&Topology->TopologyNodes[Node->NodeId];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* read topology node name */
|
|
|
|
Status = KspReadMediaCategory(Guid, &KeyInfo);
|
2009-02-17 04:52:11 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
Irp->IoStatus.Information = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-10-18 22:21:00 +00:00
|
|
|
/* store result size */
|
2010-09-23 11:36:00 +00:00
|
|
|
Irp->IoStatus.Information = KeyInfo->DataLength + sizeof(WCHAR);
|
2009-02-17 04:52:11 +00:00
|
|
|
|
2010-10-18 22:21:00 +00:00
|
|
|
/* check for buffer overflow */
|
2009-02-17 04:52:11 +00:00
|
|
|
if (KeyInfo->DataLength + sizeof(WCHAR) > IoStack->Parameters.DeviceIoControl.OutputBufferLength)
|
|
|
|
{
|
2010-10-18 22:21:00 +00:00
|
|
|
/* buffer too small */
|
2010-09-23 11:36:00 +00:00
|
|
|
Status = STATUS_BUFFER_OVERFLOW;
|
2010-06-09 14:44:46 +00:00
|
|
|
FreeItem(KeyInfo);
|
2009-02-17 04:52:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-10-18 22:21:00 +00:00
|
|
|
/* copy result buffer */
|
2015-05-29 15:01:34 +00:00
|
|
|
RtlMoveMemory(Irp->AssociatedIrp.SystemBuffer, &KeyInfo->Data, KeyInfo->DataLength);
|
2010-10-18 22:21:00 +00:00
|
|
|
|
|
|
|
/* zero terminate it */
|
2015-05-29 15:01:34 +00:00
|
|
|
((LPWSTR)Irp->AssociatedIrp.SystemBuffer)[KeyInfo->DataLength / sizeof(WCHAR)] = L'\0';
|
2010-10-18 22:21:00 +00:00
|
|
|
|
|
|
|
/* free key info */
|
2010-06-09 14:44:46 +00:00
|
|
|
FreeItem(KeyInfo);
|
2010-09-23 11:36:00 +00:00
|
|
|
|
2009-02-17 04:52:11 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Irp->IoStatus.Information = 0;
|
2010-10-18 22:21:00 +00:00
|
|
|
Status = STATUS_NOT_FOUND;
|
2009-02-17 04:52:11 +00:00
|
|
|
}
|
|
|
|
|
2015-05-29 15:01:34 +00:00
|
|
|
Irp->IoStatus.Status = Status;
|
2009-02-17 04:52:11 +00:00
|
|
|
return Status;
|
2006-12-10 05:43:49 +00:00
|
|
|
}
|
allocators.c
- Implement IKsAllocator interface and use it in new implemented KsCreateAllocator, KsCreateDefaultAllocatorEx, KsValidateAllocatorFramingEx
api.c
- Implement KsSetDevicePnpAndBaseObject, KsQueryDevicePnpObject, KsSetTargetState, KsSetTargetDeviceObject, KsSetPowerDispatch, KsFreeDeviceHeader, KsFreeObjectHeader, KsAllocateObjectCreateItem, KsFreeObjectCreateItem, KsFreeObjectCreateItemsByContext, KsCreateDefaultSecurity
clocks.c
- Implement KsCreateClock, KsCreateDefaultClock, partly implement KsAllocateDefaultClockEx, KsFreeDefaultClock, KsGetDefaultClockState, KsSetDefaultClockState, KsGetDefaultClockTime, KsSetDefaultClockTime
device.c
- Partly implement IKsDevice interface in order to let AVStream client devices initialize
- Implement KsInitializeDevice
- Implement registering of device interface for AVStream drivers
driver.c
- Implement KsGetDeviceForDeviceObject
- Set device flags for ks
- Store Address for client drivers device extension
filter.c
- Implement IKsFilter & IKsControl interface
- Handle KSPROPERTY requests
filterfactory.c
- Implement IKsFilterFactory interface
- Implement KsCreateFilterFactory, KsFilterFactorySetDeviceClassesState, KsFilterFactoryGetSymbolicLink, KsFilterFactoryAddCreateItem
- Add KsFilterFactoryUpdateCacheData
image.c
- Implement KsLoadResource
irp.c
- Implement KsDispatchQuerySecurity, KsDispatchSetSecurity, KsWriteFile, KsDefaultIoCompletion
svn path=/trunk/; revision=42109
2009-07-20 23:26:57 +00:00
|
|
|
|