-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathunknown.go
More file actions
31 lines (24 loc) · 798 Bytes
/
Copy pathunknown.go
File metadata and controls
31 lines (24 loc) · 798 Bytes
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
//go:build windows
package direct
import (
"syscall"
"unsafe"
)
var IIDUnknown = &syscall.GUID{0x00000000, 0x0000, 0x0000, [8]byte{0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}
type IUnknown struct{ *VTable }
func (inf *IUnknown) QueryInterface(riid *syscall.GUID) (unsafe.Pointer, error) {
var r unsafe.Pointer
hr, _, _ := syscall.SyscallN(inf.VTable[0], uintptr(unsafe.Pointer(inf)), uintptr(unsafe.Pointer(riid)), uintptr(unsafe.Pointer(&r)))
if hr&0x80000000 != 0 {
return nil, HResult(hr)
}
return r, nil
}
func (inf *IUnknown) AddRef() uint32 {
r, _, _ := syscall.SyscallN(inf.VTable[1], uintptr(unsafe.Pointer(inf)))
return uint32(r)
}
func (inf *IUnknown) Release() uint32 {
r, _, _ := syscall.SyscallN(inf.VTable[2], uintptr(unsafe.Pointer(inf)))
return uint32(r)
}