Setting properties and registry values
This guide explains how a Port Class audio driver can set properties and registry values for a PnP device interface. To properly register the device interface and set required values, the Portcls driver must follow these steps:
1. Register the device interface
Before calling PcRegisterSubdevice
for the sub-device, the driver should call IoRegisterDeviceInterface
to register the KSCATEGORY_AUDIO
interface. This allows the driver to set interface properties and registry values before PcRegisterSubdevice
registers and enables the interfaces.
When calling IoRegisterDeviceInterface
, the audio driver sets the parameters as follows:
- The
PhysicalDeviceObject
parameter is thePDEVICE_OBJECT
retrieved from thePcGetPhysicalDeviceObject
function. - The
InterfaceClassGuid
is set to the interface's class GUID. - The
ReferenceString
is the same as theName
parameter passed toPcRegisterSubdevice
.
After completing these tasks successfully, IoRegisterDeviceInterface
returns a SymbolicLinkName
for the registered interface.
2. Set registry values
The audio driver calls IoOpenDeviceInterfaceRegistryKey
to obtain a handle to the device interface registry key. The parameters for IoOpenDeviceInterfaceRegistryKey
are set as follows:
- The
SymbolicLinkName
is the string returned fromIoRegisterDeviceInterface
in the previous step. - The
DesiredAccess
is set toKEY_WRITE
(or other values if needed by the driver).
After completing these steps, DeviceInterfaceKey
returns the opened registry key handle. The audio driver:
- Calls
ZwSetValueKey
to set registry values. - Closes the registry key handle by calling
ZwClose
.
Note: If the driver needs to set values in a registry subkey, it should call ZwCreateKey
to create the subkey. When preparing to call ZwCreateKey
, the driver:
- Calls
InitializeObjectAttributes
and sets theObjectName
to the subkey path. - Sets
Attributes
toOBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE
. - Sets
RootDirectory
to the handle returned byIoOpenDeviceInterfaceRegistryKey
. - Calls
ZwClose
to close any handle created by callingZwCreateKey
.
3. Set properties
The audio driver calls IoSetDeviceInterfacePropertyData
to set properties. The parameters for IoSetDeviceInterfacePropertyData
are set as follows:
- The
SymbolicLinkName
is the string returned fromIoRegisterDeviceInterface
. - The remaining parameters depend on the specific property being set.
See also
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for