wintun: registry: revise value reading

- Make getStringValueRetry() reusable for reading any value type. This
  merges code from GetIntegerValueWait().
- expandString() >> toString() and extend to support REG_MULTI_SZ
  (to return first value of REG_MULTI_SZ). Furthermore, doing our own
  UTF-16 to UTF-8 conversion works around a bug in windows/registry's
  GetStringValue() non-zero terminated string handling.
- Provide toInteger() analogous to toString()
- GetStringValueWait() tolerates and reads REG_MULTI_SZ too now. It
  returns REG_MULTI_SZ[0], making GetFirstStringValueWait() redundant.

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman
2019-05-11 06:21:02 +02:00
committed by Jason A. Donenfeld
parent 5669ed326f
commit 6c1b66802f
2 changed files with 82 additions and 67 deletions

View File

@@ -342,7 +342,7 @@ func CreateInterface(description string, hwndParent uintptr) (*Wintun, bool, err
wintun.GetTcpipAdapterRegKeyName(), registry.QUERY_VALUE|registry.NOTIFY,
waitForRegistryTimeout)
if err == nil {
_, err = registryEx.GetFirstStringValueWait(key, "IpConfig", waitForRegistryTimeout)
_, err = registryEx.GetStringValueWait(key, "IpConfig", waitForRegistryTimeout)
key.Close()
}
}