mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-03 15:47:35 -04:00
windows: use proper system directory path in fallback loader
The %WINDIR% variable is an odd choice and not even entirely reliable. Since Windows 2000, there has been a specific function for determining this information, so let's use it. It's also a useful function in its own right for folks who want to launch system tools in a somewhat safe way, like netsh.exe. Updates golang/go#14959 Updates golang/go#30642 Change-Id: Ic24baf37d14f2daced0c1db2771b5a673d2c8852 Reviewed-on: https://go-review.googlesource.com/c/sys/+/165759 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
This commit is contained in:
committed by
Alex Brainman
parent
980fc434d2
commit
10058d7d4f
@@ -7,6 +7,7 @@
|
||||
package windows_test
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
@@ -51,3 +52,13 @@ func TestGetProcAddressByOrdinal(t *testing.T) {
|
||||
t.Error("shlwapi.dll:IsOS(OS_NT) returned 0, expected non-zero value")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetSystemDirectory(t *testing.T) {
|
||||
d, err := windows.GetSystemDirectory()
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to get system directory: %s", err)
|
||||
}
|
||||
if !strings.HasSuffix(strings.ToLower(d), "\\system32") {
|
||||
t.Fatalf("System directory does not end in system32: %s", d)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user