SyscallN.

This commit is contained in:
Nuno Cruces 2022-08-10 23:52:39 +01:00
parent 5cde0b4fdb
commit e256a51c4a
2 changed files with 11 additions and 15 deletions

View file

@ -50,16 +50,12 @@ func (u *IUnknown) Release() {
//go:uintptrescapes
func (u *IUnknown) call(trap uintptr, a ...uintptr) (r1, r2 uintptr, lastErr error) {
switch nargs := uintptr(len(a)); nargs {
case 0:
return syscall.Syscall(trap, nargs+1, uintptr(unsafe.Pointer(u)), 0, 0)
case 1:
return syscall.Syscall(trap, nargs+1, uintptr(unsafe.Pointer(u)), a[0], 0)
case 2:
return syscall.Syscall(trap, nargs+1, uintptr(unsafe.Pointer(u)), a[0], a[1])
default:
panic("COM call with too many arguments.")
}
return unkcall(uintptr(unsafe.Pointer(u)), trap, a...)
}
//go:uintptrescapes
func unkcall(self, trap uintptr, a ...uintptr) (r1, r2 uintptr, lastErr error) {
return syscall.SyscallN(trap, append([]uintptr{self}, a...)...)
}
// https://github.com/wine-mirror/wine/blob/master/include/objidl.idl

View file

@ -271,7 +271,7 @@ func GetWindowText(wnd HWND) string {
}
func SendMessagePointer(wnd HWND, msg uint32, wparam uintptr, lparam unsafe.Pointer) (ret uintptr) {
r0, _, _ := syscall.Syscall6(procSendMessageW.Addr(), 4, uintptr(wnd), uintptr(msg), uintptr(wparam), uintptr(lparam), 0, 0)
r0, _, _ := syscall.SyscallN(procSendMessageW.Addr(), uintptr(wnd), uintptr(msg), uintptr(wparam), uintptr(lparam))
ret = uintptr(r0)
return
}
@ -290,7 +290,7 @@ func MessageLoop(wnd HWND) error {
isDialogMessage := procIsDialogMessageW.Addr()
for {
s, _, err := syscall.Syscall6(getMessage, 4, uintptr(msg), 0, 0, 0, 0, 0)
s, _, err := syscall.SyscallN(getMessage, uintptr(msg), 0, 0, 0)
if int32(s) == -1 {
return err
}
@ -298,10 +298,10 @@ func MessageLoop(wnd HWND) error {
return nil
}
s, _, _ = syscall.Syscall(isDialogMessage, 2, uintptr(wnd), uintptr(msg), 0)
s, _, _ = syscall.SyscallN(isDialogMessage, uintptr(wnd), uintptr(msg))
if s == 0 {
syscall.Syscall(translateMessage, 1, uintptr(msg), 0, 0)
syscall.Syscall(dispatchMessage, 1, uintptr(msg), 0, 0)
syscall.SyscallN(translateMessage, uintptr(msg))
syscall.SyscallN(dispatchMessage, uintptr(msg))
}
}
}