-
Notifications
You must be signed in to change notification settings - Fork 56
/
iclrruntimeinfo.go
114 lines (102 loc) · 2.6 KB
/
iclrruntimeinfo.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
// +build windows
package clr
import (
"golang.org/x/sys/windows"
"syscall"
"unsafe"
)
type ICLRRuntimeInfo struct {
vtbl *ICLRRuntimeInfoVtbl
}
type ICLRRuntimeInfoVtbl struct {
QueryInterface uintptr
AddRef uintptr
Release uintptr
GetVersionString uintptr
GetRuntimeDirectory uintptr
IsLoaded uintptr
LoadErrorString uintptr
LoadLibrary uintptr
GetProcAddress uintptr
GetInterface uintptr
IsLoadable uintptr
SetDefaultStartupFlags uintptr
GetDefaultStartupFlags uintptr
BindAsLegacyV2Runtime uintptr
IsStarted uintptr
}
// GetRuntimeInfo is a wrapper function to return an ICLRRuntimeInfo from a standard version string
func GetRuntimeInfo(metahost *ICLRMetaHost, version string) (*ICLRRuntimeInfo, error) {
pwzVersion, err := syscall.UTF16PtrFromString(version)
if err != nil {
return nil, err
}
var pRuntimeInfo uintptr
hr := metahost.GetRuntime(pwzVersion, &IID_ICLRRuntimeInfo, &pRuntimeInfo)
err = checkOK(hr, "metahost.GetRuntime")
if err != nil {
return nil, err
}
return NewICLRRuntimeInfoFromPtr(pRuntimeInfo), nil
}
func NewICLRRuntimeInfoFromPtr(ppv uintptr) *ICLRRuntimeInfo {
return (*ICLRRuntimeInfo)(unsafe.Pointer(ppv))
}
func (obj *ICLRRuntimeInfo) AddRef() uintptr {
ret, _, _ := syscall.Syscall(
obj.vtbl.AddRef,
1,
uintptr(unsafe.Pointer(obj)),
0,
0)
return ret
}
func (obj *ICLRRuntimeInfo) Release() uintptr {
ret, _, _ := syscall.Syscall(
obj.vtbl.Release,
1,
uintptr(unsafe.Pointer(obj)),
0,
0)
return ret
}
func (obj *ICLRRuntimeInfo) GetVersionString(pcchBuffer *uint16, pVersionstringSize *uint32) uintptr {
ret, _, _ := syscall.Syscall(
obj.vtbl.GetVersionString,
3,
uintptr(unsafe.Pointer(obj)),
uintptr(unsafe.Pointer(pcchBuffer)),
uintptr(unsafe.Pointer(&pVersionstringSize)))
return ret
}
func (obj *ICLRRuntimeInfo) GetInterface(rclsid *windows.GUID, riid *windows.GUID, ppUnk *uintptr) uintptr {
ret, _, _ := syscall.Syscall6(
obj.vtbl.GetInterface,
4,
uintptr(unsafe.Pointer(obj)),
uintptr(unsafe.Pointer(rclsid)),
uintptr(unsafe.Pointer(riid)),
uintptr(unsafe.Pointer(ppUnk)),
0,
0)
return ret
}
func (obj *ICLRRuntimeInfo) BindAsLegacyV2Runtime() uintptr {
ret, _, _ := syscall.Syscall(
obj.vtbl.BindAsLegacyV2Runtime,
1,
uintptr(unsafe.Pointer(obj)),
0,
0,
)
return ret
}
func (obj *ICLRRuntimeInfo) IsLoadable(pbLoadable *bool) uintptr {
ret, _, _ := syscall.Syscall(
obj.vtbl.IsLoadable,
2,
uintptr(unsafe.Pointer(obj)),
uintptr(unsafe.Pointer(pbLoadable)),
0)
return ret
}