aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2021-08-13 10:54:04 +0200
committerSimon Rozman <simon@rozman.si>2021-08-13 13:15:18 +0200
commit144ebcb97ce837cbdbe859928b16b961bac5e885 (patch)
treeeb23ea882c8ec5b95c606651808b0d0c54a5d303
parentwinipcfg: update documentation (diff)
downloadwireguard-windows-144ebcb97ce837cbdbe859928b16b961bac5e885.tar.xz
wireguard-windows-144ebcb97ce837cbdbe859928b16b961bac5e885.zip
conf: split registry key open and create
On reading admin registry values, an on-demand auto creation of registry key is not required side effect. This restores openAdminKey() to original form, we will need anyway after the WireGuardNT call-for-testing promotion is no longer required. The GUI ExperimentalKernelDriver flipping also opened a caching registry key handle issue: should user manually delete our registry key while wireguard.exe is already running, any admin knob get fails. So, the sooner we get rid of the GUI admin knob flipping, the better. Signed-off-by: Simon Rozman <simon@rozman.si>
-rw-r--r--conf/admin_windows.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/conf/admin_windows.go b/conf/admin_windows.go
index f66b2715..9b1a4035 100644
--- a/conf/admin_windows.go
+++ b/conf/admin_windows.go
@@ -16,7 +16,7 @@ func openAdminKey() (registry.Key, error) {
return adminKey, nil
}
var err error
- adminKey, _, err = registry.CreateKey(registry.LOCAL_MACHINE, adminRegKey, registry.QUERY_VALUE|registry.SET_VALUE|registry.WOW64_64KEY)
+ adminKey, err = registry.OpenKey(registry.LOCAL_MACHINE, adminRegKey, registry.QUERY_VALUE|registry.WOW64_64KEY)
if err != nil {
return 0, err
}
@@ -36,10 +36,11 @@ func AdminBool(name string) bool {
}
func SetAdminBool(name string, val bool) error {
- key, err := openAdminKey()
+ key, _, err := registry.CreateKey(registry.LOCAL_MACHINE, adminRegKey, registry.SET_VALUE|registry.WOW64_64KEY)
if err != nil {
return err
}
+ defer key.Close()
if val {
return key.SetDWordValue(name, 1)
} else {