Commit ca264cdc authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

syscall: avoid convT2I allocs for common Windows error values

This is was already done for Unix in https://golang.org/cl/6701 +
https://golang.org/cl/8192. Do it for Windows also.

Fixes #16988

Change-Id: Ia7832b0d0d48566b0cd205652b85130df529592e
Reviewed-on: https://go-review.googlesource.com/28484
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarJosh Bleecher Snyder <josharian@gmail.com>
parent 238274df
...@@ -10,6 +10,31 @@ import ( ...@@ -10,6 +10,31 @@ import (
var _ unsafe.Pointer var _ unsafe.Pointer
// Do the interface allocations only once for common
// Errno values.
const (
errnoWSAEINPROGRESS = 10036
)
var (
errWSAEINPROGRESS error = syscall.Errno(errnoWSAEINPROGRESS)
)
// errnoErr returns common boxed Errno values, to prevent
// allocations at runtime.
func errnoErr(e syscall.Errno) error {
switch e {
case 0:
return nil
case errnoWSAEINPROGRESS:
return errWSAEINPROGRESS
}
// TODO: add more here, after collecting data on the common
// error values see on Windows. (perhaps when running
// all.bat?)
return e
}
var ( var (
modadvapi32 = syscall.NewLazyDLL(sysdll.Add("advapi32.dll")) modadvapi32 = syscall.NewLazyDLL(sysdll.Add("advapi32.dll"))
modkernel32 = syscall.NewLazyDLL(sysdll.Add("kernel32.dll")) modkernel32 = syscall.NewLazyDLL(sysdll.Add("kernel32.dll"))
...@@ -76,7 +101,7 @@ func expandEnvironmentStrings(src *uint16, dst *uint16, size uint32) (n uint32, ...@@ -76,7 +101,7 @@ func expandEnvironmentStrings(src *uint16, dst *uint16, size uint32) (n uint32,
n = uint32(r0) n = uint32(r0)
if n == 0 { if n == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = syscall.EINVAL err = syscall.EINVAL
} }
......
...@@ -10,6 +10,31 @@ import ( ...@@ -10,6 +10,31 @@ import (
var _ unsafe.Pointer var _ unsafe.Pointer
// Do the interface allocations only once for common
// Errno values.
const (
errnoWSAEINPROGRESS = 10036
)
var (
errWSAEINPROGRESS error = syscall.Errno(errnoWSAEINPROGRESS)
)
// errnoErr returns common boxed Errno values, to prevent
// allocations at runtime.
func errnoErr(e syscall.Errno) error {
switch e {
case 0:
return nil
case errnoWSAEINPROGRESS:
return errWSAEINPROGRESS
}
// TODO: add more here, after collecting data on the common
// error values see on Windows. (perhaps when running
// all.bat?)
return e
}
var ( var (
modiphlpapi = syscall.NewLazyDLL(sysdll.Add("iphlpapi.dll")) modiphlpapi = syscall.NewLazyDLL(sysdll.Add("iphlpapi.dll"))
modkernel32 = syscall.NewLazyDLL(sysdll.Add("kernel32.dll")) modkernel32 = syscall.NewLazyDLL(sysdll.Add("kernel32.dll"))
...@@ -33,7 +58,7 @@ func GetComputerNameEx(nameformat uint32, buf *uint16, n *uint32) (err error) { ...@@ -33,7 +58,7 @@ func GetComputerNameEx(nameformat uint32, buf *uint16, n *uint32) (err error) {
r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nameformat), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n))) r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nameformat), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)))
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = syscall.EINVAL err = syscall.EINVAL
} }
...@@ -45,7 +70,7 @@ func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) { ...@@ -45,7 +70,7 @@ func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) {
r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags)) r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags))
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = syscall.EINVAL err = syscall.EINVAL
} }
...@@ -64,7 +89,7 @@ func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, ...@@ -64,7 +89,7 @@ func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32,
nwrite = int32(r0) nwrite = int32(r0)
if nwrite == 0 { if nwrite == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = syscall.EINVAL err = syscall.EINVAL
} }
......
...@@ -281,7 +281,7 @@ func (r *Rets) SetReturnValuesCode() string { ...@@ -281,7 +281,7 @@ func (r *Rets) SetReturnValuesCode() string {
func (r *Rets) useLongHandleErrorCode(retvar string) string { func (r *Rets) useLongHandleErrorCode(retvar string) string {
const code = `if %s { const code = `if %s {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = %sEINVAL err = %sEINVAL
} }
...@@ -829,6 +829,31 @@ import ( ...@@ -829,6 +829,31 @@ import (
var _ unsafe.Pointer var _ unsafe.Pointer
// Do the interface allocations only once for common
// Errno values.
const (
errnoWSAEINPROGRESS = 10036
)
var (
errWSAEINPROGRESS error = {{syscalldot}}Errno(errnoWSAEINPROGRESS)
)
// errnoErr returns common boxed Errno values, to prevent
// allocations at runtime.
func errnoErr(e {{syscalldot}}Errno) error {
switch e {
case 0:
return nil
case errnoWSAEINPROGRESS:
return errWSAEINPROGRESS
}
// TODO: add more here, after collecting data on the common
// error values see on Windows. (perhaps when running
// all.bat?)
return e
}
var ( var (
{{template "dlls" .}} {{template "dlls" .}}
{{template "funcnames" .}}) {{template "funcnames" .}})
......
...@@ -9,6 +9,31 @@ import ( ...@@ -9,6 +9,31 @@ import (
var _ unsafe.Pointer var _ unsafe.Pointer
// Do the interface allocations only once for common
// Errno values.
const (
errnoWSAEINPROGRESS = 10036
)
var (
errWSAEINPROGRESS error = Errno(errnoWSAEINPROGRESS)
)
// errnoErr returns common boxed Errno values, to prevent
// allocations at runtime.
func errnoErr(e Errno) error {
switch e {
case 0:
return nil
case errnoWSAEINPROGRESS:
return errWSAEINPROGRESS
}
// TODO: add more here, after collecting data on the common
// error values see on Windows. (perhaps when running
// all.bat?)
return e
}
var ( var (
modkernel32 = NewLazyDLL(sysdll.Add("kernel32.dll")) modkernel32 = NewLazyDLL(sysdll.Add("kernel32.dll"))
modadvapi32 = NewLazyDLL(sysdll.Add("advapi32.dll")) modadvapi32 = NewLazyDLL(sysdll.Add("advapi32.dll"))
...@@ -188,7 +213,7 @@ func _LoadLibrary(libname *uint16) (handle Handle, err error) { ...@@ -188,7 +213,7 @@ func _LoadLibrary(libname *uint16) (handle Handle, err error) {
handle = Handle(r0) handle = Handle(r0)
if handle == 0 { if handle == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -200,7 +225,7 @@ func FreeLibrary(handle Handle) (err error) { ...@@ -200,7 +225,7 @@ func FreeLibrary(handle Handle) (err error) {
r1, _, e1 := Syscall(procFreeLibrary.Addr(), 1, uintptr(handle), 0, 0) r1, _, e1 := Syscall(procFreeLibrary.Addr(), 1, uintptr(handle), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -222,7 +247,7 @@ func _GetProcAddress(module Handle, procname *byte) (proc uintptr, err error) { ...@@ -222,7 +247,7 @@ func _GetProcAddress(module Handle, procname *byte) (proc uintptr, err error) {
proc = uintptr(r0) proc = uintptr(r0)
if proc == 0 { if proc == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -235,7 +260,7 @@ func GetVersion() (ver uint32, err error) { ...@@ -235,7 +260,7 @@ func GetVersion() (ver uint32, err error) {
ver = uint32(r0) ver = uint32(r0)
if ver == 0 { if ver == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -252,7 +277,7 @@ func formatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, bu ...@@ -252,7 +277,7 @@ func formatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, bu
n = uint32(r0) n = uint32(r0)
if n == 0 { if n == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -270,7 +295,7 @@ func CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes ...@@ -270,7 +295,7 @@ func CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes
handle = Handle(r0) handle = Handle(r0)
if handle == InvalidHandle { if handle == InvalidHandle {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -286,7 +311,7 @@ func ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) ( ...@@ -286,7 +311,7 @@ func ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (
r1, _, e1 := Syscall6(procReadFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(done)), uintptr(unsafe.Pointer(overlapped)), 0) r1, _, e1 := Syscall6(procReadFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(done)), uintptr(unsafe.Pointer(overlapped)), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -302,7 +327,7 @@ func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) ...@@ -302,7 +327,7 @@ func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped)
r1, _, e1 := Syscall6(procWriteFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(done)), uintptr(unsafe.Pointer(overlapped)), 0) r1, _, e1 := Syscall6(procWriteFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(done)), uintptr(unsafe.Pointer(overlapped)), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -315,7 +340,7 @@ func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence ...@@ -315,7 +340,7 @@ func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence
newlowoffset = uint32(r0) newlowoffset = uint32(r0)
if newlowoffset == 0xffffffff { if newlowoffset == 0xffffffff {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -327,7 +352,7 @@ func CloseHandle(handle Handle) (err error) { ...@@ -327,7 +352,7 @@ func CloseHandle(handle Handle) (err error) {
r1, _, e1 := Syscall(procCloseHandle.Addr(), 1, uintptr(handle), 0, 0) r1, _, e1 := Syscall(procCloseHandle.Addr(), 1, uintptr(handle), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -340,7 +365,7 @@ func GetStdHandle(stdhandle int) (handle Handle, err error) { ...@@ -340,7 +365,7 @@ func GetStdHandle(stdhandle int) (handle Handle, err error) {
handle = Handle(r0) handle = Handle(r0)
if handle == InvalidHandle { if handle == InvalidHandle {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -353,7 +378,7 @@ func findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err erro ...@@ -353,7 +378,7 @@ func findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err erro
handle = Handle(r0) handle = Handle(r0)
if handle == InvalidHandle { if handle == InvalidHandle {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -365,7 +390,7 @@ func findNextFile1(handle Handle, data *win32finddata1) (err error) { ...@@ -365,7 +390,7 @@ func findNextFile1(handle Handle, data *win32finddata1) (err error) {
r1, _, e1 := Syscall(procFindNextFileW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0) r1, _, e1 := Syscall(procFindNextFileW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -377,7 +402,7 @@ func FindClose(handle Handle) (err error) { ...@@ -377,7 +402,7 @@ func FindClose(handle Handle) (err error) {
r1, _, e1 := Syscall(procFindClose.Addr(), 1, uintptr(handle), 0, 0) r1, _, e1 := Syscall(procFindClose.Addr(), 1, uintptr(handle), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -389,7 +414,7 @@ func GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (e ...@@ -389,7 +414,7 @@ func GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (e
r1, _, e1 := Syscall(procGetFileInformationByHandle.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0) r1, _, e1 := Syscall(procGetFileInformationByHandle.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -402,7 +427,7 @@ func GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) { ...@@ -402,7 +427,7 @@ func GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) {
n = uint32(r0) n = uint32(r0)
if n == 0 { if n == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -414,7 +439,7 @@ func SetCurrentDirectory(path *uint16) (err error) { ...@@ -414,7 +439,7 @@ func SetCurrentDirectory(path *uint16) (err error) {
r1, _, e1 := Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) r1, _, e1 := Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -426,7 +451,7 @@ func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) { ...@@ -426,7 +451,7 @@ func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) {
r1, _, e1 := Syscall(procCreateDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(sa)), 0) r1, _, e1 := Syscall(procCreateDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(sa)), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -438,7 +463,7 @@ func RemoveDirectory(path *uint16) (err error) { ...@@ -438,7 +463,7 @@ func RemoveDirectory(path *uint16) (err error) {
r1, _, e1 := Syscall(procRemoveDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) r1, _, e1 := Syscall(procRemoveDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -450,7 +475,7 @@ func DeleteFile(path *uint16) (err error) { ...@@ -450,7 +475,7 @@ func DeleteFile(path *uint16) (err error) {
r1, _, e1 := Syscall(procDeleteFileW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) r1, _, e1 := Syscall(procDeleteFileW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -462,7 +487,7 @@ func MoveFile(from *uint16, to *uint16) (err error) { ...@@ -462,7 +487,7 @@ func MoveFile(from *uint16, to *uint16) (err error) {
r1, _, e1 := Syscall(procMoveFileW.Addr(), 2, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), 0) r1, _, e1 := Syscall(procMoveFileW.Addr(), 2, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -474,7 +499,7 @@ func GetComputerName(buf *uint16, n *uint32) (err error) { ...@@ -474,7 +499,7 @@ func GetComputerName(buf *uint16, n *uint32) (err error) {
r1, _, e1 := Syscall(procGetComputerNameW.Addr(), 2, uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)), 0) r1, _, e1 := Syscall(procGetComputerNameW.Addr(), 2, uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -486,7 +511,7 @@ func SetEndOfFile(handle Handle) (err error) { ...@@ -486,7 +511,7 @@ func SetEndOfFile(handle Handle) (err error) {
r1, _, e1 := Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0) r1, _, e1 := Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -504,7 +529,7 @@ func GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) { ...@@ -504,7 +529,7 @@ func GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) {
rc = uint32(r0) rc = uint32(r0)
if rc == 0xffffffff { if rc == 0xffffffff {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -517,7 +542,7 @@ func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, thre ...@@ -517,7 +542,7 @@ func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, thre
handle = Handle(r0) handle = Handle(r0)
if handle == 0 { if handle == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -529,7 +554,7 @@ func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overla ...@@ -529,7 +554,7 @@ func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overla
r1, _, e1 := Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(cphandle), uintptr(unsafe.Pointer(qty)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(overlapped)), uintptr(timeout), 0) r1, _, e1 := Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(cphandle), uintptr(unsafe.Pointer(qty)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(overlapped)), uintptr(timeout), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -541,7 +566,7 @@ func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlap ...@@ -541,7 +566,7 @@ func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlap
r1, _, e1 := Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0) r1, _, e1 := Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -553,7 +578,7 @@ func CancelIo(s Handle) (err error) { ...@@ -553,7 +578,7 @@ func CancelIo(s Handle) (err error) {
r1, _, e1 := Syscall(procCancelIo.Addr(), 1, uintptr(s), 0, 0) r1, _, e1 := Syscall(procCancelIo.Addr(), 1, uintptr(s), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -565,7 +590,7 @@ func CancelIoEx(s Handle, o *Overlapped) (err error) { ...@@ -565,7 +590,7 @@ func CancelIoEx(s Handle, o *Overlapped) (err error) {
r1, _, e1 := Syscall(procCancelIoEx.Addr(), 2, uintptr(s), uintptr(unsafe.Pointer(o)), 0) r1, _, e1 := Syscall(procCancelIoEx.Addr(), 2, uintptr(s), uintptr(unsafe.Pointer(o)), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -583,7 +608,7 @@ func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityA ...@@ -583,7 +608,7 @@ func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityA
r1, _, e1 := Syscall12(procCreateProcessW.Addr(), 10, uintptr(unsafe.Pointer(appName)), uintptr(unsafe.Pointer(commandLine)), uintptr(unsafe.Pointer(procSecurity)), uintptr(unsafe.Pointer(threadSecurity)), uintptr(_p0), uintptr(creationFlags), uintptr(unsafe.Pointer(env)), uintptr(unsafe.Pointer(currentDir)), uintptr(unsafe.Pointer(startupInfo)), uintptr(unsafe.Pointer(outProcInfo)), 0, 0) r1, _, e1 := Syscall12(procCreateProcessW.Addr(), 10, uintptr(unsafe.Pointer(appName)), uintptr(unsafe.Pointer(commandLine)), uintptr(unsafe.Pointer(procSecurity)), uintptr(unsafe.Pointer(threadSecurity)), uintptr(_p0), uintptr(creationFlags), uintptr(unsafe.Pointer(env)), uintptr(unsafe.Pointer(currentDir)), uintptr(unsafe.Pointer(startupInfo)), uintptr(unsafe.Pointer(outProcInfo)), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -602,7 +627,7 @@ func OpenProcess(da uint32, inheritHandle bool, pid uint32) (handle Handle, err ...@@ -602,7 +627,7 @@ func OpenProcess(da uint32, inheritHandle bool, pid uint32) (handle Handle, err
handle = Handle(r0) handle = Handle(r0)
if handle == 0 { if handle == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -614,7 +639,7 @@ func TerminateProcess(handle Handle, exitcode uint32) (err error) { ...@@ -614,7 +639,7 @@ func TerminateProcess(handle Handle, exitcode uint32) (err error) {
r1, _, e1 := Syscall(procTerminateProcess.Addr(), 2, uintptr(handle), uintptr(exitcode), 0) r1, _, e1 := Syscall(procTerminateProcess.Addr(), 2, uintptr(handle), uintptr(exitcode), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -626,7 +651,7 @@ func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) { ...@@ -626,7 +651,7 @@ func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) {
r1, _, e1 := Syscall(procGetExitCodeProcess.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(exitcode)), 0) r1, _, e1 := Syscall(procGetExitCodeProcess.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(exitcode)), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -638,7 +663,7 @@ func GetStartupInfo(startupInfo *StartupInfo) (err error) { ...@@ -638,7 +663,7 @@ func GetStartupInfo(startupInfo *StartupInfo) (err error) {
r1, _, e1 := Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0) r1, _, e1 := Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -651,7 +676,7 @@ func GetCurrentProcess() (pseudoHandle Handle, err error) { ...@@ -651,7 +676,7 @@ func GetCurrentProcess() (pseudoHandle Handle, err error) {
pseudoHandle = Handle(r0) pseudoHandle = Handle(r0)
if pseudoHandle == 0 { if pseudoHandle == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -663,7 +688,7 @@ func GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, ...@@ -663,7 +688,7 @@ func GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime,
r1, _, e1 := Syscall6(procGetProcessTimes.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(creationTime)), uintptr(unsafe.Pointer(exitTime)), uintptr(unsafe.Pointer(kernelTime)), uintptr(unsafe.Pointer(userTime)), 0) r1, _, e1 := Syscall6(procGetProcessTimes.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(creationTime)), uintptr(unsafe.Pointer(exitTime)), uintptr(unsafe.Pointer(kernelTime)), uintptr(unsafe.Pointer(userTime)), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -681,7 +706,7 @@ func DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetP ...@@ -681,7 +706,7 @@ func DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetP
r1, _, e1 := Syscall9(procDuplicateHandle.Addr(), 7, uintptr(hSourceProcessHandle), uintptr(hSourceHandle), uintptr(hTargetProcessHandle), uintptr(unsafe.Pointer(lpTargetHandle)), uintptr(dwDesiredAccess), uintptr(_p0), uintptr(dwOptions), 0, 0) r1, _, e1 := Syscall9(procDuplicateHandle.Addr(), 7, uintptr(hSourceProcessHandle), uintptr(hSourceHandle), uintptr(hTargetProcessHandle), uintptr(unsafe.Pointer(lpTargetHandle)), uintptr(dwDesiredAccess), uintptr(_p0), uintptr(dwOptions), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -694,7 +719,7 @@ func WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32, ...@@ -694,7 +719,7 @@ func WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32,
event = uint32(r0) event = uint32(r0)
if event == 0xffffffff { if event == 0xffffffff {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -707,7 +732,7 @@ func GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) { ...@@ -707,7 +732,7 @@ func GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) {
n = uint32(r0) n = uint32(r0)
if n == 0 { if n == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -719,7 +744,7 @@ func CreatePipe(readhandle *Handle, writehandle *Handle, sa *SecurityAttributes, ...@@ -719,7 +744,7 @@ func CreatePipe(readhandle *Handle, writehandle *Handle, sa *SecurityAttributes,
r1, _, e1 := Syscall6(procCreatePipe.Addr(), 4, uintptr(unsafe.Pointer(readhandle)), uintptr(unsafe.Pointer(writehandle)), uintptr(unsafe.Pointer(sa)), uintptr(size), 0, 0) r1, _, e1 := Syscall6(procCreatePipe.Addr(), 4, uintptr(unsafe.Pointer(readhandle)), uintptr(unsafe.Pointer(writehandle)), uintptr(unsafe.Pointer(sa)), uintptr(size), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -732,7 +757,7 @@ func GetFileType(filehandle Handle) (n uint32, err error) { ...@@ -732,7 +757,7 @@ func GetFileType(filehandle Handle) (n uint32, err error) {
n = uint32(r0) n = uint32(r0)
if n == 0 { if n == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -744,7 +769,7 @@ func CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16 ...@@ -744,7 +769,7 @@ func CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16
r1, _, e1 := Syscall6(procCryptAcquireContextW.Addr(), 5, uintptr(unsafe.Pointer(provhandle)), uintptr(unsafe.Pointer(container)), uintptr(unsafe.Pointer(provider)), uintptr(provtype), uintptr(flags), 0) r1, _, e1 := Syscall6(procCryptAcquireContextW.Addr(), 5, uintptr(unsafe.Pointer(provhandle)), uintptr(unsafe.Pointer(container)), uintptr(unsafe.Pointer(provider)), uintptr(provtype), uintptr(flags), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -756,7 +781,7 @@ func CryptReleaseContext(provhandle Handle, flags uint32) (err error) { ...@@ -756,7 +781,7 @@ func CryptReleaseContext(provhandle Handle, flags uint32) (err error) {
r1, _, e1 := Syscall(procCryptReleaseContext.Addr(), 2, uintptr(provhandle), uintptr(flags), 0) r1, _, e1 := Syscall(procCryptReleaseContext.Addr(), 2, uintptr(provhandle), uintptr(flags), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -768,7 +793,7 @@ func CryptGenRandom(provhandle Handle, buflen uint32, buf *byte) (err error) { ...@@ -768,7 +793,7 @@ func CryptGenRandom(provhandle Handle, buflen uint32, buf *byte) (err error) {
r1, _, e1 := Syscall(procCryptGenRandom.Addr(), 3, uintptr(provhandle), uintptr(buflen), uintptr(unsafe.Pointer(buf))) r1, _, e1 := Syscall(procCryptGenRandom.Addr(), 3, uintptr(provhandle), uintptr(buflen), uintptr(unsafe.Pointer(buf)))
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -781,7 +806,7 @@ func GetEnvironmentStrings() (envs *uint16, err error) { ...@@ -781,7 +806,7 @@ func GetEnvironmentStrings() (envs *uint16, err error) {
envs = (*uint16)(unsafe.Pointer(r0)) envs = (*uint16)(unsafe.Pointer(r0))
if envs == nil { if envs == nil {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -793,7 +818,7 @@ func FreeEnvironmentStrings(envs *uint16) (err error) { ...@@ -793,7 +818,7 @@ func FreeEnvironmentStrings(envs *uint16) (err error) {
r1, _, e1 := Syscall(procFreeEnvironmentStringsW.Addr(), 1, uintptr(unsafe.Pointer(envs)), 0, 0) r1, _, e1 := Syscall(procFreeEnvironmentStringsW.Addr(), 1, uintptr(unsafe.Pointer(envs)), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -806,7 +831,7 @@ func GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32 ...@@ -806,7 +831,7 @@ func GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32
n = uint32(r0) n = uint32(r0)
if n == 0 { if n == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -818,7 +843,7 @@ func SetEnvironmentVariable(name *uint16, value *uint16) (err error) { ...@@ -818,7 +843,7 @@ func SetEnvironmentVariable(name *uint16, value *uint16) (err error) {
r1, _, e1 := Syscall(procSetEnvironmentVariableW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), 0) r1, _, e1 := Syscall(procSetEnvironmentVariableW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -830,7 +855,7 @@ func SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetim ...@@ -830,7 +855,7 @@ func SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetim
r1, _, e1 := Syscall6(procSetFileTime.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(ctime)), uintptr(unsafe.Pointer(atime)), uintptr(unsafe.Pointer(wtime)), 0, 0) r1, _, e1 := Syscall6(procSetFileTime.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(ctime)), uintptr(unsafe.Pointer(atime)), uintptr(unsafe.Pointer(wtime)), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -843,7 +868,7 @@ func GetFileAttributes(name *uint16) (attrs uint32, err error) { ...@@ -843,7 +868,7 @@ func GetFileAttributes(name *uint16) (attrs uint32, err error) {
attrs = uint32(r0) attrs = uint32(r0)
if attrs == INVALID_FILE_ATTRIBUTES { if attrs == INVALID_FILE_ATTRIBUTES {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -855,7 +880,7 @@ func SetFileAttributes(name *uint16, attrs uint32) (err error) { ...@@ -855,7 +880,7 @@ func SetFileAttributes(name *uint16, attrs uint32) (err error) {
r1, _, e1 := Syscall(procSetFileAttributesW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(attrs), 0) r1, _, e1 := Syscall(procSetFileAttributesW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(attrs), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -867,7 +892,7 @@ func GetFileAttributesEx(name *uint16, level uint32, info *byte) (err error) { ...@@ -867,7 +892,7 @@ func GetFileAttributesEx(name *uint16, level uint32, info *byte) (err error) {
r1, _, e1 := Syscall(procGetFileAttributesExW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(level), uintptr(unsafe.Pointer(info))) r1, _, e1 := Syscall(procGetFileAttributesExW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(level), uintptr(unsafe.Pointer(info)))
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -886,7 +911,7 @@ func CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err ...@@ -886,7 +911,7 @@ func CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err
argv = (*[8192]*[8192]uint16)(unsafe.Pointer(r0)) argv = (*[8192]*[8192]uint16)(unsafe.Pointer(r0))
if argv == nil { if argv == nil {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -899,7 +924,7 @@ func LocalFree(hmem Handle) (handle Handle, err error) { ...@@ -899,7 +924,7 @@ func LocalFree(hmem Handle) (handle Handle, err error) {
handle = Handle(r0) handle = Handle(r0)
if handle != 0 { if handle != 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -911,7 +936,7 @@ func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error) ...@@ -911,7 +936,7 @@ func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error)
r1, _, e1 := Syscall(procSetHandleInformation.Addr(), 3, uintptr(handle), uintptr(mask), uintptr(flags)) r1, _, e1 := Syscall(procSetHandleInformation.Addr(), 3, uintptr(handle), uintptr(mask), uintptr(flags))
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -923,7 +948,7 @@ func FlushFileBuffers(handle Handle) (err error) { ...@@ -923,7 +948,7 @@ func FlushFileBuffers(handle Handle) (err error) {
r1, _, e1 := Syscall(procFlushFileBuffers.Addr(), 1, uintptr(handle), 0, 0) r1, _, e1 := Syscall(procFlushFileBuffers.Addr(), 1, uintptr(handle), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -936,7 +961,7 @@ func GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) ( ...@@ -936,7 +961,7 @@ func GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) (
n = uint32(r0) n = uint32(r0)
if n == 0 { if n == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -949,7 +974,7 @@ func GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err er ...@@ -949,7 +974,7 @@ func GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err er
n = uint32(r0) n = uint32(r0)
if n == 0 { if n == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -962,7 +987,7 @@ func GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uin ...@@ -962,7 +987,7 @@ func GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uin
n = uint32(r0) n = uint32(r0)
if n == 0 { if n == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -975,7 +1000,7 @@ func CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxS ...@@ -975,7 +1000,7 @@ func CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxS
handle = Handle(r0) handle = Handle(r0)
if handle == 0 { if handle == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -988,7 +1013,7 @@ func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow ui ...@@ -988,7 +1013,7 @@ func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow ui
addr = uintptr(r0) addr = uintptr(r0)
if addr == 0 { if addr == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1000,7 +1025,7 @@ func UnmapViewOfFile(addr uintptr) (err error) { ...@@ -1000,7 +1025,7 @@ func UnmapViewOfFile(addr uintptr) (err error) {
r1, _, e1 := Syscall(procUnmapViewOfFile.Addr(), 1, uintptr(addr), 0, 0) r1, _, e1 := Syscall(procUnmapViewOfFile.Addr(), 1, uintptr(addr), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1012,7 +1037,7 @@ func FlushViewOfFile(addr uintptr, length uintptr) (err error) { ...@@ -1012,7 +1037,7 @@ func FlushViewOfFile(addr uintptr, length uintptr) (err error) {
r1, _, e1 := Syscall(procFlushViewOfFile.Addr(), 2, uintptr(addr), uintptr(length), 0) r1, _, e1 := Syscall(procFlushViewOfFile.Addr(), 2, uintptr(addr), uintptr(length), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1024,7 +1049,7 @@ func VirtualLock(addr uintptr, length uintptr) (err error) { ...@@ -1024,7 +1049,7 @@ func VirtualLock(addr uintptr, length uintptr) (err error) {
r1, _, e1 := Syscall(procVirtualLock.Addr(), 2, uintptr(addr), uintptr(length), 0) r1, _, e1 := Syscall(procVirtualLock.Addr(), 2, uintptr(addr), uintptr(length), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1036,7 +1061,7 @@ func VirtualUnlock(addr uintptr, length uintptr) (err error) { ...@@ -1036,7 +1061,7 @@ func VirtualUnlock(addr uintptr, length uintptr) (err error) {
r1, _, e1 := Syscall(procVirtualUnlock.Addr(), 2, uintptr(addr), uintptr(length), 0) r1, _, e1 := Syscall(procVirtualUnlock.Addr(), 2, uintptr(addr), uintptr(length), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1048,7 +1073,7 @@ func TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint ...@@ -1048,7 +1073,7 @@ func TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint
r1, _, e1 := Syscall9(procTransmitFile.Addr(), 7, uintptr(s), uintptr(handle), uintptr(bytesToWrite), uintptr(bytsPerSend), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(transmitFileBuf)), uintptr(flags), 0, 0) r1, _, e1 := Syscall9(procTransmitFile.Addr(), 7, uintptr(s), uintptr(handle), uintptr(bytesToWrite), uintptr(bytsPerSend), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(transmitFileBuf)), uintptr(flags), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1066,7 +1091,7 @@ func ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree ...@@ -1066,7 +1091,7 @@ func ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree
r1, _, e1 := Syscall9(procReadDirectoryChangesW.Addr(), 8, uintptr(handle), uintptr(unsafe.Pointer(buf)), uintptr(buflen), uintptr(_p0), uintptr(mask), uintptr(unsafe.Pointer(retlen)), uintptr(unsafe.Pointer(overlapped)), uintptr(completionRoutine), 0) r1, _, e1 := Syscall9(procReadDirectoryChangesW.Addr(), 8, uintptr(handle), uintptr(unsafe.Pointer(buf)), uintptr(buflen), uintptr(_p0), uintptr(mask), uintptr(unsafe.Pointer(retlen)), uintptr(unsafe.Pointer(overlapped)), uintptr(completionRoutine), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1079,7 +1104,7 @@ func CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) { ...@@ -1079,7 +1104,7 @@ func CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) {
store = Handle(r0) store = Handle(r0)
if store == 0 { if store == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1092,7 +1117,7 @@ func CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptPr ...@@ -1092,7 +1117,7 @@ func CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptPr
handle = Handle(r0) handle = Handle(r0)
if handle == InvalidHandle { if handle == InvalidHandle {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1105,7 +1130,7 @@ func CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (contex ...@@ -1105,7 +1130,7 @@ func CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (contex
context = (*CertContext)(unsafe.Pointer(r0)) context = (*CertContext)(unsafe.Pointer(r0))
if context == nil { if context == nil {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1117,7 +1142,7 @@ func CertAddCertificateContextToStore(store Handle, certContext *CertContext, ad ...@@ -1117,7 +1142,7 @@ func CertAddCertificateContextToStore(store Handle, certContext *CertContext, ad
r1, _, e1 := Syscall6(procCertAddCertificateContextToStore.Addr(), 4, uintptr(store), uintptr(unsafe.Pointer(certContext)), uintptr(addDisposition), uintptr(unsafe.Pointer(storeContext)), 0, 0) r1, _, e1 := Syscall6(procCertAddCertificateContextToStore.Addr(), 4, uintptr(store), uintptr(unsafe.Pointer(certContext)), uintptr(addDisposition), uintptr(unsafe.Pointer(storeContext)), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1129,7 +1154,7 @@ func CertCloseStore(store Handle, flags uint32) (err error) { ...@@ -1129,7 +1154,7 @@ func CertCloseStore(store Handle, flags uint32) (err error) {
r1, _, e1 := Syscall(procCertCloseStore.Addr(), 2, uintptr(store), uintptr(flags), 0) r1, _, e1 := Syscall(procCertCloseStore.Addr(), 2, uintptr(store), uintptr(flags), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1141,7 +1166,7 @@ func CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, a ...@@ -1141,7 +1166,7 @@ func CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, a
r1, _, e1 := Syscall9(procCertGetCertificateChain.Addr(), 8, uintptr(engine), uintptr(unsafe.Pointer(leaf)), uintptr(unsafe.Pointer(time)), uintptr(additionalStore), uintptr(unsafe.Pointer(para)), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(chainCtx)), 0) r1, _, e1 := Syscall9(procCertGetCertificateChain.Addr(), 8, uintptr(engine), uintptr(unsafe.Pointer(leaf)), uintptr(unsafe.Pointer(time)), uintptr(additionalStore), uintptr(unsafe.Pointer(para)), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(chainCtx)), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1159,7 +1184,7 @@ func CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, en ...@@ -1159,7 +1184,7 @@ func CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, en
context = (*CertContext)(unsafe.Pointer(r0)) context = (*CertContext)(unsafe.Pointer(r0))
if context == nil { if context == nil {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1171,7 +1196,7 @@ func CertFreeCertificateContext(ctx *CertContext) (err error) { ...@@ -1171,7 +1196,7 @@ func CertFreeCertificateContext(ctx *CertContext) (err error) {
r1, _, e1 := Syscall(procCertFreeCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0) r1, _, e1 := Syscall(procCertFreeCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1183,7 +1208,7 @@ func CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext ...@@ -1183,7 +1208,7 @@ func CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext
r1, _, e1 := Syscall6(procCertVerifyCertificateChainPolicy.Addr(), 4, uintptr(policyOID), uintptr(unsafe.Pointer(chain)), uintptr(unsafe.Pointer(para)), uintptr(unsafe.Pointer(status)), 0, 0) r1, _, e1 := Syscall6(procCertVerifyCertificateChainPolicy.Addr(), 4, uintptr(policyOID), uintptr(unsafe.Pointer(chain)), uintptr(unsafe.Pointer(para)), uintptr(unsafe.Pointer(status)), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1241,7 +1266,7 @@ func GetConsoleMode(console Handle, mode *uint32) (err error) { ...@@ -1241,7 +1266,7 @@ func GetConsoleMode(console Handle, mode *uint32) (err error) {
r1, _, e1 := Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0) r1, _, e1 := Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1253,7 +1278,7 @@ func WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, ...@@ -1253,7 +1278,7 @@ func WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32,
r1, _, e1 := Syscall6(procWriteConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(towrite), uintptr(unsafe.Pointer(written)), uintptr(unsafe.Pointer(reserved)), 0) r1, _, e1 := Syscall6(procWriteConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(towrite), uintptr(unsafe.Pointer(written)), uintptr(unsafe.Pointer(reserved)), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1265,7 +1290,7 @@ func ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, input ...@@ -1265,7 +1290,7 @@ func ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, input
r1, _, e1 := Syscall6(procReadConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(toread), uintptr(unsafe.Pointer(read)), uintptr(unsafe.Pointer(inputControl)), 0) r1, _, e1 := Syscall6(procReadConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(toread), uintptr(unsafe.Pointer(read)), uintptr(unsafe.Pointer(inputControl)), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1278,7 +1303,7 @@ func CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, er ...@@ -1278,7 +1303,7 @@ func CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, er
handle = Handle(r0) handle = Handle(r0)
if handle == InvalidHandle { if handle == InvalidHandle {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1290,7 +1315,7 @@ func Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) { ...@@ -1290,7 +1315,7 @@ func Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) {
r1, _, e1 := Syscall(procProcess32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0) r1, _, e1 := Syscall(procProcess32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1302,7 +1327,7 @@ func Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) { ...@@ -1302,7 +1327,7 @@ func Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) {
r1, _, e1 := Syscall(procProcess32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0) r1, _, e1 := Syscall(procProcess32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1314,7 +1339,7 @@ func DeviceIoControl(handle Handle, ioControlCode uint32, inBuffer *byte, inBuff ...@@ -1314,7 +1339,7 @@ func DeviceIoControl(handle Handle, ioControlCode uint32, inBuffer *byte, inBuff
r1, _, e1 := Syscall9(procDeviceIoControl.Addr(), 8, uintptr(handle), uintptr(ioControlCode), uintptr(unsafe.Pointer(inBuffer)), uintptr(inBufferSize), uintptr(unsafe.Pointer(outBuffer)), uintptr(outBufferSize), uintptr(unsafe.Pointer(bytesReturned)), uintptr(unsafe.Pointer(overlapped)), 0) r1, _, e1 := Syscall9(procDeviceIoControl.Addr(), 8, uintptr(handle), uintptr(ioControlCode), uintptr(unsafe.Pointer(inBuffer)), uintptr(inBufferSize), uintptr(unsafe.Pointer(outBuffer)), uintptr(outBufferSize), uintptr(unsafe.Pointer(bytesReturned)), uintptr(unsafe.Pointer(overlapped)), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1326,7 +1351,7 @@ func CreateSymbolicLink(symlinkfilename *uint16, targetfilename *uint16, flags u ...@@ -1326,7 +1351,7 @@ func CreateSymbolicLink(symlinkfilename *uint16, targetfilename *uint16, flags u
r1, _, e1 := Syscall(procCreateSymbolicLinkW.Addr(), 3, uintptr(unsafe.Pointer(symlinkfilename)), uintptr(unsafe.Pointer(targetfilename)), uintptr(flags)) r1, _, e1 := Syscall(procCreateSymbolicLinkW.Addr(), 3, uintptr(unsafe.Pointer(symlinkfilename)), uintptr(unsafe.Pointer(targetfilename)), uintptr(flags))
if r1&0xff == 0 { if r1&0xff == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1338,7 +1363,7 @@ func CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr ...@@ -1338,7 +1363,7 @@ func CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr
r1, _, e1 := Syscall(procCreateHardLinkW.Addr(), 3, uintptr(unsafe.Pointer(filename)), uintptr(unsafe.Pointer(existingfilename)), uintptr(reserved)) r1, _, e1 := Syscall(procCreateHardLinkW.Addr(), 3, uintptr(unsafe.Pointer(filename)), uintptr(unsafe.Pointer(existingfilename)), uintptr(reserved))
if r1&0xff == 0 { if r1&0xff == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1358,7 +1383,7 @@ func WSACleanup() (err error) { ...@@ -1358,7 +1383,7 @@ func WSACleanup() (err error) {
r1, _, e1 := Syscall(procWSACleanup.Addr(), 0, 0, 0, 0) r1, _, e1 := Syscall(procWSACleanup.Addr(), 0, 0, 0, 0)
if r1 == socket_error { if r1 == socket_error {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1370,7 +1395,7 @@ func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbo ...@@ -1370,7 +1395,7 @@ func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbo
r1, _, e1 := Syscall9(procWSAIoctl.Addr(), 9, uintptr(s), uintptr(iocc), uintptr(unsafe.Pointer(inbuf)), uintptr(cbif), uintptr(unsafe.Pointer(outbuf)), uintptr(cbob), uintptr(unsafe.Pointer(cbbr)), uintptr(unsafe.Pointer(overlapped)), uintptr(completionRoutine)) r1, _, e1 := Syscall9(procWSAIoctl.Addr(), 9, uintptr(s), uintptr(iocc), uintptr(unsafe.Pointer(inbuf)), uintptr(cbif), uintptr(unsafe.Pointer(outbuf)), uintptr(cbob), uintptr(unsafe.Pointer(cbbr)), uintptr(unsafe.Pointer(overlapped)), uintptr(completionRoutine))
if r1 == socket_error { if r1 == socket_error {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1383,7 +1408,7 @@ func socket(af int32, typ int32, protocol int32) (handle Handle, err error) { ...@@ -1383,7 +1408,7 @@ func socket(af int32, typ int32, protocol int32) (handle Handle, err error) {
handle = Handle(r0) handle = Handle(r0)
if handle == InvalidHandle { if handle == InvalidHandle {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1395,7 +1420,7 @@ func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32 ...@@ -1395,7 +1420,7 @@ func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32
r1, _, e1 := Syscall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(optlen), 0) r1, _, e1 := Syscall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(optlen), 0)
if r1 == socket_error { if r1 == socket_error {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1407,7 +1432,7 @@ func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int3 ...@@ -1407,7 +1432,7 @@ func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int3
r1, _, e1 := Syscall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(unsafe.Pointer(optlen)), 0) r1, _, e1 := Syscall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(unsafe.Pointer(optlen)), 0)
if r1 == socket_error { if r1 == socket_error {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1419,7 +1444,7 @@ func bind(s Handle, name unsafe.Pointer, namelen int32) (err error) { ...@@ -1419,7 +1444,7 @@ func bind(s Handle, name unsafe.Pointer, namelen int32) (err error) {
r1, _, e1 := Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen)) r1, _, e1 := Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
if r1 == socket_error { if r1 == socket_error {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1431,7 +1456,7 @@ func connect(s Handle, name unsafe.Pointer, namelen int32) (err error) { ...@@ -1431,7 +1456,7 @@ func connect(s Handle, name unsafe.Pointer, namelen int32) (err error) {
r1, _, e1 := Syscall(procconnect.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen)) r1, _, e1 := Syscall(procconnect.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
if r1 == socket_error { if r1 == socket_error {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1443,7 +1468,7 @@ func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) { ...@@ -1443,7 +1468,7 @@ func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
r1, _, e1 := Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) r1, _, e1 := Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
if r1 == socket_error { if r1 == socket_error {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1455,7 +1480,7 @@ func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) { ...@@ -1455,7 +1480,7 @@ func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
r1, _, e1 := Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) r1, _, e1 := Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
if r1 == socket_error { if r1 == socket_error {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1467,7 +1492,7 @@ func listen(s Handle, backlog int32) (err error) { ...@@ -1467,7 +1492,7 @@ func listen(s Handle, backlog int32) (err error) {
r1, _, e1 := Syscall(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0) r1, _, e1 := Syscall(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0)
if r1 == socket_error { if r1 == socket_error {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1479,7 +1504,7 @@ func shutdown(s Handle, how int32) (err error) { ...@@ -1479,7 +1504,7 @@ func shutdown(s Handle, how int32) (err error) {
r1, _, e1 := Syscall(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0) r1, _, e1 := Syscall(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0)
if r1 == socket_error { if r1 == socket_error {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1491,7 +1516,7 @@ func Closesocket(s Handle) (err error) { ...@@ -1491,7 +1516,7 @@ func Closesocket(s Handle) (err error) {
r1, _, e1 := Syscall(procclosesocket.Addr(), 1, uintptr(s), 0, 0) r1, _, e1 := Syscall(procclosesocket.Addr(), 1, uintptr(s), 0, 0)
if r1 == socket_error { if r1 == socket_error {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1503,7 +1528,7 @@ func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32 ...@@ -1503,7 +1528,7 @@ func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32
r1, _, e1 := Syscall9(procAcceptEx.Addr(), 8, uintptr(ls), uintptr(as), uintptr(unsafe.Pointer(buf)), uintptr(rxdatalen), uintptr(laddrlen), uintptr(raddrlen), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(overlapped)), 0) r1, _, e1 := Syscall9(procAcceptEx.Addr(), 8, uintptr(ls), uintptr(as), uintptr(unsafe.Pointer(buf)), uintptr(rxdatalen), uintptr(laddrlen), uintptr(raddrlen), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(overlapped)), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1520,7 +1545,7 @@ func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32 ...@@ -1520,7 +1545,7 @@ func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32
r1, _, e1 := Syscall9(procWSARecv.Addr(), 7, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0, 0) r1, _, e1 := Syscall9(procWSARecv.Addr(), 7, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0, 0)
if r1 == socket_error { if r1 == socket_error {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1532,7 +1557,7 @@ func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, ...@@ -1532,7 +1557,7 @@ func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32,
r1, _, e1 := Syscall9(procWSASend.Addr(), 7, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0, 0) r1, _, e1 := Syscall9(procWSASend.Addr(), 7, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0, 0)
if r1 == socket_error { if r1 == socket_error {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1544,7 +1569,7 @@ func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *ui ...@@ -1544,7 +1569,7 @@ func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *ui
r1, _, e1 := Syscall9(procWSARecvFrom.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine))) r1, _, e1 := Syscall9(procWSARecvFrom.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)))
if r1 == socket_error { if r1 == socket_error {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1556,7 +1581,7 @@ func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32 ...@@ -1556,7 +1581,7 @@ func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32
r1, _, e1 := Syscall9(procWSASendTo.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(to)), uintptr(tolen), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine))) r1, _, e1 := Syscall9(procWSASendTo.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(to)), uintptr(tolen), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)))
if r1 == socket_error { if r1 == socket_error {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1578,7 +1603,7 @@ func _GetHostByName(name *byte) (h *Hostent, err error) { ...@@ -1578,7 +1603,7 @@ func _GetHostByName(name *byte) (h *Hostent, err error) {
h = (*Hostent)(unsafe.Pointer(r0)) h = (*Hostent)(unsafe.Pointer(r0))
if h == nil { if h == nil {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1605,7 +1630,7 @@ func _GetServByName(name *byte, proto *byte) (s *Servent, err error) { ...@@ -1605,7 +1630,7 @@ func _GetServByName(name *byte, proto *byte) (s *Servent, err error) {
s = (*Servent)(unsafe.Pointer(r0)) s = (*Servent)(unsafe.Pointer(r0))
if s == nil { if s == nil {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1633,7 +1658,7 @@ func _GetProtoByName(name *byte) (p *Protoent, err error) { ...@@ -1633,7 +1658,7 @@ func _GetProtoByName(name *byte) (p *Protoent, err error) {
p = (*Protoent)(unsafe.Pointer(r0)) p = (*Protoent)(unsafe.Pointer(r0))
if p == nil { if p == nil {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1702,7 +1727,7 @@ func SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) ...@@ -1702,7 +1727,7 @@ func SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error)
r1, _, e1 := Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(handle), uintptr(flags), 0) r1, _, e1 := Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(handle), uintptr(flags), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1715,7 +1740,7 @@ func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferL ...@@ -1715,7 +1740,7 @@ func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferL
n = int32(r0) n = int32(r0)
if n == -1 { if n == -1 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1727,7 +1752,7 @@ func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint ...@@ -1727,7 +1752,7 @@ func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint
r1, _, e1 := Syscall6(procTranslateNameW.Addr(), 5, uintptr(unsafe.Pointer(accName)), uintptr(accNameFormat), uintptr(desiredNameFormat), uintptr(unsafe.Pointer(translatedName)), uintptr(unsafe.Pointer(nSize)), 0) r1, _, e1 := Syscall6(procTranslateNameW.Addr(), 5, uintptr(unsafe.Pointer(accName)), uintptr(accNameFormat), uintptr(desiredNameFormat), uintptr(unsafe.Pointer(translatedName)), uintptr(unsafe.Pointer(nSize)), 0)
if r1&0xff == 0 { if r1&0xff == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1739,7 +1764,7 @@ func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err er ...@@ -1739,7 +1764,7 @@ func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err er
r1, _, e1 := Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize))) r1, _, e1 := Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize)))
if r1&0xff == 0 { if r1&0xff == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1775,7 +1800,7 @@ func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint3 ...@@ -1775,7 +1800,7 @@ func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint3
r1, _, e1 := Syscall9(procLookupAccountSidW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0) r1, _, e1 := Syscall9(procLookupAccountSidW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1787,7 +1812,7 @@ func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen ...@@ -1787,7 +1812,7 @@ func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen
r1, _, e1 := Syscall9(procLookupAccountNameW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(accountName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sidLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0) r1, _, e1 := Syscall9(procLookupAccountNameW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(accountName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sidLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1799,7 +1824,7 @@ func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) { ...@@ -1799,7 +1824,7 @@ func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) {
r1, _, e1 := Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(stringSid)), 0) r1, _, e1 := Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(stringSid)), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1811,7 +1836,7 @@ func ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) { ...@@ -1811,7 +1836,7 @@ func ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) {
r1, _, e1 := Syscall(procConvertStringSidToSidW.Addr(), 2, uintptr(unsafe.Pointer(stringSid)), uintptr(unsafe.Pointer(sid)), 0) r1, _, e1 := Syscall(procConvertStringSidToSidW.Addr(), 2, uintptr(unsafe.Pointer(stringSid)), uintptr(unsafe.Pointer(sid)), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1829,7 +1854,7 @@ func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) { ...@@ -1829,7 +1854,7 @@ func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) {
r1, _, e1 := Syscall(procCopySid.Addr(), 3, uintptr(destSidLen), uintptr(unsafe.Pointer(destSid)), uintptr(unsafe.Pointer(srcSid))) r1, _, e1 := Syscall(procCopySid.Addr(), 3, uintptr(destSidLen), uintptr(unsafe.Pointer(destSid)), uintptr(unsafe.Pointer(srcSid)))
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1841,7 +1866,7 @@ func OpenProcessToken(h Handle, access uint32, token *Token) (err error) { ...@@ -1841,7 +1866,7 @@ func OpenProcessToken(h Handle, access uint32, token *Token) (err error) {
r1, _, e1 := Syscall(procOpenProcessToken.Addr(), 3, uintptr(h), uintptr(access), uintptr(unsafe.Pointer(token))) r1, _, e1 := Syscall(procOpenProcessToken.Addr(), 3, uintptr(h), uintptr(access), uintptr(unsafe.Pointer(token)))
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1853,7 +1878,7 @@ func GetTokenInformation(t Token, infoClass uint32, info *byte, infoLen uint32, ...@@ -1853,7 +1878,7 @@ func GetTokenInformation(t Token, infoClass uint32, info *byte, infoLen uint32,
r1, _, e1 := Syscall6(procGetTokenInformation.Addr(), 5, uintptr(t), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), uintptr(unsafe.Pointer(returnedLen)), 0) r1, _, e1 := Syscall6(procGetTokenInformation.Addr(), 5, uintptr(t), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), uintptr(unsafe.Pointer(returnedLen)), 0)
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
...@@ -1865,7 +1890,7 @@ func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) { ...@@ -1865,7 +1890,7 @@ func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) {
r1, _, e1 := Syscall(procGetUserProfileDirectoryW.Addr(), 3, uintptr(t), uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen))) r1, _, e1 := Syscall(procGetUserProfileDirectoryW.Addr(), 3, uintptr(t), uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen)))
if r1 == 0 { if r1 == 0 {
if e1 != 0 { if e1 != 0 {
err = error(e1) err = errnoErr(e1)
} else { } else {
err = EINVAL err = EINVAL
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment