summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-10-24 11:16:55 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-10-24 11:16:55 +0200
commitc5100a61d29c9ea1c935d3dae5d963e5b9f2cb57 (patch)
tree329346ad2eeecfab3788ad89da5ee702983a177d
parentAdd PROGRESS theme part and state constants (diff)
downloadwireguard-windows-c5100a61d29c9ea1c935d3dae5d963e5b9f2cb57.tar.xz
wireguard-windows-c5100a61d29c9ea1c935d3dae5d963e5b9f2cb57.zip
oleacc: pass structs on stack for 32-bit calling convention
The original author of this code never tested it. Fixes #95
-rw-r--r--oleacc.go74
-rw-r--r--oleacc_386.go99
-rw-r--r--oleacc_amd64.go88
3 files changed, 187 insertions, 74 deletions
diff --git a/oleacc.go b/oleacc.go
index 7c5f8662..4891cc16 100644
--- a/oleacc.go
+++ b/oleacc.go
@@ -218,24 +218,6 @@ func (obj *IAccPropServices) Release() uint32 {
return uint32(ret)
}
-// SetPropValue identifies the accessible element to be annotated, specify the property to be annotated, and provide a new value for that property.
-// If server developers know the HWND of the accessible element they want to annotate, they can use one of the following methods: SetHwndPropStr, SetHwndProp, or SetHwndPropServer
-func (obj *IAccPropServices) SetPropValue(idString []byte, idProp *MSAAPROPID, v *VARIANT) HRESULT {
- var idStringPtr unsafe.Pointer
- idStringLen := len(idString)
- if idStringLen != 0 {
- idStringPtr = unsafe.Pointer(&idString[0])
- }
- ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetPropValue, 5,
- uintptr(unsafe.Pointer(obj)),
- uintptr(idStringPtr),
- uintptr(idStringLen),
- uintptr(unsafe.Pointer(idProp)),
- uintptr(unsafe.Pointer(v)),
- 0)
- return HRESULT(ret)
-}
-
// SetPropServer specifies a callback object to be used to annotate an array of properties for the accessible element. You can also specify whether the annotation is to be applied to this accessible element or to the element and its children. This method is used for server annotation.
// If server developers know the HWND of the accessible element they want to annotate, they can use SetHwndPropServer.
func (obj *IAccPropServices) SetPropServer(idString []byte, idProps []MSAAPROPID, server *IAccPropServer, annoScope AnnoScope) HRESULT {
@@ -285,34 +267,6 @@ func (obj *IAccPropServices) ClearProps(idString []byte, idProps []MSAAPROPID) H
return HRESULT(ret)
}
-// SetHwndProp wraps SetPropValue, providing a convenient entry point for callers who are annotating HWND-based accessible elements. If the new value is a string, you can use SetHwndPropStr instead.
-func (obj *IAccPropServices) SetHwndProp(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT {
- ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHwndProp, 6,
- uintptr(unsafe.Pointer(obj)),
- uintptr(hwnd),
- uintptr(idObject),
- uintptr(idChild),
- uintptr(unsafe.Pointer(idProp)),
- uintptr(unsafe.Pointer(v)))
- return HRESULT(ret)
-}
-
-// SetHwndPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HWND-based accessible elements.
-func (obj *IAccPropServices) SetHwndPropStr(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, str string) HRESULT {
- str16, err := syscall.UTF16PtrFromString(str)
- if err != nil {
- return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1)
- }
- ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHwndPropStr, 6,
- uintptr(unsafe.Pointer(obj)),
- uintptr(hwnd),
- uintptr(idObject),
- uintptr(idChild),
- uintptr(unsafe.Pointer(idProp)),
- uintptr(unsafe.Pointer(str16)))
- return HRESULT(ret)
-}
-
// SetHwndPropServer wraps SetPropServer, providing a convenient entry point for callers who are annotating HWND-based accessible elements.
func (obj *IAccPropServices) SetHwndPropServer(hwnd HWND, idObject int32, idChild uint32, idProps []MSAAPROPID, server *IAccPropServer, annoScope AnnoScope) HRESULT {
var idPropsPtr unsafe.Pointer
@@ -389,34 +343,6 @@ func (obj *IAccPropServices) DecomposeHwndIdentityString(idString []byte) (hr HR
return
}
-// SetHmenuProp wraps SetPropValue, providing a convenient entry point for callers who are annotating HMENU-based accessible elements. If the new value is a string, you can use IAccPropServices::SetHmenuPropStr instead.
-func (obj *IAccPropServices) SetHmenuProp(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT {
- ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHmenuProp, 5,
- uintptr(unsafe.Pointer(obj)),
- uintptr(hmenu),
- uintptr(idChild),
- uintptr(unsafe.Pointer(idProp)),
- uintptr(unsafe.Pointer(v)),
- 0)
- return HRESULT(ret)
-}
-
-// SetHmenuPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HMENU-based accessible elements.
-func (obj *IAccPropServices) SetHmenuPropStr(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, str string) HRESULT {
- str16, err := syscall.UTF16PtrFromString(str)
- if err != nil {
- return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1)
- }
- ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHmenuPropStr, 5,
- uintptr(unsafe.Pointer(obj)),
- uintptr(hmenu),
- uintptr(idChild),
- uintptr(unsafe.Pointer(idProp)),
- uintptr(unsafe.Pointer(str16)),
- 0)
- return HRESULT(ret)
-}
-
// SetHmenuPropServer wraps SetPropServer, providing a convenient entry point for callers who are annotating HMENU-based accessible elements.
func (obj *IAccPropServices) SetHmenuPropServer(hmenu HMENU, idChild uint32, idProps []MSAAPROPID, server *IAccPropServer, annoScope AnnoScope) HRESULT {
var idPropsPtr unsafe.Pointer
diff --git a/oleacc_386.go b/oleacc_386.go
new file mode 100644
index 00000000..d3164c18
--- /dev/null
+++ b/oleacc_386.go
@@ -0,0 +1,99 @@
+// Copyright 2010 The win Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build windows
+
+package win
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+func (idProp *MSAAPROPID) split() (uintptr, uintptr, uintptr, uintptr) {
+ if idProp == nil {
+ return 0, 0, 0, 0
+ }
+ x := (*struct { a, b, c, d uintptr })(unsafe.Pointer(idProp))
+ return x.a, x.b, x.c, x.d
+}
+
+// SetPropValue identifies the accessible element to be annotated, specify the property to be annotated, and provide a new value for that property.
+// If server developers know the HWND of the accessible element they want to annotate, they can use one of the following methods: SetHwndPropStr, SetHwndProp, or SetHwndPropServer
+func (obj *IAccPropServices) SetPropValue(idString []byte, idProp *MSAAPROPID, v *VARIANT) HRESULT {
+ var idStringPtr unsafe.Pointer
+ idStringLen := len(idString)
+ if idStringLen != 0 {
+ idStringPtr = unsafe.Pointer(&idString[0])
+ }
+ propA, propB, propC, propD := idProp.split()
+ ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetPropValue, 8,
+ uintptr(unsafe.Pointer(obj)),
+ uintptr(idStringPtr),
+ uintptr(idStringLen),
+ propA, propB, propC, propD,
+ uintptr(unsafe.Pointer(v)),
+ 0)
+ return HRESULT(ret)
+}
+
+// SetHwndProp wraps SetPropValue, providing a convenient entry point for callers who are annotating HWND-based accessible elements. If the new value is a string, you can use SetHwndPropStr instead.
+func (obj *IAccPropServices) SetHwndProp(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT {
+ propA, propB, propC, propD := idProp.split()
+ ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHwndProp, 9,
+ uintptr(unsafe.Pointer(obj)),
+ uintptr(hwnd),
+ uintptr(idObject),
+ uintptr(idChild),
+ propA, propB, propC, propD,
+ uintptr(unsafe.Pointer(v)))
+ return HRESULT(ret)
+}
+
+// SetHwndPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HWND-based accessible elements.
+func (obj *IAccPropServices) SetHwndPropStr(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, str string) HRESULT {
+ str16, err := syscall.UTF16PtrFromString(str)
+ if err != nil {
+ return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1)
+ }
+ propA, propB, propC, propD := idProp.split()
+ ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHwndPropStr, 9,
+ uintptr(unsafe.Pointer(obj)),
+ uintptr(hwnd),
+ uintptr(idObject),
+ uintptr(idChild),
+ propA, propB, propC, propD,
+ uintptr(unsafe.Pointer(str16)))
+ return HRESULT(ret)
+}
+
+// SetHmenuProp wraps SetPropValue, providing a convenient entry point for callers who are annotating HMENU-based accessible elements. If the new value is a string, you can use IAccPropServices::SetHmenuPropStr instead.
+func (obj *IAccPropServices) SetHmenuProp(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT {
+ propA, propB, propC, propD := idProp.split()
+ ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHmenuProp, 8,
+ uintptr(unsafe.Pointer(obj)),
+ uintptr(hmenu),
+ uintptr(idChild),
+ propA, propB, propC, propD,
+ uintptr(unsafe.Pointer(v)),
+ 0)
+ return HRESULT(ret)
+}
+
+// SetHmenuPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HMENU-based accessible elements.
+func (obj *IAccPropServices) SetHmenuPropStr(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, str string) HRESULT {
+ str16, err := syscall.UTF16PtrFromString(str)
+ if err != nil {
+ return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1)
+ }
+ propA, propB, propC, propD := idProp.split()
+ ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHmenuPropStr, 8,
+ uintptr(unsafe.Pointer(obj)),
+ uintptr(hmenu),
+ uintptr(idChild),
+ propA, propB, propC, propD,
+ uintptr(unsafe.Pointer(str16)),
+ 0)
+ return HRESULT(ret)
+}
diff --git a/oleacc_amd64.go b/oleacc_amd64.go
new file mode 100644
index 00000000..b88858b4
--- /dev/null
+++ b/oleacc_amd64.go
@@ -0,0 +1,88 @@
+// Copyright 2010 The win Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build windows
+
+package win
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+// SetPropValue identifies the accessible element to be annotated, specify the property to be annotated, and provide a new value for that property.
+// If server developers know the HWND of the accessible element they want to annotate, they can use one of the following methods: SetHwndPropStr, SetHwndProp, or SetHwndPropServer
+func (obj *IAccPropServices) SetPropValue(idString []byte, idProp *MSAAPROPID, v *VARIANT) HRESULT {
+ var idStringPtr unsafe.Pointer
+ idStringLen := len(idString)
+ if idStringLen != 0 {
+ idStringPtr = unsafe.Pointer(&idString[0])
+ }
+ ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetPropValue, 5,
+ uintptr(unsafe.Pointer(obj)),
+ uintptr(idStringPtr),
+ uintptr(idStringLen),
+ uintptr(unsafe.Pointer(idProp)),
+ uintptr(unsafe.Pointer(v)),
+ 0)
+ return HRESULT(ret)
+}
+
+// SetHwndProp wraps SetPropValue, providing a convenient entry point for callers who are annotating HWND-based accessible elements. If the new value is a string, you can use SetHwndPropStr instead.
+func (obj *IAccPropServices) SetHwndProp(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT {
+ ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHwndProp, 6,
+ uintptr(unsafe.Pointer(obj)),
+ uintptr(hwnd),
+ uintptr(idObject),
+ uintptr(idChild),
+ uintptr(unsafe.Pointer(idProp)),
+ uintptr(unsafe.Pointer(v)))
+ return HRESULT(ret)
+}
+
+// SetHwndPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HWND-based accessible elements.
+func (obj *IAccPropServices) SetHwndPropStr(hwnd HWND, idObject int32, idChild uint32, idProp *MSAAPROPID, str string) HRESULT {
+ str16, err := syscall.UTF16PtrFromString(str)
+ if err != nil {
+ return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1)
+ }
+ ret, _, _ := syscall.Syscall9(obj.LpVtbl.SetHwndPropStr, 7,
+ uintptr(unsafe.Pointer(obj)),
+ uintptr(hwnd),
+ uintptr(idObject),
+ uintptr(idChild),
+ uintptr(unsafe.Pointer(idProp)),
+ 0,
+ uintptr(unsafe.Pointer(str16)),
+ 0, 0)
+ return HRESULT(ret)
+}
+
+// SetHmenuProp wraps SetPropValue, providing a convenient entry point for callers who are annotating HMENU-based accessible elements. If the new value is a string, you can use IAccPropServices::SetHmenuPropStr instead.
+func (obj *IAccPropServices) SetHmenuProp(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, v *VARIANT) HRESULT {
+ ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHmenuProp, 5,
+ uintptr(unsafe.Pointer(obj)),
+ uintptr(hmenu),
+ uintptr(idChild),
+ uintptr(unsafe.Pointer(idProp)),
+ uintptr(unsafe.Pointer(v)),
+ 0)
+ return HRESULT(ret)
+}
+
+// SetHmenuPropStr wraps SetPropValue, providing a more convenient entry point for callers who are annotating HMENU-based accessible elements.
+func (obj *IAccPropServices) SetHmenuPropStr(hmenu HMENU, idChild uint32, idProp *MSAAPROPID, str string) HRESULT {
+ str16, err := syscall.UTF16PtrFromString(str)
+ if err != nil {
+ return -((E_INVALIDARG ^ 0xFFFFFFFF) + 1)
+ }
+ ret, _, _ := syscall.Syscall6(obj.LpVtbl.SetHmenuPropStr, 5,
+ uintptr(unsafe.Pointer(obj)),
+ uintptr(hmenu),
+ uintptr(idChild),
+ uintptr(unsafe.Pointer(idProp)),
+ uintptr(unsafe.Pointer(str16)),
+ 0)
+ return HRESULT(ret)
+}