Skip to content

Commit

Permalink
Update with new bindings needed for walk overhaul
Browse files Browse the repository at this point in the history
Updates tailscale/walk#33

Signed-off-by: Aaron Klotz <[email protected]>
  • Loading branch information
dblohm7 committed Apr 3, 2024
1 parent d2e5cde commit 6580b55
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/tailscale/win
go 1.19

require (
github.com/dblohm7/wingoes v0.0.0-20230131214643-2b26ab7fb5f9
github.com/dblohm7/wingoes v0.0.0-20231019175336-f6e33aa7cc34
golang.org/x/sys v0.7.0
golang.org/x/tools v0.8.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/dblohm7/wingoes v0.0.0-20230131214643-2b26ab7fb5f9 h1:BHpX4mgaPLK+6K0ByiQ3fJH9ZrwmHfPJWPIO3et9j6g=
github.com/dblohm7/wingoes v0.0.0-20230131214643-2b26ab7fb5f9/go.mod h1:54MIJVGBIdbHuav7/YRAAhRxZvpEV9Z9p6jCKPLJ2lw=
github.com/dblohm7/wingoes v0.0.0-20231019175336-f6e33aa7cc34 h1:FBMro26TLQwBk+n4fbTSmSf3QUKb09pvW4fz49lxpl0=
github.com/dblohm7/wingoes v0.0.0-20231019175336-f6e33aa7cc34/go.mod h1:6NCrWM5jRefaG7iN0iMShPalLsljHWBh9v1zxM2f8Xs=
golang.org/x/exp v0.0.0-20230127140709-cafedaf64729 h1:H2kBA039yqxDv2DScpuC0knhZXO6Evfmt7mN8sGMh/4=
golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=
golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
Expand Down
19 changes: 18 additions & 1 deletion kernel32.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build windows
// +build windows

package win

import (
"golang.org/x/sys/windows"
"runtime"
"syscall"
"unsafe"

"golang.org/x/sys/windows"
)

const MAX_PATH = 260
Expand Down Expand Up @@ -75,6 +78,7 @@ var (
getProfileString *windows.LazyProc
getThreadLocale *windows.LazyProc
getThreadUILanguage *windows.LazyProc
getTickCount64 *windows.LazyProc
getVersion *windows.LazyProc
globalAlloc *windows.LazyProc
globalFree *windows.LazyProc
Expand Down Expand Up @@ -161,6 +165,7 @@ func init() {
getProfileString = libkernel32.NewProc("GetProfileStringW")
getThreadLocale = libkernel32.NewProc("GetThreadLocale")
getThreadUILanguage = libkernel32.NewProc("GetThreadUILanguage")
getTickCount64 = libkernel32.NewProc("GetTickCount64")
getVersion = libkernel32.NewProc("GetVersion")
globalAlloc = libkernel32.NewProc("GlobalAlloc")
globalFree = libkernel32.NewProc("GlobalFree")
Expand Down Expand Up @@ -449,3 +454,15 @@ func SystemTimeToFileTime(lpSystemTime *SYSTEMTIME, lpFileTime *FILETIME) bool {

return ret != 0
}

func GetTickCount64() uint64 {
if runtime.GOARCH == "386" {
r0, r1, _ := syscall.SyscallN(getTickCount64.Addr())
return uint64(r0) | (uint64(r1) << 32)
}

r0, _, _ := syscall.SyscallN(getTickCount64.Addr())
return uint64(r0)
}

//sys SwitchToThread() (ret bool) = kernel32.SwitchToThread
2 changes: 1 addition & 1 deletion mksyscall.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

package win

//go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zsyscall_windows.go comctl32.go gdiplus.go uxtheme.go
//go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zsyscall_windows.go comctl32.go gdiplus.go kernel32.go user32.go uxtheme.go
//go:generate go run golang.org/x/tools/cmd/goimports -w zsyscall_windows.go
37 changes: 36 additions & 1 deletion user32.go
Original file line number Diff line number Diff line change
Expand Up @@ -2971,7 +2971,7 @@ func LoadString(instRes HINSTANCE, id uint32, buf *uint16, length int32) int32 {
// MB_ICONHAND (See MB_ICONERROR)
// MB_ICONINFORMATION (The sounds specified as the Windows Asterisk sound)
// MB_ICONQUESTION (The sound specified as the Windows Question sound)
// MB_ICONSTOP (See MB_ICONERROR)
// MB_ICONSTOP (See MB_ICONERROR)
// MB_ICONWARNING (The sounds specified as the Windows Exclamation sound)
// MB_OK (The sound specified as the Windows Default Beep sound)
//
Expand Down Expand Up @@ -3533,3 +3533,38 @@ func WindowFromPoint(Point POINT) HWND {

return HWND(ret)
}

const (
MSGF_USER = 4096
)

//sys CallMsgFilter(msg *MSG, nCode int32) (ret bool) = user32.CallMsgFilterW

const (
QS_KEY = 0x0001
QS_MOUSEMOVE = 0x0002
QS_MOUSEBUTTON = 0x0004
QS_POSTMESSAGE = 0x0008
QS_TIMER = 0x0010
QS_PAINT = 0x0020
QS_SENDMESSAGE = 0x0040
QS_HOTKEY = 0x0080
QS_ALLPOSTMESSAGE = 0x0100
QS_RAWINPUT = 0x0400
QS_TOUCH = 0x0800
QS_POINTER = 0x1000
QS_MOUSE = QS_MOUSEMOVE | QS_MOUSEBUTTON
QS_INPUT = QS_MOUSE | QS_KEY | QS_RAWINPUT | QS_TOUCH | QS_POINTER
QS_ALLEVENTS = QS_INPUT | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_HOTKEY
QS_ALLINPUT = QS_INPUT | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_HOTKEY | QS_SENDMESSAGE
)

//sys GetQueueStatus(flags uint32) (ret uint32) = user32.GetQueueStatus

const (
MWMO_WAITALL = 0x0001
MWMO_ALERTABLE = 0x0002
MWMO_INPUTAVAILABLE = 0x0004
)

//sys MsgWaitForMultipleObjectsEx(count uint32, handles *windows.Handle, timeoutMillis uint32, wakeMask uint32, flags uint32) (ret uint32, err error) [failretval==windows.WAIT_FAILED] = user32.MsgWaitForMultipleObjectsEx
33 changes: 33 additions & 0 deletions zsyscall_windows.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6580b55

Please sign in to comment.