mirror of
https://github.com/ropnop/go-clr
synced 2026-06-08 17:11:59 +00:00
55 lines
907 B
Go
55 lines
907 B
Go
// +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
|
|
}
|