From 54a98a7e6af65ebc3a8ec92c7c09d94d0b44a6fd Mon Sep 17 00:00:00 2001 From: Julia D'Zmura <78620953+judzmura@users.noreply.github.com> Date: Thu, 2 Feb 2023 15:53:08 -0800 Subject: Updates to make Sysvad and SimpleAudioSample Windows Drivers Compliant (#845) Updating sysvad and simpleaudiosample drivers. --- audio/simpleaudiosample/Source/Main/adapter.cpp | 69 ++++++++++++------------- 1 file changed, 34 insertions(+), 35 deletions(-) (limited to 'audio/simpleaudiosample/Source/Main/adapter.cpp') diff --git a/audio/simpleaudiosample/Source/Main/adapter.cpp b/audio/simpleaudiosample/Source/Main/adapter.cpp index 105f7fde..bbe23f26 100644 --- a/audio/simpleaudiosample/Source/Main/adapter.cpp +++ b/audio/simpleaudiosample/Source/Main/adapter.cpp @@ -45,10 +45,10 @@ _Dispatch_type_(IRP_MJ_PNP) DRIVER_DISPATCH PnpHandler; // -// Rendering streams are saved to a file by default. Use the registry value -// DoNotCreateDataFiles (DWORD) > 0 to override this default. +// Rendering streams are not saved to a file by default. Use the registry value +// DoNotCreateDataFiles (DWORD) = 0 to override this default. // -DWORD g_DoNotCreateDataFiles = 0; // default is off. +DWORD g_DoNotCreateDataFiles = 1; // default is off. DWORD g_DisableToneGenerator = 0; // default is to generate tones. UNICODE_STRING g_RegistryPath; // This is used to store the registry settings path for the driver @@ -192,7 +192,8 @@ Returns: { NTSTATUS ntStatus; - UNICODE_STRING parametersPath; + PDRIVER_OBJECT DriverObject; + HANDLE DriverKey; RTL_QUERY_REGISTRY_TABLE paramTable[] = { // QueryRoutine Flags Name EntryContext DefaultType DefaultData DefaultLength { NULL, RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_TYPECHECK, L"DoNotCreateDataFiles", &g_DoNotCreateDataFiles, (REG_DWORD << RTL_QUERY_REGISTRY_TYPECHECK_SHIFT) | REG_DWORD, &g_DoNotCreateDataFiles, sizeof(ULONG)}, @@ -202,29 +203,27 @@ Returns: DPF(D_TERSE, ("[GetRegistrySettings]")); - PAGED_CODE(); - - RtlInitUnicodeString(¶metersPath, NULL); + PAGED_CODE(); + UNREFERENCED_PARAMETER(RegistryPath); - parametersPath.MaximumLength = - RegistryPath->Length + sizeof(L"\\Parameters") + sizeof(WCHAR); + DriverObject = WdfDriverWdmGetDriverObject(WdfGetDriver()); + DriverKey = NULL; + ntStatus = IoOpenDriverRegistryKey(DriverObject, + DriverRegKeyParameters, + KEY_READ, + 0, + &DriverKey); - parametersPath.Buffer = (PWCH) ExAllocatePool2(POOL_FLAG_PAGED, parametersPath.MaximumLength, MINADAPTER_POOLTAG); - if (parametersPath.Buffer == NULL) + if (!NT_SUCCESS(ntStatus)) { - return STATUS_INSUFFICIENT_RESOURCES; + return ntStatus; } - RtlAppendUnicodeToString(¶metersPath, RegistryPath->Buffer); - RtlAppendUnicodeToString(¶metersPath, L"\\Parameters"); - - ntStatus = RtlQueryRegistryValues( - RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL, - parametersPath.Buffer, - ¶mTable[0], - NULL, - NULL - ); + ntStatus = RtlQueryRegistryValues(RTL_REGISTRY_HANDLE, + (PCWSTR) DriverKey, + ¶mTable[0], + NULL, + NULL); if (!NT_SUCCESS(ntStatus)) { @@ -240,10 +239,10 @@ Returns: DPF(D_VERBOSE, ("DoNotCreateDataFiles: %u", g_DoNotCreateDataFiles)); DPF(D_VERBOSE, ("DisableToneGenerator: %u", g_DisableToneGenerator)); - // - // Cleanup. - // - ExFreePool(parametersPath.Buffer); + if (DriverKey) + { + ZwClose(DriverKey); + } return STATUS_SUCCESS; } @@ -292,15 +291,6 @@ Return Value: ntStatus, DPF(D_ERROR, ("Registry path copy error 0x%x", ntStatus)), Done); - - // - // Get registry configuration. - // - ntStatus = GetRegistrySettings(RegistryPathName); - IF_FAILED_ACTION_JUMP( - ntStatus, - DPF(D_ERROR, ("Registry Configuration error 0x%x", ntStatus)), - Done); WDF_DRIVER_CONFIG_INIT(&config, WDF_NO_EVENT_CALLBACK); // @@ -323,6 +313,15 @@ Return Value: DPF(D_ERROR, ("WdfDriverCreate failed, 0x%x", ntStatus)), Done); + // + // Get registry configuration. + // + ntStatus = GetRegistrySettings(RegistryPathName); + IF_FAILED_ACTION_JUMP( + ntStatus, + DPF(D_ERROR, ("Registry Configuration error 0x%x", ntStatus)), + Done); + // // Tell the class driver to initialize the driver. // -- cgit v1.3.1 From 7d7f9388ae3077ca010a719dbcd3da0534272046 Mon Sep 17 00:00:00 2001 From: Julia D'Zmura <78620953+judzmura@users.noreply.github.com> Date: Thu, 9 Mar 2023 10:19:19 -0800 Subject: Updates to Sysvad and SimpleAudioSample. (#917) * Updates to Sysvad and simpleAudioSample. * Changing dash to ASCII. --- audio/simpleaudiosample/Source/Main/adapter.cpp | 2 ++ audio/simpleaudiosample/Source/Main/common.cpp | 5 ++++- audio/sysvad/APO/DelayAPO/DelayAPOMFX.cpp | 4 ++-- audio/sysvad/APO/DelayAPO/DelayAPOSFX.cpp | 2 +- .../TabletAudioSample/ComponentizedApoSample.inx | Bin 22572 -> 22624 bytes .../ComponentizedAudioSampleExtension.inx | Bin 13608 -> 13660 bytes .../TabletAudioSample/TabletAudioSample.vcxproj | 12 ++++++------ 7 files changed, 15 insertions(+), 10 deletions(-) (limited to 'audio/simpleaudiosample/Source/Main/adapter.cpp') diff --git a/audio/simpleaudiosample/Source/Main/adapter.cpp b/audio/simpleaudiosample/Source/Main/adapter.cpp index bbe23f26..a66ee5a2 100644 --- a/audio/simpleaudiosample/Source/Main/adapter.cpp +++ b/audio/simpleaudiosample/Source/Main/adapter.cpp @@ -59,6 +59,8 @@ UNICODE_STRING g_RegistryPath; // This is used to store the registry settin #pragma code_seg("PAGE") void ReleaseRegistryStringBuffer() { + PAGED_CODE(); + if (g_RegistryPath.Buffer != NULL) { ExFreePool(g_RegistryPath.Buffer); diff --git a/audio/simpleaudiosample/Source/Main/common.cpp b/audio/simpleaudiosample/Source/Main/common.cpp index 8843d3a4..457bdb17 100644 --- a/audio/simpleaudiosample/Source/Main/common.cpp +++ b/audio/simpleaudiosample/Source/Main/common.cpp @@ -2547,6 +2547,7 @@ Exit: return ntStatus; } +#pragma code_seg("PAGE") NTSTATUS CopyRegistryKey(HANDLE _hSourceKey, HANDLE _hDestinationKey, BOOL _bOverwrite = FALSE) /*++ @@ -2686,7 +2687,7 @@ Exit: return ntStatus; } - +#pragma code_seg("PAGE") NTSTATUS CAdapterCommon::MigrateDeviceInterfaceTemplateParameters ( _In_ PUNICODE_STRING SymbolicLinkName, @@ -2729,6 +2730,8 @@ Return Value: UNICODE_STRING TemplateSymbolicLinkName; UNICODE_STRING referenceString; + PAGED_CODE(); + RtlInitUnicodeString(&TemplateSymbolicLinkName, NULL); RtlInitUnicodeString(&referenceString, TemplateReferenceString); diff --git a/audio/sysvad/APO/DelayAPO/DelayAPOMFX.cpp b/audio/sysvad/APO/DelayAPO/DelayAPOMFX.cpp index e7492131..af67571b 100644 --- a/audio/sysvad/APO/DelayAPO/DelayAPOMFX.cpp +++ b/audio/sysvad/APO/DelayAPO/DelayAPOMFX.cpp @@ -292,7 +292,7 @@ STDMETHODIMP CDelayAPOMFX::LockForProcess(UINT32 u32NumInputConnections, // // A more typical approach would be to allocate the memory using AERT_Allocate, which locks the memory // But for the purposes of this APO, CoTaskMemAlloc suffices, and the risk of glitches is not important - m_pf32DelayBuffer.Allocate(GetSamplesPerFrame() * m_nDelayFrames); + m_pf32DelayBuffer.Allocate((size_t) GetSamplesPerFrame() * m_nDelayFrames); WriteSilence(m_pf32DelayBuffer, m_nDelayFrames, GetSamplesPerFrame()); if (nullptr == m_pf32DelayBuffer) { @@ -1166,4 +1166,4 @@ HRESULT CDelayAPOMFX::CheckCustomFormats(IAudioMediaType *pRequestedFormat) } return hResult; -} \ No newline at end of file +} diff --git a/audio/sysvad/APO/DelayAPO/DelayAPOSFX.cpp b/audio/sysvad/APO/DelayAPO/DelayAPOSFX.cpp index c37abb7c..67ae2788 100644 --- a/audio/sysvad/APO/DelayAPO/DelayAPOSFX.cpp +++ b/audio/sysvad/APO/DelayAPO/DelayAPOSFX.cpp @@ -241,7 +241,7 @@ STDMETHODIMP CDelayAPOSFX::LockForProcess(UINT32 u32NumInputConnections, // // A more typical approach would be to allocate the memory using AERT_Allocate, which locks the memory // But for the purposes of this APO, CoTaskMemAlloc suffices, and the risk of glitches is not important - m_pf32DelayBuffer.Allocate(GetSamplesPerFrame() * m_nDelayFrames); + m_pf32DelayBuffer.Allocate((size_t) GetSamplesPerFrame() * m_nDelayFrames); WriteSilence(m_pf32DelayBuffer, m_nDelayFrames, GetSamplesPerFrame()); if (nullptr == m_pf32DelayBuffer) diff --git a/audio/sysvad/TabletAudioSample/ComponentizedApoSample.inx b/audio/sysvad/TabletAudioSample/ComponentizedApoSample.inx index 34b8401a..b18b528c 100644 Binary files a/audio/sysvad/TabletAudioSample/ComponentizedApoSample.inx and b/audio/sysvad/TabletAudioSample/ComponentizedApoSample.inx differ diff --git a/audio/sysvad/TabletAudioSample/ComponentizedAudioSampleExtension.inx b/audio/sysvad/TabletAudioSample/ComponentizedAudioSampleExtension.inx index 4afba224..aa6928d0 100644 Binary files a/audio/sysvad/TabletAudioSample/ComponentizedAudioSampleExtension.inx and b/audio/sysvad/TabletAudioSample/ComponentizedAudioSampleExtension.inx differ diff --git a/audio/sysvad/TabletAudioSample/TabletAudioSample.vcxproj b/audio/sysvad/TabletAudioSample/TabletAudioSample.vcxproj index fe70dacf..6e4e4c44 100644 --- a/audio/sysvad/TabletAudioSample/TabletAudioSample.vcxproj +++ b/audio/sysvad/TabletAudioSample/TabletAudioSample.vcxproj @@ -40,7 +40,7 @@ Windows10 False - Windows Driver + Universal KMDF WindowsKernelModeDriver10.0 Driver @@ -48,7 +48,7 @@ Windows10 False - Windows Driver + Universal KMDF WindowsKernelModeDriver10.0 Driver @@ -56,7 +56,7 @@ Windows10 True - Windows Driver + Universal KMDF WindowsKernelModeDriver10.0 Driver @@ -64,7 +64,7 @@ Windows10 True - Windows Driver + Universal KMDF WindowsKernelModeDriver10.0 Driver @@ -72,7 +72,7 @@ Windows10 False - Windows Driver + Universal KMDF WindowsKernelModeDriver10.0 Driver @@ -80,7 +80,7 @@ Windows10 True - Windows Driver + Universal KMDF WindowsKernelModeDriver10.0 Driver -- cgit v1.3.1