github.com/metacubex/mihomo@v1.18.5/.github/patch_go122/48042aa09c2f878c4faa576948b07fe625c4707a.diff (about) 1 diff --git a/src/syscall/exec_windows.go b/src/syscall/exec_windows.go 2 index 06e684c7116b4..b311a5c74684b 100644 3 --- a/src/syscall/exec_windows.go 4 +++ b/src/syscall/exec_windows.go 5 @@ -319,17 +319,6 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle 6 } 7 } 8 9 - var maj, min, build uint32 10 - rtlGetNtVersionNumbers(&maj, &min, &build) 11 - isWin7 := maj < 6 || (maj == 6 && min <= 1) 12 - // NT kernel handles are divisible by 4, with the bottom 3 bits left as 13 - // a tag. The fully set tag correlates with the types of handles we're 14 - // concerned about here. Except, the kernel will interpret some 15 - // special handle values, like -1, -2, and so forth, so kernelbase.dll 16 - // checks to see that those bottom three bits are checked, but that top 17 - // bit is not checked. 18 - isLegacyWin7ConsoleHandle := func(handle Handle) bool { return isWin7 && handle&0x10000003 == 3 } 19 - 20 p, _ := GetCurrentProcess() 21 parentProcess := p 22 if sys.ParentProcess != 0 { 23 @@ -338,15 +327,7 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle 24 fd := make([]Handle, len(attr.Files)) 25 for i := range attr.Files { 26 if attr.Files[i] > 0 { 27 - destinationProcessHandle := parentProcess 28 - 29 - // On Windows 7, console handles aren't real handles, and can only be duplicated 30 - // into the current process, not a parent one, which amounts to the same thing. 31 - if parentProcess != p && isLegacyWin7ConsoleHandle(Handle(attr.Files[i])) { 32 - destinationProcessHandle = p 33 - } 34 - 35 - err := DuplicateHandle(p, Handle(attr.Files[i]), destinationProcessHandle, &fd[i], 0, true, DUPLICATE_SAME_ACCESS) 36 + err := DuplicateHandle(p, Handle(attr.Files[i]), parentProcess, &fd[i], 0, true, DUPLICATE_SAME_ACCESS) 37 if err != nil { 38 return 0, 0, err 39 } 40 @@ -377,14 +358,6 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle 41 42 fd = append(fd, sys.AdditionalInheritedHandles...) 43 44 - // On Windows 7, console handles aren't real handles, so don't pass them 45 - // through to PROC_THREAD_ATTRIBUTE_HANDLE_LIST. 46 - for i := range fd { 47 - if isLegacyWin7ConsoleHandle(fd[i]) { 48 - fd[i] = 0 49 - } 50 - } 51 - 52 // The presence of a NULL handle in the list is enough to cause PROC_THREAD_ATTRIBUTE_HANDLE_LIST 53 // to treat the entire list as empty, so remove NULL handles. 54 j := 0