mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 07:41:37 +08:00

* [webview2loader] Add full featured go implementation The new go loader can be activated with the exp_gowebview2loader build tag. * [build] Add information for using the new webvie2loader
38 lines
757 B
Go
38 lines
757 B
Go
package combridge
|
|
|
|
import (
|
|
"unsafe"
|
|
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
var (
|
|
modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
|
|
procGlobalAlloc = modkernel32.NewProc("GlobalAlloc")
|
|
procGlobalFree = modkernel32.NewProc("GlobalFree")
|
|
|
|
uintptrSize = unsafe.Sizeof(uintptr(0))
|
|
)
|
|
|
|
func allocUintptrObject(size int) (uintptr, []uintptr) {
|
|
v := globalAlloc(uintptr(size) * uintptrSize)
|
|
slice := unsafe.Slice((*uintptr)(unsafe.Pointer(v)), size)
|
|
return v, slice
|
|
}
|
|
|
|
func globalAlloc(dwBytes uintptr) uintptr {
|
|
ret, _, _ := procGlobalAlloc.Call(uintptr(0), dwBytes)
|
|
if ret == 0 {
|
|
panic("globalAlloc failed")
|
|
}
|
|
|
|
return ret
|
|
}
|
|
|
|
func globalFree(data uintptr) {
|
|
ret, _, _ := procGlobalFree.Call(data)
|
|
if ret != 0 {
|
|
panic("globalFree failed")
|
|
}
|
|
}
|