From 2806a5eba5850bd1423d7f07b0ac5074e5f9fdb1 Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Thu, 13 Nov 2025 13:40:12 -0800 Subject: [PATCH 1/4] Set FilePath for registry drivers --- config/dirs_windows.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/config/dirs_windows.go b/config/dirs_windows.go index 14bfa08..c2b4046 100644 --- a/config/dirs_windows.go +++ b/config/dirs_windows.go @@ -47,6 +47,17 @@ func (c ConfigLevel) key() registry.Key { } } +func (c ConfigLevel) rootKeyString() string { + switch c { + case ConfigUser: + return "HKEY_CURRENT_USER" + case ConfigSystem: + return "HKEY_LOCAL_MACHINE" + default: + return "UNKNOWN" + } +} + func (c ConfigLevel) configLocation() string { var prefix string switch c { @@ -109,7 +120,7 @@ func setKeyIntMust(k registry.Key, name string, value uint32) { } } -func driverInfoFromKey(k registry.Key, driverName string) (di DriverInfo, err error) { +func driverInfoFromKey(k registry.Key, driverName string, lvl ConfigLevel) (di DriverInfo, err error) { dkey, err := registry.OpenKey(k, driverName, registry.READ) if err != nil { return di, err @@ -143,6 +154,10 @@ func driverInfoFromKey(k registry.Key, driverName string) (di DriverInfo, err er di.Driver.Shared.defaultPath = keyMust(dkey, "driver") di.Driver.Entrypoint = keyOptional(dkey, "entrypoint") + // For drivers in the registry, set FilePath to the registry key instead + // of the filesystem path since that's technically where the driver exists. + di.FilePath = fmt.Sprintf("%s\\%s", lvl.rootKeyString(), regKeyADBC) + return } @@ -171,7 +186,7 @@ func loadRegistryConfig(lvl ConfigLevel) Config { } for _, driver := range drivers { - di, err := driverInfoFromKey(k, driver) + di, err := driverInfoFromKey(k, driver, lvl) if err != nil { log.Println(err) continue @@ -241,7 +256,7 @@ func GetDriver(cfg Config, driverName string) (DriverInfo, error) { } defer k.Close() - return driverInfoFromKey(k, driverName) + return driverInfoFromKey(k, driverName, cfg.Level) } func CreateManifest(cfg Config, driver DriverInfo) (err error) { From a37de2a7bffb180c5b0c51155f155af92f397420 Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Fri, 14 Nov 2025 16:42:15 -0800 Subject: [PATCH 2/4] testing comparing the k handle with constants --- config/dirs_windows.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/config/dirs_windows.go b/config/dirs_windows.go index c2b4046..485b546 100644 --- a/config/dirs_windows.go +++ b/config/dirs_windows.go @@ -47,17 +47,6 @@ func (c ConfigLevel) key() registry.Key { } } -func (c ConfigLevel) rootKeyString() string { - switch c { - case ConfigUser: - return "HKEY_CURRENT_USER" - case ConfigSystem: - return "HKEY_LOCAL_MACHINE" - default: - return "UNKNOWN" - } -} - func (c ConfigLevel) configLocation() string { var prefix string switch c { @@ -156,7 +145,16 @@ func driverInfoFromKey(k registry.Key, driverName string, lvl ConfigLevel) (di D // For drivers in the registry, set FilePath to the registry key instead // of the filesystem path since that's technically where the driver exists. - di.FilePath = fmt.Sprintf("%s\\%s", lvl.rootKeyString(), regKeyADBC) + var rootKey string + switch k { + case registry.CURRENT_USER: + rootKey = "HKCU" + case registry.LOCAL_MACHINE: + rootKey = "HKLM" + default: + rootKey = "UNK" + } + di.FilePath = fmt.Sprintf("%s\\%s", rootKey, regKeyADBC) return } From 1d5841e8f7b57e2d32ee0524179557768b7d14ac Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Fri, 14 Nov 2025 17:09:44 -0800 Subject: [PATCH 3/4] Revert "testing comparing the k handle with constants" This reverts commit 106e5c3647628c1f7e1f46d76233dfe778ea06e6. --- config/dirs_windows.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/config/dirs_windows.go b/config/dirs_windows.go index 485b546..c2b4046 100644 --- a/config/dirs_windows.go +++ b/config/dirs_windows.go @@ -47,6 +47,17 @@ func (c ConfigLevel) key() registry.Key { } } +func (c ConfigLevel) rootKeyString() string { + switch c { + case ConfigUser: + return "HKEY_CURRENT_USER" + case ConfigSystem: + return "HKEY_LOCAL_MACHINE" + default: + return "UNKNOWN" + } +} + func (c ConfigLevel) configLocation() string { var prefix string switch c { @@ -145,16 +156,7 @@ func driverInfoFromKey(k registry.Key, driverName string, lvl ConfigLevel) (di D // For drivers in the registry, set FilePath to the registry key instead // of the filesystem path since that's technically where the driver exists. - var rootKey string - switch k { - case registry.CURRENT_USER: - rootKey = "HKCU" - case registry.LOCAL_MACHINE: - rootKey = "HKLM" - default: - rootKey = "UNK" - } - di.FilePath = fmt.Sprintf("%s\\%s", rootKey, regKeyADBC) + di.FilePath = fmt.Sprintf("%s\\%s", lvl.rootKeyString(), regKeyADBC) return } From cda221d3b687dc612530b2da0a6be9212cf8e179 Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Fri, 14 Nov 2025 17:10:11 -0800 Subject: [PATCH 4/4] shorten strings --- config/dirs_windows.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/dirs_windows.go b/config/dirs_windows.go index c2b4046..edbdcad 100644 --- a/config/dirs_windows.go +++ b/config/dirs_windows.go @@ -50,11 +50,11 @@ func (c ConfigLevel) key() registry.Key { func (c ConfigLevel) rootKeyString() string { switch c { case ConfigUser: - return "HKEY_CURRENT_USER" + return "HKCU" case ConfigSystem: - return "HKEY_LOCAL_MACHINE" + return "HKLM" default: - return "UNKNOWN" + return "UNKN" } }