Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions hcsshim.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import (
"github.com/Microsoft/hcsshim/internal/hcserror"
)

//go:generate go run mksyscall_windows.go -output zsyscall_windows.go hcsshim.go

//sys SetCurrentThreadCompartmentId(compartmentId uint32) (hr error) = iphlpapi.SetCurrentThreadCompartmentId

const (
// Specific user-visible exit codes
WaitErrExecFailed = 32767
Expand Down
1 change: 0 additions & 1 deletion internal/hns/hns.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import "fmt"

//go:generate go run ../../mksyscall_windows.go -output zsyscall_windows.go hns.go

//sys SetCurrentThreadCompartmentId(compartmentId uint32) (hr error) = iphlpapi.SetCurrentThreadCompartmentId
//sys _hnsCall(method string, path string, object string, response **uint16) (hr error) = vmcompute.HNSCall?

type EndpointNotFoundError struct {
Expand Down
12 changes: 1 addition & 11 deletions internal/hns/zsyscall_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,11 @@ func errnoErr(e syscall.Errno) error {
}

var (
modiphlpapi = windows.NewLazySystemDLL("iphlpapi.dll")
modvmcompute = windows.NewLazySystemDLL("vmcompute.dll")

procSetCurrentThreadCompartmentId = modiphlpapi.NewProc("SetCurrentThreadCompartmentId")
procHNSCall = modvmcompute.NewProc("HNSCall")
procHNSCall = modvmcompute.NewProc("HNSCall")
)

func SetCurrentThreadCompartmentId(compartmentId uint32) (hr error) {
r0, _, _ := syscall.Syscall(procSetCurrentThreadCompartmentId.Addr(), 1, uintptr(compartmentId), 0, 0)
if int32(r0) < 0 {
hr = interop.Win32FromHresult(r0)
}
return
}

func _hnsCall(method string, path string, object string, response **uint16) (hr error) {
var _p0 *uint16
_p0, hr = syscall.UTF16PtrFromString(method)
Expand Down
52 changes: 52 additions & 0 deletions zsyscall_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT

package hcsshim

import (
"syscall"
"unsafe"

"github.com/Microsoft/hcsshim/internal/interop"
"golang.org/x/sys/windows"
)

var _ unsafe.Pointer

// Do the interface allocations only once for common
// Errno values.
const (
errnoERROR_IO_PENDING = 997
)

var (
errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
)

// errnoErr returns common boxed Errno values, to prevent
// allocations at runtime.
func errnoErr(e syscall.Errno) error {
switch e {
case 0:
return nil
case errnoERROR_IO_PENDING:
return errERROR_IO_PENDING
}
// TODO: add more here, after collecting data on the common
// error values see on Windows. (perhaps when running
// all.bat?)
return e
}

var (
modiphlpapi = windows.NewLazySystemDLL("iphlpapi.dll")

procSetCurrentThreadCompartmentId = modiphlpapi.NewProc("SetCurrentThreadCompartmentId")
)

func SetCurrentThreadCompartmentId(compartmentId uint32) (hr error) {
r0, _, _ := syscall.Syscall(procSetCurrentThreadCompartmentId.Addr(), 1, uintptr(compartmentId), 0, 0)
if int32(r0) < 0 {
hr = interop.Win32FromHresult(r0)
}
return
}