Author: tkreuzer
Date: Mon Dec 31 09:48:46 2012
New Revision: 58065
URL:
http://svn.reactos.org/svn/reactos?rev=58065&view=rev
Log:
[KS]
Pass a PUNICODE_STRING instead of a LPWSTR (and unused BufferSize) to
FindMatchingCreateItem(), make use of the Length parameter instead of trusting on NULL
termination when searching for path separators.
Modified:
trunk/reactos/drivers/ksfilter/ks/device.c
trunk/reactos/drivers/ksfilter/ks/irp.c
trunk/reactos/drivers/ksfilter/ks/ksfunc.h
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] Mon Dec 31 09:48:46 2012
@@ -218,7 +218,7 @@
return STATUS_NOT_IMPLEMENTED;
}
-static IKsDeviceVtbl vt_IKsDevice =
+static IKsDeviceVtbl vt_IKsDevice =
{
IKsDevice_fnQueryInterface,
IKsDevice_fnAddRef,
@@ -631,12 +631,16 @@
ASSERT(ObjectHeader);
/* find a matching a create item */
- Status = FindMatchingCreateItem(&ObjectHeader->ItemList,
IoStack->FileObject->FileName.Length, IoStack->FileObject->FileName.Buffer,
&CreateItemEntry);
+ Status = FindMatchingCreateItem(&ObjectHeader->ItemList,
+ &IoStack->FileObject->FileName,
+ &CreateItemEntry);
}
else
{
/* request to create a filter */
- Status = FindMatchingCreateItem(&DeviceHeader->ItemList,
IoStack->FileObject->FileName.Length, IoStack->FileObject->FileName.Buffer,
&CreateItemEntry);
+ Status = FindMatchingCreateItem(&DeviceHeader->ItemList,
+ &IoStack->FileObject->FileName,
+ &CreateItemEntry);
}
if (NT_SUCCESS(Status))
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] Mon Dec 31 09:48:46 2012
@@ -1175,7 +1175,7 @@
/* get current irp stack */
IoStack = IoGetCurrentIrpStackLocation(Irp);
- if (IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_PROPERTY
&&
+ if (IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_PROPERTY
&&
IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_METHOD
&&
IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_PROPERTY)
{
@@ -1744,41 +1744,53 @@
NTSTATUS
FindMatchingCreateItem(
PLIST_ENTRY ListHead,
- ULONG BufferSize,
- LPWSTR Buffer,
+ PUNICODE_STRING String,
OUT PCREATE_ITEM_ENTRY *OutCreateItem)
{
PLIST_ENTRY Entry;
PCREATE_ITEM_ENTRY CreateItemEntry;
UNICODE_STRING RefString;
LPWSTR pStr;
-
- /* get terminator */
- pStr = wcschr(Buffer, L'\\');
-
- /* sanity check */
- ASSERT(pStr != NULL);
-
- if (pStr == Buffer)
- {
- // skip slash
- RtlInitUnicodeString(&RefString, ++pStr);
+ ULONG Count;
+
+ /* Copy the input string */
+ RefString = *String;
+
+ /* Check if the string starts with a backslash */
+ if (String->Buffer[0] == L'\\')
+ {
+ /* Skip backslash */
+ RefString.Buffer++;
+ RefString.Length -= sizeof(WCHAR);
}
else
{
+ /* get terminator */
+ pStr = String->Buffer;
+ Count = String->Length / sizeof(WCHAR);
+ while ((Count > 0) && (*pStr != L'\\'))
+ {
+ pStr++;
+ Count--;
+ }
+
+ /* sanity check */
+ ASSERT(Count != 0);
+
// request is for pin / node / allocator
- RefString.Buffer = Buffer;
- RefString.Length = BufferSize = RefString.MaximumLength = ((ULONG_PTR)pStr -
(ULONG_PTR)Buffer);
+ RefString.Length = (USHORT)((PCHAR)pStr - (PCHAR)String->Buffer);
}
/* point to first entry */
Entry = ListHead->Flink;
/* loop all device items */
- while(Entry != ListHead)
+ while (Entry != ListHead)
{
/* get create item entry */
- CreateItemEntry = (PCREATE_ITEM_ENTRY)CONTAINING_RECORD(Entry, CREATE_ITEM_ENTRY,
Entry);
+ CreateItemEntry = (PCREATE_ITEM_ENTRY)CONTAINING_RECORD(Entry,
+ CREATE_ITEM_ENTRY,
+ Entry);
ASSERT(CreateItemEntry->CreateItem);
@@ -1796,10 +1808,11 @@
continue;
}
- DPRINT("CreateItem %S Length %u Request %wZ %u\n",
CreateItemEntry->CreateItem->ObjectClass.Buffer,
-
CreateItemEntry->CreateItem->ObjectClass.Length,
- &RefString,
- RefString.Length);
+ DPRINT("CreateItem %S Length %u Request %wZ %u\n",
+ CreateItemEntry->CreateItem->ObjectClass.Buffer,
+ CreateItemEntry->CreateItem->ObjectClass.Length,
+ &RefString,
+ RefString.Length);
if (CreateItemEntry->CreateItem->ObjectClass.Length > RefString.Length)
{
@@ -1809,7 +1822,9 @@
}
/* now check if the object class is the same */
- if (!RtlCompareUnicodeString(&CreateItemEntry->CreateItem->ObjectClass,
&RefString, TRUE))
+ if
(!RtlCompareUnicodeString(&CreateItemEntry->CreateItem->ObjectClass,
+ &RefString,
+ TRUE))
{
/* found matching create item */
*OutCreateItem = CreateItemEntry;
@@ -1865,12 +1880,16 @@
ASSERT(ObjectHeader);
/* find a matching a create item */
- Status = FindMatchingCreateItem(&ObjectHeader->ItemList,
IoStack->FileObject->FileName.Length, IoStack->FileObject->FileName.Buffer,
&CreateItemEntry);
+ Status = FindMatchingCreateItem(&ObjectHeader->ItemList,
+ &IoStack->FileObject->FileName,
+ &CreateItemEntry);
}
else
{
/* request to create a filter */
- Status = FindMatchingCreateItem(&DeviceHeader->ItemList,
IoStack->FileObject->FileName.Length, IoStack->FileObject->FileName.Buffer,
&CreateItemEntry);
+ Status = FindMatchingCreateItem(&DeviceHeader->ItemList,
+ &IoStack->FileObject->FileName,
+ &CreateItemEntry);
}
if (NT_SUCCESS(Status))
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] Mon Dec 31 09:48:46 2012
@@ -106,8 +106,7 @@
NTSTATUS
FindMatchingCreateItem(
PLIST_ENTRY ListHead,
- ULONG BufferSize,
- LPWSTR Buffer,
+ PUNICODE_STRING String,
OUT PCREATE_ITEM_ENTRY *OutCreateItem);
NTSTATUS