From: qmuntal Date: Tue, 26 Sep 2023 18:29:05 +0000 (+0200) Subject: syscall: remove Windows 7 console handle workaround X-Git-Tag: go1.22rc1~737 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=48042aa09c2f878c4faa576948b07fe625c4707a;p=gostls13.git syscall: remove Windows 7 console handle workaround Windows 7 is no longer supported, there is no need to complicate the code to support inheriting console handles. Change-Id: Ie9f5cde77a63ea4fa6032bbb7ba5bd48a0989c5b Reviewed-on: https://go-review.googlesource.com/c/go/+/531235 Reviewed-by: Bryan Mills TryBot-Result: Gopher Robot Reviewed-by: Than McIntosh Run-TryBot: Quim Muntal LUCI-TryBot-Result: Go LUCI Auto-Submit: Quim Muntal --- diff --git a/src/syscall/exec_windows.go b/src/syscall/exec_windows.go index 06e684c711..b311a5c746 100644 --- a/src/syscall/exec_windows.go +++ b/src/syscall/exec_windows.go @@ -319,17 +319,6 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle } } - var maj, min, build uint32 - rtlGetNtVersionNumbers(&maj, &min, &build) - isWin7 := maj < 6 || (maj == 6 && min <= 1) - // NT kernel handles are divisible by 4, with the bottom 3 bits left as - // a tag. The fully set tag correlates with the types of handles we're - // concerned about here. Except, the kernel will interpret some - // special handle values, like -1, -2, and so forth, so kernelbase.dll - // checks to see that those bottom three bits are checked, but that top - // bit is not checked. - isLegacyWin7ConsoleHandle := func(handle Handle) bool { return isWin7 && handle&0x10000003 == 3 } - p, _ := GetCurrentProcess() parentProcess := p if sys.ParentProcess != 0 { @@ -338,15 +327,7 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle fd := make([]Handle, len(attr.Files)) for i := range attr.Files { if attr.Files[i] > 0 { - destinationProcessHandle := parentProcess - - // On Windows 7, console handles aren't real handles, and can only be duplicated - // into the current process, not a parent one, which amounts to the same thing. - if parentProcess != p && isLegacyWin7ConsoleHandle(Handle(attr.Files[i])) { - destinationProcessHandle = p - } - - err := DuplicateHandle(p, Handle(attr.Files[i]), destinationProcessHandle, &fd[i], 0, true, DUPLICATE_SAME_ACCESS) + err := DuplicateHandle(p, Handle(attr.Files[i]), parentProcess, &fd[i], 0, true, DUPLICATE_SAME_ACCESS) if err != nil { return 0, 0, err } @@ -377,14 +358,6 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle fd = append(fd, sys.AdditionalInheritedHandles...) - // On Windows 7, console handles aren't real handles, so don't pass them - // through to PROC_THREAD_ATTRIBUTE_HANDLE_LIST. - for i := range fd { - if isLegacyWin7ConsoleHandle(fd[i]) { - fd[i] = 0 - } - } - // The presence of a NULL handle in the list is enough to cause PROC_THREAD_ATTRIBUTE_HANDLE_LIST // to treat the entire list as empty, so remove NULL handles. j := 0