From 0c1ff786ef13daa914a3351c5e6b0321aed5960e Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 18 Sep 2019 00:14:46 -0600 Subject: [PATCH] windows: do not corrupt stack with larger boolean return value Windows type PBOOL is a pointer to a 4 byte value, where 0 means false and not-0 means true. That means we should use uint32 here, not bool, since Go bools can be 1 byte. This commit was re-generated using mksyscall_windows.go from CL 196122. Updates: golang/go#34364 Change-Id: I8e83b9a09c0b58d14ac9a7dee316553940ac6ee3 Reviewed-on: https://go-review.googlesource.com/c/sys/+/196123 Run-TryBot: Jason A. Donenfeld TryBot-Result: Gobot Gobot Reviewed-by: Jason A. Donenfeld --- windows/zsyscall_windows.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/windows/zsyscall_windows.go b/windows/zsyscall_windows.go index 4a989324..b12d5e62 100644 --- a/windows/zsyscall_windows.go +++ b/windows/zsyscall_windows.go @@ -694,7 +694,14 @@ func ExitProcess(exitcode uint32) { } func IsWow64Process(handle Handle, isWow64 *bool) (err error) { - r1, _, e1 := syscall.Syscall(procIsWow64Process.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(isWow64)), 0) + var _p0 uint32 + if *isWow64 { + _p0 = 1 + } else { + _p0 = 0 + } + r1, _, e1 := syscall.Syscall(procIsWow64Process.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(&_p0)), 0) + *isWow64 = _p0 != 0 if r1 == 0 { if e1 != 0 { err = errnoErr(e1)