From 35f3e6cf4a65a85bc280e5fe63faed8ac8b25721 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 10 Nov 2020 11:04:08 +0100 Subject: [PATCH] windows: cleanup mkwinsyscall argument list CL 258038 improperly added a weird custom type to mkwinsyscall, rather than doing the norm with wrapper functions. So, we revert the change to mkwinsyscall and add the proper wrapper function to do the type conversion. Change-Id: I98134e4ce6bf4b52e1384fe84bddeedb00e18c0b Reviewed-on: https://go-review.googlesource.com/c/sys/+/268777 Trust: Jason A. Donenfeld Trust: Alex Brainman Run-TryBot: Jason A. Donenfeld TryBot-Result: Go Bot Reviewed-by: Alex Brainman --- windows/mkwinsyscall/mkwinsyscall.go | 5 ----- windows/syscall_windows.go | 6 +++++- windows/zsyscall_windows.go | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/windows/mkwinsyscall/mkwinsyscall.go b/windows/mkwinsyscall/mkwinsyscall.go index ed8c3ac1..75b5bd2a 100644 --- a/windows/mkwinsyscall/mkwinsyscall.go +++ b/windows/mkwinsyscall/mkwinsyscall.go @@ -196,11 +196,6 @@ func (p *Param) SyscallArgList() []string { s = fmt.Sprintf("unsafe.Pointer(%s)", p.Name) case t == "bool": s = p.tmpVar() - case t == "Coord": - // Convert a COORD into a uintptr (by fooling the type system). This code - // assumes the two SHORTs are correctly laid out; the "cast" to uint32 is - // just to get a pointer to pass. - s = fmt.Sprintf("*((*uint32)(unsafe.Pointer(&%s)))", p.Name) case strings.HasPrefix(t, "[]"): return []string{ fmt.Sprintf("uintptr(unsafe.Pointer(%s))", p.tmpVar()), diff --git a/windows/syscall_windows.go b/windows/syscall_windows.go index 598e8ce5..008ffc11 100644 --- a/windows/syscall_windows.go +++ b/windows/syscall_windows.go @@ -275,7 +275,7 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys GetConsoleMode(console Handle, mode *uint32) (err error) = kernel32.GetConsoleMode //sys SetConsoleMode(console Handle, mode uint32) (err error) = kernel32.SetConsoleMode //sys GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) = kernel32.GetConsoleScreenBufferInfo -//sys SetConsoleCursorPosition(console Handle, position Coord) (err error) = kernel32.SetConsoleCursorPosition +//sys setConsoleCursorPosition(console Handle, position uint32) (err error) = kernel32.SetConsoleCursorPosition //sys WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) = kernel32.WriteConsoleW //sys ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) = kernel32.ReadConsoleW //sys CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) [failretval==InvalidHandle] = kernel32.CreateToolhelp32Snapshot @@ -1480,3 +1480,7 @@ func getUILanguages(flags uint32, f func(flags uint32, numLanguages *uint32, buf return languages, nil } } + +func SetConsoleCursorPosition(console Handle, position Coord) error { + return setConsoleCursorPosition(console, *((*uint32)(unsafe.Pointer(&position)))) +} diff --git a/windows/zsyscall_windows.go b/windows/zsyscall_windows.go index 5d0a54e6..d400c351 100644 --- a/windows/zsyscall_windows.go +++ b/windows/zsyscall_windows.go @@ -2316,8 +2316,8 @@ func ResumeThread(thread Handle) (ret uint32, err error) { return } -func SetConsoleCursorPosition(console Handle, position Coord) (err error) { - r1, _, e1 := syscall.Syscall(procSetConsoleCursorPosition.Addr(), 2, uintptr(console), uintptr(*((*uint32)(unsafe.Pointer(&position)))), 0) +func setConsoleCursorPosition(console Handle, position uint32) (err error) { + r1, _, e1 := syscall.Syscall(procSetConsoleCursorPosition.Addr(), 2, uintptr(console), uintptr(position), 0) if r1 == 0 { err = errnoErr(e1) }