aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/sys/windows/zsyscall_windows.go
diff options
context:
space:
mode:
authorAntonio Huete Jimenez <tuxillo@quantumachine.net>2018-10-27 01:18:40 +0200
committertechknowlogick <hello@techknowlogick.com>2018-10-26 19:18:40 -0400
commit99c09dfbfa818c753459e90db5ff12a323d2936f (patch)
tree207f9b07137f2c01a9b7ebf53cc63da89731f518 /vendor/golang.org/x/sys/windows/zsyscall_windows.go
parent2af57c78206272c771e0798db953b9dea42e2fbe (diff)
downloadgitea-99c09dfbfa818c753459e90db5ff12a323d2936f.tar.gz
gitea-99c09dfbfa818c753459e90db5ff12a323d2936f.zip
Update vendor/golang.org/x/sys (#5059)
Diffstat (limited to 'vendor/golang.org/x/sys/windows/zsyscall_windows.go')
-rw-r--r--vendor/golang.org/x/sys/windows/zsyscall_windows.go745
1 files changed, 600 insertions, 145 deletions
diff --git a/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/zsyscall_windows.go
index 3ff8f52532..fc56aec035 100644
--- a/vendor/golang.org/x/sys/windows/zsyscall_windows.go
+++ b/vendor/golang.org/x/sys/windows/zsyscall_windows.go
@@ -1,4 +1,4 @@
-// MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT
+// Code generated by 'go generate'; DO NOT EDIT.
package windows
@@ -9,6 +9,31 @@ import (
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 (
modadvapi32 = NewLazySystemDLL("advapi32.dll")
modkernel32 = NewLazySystemDLL("kernel32.dll")
@@ -39,6 +64,8 @@ var (
procQueryServiceConfigW = modadvapi32.NewProc("QueryServiceConfigW")
procChangeServiceConfig2W = modadvapi32.NewProc("ChangeServiceConfig2W")
procQueryServiceConfig2W = modadvapi32.NewProc("QueryServiceConfig2W")
+ procEnumServicesStatusExW = modadvapi32.NewProc("EnumServicesStatusExW")
+ procQueryServiceStatusEx = modadvapi32.NewProc("QueryServiceStatusEx")
procGetLastError = modkernel32.NewProc("GetLastError")
procLoadLibraryW = modkernel32.NewProc("LoadLibraryW")
procLoadLibraryExW = modkernel32.NewProc("LoadLibraryExW")
@@ -53,6 +80,7 @@ var (
procSetFilePointer = modkernel32.NewProc("SetFilePointer")
procCloseHandle = modkernel32.NewProc("CloseHandle")
procGetStdHandle = modkernel32.NewProc("GetStdHandle")
+ procSetStdHandle = modkernel32.NewProc("SetStdHandle")
procFindFirstFileW = modkernel32.NewProc("FindFirstFileW")
procFindNextFileW = modkernel32.NewProc("FindNextFileW")
procFindClose = modkernel32.NewProc("FindClose")
@@ -68,6 +96,7 @@ var (
procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
procSetEndOfFile = modkernel32.NewProc("SetEndOfFile")
procGetSystemTimeAsFileTime = modkernel32.NewProc("GetSystemTimeAsFileTime")
+ procGetSystemTimePreciseAsFileTime = modkernel32.NewProc("GetSystemTimePreciseAsFileTime")
procGetTimeZoneInformation = modkernel32.NewProc("GetTimeZoneInformation")
procCreateIoCompletionPort = modkernel32.NewProc("CreateIoCompletionPort")
procGetQueuedCompletionStatus = modkernel32.NewProc("GetQueuedCompletionStatus")
@@ -111,6 +140,9 @@ var (
procFlushViewOfFile = modkernel32.NewProc("FlushViewOfFile")
procVirtualLock = modkernel32.NewProc("VirtualLock")
procVirtualUnlock = modkernel32.NewProc("VirtualUnlock")
+ procVirtualAlloc = modkernel32.NewProc("VirtualAlloc")
+ procVirtualFree = modkernel32.NewProc("VirtualFree")
+ procVirtualProtect = modkernel32.NewProc("VirtualProtect")
procTransmitFile = modmswsock.NewProc("TransmitFile")
procReadDirectoryChangesW = modkernel32.NewProc("ReadDirectoryChangesW")
procCertOpenSystemStoreW = modcrypt32.NewProc("CertOpenSystemStoreW")
@@ -130,6 +162,8 @@ var (
procRegQueryValueExW = modadvapi32.NewProc("RegQueryValueExW")
procGetCurrentProcessId = modkernel32.NewProc("GetCurrentProcessId")
procGetConsoleMode = modkernel32.NewProc("GetConsoleMode")
+ procSetConsoleMode = modkernel32.NewProc("SetConsoleMode")
+ procGetConsoleScreenBufferInfo = modkernel32.NewProc("GetConsoleScreenBufferInfo")
procWriteConsoleW = modkernel32.NewProc("WriteConsoleW")
procReadConsoleW = modkernel32.NewProc("ReadConsoleW")
procCreateToolhelp32Snapshot = modkernel32.NewProc("CreateToolhelp32Snapshot")
@@ -140,7 +174,30 @@ var (
procCreateHardLinkW = modkernel32.NewProc("CreateHardLinkW")
procGetCurrentThreadId = modkernel32.NewProc("GetCurrentThreadId")
procCreateEventW = modkernel32.NewProc("CreateEventW")
+ procCreateEventExW = modkernel32.NewProc("CreateEventExW")
+ procOpenEventW = modkernel32.NewProc("OpenEventW")
procSetEvent = modkernel32.NewProc("SetEvent")
+ procResetEvent = modkernel32.NewProc("ResetEvent")
+ procPulseEvent = modkernel32.NewProc("PulseEvent")
+ procDefineDosDeviceW = modkernel32.NewProc("DefineDosDeviceW")
+ procDeleteVolumeMountPointW = modkernel32.NewProc("DeleteVolumeMountPointW")
+ procFindFirstVolumeW = modkernel32.NewProc("FindFirstVolumeW")
+ procFindFirstVolumeMountPointW = modkernel32.NewProc("FindFirstVolumeMountPointW")
+ procFindNextVolumeW = modkernel32.NewProc("FindNextVolumeW")
+ procFindNextVolumeMountPointW = modkernel32.NewProc("FindNextVolumeMountPointW")
+ procFindVolumeClose = modkernel32.NewProc("FindVolumeClose")
+ procFindVolumeMountPointClose = modkernel32.NewProc("FindVolumeMountPointClose")
+ procGetDriveTypeW = modkernel32.NewProc("GetDriveTypeW")
+ procGetLogicalDrives = modkernel32.NewProc("GetLogicalDrives")
+ procGetLogicalDriveStringsW = modkernel32.NewProc("GetLogicalDriveStringsW")
+ procGetVolumeInformationW = modkernel32.NewProc("GetVolumeInformationW")
+ procGetVolumeInformationByHandleW = modkernel32.NewProc("GetVolumeInformationByHandleW")
+ procGetVolumeNameForVolumeMountPointW = modkernel32.NewProc("GetVolumeNameForVolumeMountPointW")
+ procGetVolumePathNameW = modkernel32.NewProc("GetVolumePathNameW")
+ procGetVolumePathNamesForVolumeNameW = modkernel32.NewProc("GetVolumePathNamesForVolumeNameW")
+ procQueryDosDeviceW = modkernel32.NewProc("QueryDosDeviceW")
+ procSetVolumeLabelW = modkernel32.NewProc("SetVolumeLabelW")
+ procSetVolumeMountPointW = modkernel32.NewProc("SetVolumeMountPointW")
procWSAStartup = modws2_32.NewProc("WSAStartup")
procWSACleanup = modws2_32.NewProc("WSACleanup")
procWSAIoctl = modws2_32.NewProc("WSAIoctl")
@@ -190,6 +247,7 @@ var (
procAllocateAndInitializeSid = modadvapi32.NewProc("AllocateAndInitializeSid")
procFreeSid = modadvapi32.NewProc("FreeSid")
procEqualSid = modadvapi32.NewProc("EqualSid")
+ procCheckTokenMembership = modadvapi32.NewProc("CheckTokenMembership")
procOpenProcessToken = modadvapi32.NewProc("OpenProcessToken")
procGetTokenInformation = modadvapi32.NewProc("GetTokenInformation")
procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW")
@@ -200,7 +258,7 @@ func RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Hand
handle = Handle(r0)
if handle == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -212,7 +270,7 @@ func DeregisterEventSource(handle Handle) (err error) {
r1, _, e1 := syscall.Syscall(procDeregisterEventSource.Addr(), 1, uintptr(handle), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -224,7 +282,7 @@ func ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrS
r1, _, e1 := syscall.Syscall9(procReportEventW.Addr(), 9, uintptr(log), uintptr(etype), uintptr(category), uintptr(eventId), uintptr(usrSId), uintptr(numStrings), uintptr(dataSize), uintptr(unsafe.Pointer(strings)), uintptr(unsafe.Pointer(rawData)))
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -237,7 +295,7 @@ func OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (ha
handle = Handle(r0)
if handle == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -249,7 +307,7 @@ func CloseServiceHandle(handle Handle) (err error) {
r1, _, e1 := syscall.Syscall(procCloseServiceHandle.Addr(), 1, uintptr(handle), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -262,7 +320,7 @@ func CreateService(mgr Handle, serviceName *uint16, displayName *uint16, access
handle = Handle(r0)
if handle == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -275,7 +333,7 @@ func OpenService(mgr Handle, serviceName *uint16, access uint32) (handle Handle,
handle = Handle(r0)
if handle == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -287,7 +345,7 @@ func DeleteService(service Handle) (err error) {
r1, _, e1 := syscall.Syscall(procDeleteService.Addr(), 1, uintptr(service), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -299,7 +357,7 @@ func StartService(service Handle, numArgs uint32, argVectors **uint16) (err erro
r1, _, e1 := syscall.Syscall(procStartServiceW.Addr(), 3, uintptr(service), uintptr(numArgs), uintptr(unsafe.Pointer(argVectors)))
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -311,7 +369,7 @@ func QueryServiceStatus(service Handle, status *SERVICE_STATUS) (err error) {
r1, _, e1 := syscall.Syscall(procQueryServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(status)), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -323,7 +381,7 @@ func ControlService(service Handle, control uint32, status *SERVICE_STATUS) (err
r1, _, e1 := syscall.Syscall(procControlService.Addr(), 3, uintptr(service), uintptr(control), uintptr(unsafe.Pointer(status)))
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -335,7 +393,7 @@ func StartServiceCtrlDispatcher(serviceTable *SERVICE_TABLE_ENTRY) (err error) {
r1, _, e1 := syscall.Syscall(procStartServiceCtrlDispatcherW.Addr(), 1, uintptr(unsafe.Pointer(serviceTable)), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -347,7 +405,7 @@ func SetServiceStatus(service Handle, serviceStatus *SERVICE_STATUS) (err error)
r1, _, e1 := syscall.Syscall(procSetServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(serviceStatus)), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -359,7 +417,7 @@ func ChangeServiceConfig(service Handle, serviceType uint32, startType uint32, e
r1, _, e1 := syscall.Syscall12(procChangeServiceConfigW.Addr(), 11, uintptr(service), uintptr(serviceType), uintptr(startType), uintptr(errorControl), uintptr(unsafe.Pointer(binaryPathName)), uintptr(unsafe.Pointer(loadOrderGroup)), uintptr(unsafe.Pointer(tagId)), uintptr(unsafe.Pointer(dependencies)), uintptr(unsafe.Pointer(serviceStartName)), uintptr(unsafe.Pointer(password)), uintptr(unsafe.Pointer(displayName)), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -371,7 +429,7 @@ func QueryServiceConfig(service Handle, serviceConfig *QUERY_SERVICE_CONFIG, buf
r1, _, e1 := syscall.Syscall6(procQueryServiceConfigW.Addr(), 4, uintptr(service), uintptr(unsafe.Pointer(serviceConfig)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -383,7 +441,7 @@ func ChangeServiceConfig2(service Handle, infoLevel uint32, info *byte) (err err
r1, _, e1 := syscall.Syscall(procChangeServiceConfig2W.Addr(), 3, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(info)))
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -395,7 +453,31 @@ func QueryServiceConfig2(service Handle, infoLevel uint32, buff *byte, buffSize
r1, _, e1 := syscall.Syscall6(procQueryServiceConfig2W.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func EnumServicesStatusEx(mgr Handle, infoLevel uint32, serviceType uint32, serviceState uint32, services *byte, bufSize uint32, bytesNeeded *uint32, servicesReturned *uint32, resumeHandle *uint32, groupName *uint16) (err error) {
+ r1, _, e1 := syscall.Syscall12(procEnumServicesStatusExW.Addr(), 10, uintptr(mgr), uintptr(infoLevel), uintptr(serviceType), uintptr(serviceState), uintptr(unsafe.Pointer(services)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), uintptr(unsafe.Pointer(servicesReturned)), uintptr(unsafe.Pointer(resumeHandle)), uintptr(unsafe.Pointer(groupName)), 0, 0)
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func QueryServiceStatusEx(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procQueryServiceStatusEx.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0)
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -425,7 +507,7 @@ func _LoadLibrary(libname *uint16) (handle Handle, err error) {
handle = Handle(r0)
if handle == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -447,7 +529,7 @@ func _LoadLibraryEx(libname *uint16, zero Handle, flags uintptr) (handle Handle,
handle = Handle(r0)
if handle == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -459,7 +541,7 @@ func FreeLibrary(handle Handle) (err error) {
r1, _, e1 := syscall.Syscall(procFreeLibrary.Addr(), 1, uintptr(handle), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -481,7 +563,7 @@ func _GetProcAddress(module Handle, procname *byte) (proc uintptr, err error) {
proc = uintptr(r0)
if proc == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -494,7 +576,7 @@ func GetVersion() (ver uint32, err error) {
ver = uint32(r0)
if ver == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -511,7 +593,7 @@ func FormatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, bu
n = uint32(r0)
if n == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -529,7 +611,7 @@ func CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes
handle = Handle(r0)
if handle == InvalidHandle {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -545,7 +627,7 @@ func ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (
r1, _, e1 := syscall.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 e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -561,7 +643,7 @@ func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped)
r1, _, e1 := syscall.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 e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -574,7 +656,7 @@ func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence
newlowoffset = uint32(r0)
if newlowoffset == 0xffffffff {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -586,7 +668,7 @@ func CloseHandle(handle Handle) (err error) {
r1, _, e1 := syscall.Syscall(procCloseHandle.Addr(), 1, uintptr(handle), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -594,12 +676,24 @@ func CloseHandle(handle Handle) (err error) {
return
}
-func GetStdHandle(stdhandle int) (handle Handle, err error) {
+func GetStdHandle(stdhandle uint32) (handle Handle, err error) {
r0, _, e1 := syscall.Syscall(procGetStdHandle.Addr(), 1, uintptr(stdhandle), 0, 0)
handle = Handle(r0)
if handle == InvalidHandle {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func SetStdHandle(stdhandle uint32, handle Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetStdHandle.Addr(), 2, uintptr(stdhandle), uintptr(handle), 0)
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -612,7 +706,7 @@ func findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err erro
handle = Handle(r0)
if handle == InvalidHandle {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -624,7 +718,7 @@ func findNextFile1(handle Handle, data *win32finddata1) (err error) {
r1, _, e1 := syscall.Syscall(procFindNextFileW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -636,7 +730,7 @@ func FindClose(handle Handle) (err error) {
r1, _, e1 := syscall.Syscall(procFindClose.Addr(), 1, uintptr(handle), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -648,7 +742,7 @@ func GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (e
r1, _, e1 := syscall.Syscall(procGetFileInformationByHandle.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -661,7 +755,7 @@ func GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) {
n = uint32(r0)
if n == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -673,7 +767,7 @@ func SetCurrentDirectory(path *uint16) (err error) {
r1, _, e1 := syscall.Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -685,7 +779,7 @@ func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) {
r1, _, e1 := syscall.Syscall(procCreateDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(sa)), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -697,7 +791,7 @@ func RemoveDirectory(path *uint16) (err error) {
r1, _, e1 := syscall.Syscall(procRemoveDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -709,7 +803,7 @@ func DeleteFile(path *uint16) (err error) {
r1, _, e1 := syscall.Syscall(procDeleteFileW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -721,7 +815,7 @@ func MoveFile(from *uint16, to *uint16) (err error) {
r1, _, e1 := syscall.Syscall(procMoveFileW.Addr(), 2, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -733,7 +827,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))
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -745,7 +839,7 @@ func GetComputerName(buf *uint16, n *uint32) (err error) {
r1, _, e1 := syscall.Syscall(procGetComputerNameW.Addr(), 2, uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -757,7 +851,7 @@ func GetComputerNameEx(nametype uint32, buf *uint16, n *uint32) (err error) {
r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nametype), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)))
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -769,7 +863,7 @@ func SetEndOfFile(handle Handle) (err error) {
r1, _, e1 := syscall.Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -782,12 +876,17 @@ func GetSystemTimeAsFileTime(time *Filetime) {
return
}
+func GetSystemTimePreciseAsFileTime(time *Filetime) {
+ syscall.Syscall(procGetSystemTimePreciseAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0)
+ return
+}
+
func GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) {
r0, _, e1 := syscall.Syscall(procGetTimeZoneInformation.Addr(), 1, uintptr(unsafe.Pointer(tzi)), 0, 0)
rc = uint32(r0)
if rc == 0xffffffff {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -800,7 +899,7 @@ func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, thre
handle = Handle(r0)
if handle == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -812,7 +911,7 @@ func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overla
r1, _, e1 := syscall.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 e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -824,7 +923,7 @@ func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlap
r1, _, e1 := syscall.Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -836,7 +935,7 @@ func CancelIo(s Handle) (err error) {
r1, _, e1 := syscall.Syscall(procCancelIo.Addr(), 1, uintptr(s), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -848,7 +947,7 @@ func CancelIoEx(s Handle, o *Overlapped) (err error) {
r1, _, e1 := syscall.Syscall(procCancelIoEx.Addr(), 2, uintptr(s), uintptr(unsafe.Pointer(o)), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -866,7 +965,7 @@ func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityA
r1, _, e1 := syscall.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 e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -885,7 +984,7 @@ func OpenProcess(da uint32, inheritHandle bool, pid uint32) (handle Handle, err
handle = Handle(r0)
if handle == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -897,7 +996,7 @@ func TerminateProcess(handle Handle, exitcode uint32) (err error) {
r1, _, e1 := syscall.Syscall(procTerminateProcess.Addr(), 2, uintptr(handle), uintptr(exitcode), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -909,7 +1008,7 @@ func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) {
r1, _, e1 := syscall.Syscall(procGetExitCodeProcess.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(exitcode)), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -921,7 +1020,7 @@ func GetStartupInfo(startupInfo *StartupInfo) (err error) {
r1, _, e1 := syscall.Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -934,7 +1033,7 @@ func GetCurrentProcess() (pseudoHandle Handle, err error) {
pseudoHandle = Handle(r0)
if pseudoHandle == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -946,7 +1045,7 @@ func GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime,
r1, _, e1 := syscall.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 e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -964,7 +1063,7 @@ func DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetP
r1, _, e1 := syscall.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 e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -977,7 +1076,7 @@ func WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32,
event = uint32(r0)
if event == 0xffffffff {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -990,7 +1089,7 @@ func GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) {
n = uint32(r0)
if n == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1002,7 +1101,7 @@ func CreatePipe(readhandle *Handle, writehandle *Handle, sa *SecurityAttributes,
r1, _, e1 := syscall.Syscall6(procCreatePipe.Addr(), 4, uintptr(unsafe.Pointer(readhandle)), uintptr(unsafe.Pointer(writehandle)), uintptr(unsafe.Pointer(sa)), uintptr(size), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1015,7 +1114,7 @@ func GetFileType(filehandle Handle) (n uint32, err error) {
n = uint32(r0)
if n == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1027,7 +1126,7 @@ func CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16
r1, _, e1 := syscall.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 e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1039,7 +1138,7 @@ func CryptReleaseContext(provhandle Handle, flags uint32) (err error) {
r1, _, e1 := syscall.Syscall(procCryptReleaseContext.Addr(), 2, uintptr(provhandle), uintptr(flags), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1051,7 +1150,7 @@ func CryptGenRandom(provhandle Handle, buflen uint32, buf *byte) (err error) {
r1, _, e1 := syscall.Syscall(procCryptGenRandom.Addr(), 3, uintptr(provhandle), uintptr(buflen), uintptr(unsafe.Pointer(buf)))
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1064,7 +1163,7 @@ func GetEnvironmentStrings() (envs *uint16, err error) {
envs = (*uint16)(unsafe.Pointer(r0))
if envs == nil {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1076,7 +1175,7 @@ func FreeEnvironmentStrings(envs *uint16) (err error) {
r1, _, e1 := syscall.Syscall(procFreeEnvironmentStringsW.Addr(), 1, uintptr(unsafe.Pointer(envs)), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1089,7 +1188,7 @@ func GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32
n = uint32(r0)
if n == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1101,7 +1200,7 @@ func SetEnvironmentVariable(name *uint16, value *uint16) (err error) {
r1, _, e1 := syscall.Syscall(procSetEnvironmentVariableW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1113,7 +1212,7 @@ func SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetim
r1, _, e1 := syscall.Syscall6(procSetFileTime.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(ctime)), uintptr(unsafe.Pointer(atime)), uintptr(unsafe.Pointer(wtime)), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1126,7 +1225,7 @@ func GetFileAttributes(name *uint16) (attrs uint32, err error) {
attrs = uint32(r0)
if attrs == INVALID_FILE_ATTRIBUTES {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1138,7 +1237,7 @@ func SetFileAttributes(name *uint16, attrs uint32) (err error) {
r1, _, e1 := syscall.Syscall(procSetFileAttributesW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(attrs), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1150,7 +1249,7 @@ func GetFileAttributesEx(name *uint16, level uint32, info *byte) (err error) {
r1, _, e1 := syscall.Syscall(procGetFileAttributesExW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(level), uintptr(unsafe.Pointer(info)))
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1169,7 +1268,7 @@ func CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err
argv = (*[8192]*[8192]uint16)(unsafe.Pointer(r0))
if argv == nil {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1182,7 +1281,7 @@ func LocalFree(hmem Handle) (handle Handle, err error) {
handle = Handle(r0)
if handle != 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1194,7 +1293,7 @@ func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error)
r1, _, e1 := syscall.Syscall(procSetHandleInformation.Addr(), 3, uintptr(handle), uintptr(mask), uintptr(flags))
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1206,7 +1305,7 @@ func FlushFileBuffers(handle Handle) (err error) {
r1, _, e1 := syscall.Syscall(procFlushFileBuffers.Addr(), 1, uintptr(handle), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1219,7 +1318,7 @@ func GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) (
n = uint32(r0)
if n == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1232,7 +1331,7 @@ func GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err er
n = uint32(r0)
if n == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1245,7 +1344,7 @@ func GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uin
n = uint32(r0)
if n == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1258,7 +1357,7 @@ func CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxS
handle = Handle(r0)
if handle == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1271,7 +1370,7 @@ func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow ui
addr = uintptr(r0)
if addr == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1283,7 +1382,7 @@ func UnmapViewOfFile(addr uintptr) (err error) {
r1, _, e1 := syscall.Syscall(procUnmapViewOfFile.Addr(), 1, uintptr(addr), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1295,7 +1394,7 @@ func FlushViewOfFile(addr uintptr, length uintptr) (err error) {
r1, _, e1 := syscall.Syscall(procFlushViewOfFile.Addr(), 2, uintptr(addr), uintptr(length), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1307,7 +1406,7 @@ func VirtualLock(addr uintptr, length uintptr) (err error) {
r1, _, e1 := syscall.Syscall(procVirtualLock.Addr(), 2, uintptr(addr), uintptr(length), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1319,7 +1418,44 @@ func VirtualUnlock(addr uintptr, length uintptr) (err error) {
r1, _, e1 := syscall.Syscall(procVirtualUnlock.Addr(), 2, uintptr(addr), uintptr(length), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func VirtualAlloc(address uintptr, size uintptr, alloctype uint32, protect uint32) (value uintptr, err error) {
+ r0, _, e1 := syscall.Syscall6(procVirtualAlloc.Addr(), 4, uintptr(address), uintptr(size), uintptr(alloctype), uintptr(protect), 0, 0)
+ value = uintptr(r0)
+ if value == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func VirtualFree(address uintptr, size uintptr, freetype uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procVirtualFree.Addr(), 3, uintptr(address), uintptr(size), uintptr(freetype))
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func VirtualProtect(address uintptr, size uintptr, newprotect uint32, oldprotect *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procVirtualProtect.Addr(), 4, uintptr(address), uintptr(size), uintptr(newprotect), uintptr(unsafe.Pointer(oldprotect)), 0, 0)
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1331,7 +1467,7 @@ func TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint
r1, _, e1 := syscall.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 e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1349,7 +1485,7 @@ func ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree
r1, _, e1 := syscall.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 e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1362,7 +1498,7 @@ func CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) {
store = Handle(r0)
if store == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1375,7 +1511,7 @@ func CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptPr
handle = Handle(r0)
if handle == InvalidHandle {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1388,7 +1524,7 @@ func CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (contex
context = (*CertContext)(unsafe.Pointer(r0))
if context == nil {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1400,7 +1536,7 @@ func CertAddCertificateContextToStore(store Handle, certContext *CertContext, ad
r1, _, e1 := syscall.Syscall6(procCertAddCertificateContextToStore.Addr(), 4, uintptr(store), uintptr(unsafe.Pointer(certContext)), uintptr(addDisposition), uintptr(unsafe.Pointer(storeContext)), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1412,7 +1548,7 @@ func CertCloseStore(store Handle, flags uint32) (err error) {
r1, _, e1 := syscall.Syscall(procCertCloseStore.Addr(), 2, uintptr(store), uintptr(flags), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1424,7 +1560,7 @@ func CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, a
r1, _, e1 := syscall.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 e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1442,7 +1578,7 @@ func CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, en
context = (*CertContext)(unsafe.Pointer(r0))
if context == nil {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1454,7 +1590,7 @@ func CertFreeCertificateContext(ctx *CertContext) (err error) {
r1, _, e1 := syscall.Syscall(procCertFreeCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1466,7 +1602,7 @@ func CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext
r1, _, e1 := syscall.Syscall6(procCertVerifyCertificateChainPolicy.Addr(), 4, uintptr(policyOID), uintptr(unsafe.Pointer(chain)), uintptr(unsafe.Pointer(para)), uintptr(unsafe.Pointer(status)), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1524,7 +1660,31 @@ func GetConsoleMode(console Handle, mode *uint32) (err error) {
r1, _, e1 := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func SetConsoleMode(console Handle, mode uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(console), uintptr(mode), 0)
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(info)), 0)
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1536,7 +1696,7 @@ func WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32,
r1, _, e1 := syscall.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 e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1548,7 +1708,7 @@ func ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, input
r1, _, e1 := syscall.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 e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1561,7 +1721,7 @@ func CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, er
handle = Handle(r0)
if handle == InvalidHandle {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1573,7 +1733,7 @@ func Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) {
r1, _, e1 := syscall.Syscall(procProcess32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1585,7 +1745,7 @@ func Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) {
r1, _, e1 := syscall.Syscall(procProcess32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1597,7 +1757,7 @@ func DeviceIoControl(handle Handle, ioControlCode uint32, inBuffer *byte, inBuff
r1, _, e1 := syscall.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 e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1609,7 +1769,7 @@ func CreateSymbolicLink(symlinkfilename *uint16, targetfilename *uint16, flags u
r1, _, e1 := syscall.Syscall(procCreateSymbolicLinkW.Addr(), 3, uintptr(unsafe.Pointer(symlinkfilename)), uintptr(unsafe.Pointer(targetfilename)), uintptr(flags))
if r1&0xff == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1621,7 +1781,7 @@ func CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr
r1, _, e1 := syscall.Syscall(procCreateHardLinkW.Addr(), 3, uintptr(unsafe.Pointer(filename)), uintptr(unsafe.Pointer(existingfilename)), uintptr(reserved))
if r1&0xff == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1635,12 +1795,44 @@ func GetCurrentThreadId() (id uint32) {
return
}
-func CreateEvent(eventAttrs *syscall.SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) {
+func CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) {
r0, _, e1 := syscall.Syscall6(procCreateEventW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(manualReset), uintptr(initialState), uintptr(unsafe.Pointer(name)), 0, 0)
handle = Handle(r0)
if handle == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func CreateEventEx(eventAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall6(procCreateEventExW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(desiredAccess), 0, 0)
+ handle = Handle(r0)
+ if handle == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func OpenEvent(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) {
+ var _p0 uint32
+ if inheritHandle {
+ _p0 = 1
+ } else {
+ _p0 = 0
+ }
+ r0, _, e1 := syscall.Syscall(procOpenEventW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name)))
+ handle = Handle(r0)
+ if handle == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1652,7 +1844,258 @@ func SetEvent(event Handle) (err error) {
r1, _, e1 := syscall.Syscall(procSetEvent.Addr(), 1, uintptr(event), 0, 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func ResetEvent(event Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procResetEvent.Addr(), 1, uintptr(event), 0, 0)
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func PulseEvent(event Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procPulseEvent.Addr(), 1, uintptr(event), 0, 0)
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) {
+ r1, _, e1 := syscall.Syscall(procDefineDosDeviceW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)))
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func DeleteVolumeMountPoint(volumeMountPoint *uint16) (err error) {
+ r1, _, e1 := syscall.Syscall(procDeleteVolumeMountPointW.Addr(), 1, uintptr(unsafe.Pointer(volumeMountPoint)), 0, 0)
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func FindFirstVolume(volumeName *uint16, bufferLength uint32) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall(procFindFirstVolumeW.Addr(), 2, uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength), 0)
+ handle = Handle(r0)
+ if handle == InvalidHandle {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func FindFirstVolumeMountPoint(rootPathName *uint16, volumeMountPoint *uint16, bufferLength uint32) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall(procFindFirstVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength))
+ handle = Handle(r0)
+ if handle == InvalidHandle {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func FindNextVolume(findVolume Handle, volumeName *uint16, bufferLength uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procFindNextVolumeW.Addr(), 3, uintptr(findVolume), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength))
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func FindNextVolumeMountPoint(findVolumeMountPoint Handle, volumeMountPoint *uint16, bufferLength uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procFindNextVolumeMountPointW.Addr(), 3, uintptr(findVolumeMountPoint), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength))
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func FindVolumeClose(findVolume Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procFindVolumeClose.Addr(), 1, uintptr(findVolume), 0, 0)
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func FindVolumeMountPointClose(findVolumeMountPoint Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procFindVolumeMountPointClose.Addr(), 1, uintptr(findVolumeMountPoint), 0, 0)
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func GetDriveType(rootPathName *uint16) (driveType uint32) {
+ r0, _, _ := syscall.Syscall(procGetDriveTypeW.Addr(), 1, uintptr(unsafe.Pointer(rootPathName)), 0, 0)
+ driveType = uint32(r0)
+ return
+}
+
+func GetLogicalDrives() (drivesBitMask uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procGetLogicalDrives.Addr(), 0, 0, 0, 0)
+ drivesBitMask = uint32(r0)
+ if drivesBitMask == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func GetLogicalDriveStrings(bufferLength uint32, buffer *uint16) (n uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procGetLogicalDriveStringsW.Addr(), 2, uintptr(bufferLength), uintptr(unsafe.Pointer(buffer)), 0)
+ n = uint32(r0)
+ if n == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func GetVolumeInformation(rootPathName *uint16, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) {
+ r1, _, e1 := syscall.Syscall9(procGetVolumeInformationW.Addr(), 8, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeNameBuffer)), uintptr(volumeNameSize), uintptr(unsafe.Pointer(volumeNameSerialNumber)), uintptr(unsafe.Pointer(maximumComponentLength)), uintptr(unsafe.Pointer(fileSystemFlags)), uintptr(unsafe.Pointer(fileSystemNameBuffer)), uintptr(fileSystemNameSize), 0)
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func GetVolumeInformationByHandle(file Handle, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) {
+ r1, _, e1 := syscall.Syscall9(procGetVolumeInformationByHandleW.Addr(), 8, uintptr(file), uintptr(unsafe.Pointer(volumeNameBuffer)), uintptr(volumeNameSize), uintptr(unsafe.Pointer(volumeNameSerialNumber)), uintptr(unsafe.Pointer(maximumComponentLength)), uintptr(unsafe.Pointer(fileSystemFlags)), uintptr(unsafe.Pointer(fileSystemNameBuffer)), uintptr(fileSystemNameSize), 0)
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func GetVolumeNameForVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16, bufferlength uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetVolumeNameForVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferlength))
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func GetVolumePathName(fileName *uint16, volumePathName *uint16, bufferLength uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetVolumePathNameW.Addr(), 3, uintptr(unsafe.Pointer(fileName)), uintptr(unsafe.Pointer(volumePathName)), uintptr(bufferLength))
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func GetVolumePathNamesForVolumeName(volumeName *uint16, volumePathNames *uint16, bufferLength uint32, returnLength *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procGetVolumePathNamesForVolumeNameW.Addr(), 4, uintptr(unsafe.Pointer(volumeName)), uintptr(unsafe.Pointer(volumePathNames)), uintptr(bufferLength), uintptr(unsafe.Pointer(returnLength)), 0, 0)
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func QueryDosDevice(deviceName *uint16, targetPath *uint16, max uint32) (n uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procQueryDosDeviceW.Addr(), 3, uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)), uintptr(max))
+ n = uint32(r0)
+ if n == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func SetVolumeLabel(rootPathName *uint16, volumeName *uint16) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetVolumeLabelW.Addr(), 2, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeName)), 0)
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
+func SetVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetVolumeMountPointW.Addr(), 2, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), 0)
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1672,7 +2115,7 @@ func WSACleanup() (err error) {
r1, _, e1 := syscall.Syscall(procWSACleanup.Addr(), 0, 0, 0, 0)
if r1 == socket_error {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1684,7 +2127,7 @@ func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbo
r1, _, e1 := syscall.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 e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1697,7 +2140,7 @@ func socket(af int32, typ int32, protocol int32) (handle Handle, err error) {
handle = Handle(r0)
if handle == InvalidHandle {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1709,7 +2152,7 @@ func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32
r1, _, e1 := syscall.Syscall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(optlen), 0)
if r1 == socket_error {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1721,7 +2164,7 @@ func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int3
r1, _, e1 := syscall.Syscall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(unsafe.Pointer(optlen)), 0)
if r1 == socket_error {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1733,7 +2176,7 @@ func bind(s Handle, name unsafe.Pointer, namelen int32) (err error) {
r1, _, e1 := syscall.Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
if r1 == socket_error {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1745,7 +2188,7 @@ func connect(s Handle, name unsafe.Pointer, namelen int32) (err error) {
r1, _, e1 := syscall.Syscall(procconnect.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
if r1 == socket_error {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1757,7 +2200,7 @@ func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
r1, _, e1 := syscall.Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
if r1 == socket_error {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1769,7 +2212,7 @@ func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
r1, _, e1 := syscall.Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
if r1 == socket_error {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1781,7 +2224,7 @@ func listen(s Handle, backlog int32) (err error) {
r1, _, e1 := syscall.Syscall(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0)
if r1 == socket_error {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1793,7 +2236,7 @@ func shutdown(s Handle, how int32) (err error) {
r1, _, e1 := syscall.Syscall(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0)
if r1 == socket_error {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1805,7 +2248,7 @@ func Closesocket(s Handle) (err error) {
r1, _, e1 := syscall.Syscall(procclosesocket.Addr(), 1, uintptr(s), 0, 0)
if r1 == socket_error {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1817,7 +2260,7 @@ func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32
r1, _, e1 := syscall.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 e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1834,7 +2277,7 @@ func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32
r1, _, e1 := syscall.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 e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1846,7 +2289,7 @@ func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32,
r1, _, e1 := syscall.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 e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1858,7 +2301,7 @@ func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *ui
r1, _, e1 := syscall.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 e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1870,7 +2313,7 @@ func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32
r1, _, e1 := syscall.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 e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1892,7 +2335,7 @@ func _GetHostByName(name *byte) (h *Hostent, err error) {
h = (*Hostent)(unsafe.Pointer(r0))
if h == nil {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1919,7 +2362,7 @@ func _GetServByName(name *byte, proto *byte) (s *Servent, err error) {
s = (*Servent)(unsafe.Pointer(r0))
if s == nil {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -1947,7 +2390,7 @@ func _GetProtoByName(name *byte) (p *Protoent, err error) {
p = (*Protoent)(unsafe.Pointer(r0))
if p == nil {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -2016,7 +2459,7 @@ func SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error)
r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(handle), uintptr(flags), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -2029,7 +2472,7 @@ func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferL
n = int32(r0)
if n == -1 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -2056,7 +2499,7 @@ func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32,
nwrite = int32(r0)
if nwrite == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -2068,7 +2511,7 @@ func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint
r1, _, e1 := syscall.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 e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -2080,7 +2523,7 @@ func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err er
r1, _, e1 := syscall.Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize)))
if r1&0xff == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -2116,7 +2559,7 @@ func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint3
r1, _, e1 := syscall.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 e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -2128,7 +2571,7 @@ func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen
r1, _, e1 := syscall.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 e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -2140,7 +2583,7 @@ func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) {
r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(stringSid)), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -2152,7 +2595,7 @@ func ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) {
r1, _, e1 := syscall.Syscall(procConvertStringSidToSidW.Addr(), 2, uintptr(unsafe.Pointer(stringSid)), uintptr(unsafe.Pointer(sid)), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -2170,7 +2613,7 @@ func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) {
r1, _, e1 := syscall.Syscall(procCopySid.Addr(), 3, uintptr(destSidLen), uintptr(unsafe.Pointer(destSid)), uintptr(unsafe.Pointer(srcSid)))
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -2182,7 +2625,7 @@ func AllocateAndInitializeSid(identAuth *SidIdentifierAuthority, subAuth byte, s
r1, _, e1 := syscall.Syscall12(procAllocateAndInitializeSid.Addr(), 11, uintptr(unsafe.Pointer(identAuth)), uintptr(subAuth), uintptr(subAuth0), uintptr(subAuth1), uintptr(subAuth2), uintptr(subAuth3), uintptr(subAuth4), uintptr(subAuth5), uintptr(subAuth6), uintptr(subAuth7), uintptr(unsafe.Pointer(sid)), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -2194,7 +2637,7 @@ func FreeSid(sid *SID) (err error) {
r1, _, e1 := syscall.Syscall(procFreeSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
if r1 != 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -2208,11 +2651,23 @@ func EqualSid(sid1 *SID, sid2 *SID) (isEqual bool) {
return
}
+func checkTokenMembership(tokenHandle Token, sidToCheck *SID, isMember *int32) (err error) {
+ r1, _, e1 := syscall.Syscall(procCheckTokenMembership.Addr(), 3, uintptr(tokenHandle), uintptr(unsafe.Pointer(sidToCheck)), uintptr(unsafe.Pointer(isMember)))
+ if r1 == 0 {
+ if e1 != 0 {
+ err = errnoErr(e1)
+ } else {
+ err = syscall.EINVAL
+ }
+ }
+ return
+}
+
func OpenProcessToken(h Handle, access uint32, token *Token) (err error) {
r1, _, e1 := syscall.Syscall(procOpenProcessToken.Addr(), 3, uintptr(h), uintptr(access), uintptr(unsafe.Pointer(token)))
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -2224,7 +2679,7 @@ func GetTokenInformation(t Token, infoClass uint32, info *byte, infoLen uint32,
r1, _, e1 := syscall.Syscall6(procGetTokenInformation.Addr(), 5, uintptr(t), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), uintptr(unsafe.Pointer(returnedLen)), 0)
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
@@ -2236,7 +2691,7 @@ func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) {
r1, _, e1 := syscall.Syscall(procGetUserProfileDirectoryW.Addr(), 3, uintptr(t), uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen)))
if r1 == 0 {
if e1 != 0 {
- err = error(e1)
+ err = errnoErr(e1)
} else {
err = syscall.EINVAL
}