diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-13 09:01:49 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-13 13:28:00 +0200 |
commit | 11eca3ec39277009dd1d9730bc8c55c0cd77ba94 (patch) | |
tree | 710f0442ce9e89bc7832c9db56bfa8cdef00bb64 /service/securityapi.go | |
parent | ui: lock runtime thread as early as possible (diff) | |
download | wireguard-windows-11eca3ec39277009dd1d9730bc8c55c0cd77ba94.tar.xz wireguard-windows-11eca3ec39277009dd1d9730bc8c55c0cd77ba94.zip |
service: allow go to create correct environment block
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | service/securityapi.go | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/service/securityapi.go b/service/securityapi.go index 37713b32..d89d9404 100644 --- a/service/securityapi.go +++ b/service/securityapi.go @@ -9,7 +9,6 @@ import ( "errors" "golang.org/x/sys/windows" "runtime" - "unicode/utf16" "unsafe" ) @@ -53,34 +52,6 @@ const ( SE_GROUP_USE_FOR_DENY_ONLY = 0x00000010 ) -//sys createEnvironmentBlock(block *uintptr, token windows.Token, inheritExisting bool) (err error) = userenv.CreateEnvironmentBlock -//sys destroyEnvironmentBlock(block uintptr) (err error) = userenv.DestroyEnvironmentBlock - -func userEnviron(token windows.Token) (env []string, err error) { - var block uintptr - err = createEnvironmentBlock(&block, token, false) - if err != nil { - return - } - offset := uintptr(0) - for { - entry := (*[(1 << 30) - 1]uint16)(unsafe.Pointer(block + offset))[:] - for i, v := range entry { - if v == 0 { - entry = entry[:i] - break - } - } - if len(entry) == 0 { - break - } - env = append(env, string(utf16.Decode(entry))) - offset += 2 * (uintptr(len(entry)) + 1) - } - destroyEnvironmentBlock(block) - return -} - func tokenIsElevated(token windows.Token) bool { var isElevated uint32 var outLen uint32 |