From 6c1b66802f533f4b6ebad72147e1fd6fe11c6cd7 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Sat, 11 May 2019 06:21:02 +0200 Subject: 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 --- tun/wintun/wintun_windows.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tun/wintun/wintun_windows.go') diff --git a/tun/wintun/wintun_windows.go b/tun/wintun/wintun_windows.go index 4dfc0bc..2e32f64 100644 --- a/tun/wintun/wintun_windows.go +++ b/tun/wintun/wintun_windows.go @@ -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() } } -- cgit v1.2.3