wintun: registry: replace REG_NOTIFY with NOTIFY
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
c267965bf8
commit
1c92b48415
@ -16,10 +16,6 @@ import (
|
|||||||
"golang.org/x/sys/windows/registry"
|
"golang.org/x/sys/windows/registry"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
KEY_NOTIFY uint32 = 0x0010 // should be defined upstream as registry.KEY_NOTIFY
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// REG_NOTIFY_CHANGE_NAME notifies the caller if a subkey is added or deleted.
|
// REG_NOTIFY_CHANGE_NAME notifies the caller if a subkey is added or deleted.
|
||||||
REG_NOTIFY_CHANGE_NAME uint32 = 0x00000001
|
REG_NOTIFY_CHANGE_NAME uint32 = 0x00000001
|
||||||
@ -66,7 +62,7 @@ func OpenKeyWait(k registry.Key, path string, access uint32, timeout time.Durati
|
|||||||
if isLast {
|
if isLast {
|
||||||
accessFlags = access
|
accessFlags = access
|
||||||
} else {
|
} else {
|
||||||
accessFlags = KEY_NOTIFY
|
accessFlags = registry.NOTIFY
|
||||||
}
|
}
|
||||||
key, err = registry.OpenKey(k, keyName, accessFlags)
|
key, err = registry.OpenKey(k, keyName, accessFlags)
|
||||||
if err == windows.ERROR_FILE_NOT_FOUND || err == windows.ERROR_PATH_NOT_FOUND {
|
if err == windows.ERROR_FILE_NOT_FOUND || err == windows.ERROR_PATH_NOT_FOUND {
|
||||||
@ -97,7 +93,7 @@ func OpenKeyWait(k registry.Key, path string, access uint32, timeout time.Durati
|
|||||||
}
|
}
|
||||||
|
|
||||||
func WaitForKey(k registry.Key, path string, timeout time.Duration) error {
|
func WaitForKey(k registry.Key, path string, timeout time.Duration) error {
|
||||||
key, err := OpenKeyWait(k, path, KEY_NOTIFY, timeout)
|
key, err := OpenKeyWait(k, path, registry.NOTIFY, timeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -109,7 +105,7 @@ func WaitForKey(k registry.Key, path string, timeout time.Duration) error {
|
|||||||
// getStringValueRetry function reads a string value from registry. It waits for
|
// getStringValueRetry function reads a string value from registry. It waits for
|
||||||
// the registry value to become available or returns error on timeout.
|
// the registry value to become available or returns error on timeout.
|
||||||
//
|
//
|
||||||
// Key must be opened with at least QUERY_VALUE|KEY_NOTIFY access.
|
// Key must be opened with at least QUERY_VALUE|NOTIFY access.
|
||||||
//
|
//
|
||||||
func getStringValueRetry(key registry.Key, name string, timeout time.Duration, useFirstFromMulti bool) (string, uint32, error) {
|
func getStringValueRetry(key registry.Key, name string, timeout time.Duration, useFirstFromMulti bool) (string, uint32, error) {
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
@ -184,7 +180,7 @@ func expandString(value string, valueType uint32, err error) (string, error) {
|
|||||||
// GetStringValueWait function reads a string value from registry. It waits
|
// GetStringValueWait function reads a string value from registry. It waits
|
||||||
// for the registry value to become available or returns error on timeout.
|
// for the registry value to become available or returns error on timeout.
|
||||||
//
|
//
|
||||||
// Key must be opened with at least QUERY_VALUE|KEY_NOTIFY access.
|
// Key must be opened with at least QUERY_VALUE|NOTIFY access.
|
||||||
//
|
//
|
||||||
// If the value type is REG_EXPAND_SZ the environment variables are expanded.
|
// If the value type is REG_EXPAND_SZ the environment variables are expanded.
|
||||||
// Should expanding fail, original string value and nil error are returned.
|
// Should expanding fail, original string value and nil error are returned.
|
||||||
@ -217,7 +213,7 @@ func GetStringValue(key registry.Key, name string) (string, error) {
|
|||||||
// It waits for the registry value to become available or returns error on
|
// It waits for the registry value to become available or returns error on
|
||||||
// timeout.
|
// timeout.
|
||||||
//
|
//
|
||||||
// Key must be opened with at least QUERY_VALUE|KEY_NOTIFY access.
|
// Key must be opened with at least QUERY_VALUE|NOTIFY access.
|
||||||
//
|
//
|
||||||
func GetIntegerValueWait(key registry.Key, name string, timeout time.Duration) (uint64, error) {
|
func GetIntegerValueWait(key registry.Key, name string, timeout time.Duration) (uint64, error) {
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
|
@ -66,7 +66,7 @@ func Test_GetValueWait(t *testing.T) {
|
|||||||
key.Close()
|
key.Close()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
key, err := OpenKeyWait(keyRoot, path, registry.QUERY_VALUE|KEY_NOTIFY, time.Second*2)
|
key, err := OpenKeyWait(keyRoot, path, registry.QUERY_VALUE|registry.NOTIFY, time.Second*2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error waiting for registry key: %v", err)
|
t.Errorf("Error waiting for registry key: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -299,7 +299,7 @@ func CreateInterface(description string, hwndParent uintptr) (*Wintun, bool, err
|
|||||||
if i != 0 {
|
if i != 0 {
|
||||||
time.Sleep(pollTimeout)
|
time.Sleep(pollTimeout)
|
||||||
}
|
}
|
||||||
key, err = devInfoList.OpenDevRegKey(deviceData, setupapi.DICS_FLAG_GLOBAL, 0, setupapi.DIREG_DRV, registry.QUERY_VALUE|registryEx.KEY_NOTIFY)
|
key, err = devInfoList.OpenDevRegKey(deviceData, setupapi.DICS_FLAG_GLOBAL, 0, setupapi.DIREG_DRV, registry.QUERY_VALUE|registry.NOTIFY)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -326,7 +326,7 @@ func CreateInterface(description string, hwndParent uintptr) (*Wintun, bool, err
|
|||||||
key, err = registryEx.OpenKeyWait(
|
key, err = registryEx.OpenKeyWait(
|
||||||
registry.LOCAL_MACHINE,
|
registry.LOCAL_MACHINE,
|
||||||
wintun.GetNetRegKeyName(),
|
wintun.GetNetRegKeyName(),
|
||||||
registry.QUERY_VALUE|registryEx.KEY_NOTIFY,
|
registry.QUERY_VALUE|registry.NOTIFY,
|
||||||
waitForRegistryTimeout)
|
waitForRegistryTimeout)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
_, err = registryEx.GetStringValueWait(key, "Name", waitForRegistryTimeout)
|
_, err = registryEx.GetStringValueWait(key, "Name", waitForRegistryTimeout)
|
||||||
@ -338,7 +338,7 @@ func CreateInterface(description string, hwndParent uintptr) (*Wintun, bool, err
|
|||||||
// Wait for TCP/IP adapter registry key to emerge and populate.
|
// Wait for TCP/IP adapter registry key to emerge and populate.
|
||||||
key, err = registryEx.OpenKeyWait(
|
key, err = registryEx.OpenKeyWait(
|
||||||
registry.LOCAL_MACHINE,
|
registry.LOCAL_MACHINE,
|
||||||
wintun.GetTcpipAdapterRegKeyName(), registry.QUERY_VALUE|registryEx.KEY_NOTIFY,
|
wintun.GetTcpipAdapterRegKeyName(), registry.QUERY_VALUE|registry.NOTIFY,
|
||||||
waitForRegistryTimeout)
|
waitForRegistryTimeout)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
_, err = registryEx.GetFirstStringValueWait(key, "IpConfig", waitForRegistryTimeout)
|
_, err = registryEx.GetFirstStringValueWait(key, "IpConfig", waitForRegistryTimeout)
|
||||||
|
Loading…
Reference in New Issue
Block a user