1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/vendor/src/github.com/microsoft/hcsshim/getsharedbaseimages.go

54 lines
1.1 KiB
Go
Raw Normal View History

package hcsshim
import (
"fmt"
"syscall"
"unsafe"
"github.com/Sirupsen/logrus"
)
func GetSharedBaseImages() (imageData string, err error) {
title := "hcsshim::GetSharedBaseImages "
// Load the DLL and get a handle to the procedure we need
dll, proc, err := loadAndFind(procGetSharedBaseImages)
if dll != nil {
defer dll.Release()
}
if err != nil {
return
}
// Load the OLE DLL and get a handle to the CoTaskMemFree procedure
dll2, proc2, err := loadAndFindFromDll(oleDLLName, procCoTaskMemFree)
if dll2 != nil {
defer dll2.Release()
}
if err != nil {
return
}
var output uintptr
// Call the procedure again
logrus.Debugf("Calling proc")
r1, _, _ := proc.Call(
uintptr(unsafe.Pointer(&output)))
if r1 != 0 {
err = fmt.Errorf(title+" - Win32 API call returned error r1=%d errno=%s",
r1, syscall.Errno(r1))
logrus.Error(err)
return
}
// Defer the cleanup of the memory using CoTaskMemFree
defer proc2.Call(output)
imageData = syscall.UTF16ToString((*[1 << 30]uint16)(unsafe.Pointer(output))[:])
logrus.Debugf(title+" - succeeded output=%s", imageData)
return
}