Index: boot/bootdata/packages/reactos.dff.in =================================================================== --- boot/bootdata/packages/reactos.dff.in (revision 66600) +++ boot/bootdata/packages/reactos.dff.in (working copy) @@ -110,3 +110,4 @@ "modules/optional/gnutls/libp11-kit-0.dll" 53 optional "modules/optional/gnutls/libwinpthread-1.dll" 53 optional "modules/optional/gnutls/zlib1.dll" 53 optional +"modules/optional/devcon.exe" 1 optional Index: dll/cpl/mmsys/mmsys.c =================================================================== --- dll/cpl/mmsys/mmsys.c (revision 66606) +++ dll/cpl/mmsys/mmsys.c (working copy) @@ -544,7 +544,7 @@ } wcscpy(pBuffer, L"inf\\machine.inf"); - InstallSoftwareBusPnpEnumerator(szBuffer, L"ROOT\\SWENUM"); + InstallSoftwareBusPnpEnumerator(szBuffer, L"ROOT\\SWENUM\0"); } hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT); Index: dll/cpl/mmsys/volume.c =================================================================== --- dll/cpl/mmsys/volume.c (revision 66600) +++ dll/cpl/mmsys/volume.c (working copy) @@ -9,6 +9,8 @@ #include "mmsys.h" +#include + #include #define VOLUME_DIVIDER 0xFFF @@ -237,13 +239,13 @@ SendDlgItemMessage(hwndDlg, IDC_MUTE_ICON, STM_SETIMAGE, IMAGE_ICON, (LPARAM)pGlobalData->hIconMuted); return; } - + DPRINT1("mixerOpen\n"); if (mixerOpen(&pGlobalData->hMixer, 0, PtrToUlong(hwndDlg), 0, MIXER_OBJECTF_MIXER | CALLBACK_WINDOW) != MMSYSERR_NOERROR) { MessageBox(hwndDlg, _T("Cannot open mixer"), NULL, MB_OK); return; } - + DPRINT1("mixerGetDevCaps\n"); ZeroMemory(&mxc, sizeof(MIXERCAPS)); if (mixerGetDevCaps(PtrToUint(pGlobalData->hMixer), &mxc, sizeof(MIXERCAPS)) != MMSYSERR_NOERROR) { @@ -250,6 +252,7 @@ MessageBox(hwndDlg, _T("mixerGetDevCaps failed"), NULL, MB_OK); return; } + DPRINT1("mixerGetMuteControl\n"); GetMuteControl(pGlobalData); GetMuteState(pGlobalData); @@ -263,6 +266,7 @@ SendDlgItemMessage(hwndDlg, IDC_MUTE_CHECKBOX, BM_SETCHECK, (WPARAM)BST_UNCHECKED, (LPARAM)0); SendDlgItemMessage(hwndDlg, IDC_MUTE_ICON, STM_SETIMAGE, IMAGE_ICON, (LPARAM)pGlobalData->hIconUnMuted); } + DPRINT1("mixerGetVolumeControl\n"); GetVolumeControl(pGlobalData); GetVolumeValue(pGlobalData); Index: dll/win32/wdmaud.drv/legacy.c =================================================================== --- dll/win32/wdmaud.drv/legacy.c (revision 66600) +++ dll/win32/wdmaud.drv/legacy.c (working copy) @@ -255,6 +255,63 @@ IN PSOUND_DEVICE SoundDevice, OUT PVOID *Handle) { +#if 1 + HDEVINFO hDevInfo; + SP_DEVICE_INTERFACE_DATA DeviceInterfaceData; + GUID SWBusGuid = {STATIC_KSCATEGORY_WDMAUD}; + PSP_DEVICE_INTERFACE_DETAIL_DATA_W DeviceInterfaceDetailData; + + if ( KernelHandle == INVALID_HANDLE_VALUE ) + { + hDevInfo = SetupDiGetClassDevsW(&SWBusGuid, NULL, NULL, DIGCF_DEVICEINTERFACE| DIGCF_PRESENT); + if (!hDevInfo) + { + // failed + return MMSYSERR_ERROR; + } + + DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); + if (!SetupDiEnumDeviceInterfaces(hDevInfo, NULL, &SWBusGuid, 0, &DeviceInterfaceData)) + { + // failed + SetupDiDestroyDeviceInfoList(hDevInfo); + return MMSYSERR_ERROR; + } + + DeviceInterfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA_W)HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR) + sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W)); + if (!DeviceInterfaceDetailData) + { + // failed + SetupDiDestroyDeviceInfoList(hDevInfo); + return MMSYSERR_ERROR; + } + + DeviceInterfaceDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W); + if (!SetupDiGetDeviceInterfaceDetailW(hDevInfo, &DeviceInterfaceData, DeviceInterfaceDetailData,MAX_PATH * sizeof(WCHAR) + sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W), NULL, NULL)) + { + // failed + HeapFree(GetProcessHeap(), 0, DeviceInterfaceDetailData); + SetupDiDestroyDeviceInfoList(hDevInfo); + return MMSYSERR_ERROR; + } + SND_TRACE(L"Opening wdmaud device '%s'\n",DeviceInterfaceDetailData->DevicePath); + KernelHandle = CreateFileW(DeviceInterfaceDetailData->DevicePath, + GENERIC_READ | GENERIC_WRITE, + 0, + NULL, + OPEN_EXISTING, + FILE_FLAG_OVERLAPPED, + NULL); + } + + HeapFree(GetProcessHeap(), 0, DeviceInterfaceDetailData); + SetupDiDestroyDeviceInfoList(hDevInfo); + if ( KernelHandle == INVALID_HANDLE_VALUE ) + return MMSYSERR_ERROR; + + ++ OpenCount; + return MMSYSERR_NOERROR; +#else /* Only open this if it's not already open */ if ( KernelHandle == INVALID_HANDLE_VALUE ) { @@ -274,6 +331,7 @@ ++ OpenCount; return MMSYSERR_NOERROR; +#endif } MMRESULT Index: dll/win32/wdmaud.drv/wdmaud.h =================================================================== --- dll/win32/wdmaud.drv/wdmaud.h (revision 66600) +++ dll/win32/wdmaud.drv/wdmaud.h (working copy) @@ -8,6 +8,9 @@ #define COM_NO_WINDOWS_H #include +#include +#include + #include #include #include @@ -14,6 +17,7 @@ #include #include #include +#include BOOL WdmAudInitUserModeMixer(VOID); Index: drivers/ksfilter/ks/misc.c =================================================================== --- drivers/ksfilter/ks/misc.c (revision 66600) +++ drivers/ksfilter/ks/misc.c (working copy) @@ -11,6 +11,8 @@ #define NDEBUG #include +#define TAG_KS 'ssKK' + VOID CompleteRequest( PIRP Irp, @@ -29,7 +31,7 @@ IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes) { - PVOID Item = ExAllocatePool(PoolType, NumberOfBytes); + PVOID Item = ExAllocatePoolWithTag(PoolType, NumberOfBytes, TAG_KS); if (!Item) return Item; Index: drivers/ksfilter/ks/swenum.c =================================================================== --- drivers/ksfilter/ks/swenum.c (revision 66600) +++ drivers/ksfilter/ks/swenum.c (working copy) @@ -98,7 +98,7 @@ RtlInitUnicodeString(&ReferenceString, DeviceEntry->DeviceName); /* register device interface */ - Status = IoRegisterDeviceInterface(BusDeviceExtension->PhysicalDeviceObject, &DeviceEntry->DeviceGuid, NULL, &BusInstanceEntry->SymbolicLink); + Status = IoRegisterDeviceInterface(BusDeviceExtension->PhysicalDeviceObject, &BusInstanceEntry->InterfaceGuid, &ReferenceString, &BusInstanceEntry->SymbolicLink); /* check for success */ if (!NT_SUCCESS(Status)) @@ -255,8 +255,8 @@ IN PHANDLE hKey, IN PBUS_ENUM_DEVICE_EXTENSION BusDeviceExtension, IN PBUS_DEVICE_ENTRY DeviceEntry, - IN LPWSTR ReferenceString, - IN LPWSTR InterfaceString) + IN LPWSTR InterfaceString, + IN LPWSTR ReferenceString) { GUID InterfaceGUID; NTSTATUS Status; @@ -700,7 +700,7 @@ /* construct buffer */ swprintf(Buffer, L"%s\\%s", DeviceEntry->PDODeviceName, DeviceEntry->Instance); - ExFreePool(IoStack->FileObject->FileName.Buffer); + //ExFreePool(IoStack->FileObject->FileName.Buffer); /* store new file name */ RtlInitUnicodeString(&IoStack->FileObject->FileName, Buffer); @@ -906,7 +906,7 @@ ASSERT(DeviceEntry->Instance); /* calculate length */ - Length = wcslen(DeviceEntry->Instance) + 1; + Length = wcslen(DeviceEntry->Instance) + 2; /* allocate buffer */ Name = AllocateItem(PagedPool, Length * sizeof(WCHAR)); @@ -945,11 +945,11 @@ Length = wcslen(BusDeviceExtension->BusIdentifier); Length += wcslen(DeviceEntry->BusId); - /* extra length for '\\' and zero byte */ - Length += 2; + /* extra length for '\\' and 2 zero bytes */ + Length += 4; /* allocate buffer */ - Name = ExAllocatePool(PagedPool, Length * sizeof(WCHAR)); + Name = AllocateItem(PagedPool, Length * sizeof(WCHAR)); if (!Name) { /* failed to allocate buffer */ @@ -957,7 +957,10 @@ } /* construct id */ - swprintf(Name, L"%s\\%s", BusDeviceExtension->BusIdentifier, DeviceEntry->BusId); + wcscpy(Name, BusDeviceExtension->BusIdentifier); + wcscat(Name, L"\\"); + wcscat(Name, DeviceEntry->BusId); + //swprintf(Name, L"%s\\%s", BusDeviceExtension->BusIdentifier, DeviceEntry->BusId); /* store result */ Irp->IoStatus.Information = (ULONG_PTR)Name; @@ -1205,7 +1208,7 @@ if (Diff.QuadPart > Int32x32To64(15000, 10000)) { - DPRINT1("DeviceID %S Instance %S TimeCreated %I64u Now %I64u Diff %I64u hung\n", DeviceEntry->DeviceName, DeviceEntry->Instance, DeviceEntry->TimeCreated.QuadPart, Time.QuadPart, Diff.QuadPart); + //DPRINT1("DeviceID %S Instance %S TimeCreated %I64u Now %I64u Diff %I64u hung\n", DeviceEntry->DeviceName, DeviceEntry->Instance, DeviceEntry->TimeCreated.QuadPart, Time.QuadPart, Diff.QuadPart); /* release spin lock */ KeReleaseSpinLock(&BusDeviceExtension->Lock, OldLevel); @@ -1509,6 +1512,9 @@ UNICODE_STRING ServiceKeyPath = RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Services\\"); PBUS_ENUM_DEVICE_EXTENSION BusDeviceExtension; PDEV_EXTENSION DeviceExtension; + PBUS_DEVICE_ENTRY DeviceEntry; + PLIST_ENTRY Entry; + KIRQL OldLevel; DPRINT1("KsCreateBusEnumObject %S BusDeviceObject %p\n", ServiceRelativePath, BusDeviceObject); @@ -1676,7 +1682,41 @@ FreeItem(BusDeviceExtension->ServicePath.Buffer); FreeItem(BusDeviceExtension); } +#if 1 + /* acquire device entry lock */ + KeAcquireSpinLock(&BusDeviceExtension->Lock, &OldLevel); + /* now iterate all device entries */ + Entry = BusDeviceExtension->Common.Entry.Flink; + while(Entry != &BusDeviceExtension->Common.Entry) + { + /* get device entry */ + DeviceEntry = (PBUS_DEVICE_ENTRY)CONTAINING_RECORD(Entry, BUS_DEVICE_ENTRY, Entry); + if (!DeviceEntry->PDO) + { + /* release device entry lock */ + KeReleaseSpinLock(&BusDeviceExtension->Lock, OldLevel); + + /* create pdo */ + Status = KspCreatePDO(BusDeviceExtension, DeviceEntry, &DeviceEntry->PDO); + + /* acquire device entry lock */ + KeAcquireSpinLock(&BusDeviceExtension->Lock, &OldLevel); + + /* done */ + break; + } + /* move to next entry */ + Entry = Entry->Flink; + } + + /* release device entry lock */ + KeReleaseSpinLock(&BusDeviceExtension->Lock, OldLevel); + + + /* invalidate device relations */ + IoInvalidateDeviceRelations(BusDeviceExtension->PhysicalDeviceObject, BusRelations); +#endif DPRINT("KsCreateBusEnumObject Status %x\n", Status); /* done */ return Status; @@ -1908,7 +1948,8 @@ Status = KspDoReparseForIrp(Irp, DeviceEntry); DPRINT("REPARSE Irp %p '%wZ'\n", Irp, &IoStack->FileObject->FileName); - Irp->IoStatus.Status = Status; + Irp->IoStatus.Status = Status; + Irp->IoStatus.Information = IO_REPARSE; return Status; } @@ -2051,12 +2092,9 @@ /* set state no notstarted */ DeviceEntry->DeviceState = NotStarted; - /* time to create PDO */ - KspCreatePDO(BusDeviceExtension, DeviceEntry, &DeviceEntry->PDO); + /* complete pending irps */ + KspCompletePendingIrps(DeviceEntry, STATUS_DEVICE_REMOVED); - /* invalidate device relations */ - IoInvalidateDeviceRelations(BusDeviceExtension->PhysicalDeviceObject, BusRelations); - /* done */ Status = STATUS_SUCCESS; } Index: drivers/ksfilter/swenum/swenum.c =================================================================== --- drivers/ksfilter/swenum/swenum.c (revision 66600) +++ drivers/ksfilter/swenum/swenum.c (working copy) @@ -110,7 +110,7 @@ Status = KsServiceBusEnumPnpRequest(DeviceObject, Irp); /* check if the request was for a pdo */ - if (!ChildDevice) + if (ChildDevice) { if (Status != STATUS_NOT_SUPPORTED) { @@ -144,9 +144,9 @@ if (!NT_SUCCESS(Status)) { /* failed to get pnp object */ - Irp->IoStatus.Status = Status; + Irp->IoStatus.Status = STATUS_NOT_SUPPORTED; IoCompleteRequest(Irp, IO_NO_INCREMENT); - return Status; + return STATUS_NOT_SUPPORTED; } /* sanity check */ Index: drivers/wdm/audio/legacy/wdmaud/control.c =================================================================== --- drivers/wdm/audio/legacy/wdmaud/control.c (revision 66600) +++ drivers/wdm/audio/legacy/wdmaud/control.c (working copy) @@ -9,7 +9,7 @@ #include "wdmaud.h" -#define NDEBUG +#define YDEBUG #include const GUID KSPROPSETID_Sysaudio = {0xCBE3FAA0L, 0xCC75, 0x11D0, {0xB4, 0x65, 0x00, 0x00, 0x1A, 0x18, 0x18, 0xE6}}; @@ -49,10 +49,7 @@ { ULONG Result = 0; NTSTATUS Status = STATUS_SUCCESS; - //PWDMAUD_DEVICE_EXTENSION DeviceExtension; - //DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - if (DeviceInfo->DeviceType == MIXER_DEVICE_TYPE) { Result = WdmAudGetMixerDeviceCount(); @@ -78,7 +75,7 @@ /* store result count */ DeviceInfo->DeviceCount = Result; - DPRINT("WdmAudControlDeviceType Status %x Devices %u\n", Status, DeviceInfo->DeviceCount); + DPRINT1("WdmAudControlDeviceType Status %x Devices %u\n", Status, DeviceInfo->DeviceCount); return SetIrpIoStatus(Irp, STATUS_SUCCESS, sizeof(WDMAUD_DEVICE_INFO)); } @@ -114,7 +111,7 @@ ObDereferenceObject(FileObject); - DPRINT("WdmAudControlDeviceState Status %x\n", Status); + DPRINT1("WdmAudControlDeviceState Status %x\n", Status); return SetIrpIoStatus(Irp, Status, sizeof(WDMAUD_DEVICE_INFO)); } @@ -231,14 +228,10 @@ IN PIRP Irp, IN PWDMAUD_DEVICE_INFO DeviceInfo) { - //PWDMAUD_DEVICE_EXTENSION DeviceExtension; NTSTATUS Status; LPWSTR Device; ULONG Size, Length; - /* get device extension */ - //DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension; - /* get device interface string input length */ Size = DeviceInfo->u.Interface.DeviceInterfaceStringSize; @@ -420,19 +413,11 @@ /* grab next mdl */ Mdl = NextMdl; } - + //IoFreeMdl(Mdl); /* clear mdl list */ - Irp->MdlAddress = NULL; + Irp->MdlAddress = Context->Mdl; - /* check if mdl is locked */ - if (Context->Mdl->MdlFlags & MDL_PAGES_LOCKED) - { - /* unlock pages */ - MmUnlockPages(Context->Mdl); - } - /* now free the mdl */ - IoFreeMdl(Context->Mdl); DPRINT("IoCompletion Irp %p IoStatus %lx Information %lx Length %lu\n", Irp, Irp->IoStatus.Status, Irp->IoStatus.Information, Length); @@ -442,6 +427,9 @@ Irp->IoStatus.Information = 0; } + /* dereference file object */ + ObDereferenceObject(Context->FileObject); + /* free context */ FreeItem(Context); @@ -469,6 +457,7 @@ if (!Context) { /* not enough memory */ + DPRINT1("Failed to allocate completion context\n"); Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES; IoCompleteRequest(Irp, IO_NO_INCREMENT); @@ -502,8 +491,6 @@ /* remove mdladdress as KsProbeStreamIrp will interprete it as an already probed audio buffer */ Irp->MdlAddress = NULL; - /* check for success */ - if (IoStack->MajorFunction == IRP_MJ_WRITE) { /* probe the write stream irp */ @@ -520,6 +507,7 @@ { DPRINT1("KsProbeStreamIrp failed with Status %x Cancel %u\n", Status, Irp->Cancel); Irp->MdlAddress = Mdl; + FreeItem(Context); return SetIrpIoStatus(Irp, Status, 0); } @@ -532,9 +520,14 @@ if (!NT_SUCCESS(Status)) { DPRINT1("Invalid pin handle %p\n", DeviceInfo->hDevice); + Irp->MdlAddress = Mdl; + FreeItem(Context); return SetIrpIoStatus(Irp, Status, 0); } + /* store file object whose reference is released in the completion callback */ + Context->FileObject = FileObject; + /* skip current irp stack location */ IoSkipCurrentIrpStackLocation(Irp); @@ -541,30 +534,16 @@ /* get next stack location */ IoStack = IoGetNextIrpStackLocation(Irp); - if (Read) - { - IoStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_KS_READ_STREAM; - } - else - { - IoStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_KS_WRITE_STREAM; - } - - /* attach file object */ + /* prepare stack location */ IoStack->FileObject = FileObject; IoStack->Parameters.Write.Length = Length; IoStack->MajorFunction = IRP_MJ_WRITE; - + IoStack->Parameters.DeviceIoControl.IoControlCode = (Read ? IOCTL_KS_READ_STREAM : IOCTL_KS_WRITE_STREAM); IoSetCompletionRoutine(Irp, IoCompletion, (PVOID)Context, TRUE, TRUE, TRUE); - /* mark irp as pending */ // IoMarkIrpPending(Irp); /* call the driver */ Status = IoCallDriver(IoGetRelatedDeviceObject(FileObject), Irp); - - /* dereference file object */ - ObDereferenceObject(FileObject); - return Status; } Index: drivers/wdm/audio/legacy/wdmaud/deviface.c =================================================================== --- drivers/wdm/audio/legacy/wdmaud/deviface.c (revision 66600) +++ drivers/wdm/audio/legacy/wdmaud/deviface.c (working copy) @@ -153,17 +153,19 @@ return Status; } - InsertTailList(&DeviceExtension->SysAudioDeviceList, &Entry->Entry); - DeviceExtension->NumSysAudioDevices++; - DPRINT("Opening device %S\n", Entry->SymbolicLink.Buffer); Status = WdmAudOpenSysAudioDevice(Entry->SymbolicLink.Buffer, &hSysAudio); if (!NT_SUCCESS(Status)) { DPRINT1("Failed to open sysaudio %x\n", Status); + FreeItem(Entry->SymbolicLink.Buffer); + FreeItem(Entry); return Status; } + InsertTailList(&DeviceExtension->SysAudioDeviceList, &Entry->Entry); + DeviceExtension->NumSysAudioDevices++; + /* get the file object */ Status = ObReferenceObjectByHandle(hSysAudio, FILE_READ_DATA | FILE_WRITE_DATA, *IoFileObjectType, KernelMode, (PVOID*)&FileObject, NULL); if (!NT_SUCCESS(Status)) @@ -188,6 +190,7 @@ NTSTATUS Status; UNICODE_STRING SymlinkName = RTL_CONSTANT_STRING(L"\\DosDevices\\wdmaud"); UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\wdmaud"); +#if 1 UNICODE_STRING SymbolicLinkName; Status = IoRegisterDeviceInterface(PhysicalDeviceObject, &KSCATEGORY_WDMAUD, NULL, &SymbolicLinkName); @@ -195,10 +198,10 @@ { IoSetDeviceInterfaceState(&SymbolicLinkName, TRUE); RtlFreeUnicodeString(&SymbolicLinkName); - DeviceExtension->DeviceInterfaceSupport = TRUE; + //DeviceExtension->DeviceInterfaceSupport = TRUE; return Status; } - +#else /* failed to register device interface * create a symbolic link instead */ @@ -207,11 +210,10 @@ Status = IoCreateSymbolicLink(&SymlinkName, &DeviceName); if (!NT_SUCCESS(Status)) { - IoDeleteDevice(PhysicalDeviceObject); //FIXME - DPRINT("Failed to create wdmaud symlink!\n"); + DPRINT1("Failed to create wdmaud symlink!\n"); return Status; } - +#endif return Status; } Index: drivers/wdm/audio/legacy/wdmaud/entry.c =================================================================== --- drivers/wdm/audio/legacy/wdmaud/entry.c (revision 66600) +++ drivers/wdm/audio/legacy/wdmaud/entry.c (working copy) @@ -31,6 +31,19 @@ /* get device extension */ DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + + if (DeviceExtension->FileObject == NULL) + { + /* find available sysaudio devices */ + Status = WdmAudOpenSysAudioDevices(DeviceObject, DeviceExtension); + if (!NT_SUCCESS(Status)) + { + DPRINT1("WdmAudOpenSysAudioDevices failed with %x\n", Status); + return; + } + } + + /* get device count */ DeviceCount = GetSysAudioDeviceCount(DeviceObject); @@ -61,6 +74,7 @@ IN PVOID Context) { PWDMAUD_DEVICE_EXTENSION DeviceExtension; + NTSTATUS Status; /* get device extension */ DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension; @@ -74,8 +88,9 @@ NTSTATUS NTAPI -WdmAudInstallDevice( - IN PDRIVER_OBJECT DriverObject) +WdmaudAddDevice( + IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT PhysicalDeviceObject) { UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\wdmaud"); UNICODE_STRING SymlinkName = RTL_CONSTANT_STRING(L"\\DosDevices\\wdmaud"); @@ -83,11 +98,11 @@ NTSTATUS Status; PWDMAUD_DEVICE_EXTENSION DeviceExtension; - DPRINT("WdmAudInstallDevice called\n"); + DPRINT1("WdmaudAddDevice called\n"); Status = IoCreateDevice(DriverObject, sizeof(WDMAUD_DEVICE_EXTENSION), - &DeviceName, + NULL, FILE_DEVICE_KS, 0, FALSE, @@ -113,7 +128,7 @@ } /* register device interfaces */ - Status = WdmAudRegisterDeviceInterface(DeviceObject, DeviceExtension); + Status = WdmAudRegisterDeviceInterface(PhysicalDeviceObject, DeviceExtension); if (!NT_SUCCESS(Status)) { DPRINT1("WdmRegisterDeviceInterface failed with %x\n", Status); @@ -136,26 +151,20 @@ /* initialize timer */ IoInitializeTimer(DeviceObject, WdmAudTimerRoutine, (PVOID)WdmAudTimerRoutine); - /* find available sysaudio devices */ - Status = WdmAudOpenSysAudioDevices(DeviceObject, DeviceExtension); - if (!NT_SUCCESS(Status)) - { - DPRINT1("WdmAudOpenSysAudioDevices failed with %x\n", Status); - IoDeleteSymbolicLink(&SymlinkName); - IoDeleteDevice(DeviceObject); - return Status; - } - /* allocate ks device header */ Status = KsAllocateDeviceHeader(&DeviceExtension->DeviceHeader, 0, NULL); if (!NT_SUCCESS(Status)) { DPRINT1("KsAllocateDeviceHeader failed with %x\n", Status); - IoDeleteSymbolicLink(&SymlinkName); IoDeleteDevice(DeviceObject); return Status; } + /* attach to device stack */ + DeviceExtension->NextDeviceObject = IoAttachDeviceToDeviceStack(DeviceObject, PhysicalDeviceObject); + KsSetDevicePnpAndBaseObject(DeviceExtension->DeviceHeader, DeviceExtension->NextDeviceObject, DeviceObject); + + /* start the timer */ IoStartTimer(DeviceObject); @@ -203,10 +212,10 @@ NTSTATUS Status; PIO_STACK_LOCATION IoStack; PWDMAUD_CLIENT pClient; - //PWDMAUD_DEVICE_EXTENSION DeviceExtension; + PWDMAUD_DEVICE_EXTENSION DeviceExtension; /* get device extension */ - //DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + DeviceExtension = (PWDMAUD_DEVICE_EXTENSION)DeviceObject->DeviceExtension; #if KS_IMPLEMENTED Status = KsReferenceSoftwareBusObject((KSDEVICE_HEADER)DeviceObject->DeviceExtension); @@ -217,6 +226,13 @@ } #endif + if (DeviceExtension->FileObject == NULL) + { + /* initialize */ + WdmAudInitWorkerRoutine(DeviceObject, NULL); + } + + Status = WdmAudOpenSysaudio(DeviceObject, &pClient); if (!NT_SUCCESS(Status)) { @@ -232,6 +248,8 @@ IoStack = IoGetCurrentIrpStackLocation(Irp); ASSERT(IoStack->FileObject); + DPRINT1("WdmAudCreate Irp %p FileName %wZ\n", Irp, &IoStack->FileObject->FileName); + /* store client context in file object */ IoStack->FileObject->FsContext = pClient; Status = STATUS_SUCCESS; @@ -354,6 +372,7 @@ Driver->MajorFunction[IRP_MJ_WRITE] = WdmAudReadWrite; Driver->MajorFunction[IRP_MJ_READ] = WdmAudReadWrite; Driver->MajorFunction[IRP_MJ_POWER] = KsDefaultDispatchPower; + Driver->DriverExtension->AddDevice = WdmaudAddDevice; - return WdmAudInstallDevice(Driver); + return STATUS_SUCCESS; } Index: drivers/wdm/audio/legacy/wdmaud/sup.c =================================================================== --- drivers/wdm/audio/legacy/wdmaud/sup.c (revision 66600) +++ drivers/wdm/audio/legacy/wdmaud/sup.c (working copy) @@ -14,12 +14,14 @@ #define NDEBUG #include +#define TAG_WDMAUD 'DMDW' + PVOID AllocateItem( IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes) { - PVOID Item = ExAllocatePool(PoolType, NumberOfBytes); + PVOID Item = ExAllocatePoolWithTag(PoolType, NumberOfBytes, TAG_WDMAUD); if (!Item) return Item; Index: drivers/wdm/audio/legacy/wdmaud/wdmaud.h =================================================================== --- drivers/wdm/audio/legacy/wdmaud/wdmaud.h (revision 66600) +++ drivers/wdm/audio/legacy/wdmaud/wdmaud.h (working copy) @@ -11,6 +11,7 @@ PMDL Mdl; ULONG Length; ULONG Function; + PFILE_OBJECT FileObject; }WDMAUD_COMPLETION_CONTEXT, *PWDMAUD_COMPLETION_CONTEXT; @@ -66,6 +67,7 @@ KEVENT InitializationCompletionEvent; ULONG WorkItemActive; + PDEVICE_OBJECT NextDeviceObject; }WDMAUD_DEVICE_EXTENSION, *PWDMAUD_DEVICE_EXTENSION; typedef struct Index: lib/drivers/sound/mmixer/controls.c =================================================================== --- lib/drivers/sound/mmixer/controls.c (revision 66600) +++ lib/drivers/sound/mmixer/controls.c (working copy) @@ -1358,7 +1358,10 @@ /* sanity checks */ ASSERT(PinsCount != 0); - ASSERT(PinsCount == 1); + if (PinsCount != 1) + { + DPRINT1("MMixerHandlePhysicalConnection Expected 1 pin but got %lu\n", PinsCount); + } /* create destination line */ Status = MMixerBuildMixerDestinationLine(MixerContext, MixerInfo, MixerData->hDevice, Pins[0], bInput); Index: media/inf/wdmaudio.inf =================================================================== --- media/inf/wdmaudio.inf (revision 66600) +++ media/inf/wdmaudio.inf (working copy) @@ -25,8 +25,11 @@ ExcludeFromSelect = WDMAUDIO_CopyFilesOnlyId [GenericMfg] +;%WDM_KMIXER.DeviceDesc% = WDM_KMIXER, SW\{B7EAFDC0-A680-11D0-96D8-00AA0051E51D} +;%WDM_SYSAUDIO.DeviceDesc% = WDM_SYSAUDIO, SW\{A7C7A5B0-5AF3-11D1-9CED-00A024BF0407} %WDM_WDMAUD.DeviceDesc% = WDM_WDMAUD, SW\{CD171DE3-69E5-11D2-B56D-0000F8754380} -%WDM_DRMKAUD.DeviceDesc% = WDM_DRMKAUD, SW\{EEC12DB6-AD9C-4168-8658-B03DAEF417FE} +;%WDM_DRMKAUD.DeviceDesc% = WDM_DRMKAUD, SW\{EEC12DB6-AD9C-4168-8658-B03DAEF417FE} + %WDMAUDIO_CopyFilesOnlyId.DeviceDesc% = WDMAUDIO.CopyFilesOnly, WDMAUDIO_CopyFilesOnlyId [WDMAUDIO.CopyFilesOnly] @@ -43,12 +46,70 @@ CopyFiles = WDM.CopyFiles [DeviceRegistration] +; Kmixer swenum install +;HKLM,%RunOnce%,"WDM_KMIXER0",,"rundll32.exe streamci.dll,StreamingDeviceSetup %WDM_KMIXER.DeviceId%,%KSNAME_Filter%,%KSCATEGORY_MIXER%,%17%\WDMAUDIO.inf,WDM_KMIXER.Interface.Install" +;HKLM,%RunOnce%,"WDM_KMIXER1",,"rundll32.exe streamci.dll,StreamingDeviceSetup %WDM_KMIXER.DeviceId%,%KSNAME_Filter%,%KSCATEGORY_AUDIO%,%17%\WDMAUDIO.inf,WDM_KMIXER.Interface.Install" + +; Sysaudio swenum install +;HKLM,%RunOnce%,"WDM_SYSAUDIO",,"rundll32.exe streamci.dll,StreamingDeviceSetup %WDM_SYSAUDIO.DeviceId%,%KSNAME_Filter%,%KSCATEGORY_SYSAUDIO%,%17%\WDMAUDIO.inf,WDM_SYSAUDIO.Interface.Install" + ; WDMAud install HKLM,%RunOnce%,"WDM_WDMAUD",,"rundll32.exe streamci.dll,StreamingDeviceSetup %WDM_WDMAUD.DeviceId%,%KSNAME_Filter%,%KSCATEGORY_WDMAUD%,%17%\WDMAUDIO.inf,WDM_WDMAUD.Interface.Install" + ; DRMKAUD install -HKLM,%RunOnce%,"WDM_DRMKAUD",,"rundll32.exe streamci,StreamingDeviceSetup %WDM_DRMKAUD.DeviceId%,%KSNAME_DRMKAUD%,%KSCATEGORY_DRM_DESCRAMBLE%,%17%\WDMAUDIO.inf,WDM_DRMKAUD.Interface.Install" +;HKLM,%RunOnce%,"WDM_DRMKAUD",,"rundll32.exe streamci,StreamingDeviceSetup %WDM_DRMKAUD.DeviceId%,%KSNAME_DRMKAUD%,%KSCATEGORY_DRM_DESCRAMBLE%,%17%\WDMAUDIO.inf,WDM_DRMKAUD.Interface.Install" ;-------------------------------------------------------------------------------- +; SysAudio Install +[WDM_SYSAUDIO.Interface.Install] +AddReg=WDM_SYSAUDIO.Interface.AddReg + +[WDM_SYSAUDIO.Interface.AddReg] +HKR,,CLSID,,%Proxy.CLSID% +HKR,,FriendlyName,,%WDM_SYSAUDIO.FriendlyName% + +[WDM_SYSAUDIO] +CopyFiles = WDM_SYSAUDIO.CopyFiles + + +[WDM_SYSAUDIO.CopyFiles] +sysaudio.sys + +[WDM_SYSAUDIO.Services] +AddService = sysaudio,0x00000002, sysaudio_Service_Inst + +[sysaudio_Service_Inst] +DisplayName = %sysaudio.SvcDesc% +ServiceType = 1 ; SERVICE_KERNEL_DRIVER +StartType = 3 ; SERVICE_DEMAND_START +ErrorControl = 1 ; SERVICE_ERROR_NORMAL +ServiceBinary = %10%\system32\drivers\sysaudio.sys + +;-------------------------------------------------------------------------------- +; KMixer Install +[WDM_KMIXER.Interface.Install] +AddReg=WDM_KMIXER.Interface.AddReg + +[WDM_KMIXER.Interface.AddReg] +HKR,,CLSID,,%Proxy.CLSID% +HKR,,FriendlyName,,%WDM_KMIXER.FriendlyName% + +[WDM_KMIXER] +CopyFiles = WDM_KMIXER.CopyFiles + +[WDM_KMIXER.CopyFiles] +kmixer.sys + +[WDM_KMIXER.Services] +AddService = kmixer, 0x00000002, kmixer_Service_Inst + +[kmixer_Service_Inst] +DisplayName = %kmixer.SvcDesc% +ServiceType = 1 ; SERVICE_KERNEL_DRIVER +StartType = 3 ; SERVICE_DEMAND_START +ErrorControl = 1 ; SERVICE_ERROR_NORMAL +ServiceBinary = %10%\system32\drivers\kmixer.sys +;-------------------------------------------------------------------------------- ; WDMAUD Install [WDM_WDMAUD.Interface.Install] AddReg=WDM_WDMAUD.Interface.AddReg @@ -119,6 +180,8 @@ Proxy.CLSID = "{17CCA71B-ECD7-11D0-B908-00A0C9223196}" KSNAME_Filter = "{9B365890-165F-11D0-A195-0020AFD156E4}" KSNAME_DRMKAUD = "{ABD61E00-9350-47e2-A632-4438B90C6641}" +WDM_SYSAUDIO.DeviceId = "{A7C7A5B0-5AF3-11D1-9CED-00A024BF0407}" +KSCATEGORY_SYSAUDIO = "{A7C7A5B1-5AF3-11D1-9CED-00A024BF0407}" WDM_DRMKAUD.DeviceId = "{EEC12DB6-AD9C-4168-8658-B03DAEF417FE}" KSCATEGORY_DRM_DESCRAMBLE = "{FFBB6E3F-CCFE-4D84-90D9-421418B03A8E}" KSCATEGORY_DATATRANSFORM = "{2EB07EA0-7E70-11D0-A5D6-28DB04C10000}" @@ -129,6 +192,12 @@ ;Localizable +WDM_KMIXER.DeviceDesc = "ReactOS Wave Audio Mixer" +WDM_KMIXER.FriendlyName = "ReactOS Wave Audio Mixer" +kmixer.SvcDesc = "ReactOS Wave Audio Mixer" +WDM_SYSAUDIO.DeviceDesc = "ReactOS System audio device" +WDM_SYSAUDIO.FriendlyName = "ReactOS System audio device" +sysaudio.SvcDesc = "ReactOS System audio device" WDM_DRMKAUD.DeviceDesc = "ReactOS Trusted Audio Drivers" WDM_DRMKAUD.FriendlyName = "ReactOS Trusted Audio Drivers" drmkaud.SvcDesc = "ReactOS Trusted Audio Drivers" Index: ntoskrnl/io/iomgr/deviface.c =================================================================== --- ntoskrnl/io/iomgr/deviface.c (revision 66600) +++ ntoskrnl/io/iomgr/deviface.c (working copy) @@ -103,7 +103,7 @@ &ObjectAttributes, 0, NULL, - REG_OPTION_NON_VOLATILE, + REG_OPTION_VOLATILE, NULL); ZwClose(ClassesKey); if (!NT_SUCCESS(Status)) @@ -154,11 +154,11 @@ &ObjectAttributes, 0, NULL, - REG_OPTION_NON_VOLATILE, + REG_OPTION_VOLATILE, NULL); if (!NT_SUCCESS(Status)) { - DPRINT1("Failed to open %wZ%wZ\\%wZ\n", &BaseKeyU, &GuidString, &SubKeyName); + DPRINT1("Failed to open %wZ%wZ\\%wZ Status %x\n", &BaseKeyU, &GuidString, &SubKeyName, Status); goto cleanup; } @@ -172,7 +172,7 @@ &ObjectAttributes, 0, NULL, - REG_OPTION_NON_VOLATILE, + REG_OPTION_VOLATILE, NULL); if (!NT_SUCCESS(Status)) { Index: ntoskrnl/ob/oblink.c =================================================================== --- ntoskrnl/ob/oblink.c (revision 66600) +++ ntoskrnl/ob/oblink.c (working copy) @@ -452,7 +452,7 @@ MaximumLength = LengthUsed + sizeof(WCHAR); NewTargetPath = ExAllocatePoolWithTag(NonPagedPool, MaximumLength, - TAG_SYMLINK_TTARGET); + OB_NAME_TAG); if (!NewTargetPath) return STATUS_INSUFFICIENT_RESOURCES; } else