-
Notifications
You must be signed in to change notification settings - Fork 56
/
iunknown.go
54 lines (45 loc) · 907 Bytes
/
iunknown.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
// +build windows
package clr
import (
"syscall"
"unsafe"
"golang.org/x/sys/windows"
)
type IUnknown struct {
vtbl *IUnknownVtbl
}
type IUnknownVtbl struct {
QueryInterface uintptr
AddRef uintptr
Release uintptr
}
func NewIUnknownFromPtr(ppv uintptr) *IUnknown {
return (*IUnknown)(unsafe.Pointer(ppv))
}
func (obj *IUnknown) 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 *IUnknown) AddRef() uintptr {
ret, _, _ := syscall.Syscall(
obj.vtbl.AddRef,
1,
uintptr(unsafe.Pointer(obj)),
0,
0)
return ret
}
func (obj *IUnknown) Release() uintptr {
ret, _, _ := syscall.Syscall(
obj.vtbl.Release,
1,
uintptr(unsafe.Pointer(obj)),
0,
0)
return ret
}