summaryrefslogtreecommitdiff
path: root/audio/simpleaudiosample/Source
diff options
context:
space:
mode:
authorJulia D'Zmura <[email protected]>2023-02-02 15:53:08 -0800
committerGitHub <[email protected]>2023-02-02 15:53:08 -0800
commit54a98a7e6af65ebc3a8ec92c7c09d94d0b44a6fd (patch)
tree9a159a9b2dde990a70ae5b62760236314f165c41 /audio/simpleaudiosample/Source
parent520c37087776a198544ab9b721d802dd30864736 (diff)
Updates to make Sysvad and SimpleAudioSample Windows Drivers Compliant (#845)
Updating sysvad and simpleaudiosample drivers.
Diffstat (limited to 'audio/simpleaudiosample/Source')
-rw-r--r--audio/simpleaudiosample/Source/Filters/Filters.vcxproj12
-rw-r--r--audio/simpleaudiosample/Source/Inc/Inc.vcxproj12
-rw-r--r--audio/simpleaudiosample/Source/Main/Main.vcxproj12
-rw-r--r--audio/simpleaudiosample/Source/Main/adapter.cpp69
-rw-r--r--audio/simpleaudiosample/Source/Main/minwavertstream.cpp47
-rw-r--r--audio/simpleaudiosample/Source/Utilities/Utilities.vcxproj12
-rw-r--r--audio/simpleaudiosample/Source/Utilities/savedata.cpp104
7 files changed, 151 insertions, 117 deletions
diff --git a/audio/simpleaudiosample/Source/Filters/Filters.vcxproj b/audio/simpleaudiosample/Source/Filters/Filters.vcxproj
index 82fd07dc..1bc012e0 100644
--- a/audio/simpleaudiosample/Source/Filters/Filters.vcxproj
+++ b/audio/simpleaudiosample/Source/Filters/Filters.vcxproj
@@ -38,7 +38,7 @@
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>False</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
@@ -46,7 +46,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>False</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
@@ -54,7 +54,7 @@
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>True</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
@@ -62,7 +62,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>True</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
@@ -70,7 +70,7 @@
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>False</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
@@ -78,7 +78,7 @@
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>True</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
diff --git a/audio/simpleaudiosample/Source/Inc/Inc.vcxproj b/audio/simpleaudiosample/Source/Inc/Inc.vcxproj
index ab768d84..14fce7b3 100644
--- a/audio/simpleaudiosample/Source/Inc/Inc.vcxproj
+++ b/audio/simpleaudiosample/Source/Inc/Inc.vcxproj
@@ -38,7 +38,7 @@
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>False</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
@@ -46,7 +46,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>False</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
@@ -54,7 +54,7 @@
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>True</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
@@ -62,7 +62,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>True</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
@@ -70,7 +70,7 @@
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>False</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
@@ -78,7 +78,7 @@
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>True</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
diff --git a/audio/simpleaudiosample/Source/Main/Main.vcxproj b/audio/simpleaudiosample/Source/Main/Main.vcxproj
index a68d0242..be92b9d4 100644
--- a/audio/simpleaudiosample/Source/Main/Main.vcxproj
+++ b/audio/simpleaudiosample/Source/Main/Main.vcxproj
@@ -40,7 +40,7 @@
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>False</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>Driver</ConfigurationType>
@@ -48,7 +48,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>False</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>Driver</ConfigurationType>
@@ -56,7 +56,7 @@
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>True</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>Driver</ConfigurationType>
@@ -64,7 +64,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>True</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>Driver</ConfigurationType>
@@ -72,7 +72,7 @@
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>False</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>Driver</ConfigurationType>
@@ -80,7 +80,7 @@
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>True</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>Driver</ConfigurationType>
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(&parametersPath, 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(&parametersPath, RegistryPath->Buffer);
- RtlAppendUnicodeToString(&parametersPath, L"\\Parameters");
-
- ntStatus = RtlQueryRegistryValues(
- RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL,
- parametersPath.Buffer,
- &paramTable[0],
- NULL,
- NULL
- );
+ ntStatus = RtlQueryRegistryValues(RTL_REGISTRY_HANDLE,
+ (PCWSTR) DriverKey,
+ &paramTable[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);
//
@@ -324,6 +314,15 @@ Return Value:
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.
//
ntStatus = PcInitializeAdapterDriver(DriverObject,
diff --git a/audio/simpleaudiosample/Source/Main/minwavertstream.cpp b/audio/simpleaudiosample/Source/Main/minwavertstream.cpp
index 27289a0e..c189c939 100644
--- a/audio/simpleaudiosample/Source/Main/minwavertstream.cpp
+++ b/audio/simpleaudiosample/Source/Main/minwavertstream.cpp
@@ -108,8 +108,8 @@ NTSTATUS CMiniportWaveRTStream::ReadRegistrySettings()
PAGED_CODE();
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"HostCaptureToneFrequency", &m_ulHostCaptureToneFrequency, (REG_DWORD << RTL_QUERY_REGISTRY_TYPECHECK_SHIFT) | REG_DWORD, &m_ulHostCaptureToneFrequency, sizeof(DWORD) },
@@ -119,30 +119,37 @@ NTSTATUS CMiniportWaveRTStream::ReadRegistrySettings()
{ NULL, 0, NULL, NULL, 0, NULL, 0 }
};
- RtlInitUnicodeString(&parametersPath, NULL);
-
- // The sizeof(WCHAR) is added to the maximum length, for allowing a space for null termination of the string.
- parametersPath.MaximumLength =
- g_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, MINWAVERT_POOLTAG);
- if (parametersPath.Buffer == NULL)
+ if (!NT_SUCCESS(ntStatus))
{
- return STATUS_INSUFFICIENT_RESOURCES;
+ return ntStatus;
}
- RtlAppendUnicodeToString(&parametersPath, g_RegistryPath.Buffer);
- RtlAppendUnicodeToString(&parametersPath, L"\\Parameters");
+ ntStatus = RtlQueryRegistryValues(RTL_REGISTRY_HANDLE,
+ (PCWSTR) DriverKey,
+ &paramTable[0],
+ NULL,
+ NULL);
- ntStatus = RtlQueryRegistryValues(
- RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL,
- parametersPath.Buffer,
- &paramTable[0],
- NULL,
- NULL
- );
+ if (!NT_SUCCESS(ntStatus))
+ {
+ DPF(D_VERBOSE, ("RtlQueryRegistryValues failed, using default values, 0x%x", ntStatus));
+ //
+ // Don't return error because we will operate with default values.
+ //
+ }
- ExFreePool(parametersPath.Buffer);
+ if (DriverKey)
+ {
+ ZwClose(DriverKey);
+ }
return ntStatus;
}
diff --git a/audio/simpleaudiosample/Source/Utilities/Utilities.vcxproj b/audio/simpleaudiosample/Source/Utilities/Utilities.vcxproj
index 0a71bf42..710bf748 100644
--- a/audio/simpleaudiosample/Source/Utilities/Utilities.vcxproj
+++ b/audio/simpleaudiosample/Source/Utilities/Utilities.vcxproj
@@ -38,7 +38,7 @@
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>False</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
@@ -46,7 +46,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>False</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
@@ -54,7 +54,7 @@
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>True</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
@@ -62,7 +62,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>True</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
@@ -70,7 +70,7 @@
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>False</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
@@ -78,7 +78,7 @@
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>True</UseDebugLibraries>
- <DriverTargetPlatform>Universal</DriverTargetPlatform>
+ <DriverTargetPlatform>Windows Driver</DriverTargetPlatform>
<DriverType>KMDF</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
diff --git a/audio/simpleaudiosample/Source/Utilities/savedata.cpp b/audio/simpleaudiosample/Source/Utilities/savedata.cpp
index 7b2a11e9..02c3f602 100644
--- a/audio/simpleaudiosample/Source/Utilities/savedata.cpp
+++ b/audio/simpleaudiosample/Source/Utilities/savedata.cpp
@@ -44,8 +44,9 @@ Abstract:
#define DEFAULT_FRAME_SIZE PAGE_SIZE * 4
#define DEFAULT_BUFFER_SIZE DEFAULT_FRAME_SIZE * DEFAULT_FRAME_COUNT
-#define DEFAULT_FILE_NAME L"\\DosDevices\\C:\\STREAM"
-#define OSDATA_FILE_NAME L"\\DosDevices\\O:\\STREAM"
+#define DEFAULT_FILE_FOLDER1 L"\\DriverData\\Audio_Samples"
+#define DEFAULT_FILE_FOLDER2 L"\\DriverData\\Audio_Samples\\SimpleAudioSample"
+#define DEFAULT_FILE_NAME L"\\DriverData\\Audio_Samples\\SimpleAudioSample\\STREAM"
#define OFFLOAD_FILE_NAME L"OFFLOAD"
#define HOST_FILE_NAME L"HOST"
@@ -444,59 +445,86 @@ CSaveData::Initialize
{
PAGED_CODE();
- NTSTATUS ntStatus = STATUS_SUCCESS;
- WCHAR szTemp[MAX_PATH];
- size_t cLen;
- OBJECT_ATTRIBUTES objectAttributes;
- UNICODE_STRING osDataVolumeString;
- HANDLE osDataFileHandle = NULL;
- IO_STATUS_BLOCK ioStatusBlock;
+ NTSTATUS ntStatus = STATUS_SUCCESS;
+ WCHAR szTemp[MAX_PATH];
+ size_t cLen = 0;
+ IO_STATUS_BLOCK ioStatusBlock = {0};
+ HANDLE fileHandle;
+ OBJECT_ATTRIBUTES objectAttributes;
+ UNICODE_STRING fileName;
DPF_ENTER(("[CSaveData::Initialize]"));
m_ulStreamId++;
- // Probe if OSData volume exists.
- //
- RtlStringCchPrintfW(szTemp, MAX_PATH, L"%s_probe.txt", OSDATA_FILE_NAME);
- RtlInitUnicodeString(&osDataVolumeString, szTemp);
- InitializeObjectAttributes
- (
- &objectAttributes,
- &osDataVolumeString,
- OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
- NULL,
- NULL
- );
+ RtlInitUnicodeString(&fileName, DEFAULT_FILE_FOLDER1);
+ InitializeObjectAttributes(
+ &objectAttributes,
+ &fileName,
+ OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE,
+ NULL,
+ NULL);
- ntStatus =
- ZwCreateFile
- (
- &osDataFileHandle,
- GENERIC_WRITE | SYNCHRONIZE,
+ // Create the folder.
+ ntStatus = ZwCreateFile(
+ &fileHandle,
+ 0,
&objectAttributes,
&ioStatusBlock,
NULL,
FILE_ATTRIBUTE_NORMAL,
0,
- FILE_OVERWRITE_IF,
- FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT,
+ FILE_OPEN_IF,
+ FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT,
NULL,
- 0
- );
+ 0);
+
+ if (NT_SUCCESS(ntStatus))
+ {
+ ZwClose(fileHandle);
+ fileHandle = NULL;
+
+ RtlInitUnicodeString(&fileName, DEFAULT_FILE_FOLDER2);
+ InitializeObjectAttributes(
+ &objectAttributes,
+ &fileName,
+ OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE,
+ NULL,
+ NULL);
+
+ // Create the folder.
+ ntStatus = ZwCreateFile(
+ &fileHandle,
+ 0,
+ &objectAttributes,
+ &ioStatusBlock,
+ NULL,
+ FILE_ATTRIBUTE_NORMAL,
+ 0,
+ FILE_OPEN_IF,
+ FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT,
+ NULL,
+ 0);
+
+ if (NT_SUCCESS(ntStatus))
+ {
+ ZwClose(fileHandle);
+ fileHandle = NULL;
+ }
+ }
+
if (NT_SUCCESS(ntStatus))
{
- ZwClose(osDataFileHandle);
+ // Allocate data file name.
+ //
+ RtlStringCchPrintfW(szTemp, MAX_PATH, L"%s_%s_%d.wav", DEFAULT_FILE_NAME, HOST_FILE_NAME, m_ulStreamId);
+ m_FileName.Length = 0;
+ ntStatus = RtlStringCchLengthW (szTemp, sizeof(szTemp)/sizeof(szTemp[0]), &cLen);
}
- // Allocate data file name.
- //
- RtlStringCchPrintfW(szTemp, MAX_PATH, L"%s_%s_%d.wav", NT_SUCCESS(ntStatus) ? OSDATA_FILE_NAME : DEFAULT_FILE_NAME, HOST_FILE_NAME, m_ulStreamId);
- m_FileName.Length = 0;
- ntStatus = RtlStringCchLengthW (szTemp, sizeof(szTemp)/sizeof(szTemp[0]), &cLen);
if (NT_SUCCESS(ntStatus))
{
- m_FileName.MaximumLength = (USHORT)((cLen * sizeof(WCHAR)) + sizeof(WCHAR));//convert to wchar and add room for NULL
+ m_FileName.MaximumLength = (USHORT)((cLen * sizeof(WCHAR)) + sizeof(WCHAR));//convert to wchar and add room for NULL
m_FileName.Buffer = (PWSTR)
ExAllocatePool2
(
@@ -574,7 +602,7 @@ CSaveData::Initialize
(
&m_objectAttributes,
&m_FileName,
- OBJ_CASE_INSENSITIVE|OBJ_KERNEL_HANDLE,
+ OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
NULL,
NULL
);