| 1 | //go:build windows |
| 2 | |
| 3 | package edge |
| 4 | |
| 5 | import ( |
| 6 | "golang.org/x/sys/windows" |
| 7 | "unsafe" |
| 8 | ) |
| 9 | |
| 10 | type EventRegistrationToken struct { |
| 11 | value int64 |
| 12 | } |
| 13 | |
| 14 | // IUnknown |
| 15 | type IUnknown struct { |
| 16 | Vtbl *IUnknownVtbl |
| 17 | } |
| 18 | |
| 19 | type IUnknownVtbl struct { |
| 20 | QueryInterface ComProc |
| 21 | AddRef ComProc |
| 22 | Release ComProc |
| 23 | } |
| 24 | |
| 25 | func (i *IUnknownVtbl) CallRelease(this unsafe.Pointer) uint32 { |
| 26 | ret, _, _ := i.Release.Call( |
| 27 | uintptr(this), |
| 28 | ) |
| 29 | |
| 30 | return uint32(ret) |
| 31 | } |
| 32 | |
| 33 | type IUnknownImpl interface { |
| 34 | QueryInterface(refiid, object uintptr) uintptr |
| 35 | AddRef() uintptr |
| 36 | Release() uintptr |
| 37 | } |
| 38 | |
| 39 | type POINT struct { |
| 40 | X, Y int32 |
| 41 | } |
| 42 | type RECT struct { |
| 43 | Left int32 |
| 44 | Top int32 |
| 45 | Right int32 |
| 46 | Bottom int32 |
| 47 | } |
| 48 | type HANDLE uintptr |
| 49 | type HBRUSH uintptr |
| 50 | type HCURSOR uintptr |
| 51 | type HICON uintptr |
| 52 | type HINSTANCE uintptr |
| 53 | type HMENU uintptr |
| 54 | type HMODULE uintptr |
| 55 | type HWND uintptr |
| 56 | |
| 57 | // NOTE: For sure, this is wrong! |
| 58 | type VARIANT uintptr |
| 59 | |
| 60 | type IDataObject struct { |
| 61 | IUnknown |
| 62 | } |
| 63 | |
| 64 | func ptr[T any](p T) *T { |
| 65 | return &p |
| 66 | } |
| 67 | |
| 68 | const ERROR_SUCCESS = windows.ERROR_SUCCESS |
| 69 | |
| 70 | func UTF16PtrFromString(s string) (*uint16, error) { |
| 71 | return windows.UTF16PtrFromString(s) |
| 72 | } |
| 73 | |
| 74 | func UTF16PtrToString(s *uint16) string { |
| 75 | return windows.UTF16PtrToString(s) |
| 76 | } |
| 77 | |
| 78 | func CoTaskMemFree(pv unsafe.Pointer) { |
| 79 | windows.CoTaskMemFree(pv) |
| 80 | } |
| 81 |