-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathzsyscall_windows.go
99 lines (84 loc) · 3.47 KB
/
zsyscall_windows.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Code generated by 'go generate'; DO NOT EDIT.
package wsllib
import (
"syscall"
"unsafe"
"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)
errERROR_EINVAL error = syscall.EINVAL
)
// errnoErr returns common boxed Errno values, to prevent
// allocations at runtime.
func errnoErr(e syscall.Errno) error {
switch e {
case 0:
return errERROR_EINVAL
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 (
modwslapi = windows.NewLazySystemDLL("wslapi.dll")
procWslConfigureDistribution = modwslapi.NewProc("WslConfigureDistribution")
procWslGetDistributionConfiguration = modwslapi.NewProc("WslGetDistributionConfiguration")
procWslIsDistributionRegistered = modwslapi.NewProc("WslIsDistributionRegistered")
procWslLaunch = modwslapi.NewProc("WslLaunch")
procWslRegisterDistribution = modwslapi.NewProc("WslRegisterDistribution")
procWslUnregisterDistribution = modwslapi.NewProc("WslUnregisterDistribution")
)
func _WslConfigureDistribution(distributionName *uint16, defaultUID uint64, wslDistributionFlags uint32) (res error) {
r0, _, _ := syscall.Syscall(procWslConfigureDistribution.Addr(), 3, uintptr(unsafe.Pointer(distributionName)), uintptr(defaultUID), uintptr(wslDistributionFlags))
if r0 != 0 {
res = syscall.Errno(r0)
}
return
}
func _WslGetDistributionConfiguration(distributionName *uint16, distributionVersion *uint32, defaultUID *uint64, wslDistributionFlags *uint32, defaultEnv ***uint16, defaultEnvCnt *uint64) (res error) {
r0, _, _ := syscall.Syscall6(procWslGetDistributionConfiguration.Addr(), 6, uintptr(unsafe.Pointer(distributionName)), uintptr(unsafe.Pointer(distributionVersion)), uintptr(unsafe.Pointer(defaultUID)), uintptr(unsafe.Pointer(wslDistributionFlags)), uintptr(unsafe.Pointer(defaultEnv)), uintptr(unsafe.Pointer(defaultEnvCnt)))
if r0 != 0 {
res = syscall.Errno(r0)
}
return
}
func _WslIsDistributionRegistered(distributionName *uint16) (res bool) {
r0, _, _ := syscall.Syscall(procWslIsDistributionRegistered.Addr(), 1, uintptr(unsafe.Pointer(distributionName)), 0, 0)
res = r0 != 0
return
}
func _WslLaunch(distributionName *uint16, command *uint16, useCurrentWorkingDirectory bool, stdIn syscall.Handle, stdOut syscall.Handle, stdErr syscall.Handle, process *syscall.Handle) (err error) {
var _p0 uint32
if useCurrentWorkingDirectory {
_p0 = 1
}
r1, _, e1 := syscall.Syscall9(procWslLaunch.Addr(), 7, uintptr(unsafe.Pointer(distributionName)), uintptr(unsafe.Pointer(command)), uintptr(_p0), uintptr(stdIn), uintptr(stdOut), uintptr(stdErr), uintptr(unsafe.Pointer(process)), 0, 0)
if r1 == 0 {
err = errnoErr(e1)
}
return
}
func _WslRegisterDistribution(distributionName *uint16, tarGzFilename *uint16) (res error) {
r0, _, _ := syscall.Syscall(procWslRegisterDistribution.Addr(), 2, uintptr(unsafe.Pointer(distributionName)), uintptr(unsafe.Pointer(tarGzFilename)), 0)
if r0 != 0 {
res = syscall.Errno(r0)
}
return
}
func _WslUnregisterDistribution(distributionName *uint16) (res error) {
r0, _, _ := syscall.Syscall(procWslUnregisterDistribution.Addr(), 1, uintptr(unsafe.Pointer(distributionName)), 0, 0)
if r0 != 0 {
res = syscall.Errno(r0)
}
return
}