forked from ropnop/go-clr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
methodinfo.go
130 lines (117 loc) · 3.24 KB
/
methodinfo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// +build windows
package clr
import (
"syscall"
"unsafe"
"golang.org/x/sys/windows"
)
// from mscorlib.tlh
type MethodInfo struct {
vtbl *MethodInfoVtbl
}
type MethodInfoVtbl struct {
QueryInterface uintptr
AddRef uintptr
Release uintptr
GetTypeInfoCount uintptr
GetTypeInfo uintptr
GetIDsOfNames uintptr
Invoke uintptr
get_ToString uintptr
Equals uintptr
GetHashCode uintptr
GetType uintptr
get_MemberType uintptr
get_name uintptr
get_DeclaringType uintptr
get_ReflectedType uintptr
GetCustomAttributes uintptr
GetCustomAttributes_2 uintptr
IsDefined uintptr
GetParameters uintptr
GetMethodImplementationFlags uintptr
get_MethodHandle uintptr
get_Attributes uintptr
get_CallingConvention uintptr
Invoke_2 uintptr
get_IsPublic uintptr
get_IsPrivate uintptr
get_IsFamily uintptr
get_IsAssembly uintptr
get_IsFamilyAndAssembly uintptr
get_IsFamilyOrAssembly uintptr
get_IsStatic uintptr
get_IsFinal uintptr
get_IsVirtual uintptr
get_IsHideBySig uintptr
get_IsAbstract uintptr
get_IsSpecialName uintptr
get_IsConstructor uintptr
Invoke_3 uintptr
get_returnType uintptr
get_ReturnTypeCustomAttributes uintptr
GetBaseDefinition uintptr
}
func NewMethodInfoFromPtr(ppv uintptr) *MethodInfo {
return (*MethodInfo)(unsafe.Pointer(ppv))
}
func (obj *MethodInfo) QueryInterface(riid *windows.GUID, ppvObject *uintptr) uintptr {
ret, _, _ := syscall.Syscall(
obj.vtbl.QueryInterface,
3,
uintptr(unsafe.Pointer(obj)),
uintptr(unsafe.Pointer(riid)),
uintptr(unsafe.Pointer(ppvObject)))
return ret
}
func (obj *MethodInfo) AddRef() uintptr {
ret, _, _ := syscall.Syscall(
obj.vtbl.AddRef,
1,
uintptr(unsafe.Pointer(obj)),
0,
0)
return ret
}
func (obj *MethodInfo) Release() uintptr {
ret, _, _ := syscall.Syscall(
obj.vtbl.Release,
1,
uintptr(unsafe.Pointer(obj)),
0,
0)
return ret
}
func (obj *MethodInfo) GetType(pRetVal *uintptr) uintptr {
ret, _, _ := syscall.Syscall(
obj.vtbl.GetType,
2,
uintptr(unsafe.Pointer(obj)),
uintptr(unsafe.Pointer(pRetVal)),
0)
return ret
}
func (obj *MethodInfo) Invoke_3(variantObj Variant, parameters uintptr, pRetVal *uintptr) uintptr {
ret, _, _ := syscall.Syscall6(
obj.vtbl.Invoke_3,
4,
uintptr(unsafe.Pointer(obj)),
uintptr(unsafe.Pointer(&variantObj)),
parameters,
uintptr(unsafe.Pointer(pRetVal)),
0,
0,
)
return ret
}
// GetString returns a string version of the method's signature
func (obj *MethodInfo) GetString(addr *uintptr) error {
ret, _, _ := syscall.Syscall(
obj.vtbl.get_ToString,
2,
uintptr(unsafe.Pointer(obj)),
uintptr(unsafe.Pointer(addr)),
0,
)
return checkOK(ret, "get_ToString")
}