From c600a169fb5213b7d88be008d88cd501da50f76b Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Tue, 2 Nov 2010 09:37:30 +0000 Subject: [PATCH] [KSUSER, KS, SYSAUDIO] - Make pin / node / allocator create requests compatible to ms by removing obsolete slash before object class - Return correct error code in ksuser's KsCreatePin - ReactOS KS is now able to create audio pins in Windows XP, though playback is not yet working - All changes except ksuser change has been verified to work with VBox 3.2.10 - KS user changes not tested yet as KSStudio not working in trunk svn path=/trunk/; revision=49428 --- reactos/dll/directx/ksuser/ksuser.c | 70 ++++++++++++++---------- reactos/drivers/ksfilter/ks/irp.c | 18 +++--- reactos/drivers/ksfilter/ks/misc.c | 2 +- reactos/drivers/ksfilter/ks/topology.c | 3 +- reactos/drivers/wdm/audio/sysaudio/pin.c | 2 +- 5 files changed, 53 insertions(+), 42 deletions(-) diff --git a/reactos/dll/directx/ksuser/ksuser.c b/reactos/dll/directx/ksuser/ksuser.c index 8f62abf950d..1b231674693 100644 --- a/reactos/dll/directx/ksuser/ksuser.c +++ b/reactos/dll/directx/ksuser/ksuser.c @@ -1,34 +1,19 @@ /* - * KSUSER.DLL - ReactOS - * - * Copyright 2008 Magnus Olsen and Dmitry Chapyshev - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Kernel Streaming + * FILE: dll/directx/ksuser/ksuser.c + * PURPOSE: KS USER functions + * PROGRAMMER: Magnus Olsen and Dmitry Chapyshev and Johannes Anderwald */ - #include "ksuser.h" #define NDEBUG #include -NTSTATUS NTAPI KsiCreateObjectType( HANDLE hHandle, PVOID guidstr, PVOID Buffer, ULONG BufferSize, ACCESS_MASK DesiredAccess, PHANDLE phHandle); - NTSTATUS NTAPI KsiCreateObjectType( HANDLE hHandle, - PVOID IID, + LPWSTR ObjectType, PVOID Buffer, ULONG BufferSize, ACCESS_MASK DesiredAccess, @@ -42,31 +27,56 @@ KsiCreateObjectType( HANDLE hHandle, OBJECT_ATTRIBUTES ObjectAttributes; IO_STATUS_BLOCK IoStatusBlock; - Length = wcslen(IID); + /* get length of object type */ + Length = wcslen(ObjectType); + + /* get length for request */ + TotalSize = (Length * sizeof(WCHAR)) + BufferSize; - TotalSize = (Length * sizeof(WCHAR)) + BufferSize + 4 * sizeof(WCHAR); + /* append space for '\\'*/ + TotalSize += sizeof(WCHAR); + /* allocate buffer */ pStr = HeapAlloc(GetProcessHeap(), 0, TotalSize); if (!pStr) - return STATUS_INSUFFICIENT_RESOURCES; - pStr[0] = L'\\'; - wcscpy(&pStr[1], (LPWSTR)IID); - pStr[Length+1] = L'\\'; - memcpy(&pStr[Length+2], Buffer, BufferSize); - pStr[Length+3+(BufferSize/sizeof(WCHAR))] = L'\0'; + { + /* out of memory */ + return ERROR_NOT_ENOUGH_MEMORY; + } + + /* copy object type */ + wcscpy(pStr, ObjectType); - RtlInitUnicodeString(&ObjectName, pStr); + /* append slash */ + pStr[Length] = L'\\'; + + /* append parameters */ + memcpy(&pStr[Length+1], Buffer, BufferSize); + + /* initialize object name */ + ObjectName.Buffer = pStr; ObjectName.Length = ObjectName.MaximumLength = TotalSize; + /* initialize object attributes */ InitializeObjectAttributes(&ObjectAttributes, &ObjectName, OBJ_CASE_INSENSITIVE, hHandle, NULL); + /* create the object */ Status = NtCreateFile(phHandle, DesiredAccess, &ObjectAttributes, &IoStatusBlock, NULL, FILE_ATTRIBUTE_NORMAL, 0, 1, 0, NULL, 0); + + /* free buffer */ HeapFree(GetProcessHeap(), 0, pStr); + + /* check for success */ if (!NT_SUCCESS(Status)) { + /* failed zero handle */ *phHandle = INVALID_HANDLE_VALUE; + + /* convert error code */ Status = RtlNtStatusToDosError(Status); } + + /* done */ return Status; } diff --git a/reactos/drivers/ksfilter/ks/irp.c b/reactos/drivers/ksfilter/ks/irp.c index 192aae54d52..faeb0a2a38e 100644 --- a/reactos/drivers/ksfilter/ks/irp.c +++ b/reactos/drivers/ksfilter/ks/irp.c @@ -1739,22 +1739,24 @@ FindMatchingCreateItem( PLIST_ENTRY Entry; PCREATE_ITEM_ENTRY CreateItemEntry; UNICODE_STRING RefString; + LPWSTR pStr; + /* get terminator */ + pStr = wcschr(Buffer, L'\\'); -#ifndef MS_KSUSER - /* remove '\' slash */ - Buffer++; - BufferSize -= sizeof(WCHAR); -#endif + /* sanity check */ + ASSERT(pStr != NULL); - if (!wcschr(Buffer, L'\\')) + if (pStr == Buffer) { - RtlInitUnicodeString(&RefString, Buffer); + // skip slash + RtlInitUnicodeString(&RefString, ++pStr); } else { + // request is for pin / node / allocator RefString.Buffer = Buffer; - RefString.Length = RefString.MaximumLength = ((ULONG_PTR)wcschr(Buffer, L'\\') - (ULONG_PTR)Buffer); + RefString.Length = BufferSize = RefString.MaximumLength = ((ULONG_PTR)pStr - (ULONG_PTR)Buffer); } /* point to first entry */ diff --git a/reactos/drivers/ksfilter/ks/misc.c b/reactos/drivers/ksfilter/ks/misc.c index d6b1e26078a..057103d3414 100644 --- a/reactos/drivers/ksfilter/ks/misc.c +++ b/reactos/drivers/ksfilter/ks/misc.c @@ -95,7 +95,7 @@ KspCopyCreateRequest( IoStack = IoGetCurrentIrpStackLocation(Irp); /* get object class length */ - ObjectLength = (wcslen(ObjectClass) + 2) * sizeof(WCHAR); + ObjectLength = (wcslen(ObjectClass) + 1) * sizeof(WCHAR); /* check for minium length requirement */ if (ObjectLength + *Size > IoStack->FileObject->FileName.MaximumLength) diff --git a/reactos/drivers/ksfilter/ks/topology.c b/reactos/drivers/ksfilter/ks/topology.c index 321f0ba59ed..63ccaf277c6 100644 --- a/reactos/drivers/ksfilter/ks/topology.c +++ b/reactos/drivers/ksfilter/ks/topology.c @@ -27,7 +27,7 @@ KspCreateObjectType( /* calculate request length */ Name.Length = 0; - Name.MaximumLength = wcslen(ObjectType) * sizeof(WCHAR) + CreateParametersSize + 2 * sizeof(WCHAR); + Name.MaximumLength = wcslen(ObjectType) * sizeof(WCHAR) + CreateParametersSize + 1 * sizeof(WCHAR); Name.MaximumLength += sizeof(WCHAR); /* acquire request buffer */ Name.Buffer = AllocateItem(NonPagedPool, Name.MaximumLength); @@ -42,7 +42,6 @@ KspCreateObjectType( * For pins the parent is the reference string used in registration * For clocks it is full path for pin\{ClockGuid}\ClockCreateParams */ - RtlAppendUnicodeToString(&Name, L"\\"); RtlAppendUnicodeToString(&Name, ObjectType); RtlAppendUnicodeToString(&Name, L"\\"); /* append create parameters */ diff --git a/reactos/drivers/wdm/audio/sysaudio/pin.c b/reactos/drivers/wdm/audio/sysaudio/pin.c index eb5ee6177e0..0a665bed4f8 100644 --- a/reactos/drivers/wdm/audio/sysaudio/pin.c +++ b/reactos/drivers/wdm/audio/sysaudio/pin.c @@ -398,7 +398,7 @@ GetConnectRequest( IoStack = IoGetCurrentIrpStackLocation(Irp); /* get object class length */ - ObjectLength = (wcslen(KSSTRING_Pin) + 2) * sizeof(WCHAR); + ObjectLength = (wcslen(KSSTRING_Pin) + 1) * sizeof(WCHAR); /* check for minium length requirement */ if (ObjectLength + sizeof(KSPIN_CONNECT) > IoStack->FileObject->FileName.MaximumLength) -- 2.17.1