Author: janderwald Date: Tue Nov 2 09:37:30 2010 New Revision: 49428
URL: http://svn.reactos.org/svn/reactos?rev=49428&view=rev Log: [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
Modified: trunk/reactos/dll/directx/ksuser/ksuser.c trunk/reactos/drivers/ksfilter/ks/irp.c trunk/reactos/drivers/ksfilter/ks/misc.c trunk/reactos/drivers/ksfilter/ks/topology.c trunk/reactos/drivers/wdm/audio/sysaudio/pin.c
Modified: trunk/reactos/dll/directx/ksuser/ksuser.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ksuser/ksuser.c... ============================================================================== --- trunk/reactos/dll/directx/ksuser/ksuser.c [iso-8859-1] (original) +++ trunk/reactos/dll/directx/ksuser/ksuser.c [iso-8859-1] Tue Nov 2 09:37:30 2010 @@ -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 <debug.h>
-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 @@ OBJECT_ATTRIBUTES ObjectAttributes; IO_STATUS_BLOCK IoStatusBlock;
- Length = wcslen(IID); - - TotalSize = (Length * sizeof(WCHAR)) + BufferSize + 4 * sizeof(WCHAR); - + /* get length of object type */ + Length = wcslen(ObjectType); + + /* get length for request */ + TotalSize = (Length * sizeof(WCHAR)) + BufferSize; + + /* 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'; - - RtlInitUnicodeString(&ObjectName, pStr); + { + /* out of memory */ + return ERROR_NOT_ENOUGH_MEMORY; + } + + /* copy object type */ + wcscpy(pStr, ObjectType); + + /* 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; }
Modified: trunk/reactos/drivers/ksfilter/ks/irp.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/irp.c?r... ============================================================================== --- trunk/reactos/drivers/ksfilter/ks/irp.c [iso-8859-1] (original) +++ trunk/reactos/drivers/ksfilter/ks/irp.c [iso-8859-1] Tue Nov 2 09:37:30 2010 @@ -1739,22 +1739,24 @@ PLIST_ENTRY Entry; PCREATE_ITEM_ENTRY CreateItemEntry; UNICODE_STRING RefString; - - -#ifndef MS_KSUSER - /* remove '' slash */ - Buffer++; - BufferSize -= sizeof(WCHAR); -#endif - - if (!wcschr(Buffer, L'\')) - { - RtlInitUnicodeString(&RefString, Buffer); + LPWSTR pStr; + + /* get terminator */ + pStr = wcschr(Buffer, L'\'); + + /* sanity check */ + ASSERT(pStr != NULL); + + if (pStr == 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 */
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] Tue Nov 2 09:37:30 2010 @@ -95,7 +95,7 @@ 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)
Modified: trunk/reactos/drivers/ksfilter/ks/topology.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/topolog... ============================================================================== --- trunk/reactos/drivers/ksfilter/ks/topology.c [iso-8859-1] (original) +++ trunk/reactos/drivers/ksfilter/ks/topology.c [iso-8859-1] Tue Nov 2 09:37:30 2010 @@ -27,7 +27,7 @@
/* 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 @@ * 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 */
Modified: trunk/reactos/drivers/wdm/audio/sysaudio/pin.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/sysaudio/... ============================================================================== --- trunk/reactos/drivers/wdm/audio/sysaudio/pin.c [iso-8859-1] (original) +++ trunk/reactos/drivers/wdm/audio/sysaudio/pin.c [iso-8859-1] Tue Nov 2 09:37:30 2010 @@ -398,7 +398,7 @@ 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)