Author: janderwald
Date: Wed Jul 22 21:08:57 2009
New Revision: 42146
URL:
http://svn.reactos.org/svn/reactos?rev=42146&view=rev
Log:
- Use KSSTRING instead of hardcoding object class
- Implement KsValidateAllocatorCreateRequest, KsValidateClockCreateRequest,
KsValidateTopologyNodeCreateRequest
Modified:
trunk/reactos/drivers/ksfilter/ks/allocators.c
trunk/reactos/drivers/ksfilter/ks/api.c
trunk/reactos/drivers/ksfilter/ks/clocks.c
trunk/reactos/drivers/ksfilter/ks/connectivity.c
trunk/reactos/drivers/ksfilter/ks/device.c
trunk/reactos/drivers/ksfilter/ks/image.c
trunk/reactos/drivers/ksfilter/ks/ksfunc.h
trunk/reactos/drivers/ksfilter/ks/misc.c
trunk/reactos/drivers/ksfilter/ks/topology.c
Modified: trunk/reactos/drivers/ksfilter/ks/allocators.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/alloca…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/allocators.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/allocators.c [iso-8859-1] Wed Jul 22 21:08:57 2009
@@ -368,7 +368,7 @@
OUT PHANDLE AllocatorHandle)
{
return KspCreateObjectType(ConnectionHandle,
- L"{642F5D00-4791-11D0-A5D6-28DB04C10000}",
//KSNAME_Allocator
+ KSSTRING_Allocator,
(PVOID)AllocatorFraming,
sizeof(KSALLOCATOR_FRAMING),
GENERIC_READ,
@@ -386,15 +386,47 @@
}
/*
- @unimplemented
+ @implemented
*/
-KSDDKAPI NTSTATUS NTAPI
+KSDDKAPI
+NTSTATUS
+NTAPI
KsValidateAllocatorCreateRequest(
IN PIRP Irp,
- OUT PKSALLOCATOR_FRAMING* AllocatorFraming)
-{
- UNIMPLEMENTED;
- return STATUS_UNSUCCESSFUL;
+ OUT PKSALLOCATOR_FRAMING* OutAllocatorFraming)
+{
+ PKSALLOCATOR_FRAMING AllocatorFraming;
+ ULONG Size;
+ NTSTATUS Status;
+ ULONG SupportedFlags;
+
+ /* set minimum request size */
+ Size = sizeof(KSALLOCATOR_FRAMING);
+
+ Status = KspCopyCreateRequest(Irp,
+ KSSTRING_Allocator,
+ &Size,
+ (PVOID*)&AllocatorFraming);
+
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ /* allowed supported flags */
+ SupportedFlags = (KSALLOCATOR_OPTIONF_COMPATIBLE | KSALLOCATOR_OPTIONF_SYSTEM_MEMORY
|
+ KSALLOCATOR_REQUIREMENTF_INPLACE_MODIFIER |
KSALLOCATOR_REQUIREMENTF_SYSTEM_MEMORY | KSALLOCATOR_REQUIREMENTF_FRAME_INTEGRITY |
+ KSALLOCATOR_REQUIREMENTF_MUST_ALLOCATE);
+
+
+ if (!AllocatorFraming->FrameSize || (AllocatorFraming->OptionsFlags &
(~SupportedFlags)))
+ {
+ FreeItem(AllocatorFraming);
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* store result */
+ *OutAllocatorFraming = AllocatorFraming;
+
+ return Status;
}
NTSTATUS
Modified: trunk/reactos/drivers/ksfilter/ks/api.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/api.c?…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/api.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/api.c [iso-8859-1] Wed Jul 22 21:08:57 2009
@@ -779,7 +779,7 @@
}
/*
- @unimplemented
+ @implemented
*/
KSDDKAPI
NTSTATUS
Modified: trunk/reactos/drivers/ksfilter/ks/clocks.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/clocks…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/clocks.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/clocks.c [iso-8859-1] Wed Jul 22 21:08:57 2009
@@ -46,7 +46,7 @@
OUT PHANDLE ClockHandle)
{
return KspCreateObjectType(ConnectionHandle,
- L"{53172480-4791-11D0-A5D6-28DB04C10000}", /*
KSName_Clock */
+ KSSTRING_Clock,
ClockCreate,
sizeof(KSCLOCK_CREATE),
GENERIC_READ,
@@ -54,17 +54,40 @@
}
/*
- @unimplemented
+ @implemented
*/
KSDDKAPI
NTSTATUS
NTAPI
KsValidateClockCreateRequest(
IN PIRP Irp,
- OUT PKSCLOCK_CREATE* ClockCreate)
-{
- UNIMPLEMENTED;
- return STATUS_UNSUCCESSFUL;
+ OUT PKSCLOCK_CREATE* OutClockCreate)
+{
+ PKSCLOCK_CREATE ClockCreate;
+ NTSTATUS Status;
+ ULONG Size;
+
+ /* minimum request size */
+ Size = sizeof(KSCLOCK_CREATE);
+
+ /* copy create request */
+ Status = KspCopyCreateRequest(Irp,
+ KSSTRING_Clock,
+ &Size,
+ (PVOID*)&ClockCreate);
+
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ if (ClockCreate->CreateFlags != 0)
+ {
+ /* flags must be zero */
+ FreeItem(ClockCreate);
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ *OutClockCreate = ClockCreate;
+ return STATUS_SUCCESS;
}
NTSTATUS
Modified: trunk/reactos/drivers/ksfilter/ks/connectivity.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/connec…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/connectivity.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/connectivity.c [iso-8859-1] Wed Jul 22 21:08:57
2009
@@ -31,7 +31,7 @@
}
return KspCreateObjectType(FilterHandle,
- L"{146F1A80-4791-11D0-A5D6-28DB04C10000}",
//KSNAME_Pin
+ KSSTRING_Pin,
(PVOID)Connect,
ConnectSize,
DesiredAccess,
Modified: trunk/reactos/drivers/ksfilter/ks/device.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/device…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/device.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/device.c [iso-8859-1] Wed Jul 22 21:08:57 2009
@@ -613,7 +613,7 @@
}
/*
- @unimplemented
+ @implemented
*/
KSDDKAPI
NTSTATUS
Modified: trunk/reactos/drivers/ksfilter/ks/image.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/image.…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/image.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/image.c [iso-8859-1] Wed Jul 22 21:08:57 2009
@@ -9,7 +9,7 @@
#include "priv.h"
/*
- @unimplemented
+ @implemented
*/
KSDDKAPI
NTSTATUS
Modified: trunk/reactos/drivers/ksfilter/ks/ksfunc.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/ksfunc…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/ksfunc.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/ksfunc.h [iso-8859-1] Wed Jul 22 21:08:57 2009
@@ -107,4 +107,11 @@
LPWSTR Buffer,
OUT PCREATE_ITEM_ENTRY *OutCreateItem);
+NTSTATUS
+KspCopyCreateRequest(
+ IN PIRP Irp,
+ IN LPWSTR ObjectClass,
+ IN OUT PULONG Size,
+ OUT PVOID * Result);
+
#endif
Modified: trunk/reactos/drivers/ksfilter/ks/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/misc.c…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/misc.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/misc.c [iso-8859-1] Wed Jul 22 21:08:57 2009
@@ -98,3 +98,44 @@
UNIMPLEMENTED;
return STATUS_UNSUCCESSFUL;
}
+
+
+NTSTATUS
+KspCopyCreateRequest(
+ IN PIRP Irp,
+ IN LPWSTR ObjectClass,
+ IN OUT PULONG Size,
+ OUT PVOID * Result)
+{
+ PIO_STACK_LOCATION IoStack;
+ ULONG ObjectLength, ParametersLength;
+ PVOID Buffer;
+
+ /* get current irp stack */
+ IoStack = IoGetCurrentIrpStackLocation(Irp);
+
+ /* get object class length */
+ ObjectLength = (wcslen(ObjectClass) + 2) * sizeof(WCHAR);
+
+ /* check for minium length requirement */
+ if (ObjectLength + *Size > IoStack->FileObject->FileName.MaximumLength)
+ return STATUS_UNSUCCESSFUL;
+
+ /* extract parameters length */
+ ParametersLength = IoStack->FileObject->FileName.MaximumLength - ObjectLength;
+
+ /* allocate buffer */
+ Buffer = AllocateItem(NonPagedPool, ParametersLength);
+ if (!Buffer)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
+ /* copy parameters */
+ RtlMoveMemory(Buffer, &IoStack->FileObject->FileName.Buffer[ObjectLength /
sizeof(WCHAR)], ParametersLength);
+
+ /* store result */
+ *Result = Buffer;
+ *Size = ParametersLength;
+
+ return STATUS_SUCCESS;
+}
+
Modified: trunk/reactos/drivers/ksfilter/ks/topology.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/topolo…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/topology.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/topology.c [iso-8859-1] Wed Jul 22 21:08:57 2009
@@ -84,7 +84,7 @@
OUT PHANDLE NodeHandle)
{
return KspCreateObjectType(ParentHandle,
- L"{0621061A-EE75-11D0-B915-00A0C9223196}",
+ KSSTRING_TopologyNode,
(PVOID)NodeCreate,
sizeof(KSNODE_CREATE),
DesiredAccess,
@@ -92,16 +92,47 @@
}
/*
- @unimplemented
+ @implemented
*/
-KSDDKAPI NTSTATUS NTAPI
+KSDDKAPI
+NTSTATUS
+NTAPI
KsValidateTopologyNodeCreateRequest(
IN PIRP Irp,
IN PKSTOPOLOGY Topology,
- OUT PKSNODE_CREATE* NodeCreate)
-{
- UNIMPLEMENTED;
- return STATUS_UNSUCCESSFUL;
+ OUT PKSNODE_CREATE* OutNodeCreate)
+{
+ 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;
+
+ if (NodeCreate->CreateFlags != 0 || (NodeCreate->Node >=
Topology->TopologyNodesCount && NodeCreate->Node != (ULONG)-1))
+ {
+ /* invalid node create */
+ FreeItem(NodeCreate);
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ /* store result */
+ *OutNodeCreate = NodeCreate;
+
+ return Status;
}
/*