Skip to content

Introduce new configuration system #197

@nefarius

Description

@nefarius

Using properties to store and fetch configuration properties has reached its limits. I've thought about a better way to fetch configuration within the driver. Primarily it needs to work in good ol' pure C and shouldn't be too much of a hassle to also write to from C# (as DSHMC is a .NET application). It boiled down to two technologies to use: the registry or the filesystem.

Registry access if very limited, almost unusable in UMDF and that's on purpose, the hosting process of an user-mode driver runs under very low privileges for security reasons and I don't want to change that. There are ways to create registry keys and alter their permissions to allow the LocalService account read and write permissions but it didn't feel quite right.

Another way that is "easy" in an UMDF driver is to read from the filesystem, since we're running in user-mode, the common file primitives to open and read files work out of the box. At first I thought about using an INI parser, but to my delight I found a lightweight JSON parser so I settled on using JSON. It's an established standard, simple syntax for humans and it has native support in .NET, so it ticks all the boxes!

The driver will attempt to read the file C:\ProgramData\DsHidMini\DsHidMini.json and fallback to default values, if not found or parsing errors occur. This path has been chosen as the driver can read it without any modifications and any user can alter the file if they'd like to tinker with it outside of DSHMC. This will also allow for DSHMC to only require administrative elevation to restart the device, but no longer to simply store settings!

Related issues

These could be addressed and potentially fixed in entirety with this new feature:

JSON Schema

See example config file (work in progress).

Metadata

Metadata

Assignees

Labels

CoreCore/Common Driver TopicDSHMCUI-related onlyenhancementNew feature or request

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions