Author: janderwald
Date: Thu Jul 30 18:51:03 2009
New Revision: 42303
URL:
http://svn.reactos.org/svn/reactos?rev=42303&view=rev
Log:
- Partly Implement KsCacheMedium
- Implement KsHandleSizedListQuery
- Remove KsGetChildCreateParameter, it is not exported in NT 5.1 KS
Modified:
trunk/reactos/drivers/ksfilter/ks/api.c
trunk/reactos/drivers/ksfilter/ks/connectivity.c
trunk/reactos/drivers/ksfilter/ks/irp.c
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] Thu Jul 30 18:51:03 2009
@@ -8,6 +8,9 @@
#include "priv.h"
+
+const GUID GUID_NULL = {0x00000000L, 0x0000, 0x0000, {0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00}};
+const GUID KSMEDIUMSETID_Standard = {0x4747B320L, 0x62CE, 0x11CF, {0xA5, 0xD6, 0x28,
0xDB, 0x04, 0xC1, 0x00, 0x00}};
/*
@implemented
@@ -1163,7 +1166,7 @@
}
/*
- @implemented
+ @unimplemented
*/
KSDDKAPI
NTSTATUS
@@ -1179,7 +1182,7 @@
/*
- @unimplemented
+ @implemented
*/
KSDDKAPI
NTSTATUS
@@ -1189,8 +1192,83 @@
IN PKSPIN_MEDIUM Medium,
IN ULONG PinDirection)
{
- UNIMPLEMENTED;
- return STATUS_UNSUCCESSFUL;
+ HANDLE hKey;
+ UNICODE_STRING Path;
+ UNICODE_STRING BasePath =
RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\MediumCache\\");
+ UNICODE_STRING GuidString;
+ NTSTATUS Status;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ BOOLEAN PathAdjusted = FALSE;
+ ULONG Value = 0;
+
+ /* first check if the medium is standard */
+ if (IsEqualGUIDAligned(&KSMEDIUMSETID_Standard, &Medium->Set) ||
+ IsEqualGUIDAligned(&GUID_NULL, &Medium->Set))
+ {
+ /* no need to cache that */
+ return STATUS_SUCCESS;
+ }
+
+ /* convert guid to string */
+ Status = RtlStringFromGUID(&Medium->Set, &GuidString);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ /* allocate path buffer */
+ Path.Length = 0;
+ Path.MaximumLength = BasePath.MaximumLength + GuidString.MaximumLength + 10 *
sizeof(WCHAR);
+ Path.Buffer = AllocateItem(PagedPool, Path.MaximumLength);
+ if (!Path.Buffer)
+ {
+ /* not enough resources */
+ RtlFreeUnicodeString(&GuidString);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ RtlAppendUnicodeStringToString(&Path, &BasePath);
+ RtlAppendUnicodeStringToString(&Path, &GuidString);
+ RtlAppendUnicodeToString(&Path, L"-");
+ /* FIXME append real instance id */
+ RtlAppendUnicodeToString(&Path, L"0");
+ RtlAppendUnicodeToString(&Path, L"-");
+ /* FIXME append real instance id */
+ RtlAppendUnicodeToString(&Path, L"0");
+
+ /* free guid string */
+ RtlFreeUnicodeString(&GuidString);
+
+ /* initialize object attributes */
+ InitializeObjectAttributes(&ObjectAttributes, &Path, OBJ_KERNEL_HANDLE |
OBJ_CASE_INSENSITIVE, NULL, NULL);
+ /* create the key */
+ Status = ZwCreateKey(&hKey, GENERIC_WRITE, &ObjectAttributes, 0, NULL, 0,
NULL);
+
+ /* free path buffer */
+ FreeItem(Path.Buffer);
+
+ if (NT_SUCCESS(Status))
+ {
+ /* store symbolic link */
+ if (SymbolicLink->Buffer[1] == L'?' &&
SymbolicLink->Buffer[2] == L'?')
+ {
+ /* replace kernel path with user mode path */
+ SymbolicLink->Buffer[1] = L'\\';
+ PathAdjusted = TRUE;
+ }
+
+ /* store the key */
+ Status = ZwSetValueKey(hKey, SymbolicLink, 0, REG_DWORD, &Value,
sizeof(ULONG));
+
+ if (PathAdjusted)
+ {
+ /* restore kernel path */
+ SymbolicLink->Buffer[1] = L'?';
+ }
+
+ ZwClose(hKey);
+ }
+
+ /* done */
+ return Status;
}
/*
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] Thu Jul 30 18:51:03
2009
@@ -402,34 +402,42 @@
ULONG Index;
NTSTATUS Status;
+ /* get current irp stack location */
IoStack = IoGetCurrentIrpStackLocation(Irp);
+ /* calculate minimum data size */
Size = sizeof(KSP_PIN) + sizeof(KSMULTIPLE_ITEM) + sizeof(KSDATARANGE);
if (IoStack->Parameters.DeviceIoControl.InputBufferLength < Size)
{
- Irp->IoStatus.Information = 0;
- Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
+ /* buffer too small */
+ Irp->IoStatus.Information = Size;
+ Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
return STATUS_BUFFER_TOO_SMALL;
}
-
+ /* is pin id out of bounds */
if (Pin->PinId >= DescriptorsCount)
{
+ /* it is */
Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
Irp->IoStatus.Information = 0;
return STATUS_INVALID_PARAMETER;
}
+ /* get start item */
Item = (KSMULTIPLE_ITEM*)IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
+ /* get first data range */
DataRange = (KSDATARANGE*)(Item + 1);
-
+ /* iterate through all data ranges */
for(Index = 0; Index < Item->Count; Index++, DataRange++)
{
+ /* call intersect handler */
Status = IntersectHandler(Irp, Pin, DataRange, Data);
if (NT_SUCCESS(Status))
{
- if (IoStack->Parameters.DeviceIoControl.OutputBufferLength <
sizeof(KSDATARANGE))
- {
- Irp->IoStatus.Information = sizeof(KSDATARANGE);
+ if (IoStack->Parameters.DeviceIoControl.OutputBufferLength <
DataRange->FormatSize)
+ {
+ /* buffer is too small */
+ Irp->IoStatus.Information = DataRange->FormatSize;
Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
return STATUS_BUFFER_TOO_SMALL;
}
@@ -447,7 +455,7 @@
}
/*
- @unimplemented
+ @implemented
*/
KSDDKAPI
@@ -459,5 +467,35 @@
IN ULONG DataItemSize,
IN const VOID* DataItems)
{
+ ULONG Size;
+ PIO_STACK_LOCATION IoStack;
+ PKSMULTIPLE_ITEM Item;
+
+ /* get current irp stack location */
+ IoStack = IoGetCurrentIrpStackLocation(Irp);
+
+ Size = DataItemSize * DataItemsCount + sizeof(KSMULTIPLE_ITEM);
+
+
+ if (IoStack->Parameters.DeviceIoControl.InputBufferLength < Size)
+ {
+ /* buffer too small */
+ Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
+ Irp->IoStatus.Information = Size;
+ return STATUS_BUFFER_TOO_SMALL;
+ }
+
+ /* get multiple item */
+ Item = (PKSMULTIPLE_ITEM)IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
+
+ Item->Count = DataItemsCount;
+ Item->Size = DataItemSize;
+ /* copy items */
+ RtlMoveMemory((PVOID)(Item + 1), DataItems, DataItemSize * DataItemsCount);
+ /* store result */
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ Irp->IoStatus.Information = Size;
+ /* done */
return STATUS_SUCCESS;
}
+
Modified: trunk/reactos/drivers/ksfilter/ks/irp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/irp.c?…
==============================================================================
--- trunk/reactos/drivers/ksfilter/ks/irp.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/ksfilter/ks/irp.c [iso-8859-1] Thu Jul 30 18:51:03 2009
@@ -1138,20 +1138,6 @@
Irp->IoStatus.Status = STATUS_CANCELLED;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
}
-}
-
-/*
- @unimplemented
-*/
-KSDDKAPI
-NTSTATUS
-NTAPI
-KsGetChildCreateParameter(
- IN PIRP Irp,
- OUT PVOID* CreateParameter)
-{
- UNIMPLEMENTED;
- return STATUS_UNSUCCESSFUL;
}
NTSTATUS