Skip to content

Commit

Permalink
Updating sysvad and simpleaudiosample drivers.
Browse files Browse the repository at this point in the history
  • Loading branch information
judzmura committed Feb 2, 2023
1 parent 520c370 commit b033e01
Show file tree
Hide file tree
Showing 34 changed files with 615 additions and 350 deletions.
12 changes: 6 additions & 6 deletions audio/simpleaudiosample/Source/Filters/Filters.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,47 +38,47 @@
<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>
</PropertyGroup>
<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>
</PropertyGroup>
<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>
</PropertyGroup>
<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>
</PropertyGroup>
<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>
</PropertyGroup>
<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>
Expand Down
12 changes: 6 additions & 6 deletions audio/simpleaudiosample/Source/Inc/Inc.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,47 +38,47 @@
<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>
</PropertyGroup>
<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>
</PropertyGroup>
<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>
</PropertyGroup>
<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>
</PropertyGroup>
<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>
</PropertyGroup>
<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>
Expand Down
12 changes: 6 additions & 6 deletions audio/simpleaudiosample/Source/Main/Main.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,47 +40,47 @@
<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>
</PropertyGroup>
<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>
</PropertyGroup>
<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>
</PropertyGroup>
<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>
</PropertyGroup>
<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>
</PropertyGroup>
<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>
Expand Down
69 changes: 34 additions & 35 deletions audio/simpleaudiosample/Source/Main/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -192,7 +192,8 @@ Routine Description:

{
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)},
Expand All @@ -202,29 +203,27 @@ Routine Description:

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))
{
Expand All @@ -240,10 +239,10 @@ Routine Description:
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;
}
Expand Down Expand Up @@ -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);
//
Expand All @@ -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.
//
Expand Down
47 changes: 27 additions & 20 deletions audio/simpleaudiosample/Source/Main/minwavertstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
Expand All @@ -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;
}
Expand Down
12 changes: 6 additions & 6 deletions audio/simpleaudiosample/Source/Utilities/Utilities.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,47 +38,47 @@
<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>
</PropertyGroup>
<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>
</PropertyGroup>
<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>
</PropertyGroup>
<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>
</PropertyGroup>
<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>
</PropertyGroup>
<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>
Expand Down
Loading

0 comments on commit b033e01

Please sign in to comment.