-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-Windows
Milestone
Description
What version of Go are you using (go version)?
go1.9 windows/amd64
on Windows8.1
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env)?
GOARCH=amd64
GOHOSTARCH=amd64
GOHOSTOS=windows
GOOS=windows
What did you do?
package main
import (
syswin "golang.org/x/sys/windows"
// "syscall"
)
var (
kernel32DLL = syswin.NewLazySystemDLL("kernel32.dll")
user32DLL = syswin.NewLazySystemDLL("user32.dll")
procGetCurrentThreadId = kernel32DLL.NewProc("GetCurrentThreadId")
procSetWindowsHookEx = user32DLL.NewProc("SetWindowsHookExW")
procCallNextHookEx = user32DLL.NewProc("CallNextHookEx")
)
var hook uintptr
func main() {
if err := kernel32DLL.Load(); err != nil {
panic("kernel32.dll not found")
}
defer syswin.FreeLibrary(syswin.Handle(kernel32DLL.Handle()))
if err := user32DLL.Load(); err != nil {
panic("user32.dll not found")
}
defer syswin.FreeLibrary(syswin.Handle(user32DLL.Handle()))
thread_id, _, _ := procGetCurrentThreadId.Call()
// use syscall instead of syswin here, and the code will work
hook, _, _ = procSetWindowsHookEx.Call(2, syswin.NewCallback(callbackFunc), 0 , thread_id)
}
func callbackFunc(code, wparam, lparam uintptr) uintptr {
ret, _, _ := procCallNextHookEx.Call(hook, code, wparam, lparam)
return ret
}What did you expect to see?
NewCallback function in x/sys/windows working correctly as in syscall
What did you see instead?
# command-line-arguments
golang.org/x/sys/windows.NewCallback: call to external function
main.main: relocation target golang.org/x/sys/windows.NewCallback not defined
main.main: undefined: "golang.org/x/sys/windows.NewCallback"
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-Windows