/
objidl.go
75 lines (66 loc) · 1.52 KB
/
objidl.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
package winrt
import (
"syscall"
"unsafe"
"github.com/go-ole/go-ole"
)
var IMarshalID = ole.NewGUID("{00000003-0000-0000-C000-000000000046}")
type IMarshal struct {
ole.IUnknown
}
type IMarshalVtbl struct {
ole.IUnknownVtbl
GetUnmarshalClass uintptr
GetMarshalSizeMax uintptr
MarshalInterface uintptr
UnmarshalInterface uintptr
ReleaseMarshalData uintptr
DisconnectObject uintptr
}
func (v *IMarshal) VTable() *IMarshalVtbl {
return (*IMarshalVtbl)(unsafe.Pointer(v.RawVTable))
}
func (v *IMarshal) GetUnmarshalClass(
riid *ole.GUID,
pv *uintptr,
dwDestContext uint32,
pvDestContext *uintptr,
mshlflags uint32,
pCid *uintptr,
) error {
r1, _, _ := syscall.SyscallN(
v.VTable().GetUnmarshalClass, uintptr(unsafe.Pointer(v)),
uintptr(unsafe.Pointer(riid)),
uintptr(unsafe.Pointer(pv)),
uintptr(dwDestContext),
uintptr(unsafe.Pointer(pvDestContext)),
uintptr(mshlflags),
uintptr(unsafe.Pointer(pCid)),
)
if r1 != 0 {
return ole.NewError(r1)
}
return nil
}
func (v *IMarshal) GetMarshalSizeMax(
riid *ole.GUID,
pv *uintptr,
dwDestContext uint32,
pvDestContext *uintptr,
mshlflags uint32,
) (size uint32, err error) {
r1, _, _ := syscall.SyscallN(
v.VTable().GetUnmarshalClass, uintptr(unsafe.Pointer(v)),
uintptr(unsafe.Pointer(riid)),
uintptr(unsafe.Pointer(pv)),
uintptr(dwDestContext),
uintptr(unsafe.Pointer(pvDestContext)),
uintptr(mshlflags),
uintptr(unsafe.Pointer(&size)),
)
if r1 != 0 {
return 0, ole.NewError(r1)
}
return size, nil
}
// TODO: implement other methods