github.com/ie310mu/ie310go/forks/golang.org/x/sys@v0.0.0-20190821095322-9a46783d4de5/windows/zsyscall_windows.go (about) 1 // Code generated by 'go generate'; DO NOT EDIT. 2 3 package windows 4 5 import ( 6 "syscall" 7 "unsafe" 8 ) 9 10 var _ unsafe.Pointer 11 12 // Do the interface allocations only once for common 13 // Errno values. 14 const ( 15 errnoERROR_IO_PENDING = 997 16 ) 17 18 var ( 19 errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) 20 ) 21 22 // errnoErr returns common boxed Errno values, to prevent 23 // allocations at runtime. 24 func errnoErr(e syscall.Errno) error { 25 switch e { 26 case 0: 27 return nil 28 case errnoERROR_IO_PENDING: 29 return errERROR_IO_PENDING 30 } 31 // TODO: add more here, after collecting data on the common 32 // error values see on Windows. (perhaps when running 33 // all.bat?) 34 return e 35 } 36 37 var ( 38 modadvapi32 = NewLazySystemDLL("advapi32.dll") 39 modkernel32 = NewLazySystemDLL("kernel32.dll") 40 modshell32 = NewLazySystemDLL("shell32.dll") 41 moduserenv = NewLazySystemDLL("userenv.dll") 42 modmswsock = NewLazySystemDLL("mswsock.dll") 43 modcrypt32 = NewLazySystemDLL("crypt32.dll") 44 moduser32 = NewLazySystemDLL("user32.dll") 45 modole32 = NewLazySystemDLL("ole32.dll") 46 modws2_32 = NewLazySystemDLL("ws2_32.dll") 47 moddnsapi = NewLazySystemDLL("dnsapi.dll") 48 modiphlpapi = NewLazySystemDLL("iphlpapi.dll") 49 modsecur32 = NewLazySystemDLL("secur32.dll") 50 modnetapi32 = NewLazySystemDLL("netapi32.dll") 51 modwtsapi32 = NewLazySystemDLL("wtsapi32.dll") 52 53 procRegisterEventSourceW = modadvapi32.NewProc("RegisterEventSourceW") 54 procDeregisterEventSource = modadvapi32.NewProc("DeregisterEventSource") 55 procReportEventW = modadvapi32.NewProc("ReportEventW") 56 procOpenSCManagerW = modadvapi32.NewProc("OpenSCManagerW") 57 procCloseServiceHandle = modadvapi32.NewProc("CloseServiceHandle") 58 procCreateServiceW = modadvapi32.NewProc("CreateServiceW") 59 procOpenServiceW = modadvapi32.NewProc("OpenServiceW") 60 procDeleteService = modadvapi32.NewProc("DeleteService") 61 procStartServiceW = modadvapi32.NewProc("StartServiceW") 62 procQueryServiceStatus = modadvapi32.NewProc("QueryServiceStatus") 63 procQueryServiceLockStatusW = modadvapi32.NewProc("QueryServiceLockStatusW") 64 procControlService = modadvapi32.NewProc("ControlService") 65 procStartServiceCtrlDispatcherW = modadvapi32.NewProc("StartServiceCtrlDispatcherW") 66 procSetServiceStatus = modadvapi32.NewProc("SetServiceStatus") 67 procChangeServiceConfigW = modadvapi32.NewProc("ChangeServiceConfigW") 68 procQueryServiceConfigW = modadvapi32.NewProc("QueryServiceConfigW") 69 procChangeServiceConfig2W = modadvapi32.NewProc("ChangeServiceConfig2W") 70 procQueryServiceConfig2W = modadvapi32.NewProc("QueryServiceConfig2W") 71 procEnumServicesStatusExW = modadvapi32.NewProc("EnumServicesStatusExW") 72 procQueryServiceStatusEx = modadvapi32.NewProc("QueryServiceStatusEx") 73 procNotifyServiceStatusChangeW = modadvapi32.NewProc("NotifyServiceStatusChangeW") 74 procGetLastError = modkernel32.NewProc("GetLastError") 75 procLoadLibraryW = modkernel32.NewProc("LoadLibraryW") 76 procLoadLibraryExW = modkernel32.NewProc("LoadLibraryExW") 77 procFreeLibrary = modkernel32.NewProc("FreeLibrary") 78 procGetProcAddress = modkernel32.NewProc("GetProcAddress") 79 procGetVersion = modkernel32.NewProc("GetVersion") 80 procFormatMessageW = modkernel32.NewProc("FormatMessageW") 81 procExitProcess = modkernel32.NewProc("ExitProcess") 82 procIsWow64Process = modkernel32.NewProc("IsWow64Process") 83 procCreateFileW = modkernel32.NewProc("CreateFileW") 84 procReadFile = modkernel32.NewProc("ReadFile") 85 procWriteFile = modkernel32.NewProc("WriteFile") 86 procGetOverlappedResult = modkernel32.NewProc("GetOverlappedResult") 87 procSetFilePointer = modkernel32.NewProc("SetFilePointer") 88 procCloseHandle = modkernel32.NewProc("CloseHandle") 89 procGetStdHandle = modkernel32.NewProc("GetStdHandle") 90 procSetStdHandle = modkernel32.NewProc("SetStdHandle") 91 procFindFirstFileW = modkernel32.NewProc("FindFirstFileW") 92 procFindNextFileW = modkernel32.NewProc("FindNextFileW") 93 procFindClose = modkernel32.NewProc("FindClose") 94 procGetFileInformationByHandle = modkernel32.NewProc("GetFileInformationByHandle") 95 procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx") 96 procGetCurrentDirectoryW = modkernel32.NewProc("GetCurrentDirectoryW") 97 procSetCurrentDirectoryW = modkernel32.NewProc("SetCurrentDirectoryW") 98 procCreateDirectoryW = modkernel32.NewProc("CreateDirectoryW") 99 procRemoveDirectoryW = modkernel32.NewProc("RemoveDirectoryW") 100 procDeleteFileW = modkernel32.NewProc("DeleteFileW") 101 procMoveFileW = modkernel32.NewProc("MoveFileW") 102 procMoveFileExW = modkernel32.NewProc("MoveFileExW") 103 procGetComputerNameW = modkernel32.NewProc("GetComputerNameW") 104 procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW") 105 procSetEndOfFile = modkernel32.NewProc("SetEndOfFile") 106 procGetSystemTimeAsFileTime = modkernel32.NewProc("GetSystemTimeAsFileTime") 107 procGetSystemTimePreciseAsFileTime = modkernel32.NewProc("GetSystemTimePreciseAsFileTime") 108 procGetTimeZoneInformation = modkernel32.NewProc("GetTimeZoneInformation") 109 procCreateIoCompletionPort = modkernel32.NewProc("CreateIoCompletionPort") 110 procGetQueuedCompletionStatus = modkernel32.NewProc("GetQueuedCompletionStatus") 111 procPostQueuedCompletionStatus = modkernel32.NewProc("PostQueuedCompletionStatus") 112 procCancelIo = modkernel32.NewProc("CancelIo") 113 procCancelIoEx = modkernel32.NewProc("CancelIoEx") 114 procCreateProcessW = modkernel32.NewProc("CreateProcessW") 115 procOpenProcess = modkernel32.NewProc("OpenProcess") 116 procShellExecuteW = modshell32.NewProc("ShellExecuteW") 117 procTerminateProcess = modkernel32.NewProc("TerminateProcess") 118 procGetExitCodeProcess = modkernel32.NewProc("GetExitCodeProcess") 119 procGetStartupInfoW = modkernel32.NewProc("GetStartupInfoW") 120 procGetCurrentProcess = modkernel32.NewProc("GetCurrentProcess") 121 procGetCurrentThread = modkernel32.NewProc("GetCurrentThread") 122 procGetProcessTimes = modkernel32.NewProc("GetProcessTimes") 123 procDuplicateHandle = modkernel32.NewProc("DuplicateHandle") 124 procWaitForSingleObject = modkernel32.NewProc("WaitForSingleObject") 125 procWaitForMultipleObjects = modkernel32.NewProc("WaitForMultipleObjects") 126 procGetTempPathW = modkernel32.NewProc("GetTempPathW") 127 procCreatePipe = modkernel32.NewProc("CreatePipe") 128 procGetFileType = modkernel32.NewProc("GetFileType") 129 procCryptAcquireContextW = modadvapi32.NewProc("CryptAcquireContextW") 130 procCryptReleaseContext = modadvapi32.NewProc("CryptReleaseContext") 131 procCryptGenRandom = modadvapi32.NewProc("CryptGenRandom") 132 procGetEnvironmentStringsW = modkernel32.NewProc("GetEnvironmentStringsW") 133 procFreeEnvironmentStringsW = modkernel32.NewProc("FreeEnvironmentStringsW") 134 procGetEnvironmentVariableW = modkernel32.NewProc("GetEnvironmentVariableW") 135 procSetEnvironmentVariableW = modkernel32.NewProc("SetEnvironmentVariableW") 136 procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock") 137 procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock") 138 procGetTickCount64 = modkernel32.NewProc("GetTickCount64") 139 procSetFileTime = modkernel32.NewProc("SetFileTime") 140 procGetFileAttributesW = modkernel32.NewProc("GetFileAttributesW") 141 procSetFileAttributesW = modkernel32.NewProc("SetFileAttributesW") 142 procGetFileAttributesExW = modkernel32.NewProc("GetFileAttributesExW") 143 procGetCommandLineW = modkernel32.NewProc("GetCommandLineW") 144 procCommandLineToArgvW = modshell32.NewProc("CommandLineToArgvW") 145 procLocalFree = modkernel32.NewProc("LocalFree") 146 procSetHandleInformation = modkernel32.NewProc("SetHandleInformation") 147 procFlushFileBuffers = modkernel32.NewProc("FlushFileBuffers") 148 procGetFullPathNameW = modkernel32.NewProc("GetFullPathNameW") 149 procGetLongPathNameW = modkernel32.NewProc("GetLongPathNameW") 150 procGetShortPathNameW = modkernel32.NewProc("GetShortPathNameW") 151 procCreateFileMappingW = modkernel32.NewProc("CreateFileMappingW") 152 procMapViewOfFile = modkernel32.NewProc("MapViewOfFile") 153 procUnmapViewOfFile = modkernel32.NewProc("UnmapViewOfFile") 154 procFlushViewOfFile = modkernel32.NewProc("FlushViewOfFile") 155 procVirtualLock = modkernel32.NewProc("VirtualLock") 156 procVirtualUnlock = modkernel32.NewProc("VirtualUnlock") 157 procVirtualAlloc = modkernel32.NewProc("VirtualAlloc") 158 procVirtualFree = modkernel32.NewProc("VirtualFree") 159 procVirtualProtect = modkernel32.NewProc("VirtualProtect") 160 procTransmitFile = modmswsock.NewProc("TransmitFile") 161 procReadDirectoryChangesW = modkernel32.NewProc("ReadDirectoryChangesW") 162 procCertOpenSystemStoreW = modcrypt32.NewProc("CertOpenSystemStoreW") 163 procCertOpenStore = modcrypt32.NewProc("CertOpenStore") 164 procCertEnumCertificatesInStore = modcrypt32.NewProc("CertEnumCertificatesInStore") 165 procCertAddCertificateContextToStore = modcrypt32.NewProc("CertAddCertificateContextToStore") 166 procCertCloseStore = modcrypt32.NewProc("CertCloseStore") 167 procCertGetCertificateChain = modcrypt32.NewProc("CertGetCertificateChain") 168 procCertFreeCertificateChain = modcrypt32.NewProc("CertFreeCertificateChain") 169 procCertCreateCertificateContext = modcrypt32.NewProc("CertCreateCertificateContext") 170 procCertFreeCertificateContext = modcrypt32.NewProc("CertFreeCertificateContext") 171 procCertVerifyCertificateChainPolicy = modcrypt32.NewProc("CertVerifyCertificateChainPolicy") 172 procRegOpenKeyExW = modadvapi32.NewProc("RegOpenKeyExW") 173 procRegCloseKey = modadvapi32.NewProc("RegCloseKey") 174 procRegQueryInfoKeyW = modadvapi32.NewProc("RegQueryInfoKeyW") 175 procRegEnumKeyExW = modadvapi32.NewProc("RegEnumKeyExW") 176 procRegQueryValueExW = modadvapi32.NewProc("RegQueryValueExW") 177 procGetCurrentProcessId = modkernel32.NewProc("GetCurrentProcessId") 178 procGetConsoleMode = modkernel32.NewProc("GetConsoleMode") 179 procSetConsoleMode = modkernel32.NewProc("SetConsoleMode") 180 procGetConsoleScreenBufferInfo = modkernel32.NewProc("GetConsoleScreenBufferInfo") 181 procWriteConsoleW = modkernel32.NewProc("WriteConsoleW") 182 procReadConsoleW = modkernel32.NewProc("ReadConsoleW") 183 procCreateToolhelp32Snapshot = modkernel32.NewProc("CreateToolhelp32Snapshot") 184 procProcess32FirstW = modkernel32.NewProc("Process32FirstW") 185 procProcess32NextW = modkernel32.NewProc("Process32NextW") 186 procThread32First = modkernel32.NewProc("Thread32First") 187 procThread32Next = modkernel32.NewProc("Thread32Next") 188 procDeviceIoControl = modkernel32.NewProc("DeviceIoControl") 189 procCreateSymbolicLinkW = modkernel32.NewProc("CreateSymbolicLinkW") 190 procCreateHardLinkW = modkernel32.NewProc("CreateHardLinkW") 191 procGetCurrentThreadId = modkernel32.NewProc("GetCurrentThreadId") 192 procCreateEventW = modkernel32.NewProc("CreateEventW") 193 procCreateEventExW = modkernel32.NewProc("CreateEventExW") 194 procOpenEventW = modkernel32.NewProc("OpenEventW") 195 procSetEvent = modkernel32.NewProc("SetEvent") 196 procResetEvent = modkernel32.NewProc("ResetEvent") 197 procPulseEvent = modkernel32.NewProc("PulseEvent") 198 procSleepEx = modkernel32.NewProc("SleepEx") 199 procCreateJobObjectW = modkernel32.NewProc("CreateJobObjectW") 200 procAssignProcessToJobObject = modkernel32.NewProc("AssignProcessToJobObject") 201 procTerminateJobObject = modkernel32.NewProc("TerminateJobObject") 202 procSetErrorMode = modkernel32.NewProc("SetErrorMode") 203 procResumeThread = modkernel32.NewProc("ResumeThread") 204 procSetPriorityClass = modkernel32.NewProc("SetPriorityClass") 205 procGetPriorityClass = modkernel32.NewProc("GetPriorityClass") 206 procSetInformationJobObject = modkernel32.NewProc("SetInformationJobObject") 207 procGenerateConsoleCtrlEvent = modkernel32.NewProc("GenerateConsoleCtrlEvent") 208 procDefineDosDeviceW = modkernel32.NewProc("DefineDosDeviceW") 209 procDeleteVolumeMountPointW = modkernel32.NewProc("DeleteVolumeMountPointW") 210 procFindFirstVolumeW = modkernel32.NewProc("FindFirstVolumeW") 211 procFindFirstVolumeMountPointW = modkernel32.NewProc("FindFirstVolumeMountPointW") 212 procFindNextVolumeW = modkernel32.NewProc("FindNextVolumeW") 213 procFindNextVolumeMountPointW = modkernel32.NewProc("FindNextVolumeMountPointW") 214 procFindVolumeClose = modkernel32.NewProc("FindVolumeClose") 215 procFindVolumeMountPointClose = modkernel32.NewProc("FindVolumeMountPointClose") 216 procGetDriveTypeW = modkernel32.NewProc("GetDriveTypeW") 217 procGetLogicalDrives = modkernel32.NewProc("GetLogicalDrives") 218 procGetLogicalDriveStringsW = modkernel32.NewProc("GetLogicalDriveStringsW") 219 procGetVolumeInformationW = modkernel32.NewProc("GetVolumeInformationW") 220 procGetVolumeInformationByHandleW = modkernel32.NewProc("GetVolumeInformationByHandleW") 221 procGetVolumeNameForVolumeMountPointW = modkernel32.NewProc("GetVolumeNameForVolumeMountPointW") 222 procGetVolumePathNameW = modkernel32.NewProc("GetVolumePathNameW") 223 procGetVolumePathNamesForVolumeNameW = modkernel32.NewProc("GetVolumePathNamesForVolumeNameW") 224 procQueryDosDeviceW = modkernel32.NewProc("QueryDosDeviceW") 225 procSetVolumeLabelW = modkernel32.NewProc("SetVolumeLabelW") 226 procSetVolumeMountPointW = modkernel32.NewProc("SetVolumeMountPointW") 227 procMessageBoxW = moduser32.NewProc("MessageBoxW") 228 procCLSIDFromString = modole32.NewProc("CLSIDFromString") 229 procStringFromGUID2 = modole32.NewProc("StringFromGUID2") 230 procCoCreateGuid = modole32.NewProc("CoCreateGuid") 231 procWSAStartup = modws2_32.NewProc("WSAStartup") 232 procWSACleanup = modws2_32.NewProc("WSACleanup") 233 procWSAIoctl = modws2_32.NewProc("WSAIoctl") 234 procsocket = modws2_32.NewProc("socket") 235 procsetsockopt = modws2_32.NewProc("setsockopt") 236 procgetsockopt = modws2_32.NewProc("getsockopt") 237 procbind = modws2_32.NewProc("bind") 238 procconnect = modws2_32.NewProc("connect") 239 procgetsockname = modws2_32.NewProc("getsockname") 240 procgetpeername = modws2_32.NewProc("getpeername") 241 proclisten = modws2_32.NewProc("listen") 242 procshutdown = modws2_32.NewProc("shutdown") 243 procclosesocket = modws2_32.NewProc("closesocket") 244 procAcceptEx = modmswsock.NewProc("AcceptEx") 245 procGetAcceptExSockaddrs = modmswsock.NewProc("GetAcceptExSockaddrs") 246 procWSARecv = modws2_32.NewProc("WSARecv") 247 procWSASend = modws2_32.NewProc("WSASend") 248 procWSARecvFrom = modws2_32.NewProc("WSARecvFrom") 249 procWSASendTo = modws2_32.NewProc("WSASendTo") 250 procgethostbyname = modws2_32.NewProc("gethostbyname") 251 procgetservbyname = modws2_32.NewProc("getservbyname") 252 procntohs = modws2_32.NewProc("ntohs") 253 procgetprotobyname = modws2_32.NewProc("getprotobyname") 254 procDnsQuery_W = moddnsapi.NewProc("DnsQuery_W") 255 procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree") 256 procDnsNameCompare_W = moddnsapi.NewProc("DnsNameCompare_W") 257 procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW") 258 procFreeAddrInfoW = modws2_32.NewProc("FreeAddrInfoW") 259 procGetIfEntry = modiphlpapi.NewProc("GetIfEntry") 260 procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo") 261 procSetFileCompletionNotificationModes = modkernel32.NewProc("SetFileCompletionNotificationModes") 262 procWSAEnumProtocolsW = modws2_32.NewProc("WSAEnumProtocolsW") 263 procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses") 264 procGetACP = modkernel32.NewProc("GetACP") 265 procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar") 266 procTranslateNameW = modsecur32.NewProc("TranslateNameW") 267 procGetUserNameExW = modsecur32.NewProc("GetUserNameExW") 268 procNetUserGetInfo = modnetapi32.NewProc("NetUserGetInfo") 269 procNetGetJoinInformation = modnetapi32.NewProc("NetGetJoinInformation") 270 procNetApiBufferFree = modnetapi32.NewProc("NetApiBufferFree") 271 procLookupAccountSidW = modadvapi32.NewProc("LookupAccountSidW") 272 procLookupAccountNameW = modadvapi32.NewProc("LookupAccountNameW") 273 procConvertSidToStringSidW = modadvapi32.NewProc("ConvertSidToStringSidW") 274 procConvertStringSidToSidW = modadvapi32.NewProc("ConvertStringSidToSidW") 275 procGetLengthSid = modadvapi32.NewProc("GetLengthSid") 276 procCopySid = modadvapi32.NewProc("CopySid") 277 procAllocateAndInitializeSid = modadvapi32.NewProc("AllocateAndInitializeSid") 278 procCreateWellKnownSid = modadvapi32.NewProc("CreateWellKnownSid") 279 procIsWellKnownSid = modadvapi32.NewProc("IsWellKnownSid") 280 procFreeSid = modadvapi32.NewProc("FreeSid") 281 procEqualSid = modadvapi32.NewProc("EqualSid") 282 procGetSidIdentifierAuthority = modadvapi32.NewProc("GetSidIdentifierAuthority") 283 procGetSidSubAuthorityCount = modadvapi32.NewProc("GetSidSubAuthorityCount") 284 procGetSidSubAuthority = modadvapi32.NewProc("GetSidSubAuthority") 285 procIsValidSid = modadvapi32.NewProc("IsValidSid") 286 procCheckTokenMembership = modadvapi32.NewProc("CheckTokenMembership") 287 procOpenProcessToken = modadvapi32.NewProc("OpenProcessToken") 288 procOpenThreadToken = modadvapi32.NewProc("OpenThreadToken") 289 procImpersonateSelf = modadvapi32.NewProc("ImpersonateSelf") 290 procRevertToSelf = modadvapi32.NewProc("RevertToSelf") 291 procSetThreadToken = modadvapi32.NewProc("SetThreadToken") 292 procLookupPrivilegeValueW = modadvapi32.NewProc("LookupPrivilegeValueW") 293 procAdjustTokenPrivileges = modadvapi32.NewProc("AdjustTokenPrivileges") 294 procAdjustTokenGroups = modadvapi32.NewProc("AdjustTokenGroups") 295 procGetTokenInformation = modadvapi32.NewProc("GetTokenInformation") 296 procSetTokenInformation = modadvapi32.NewProc("SetTokenInformation") 297 procDuplicateTokenEx = modadvapi32.NewProc("DuplicateTokenEx") 298 procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW") 299 procGetSystemDirectoryW = modkernel32.NewProc("GetSystemDirectoryW") 300 procWTSQueryUserToken = modwtsapi32.NewProc("WTSQueryUserToken") 301 procWTSEnumerateSessionsW = modwtsapi32.NewProc("WTSEnumerateSessionsW") 302 procWTSFreeMemory = modwtsapi32.NewProc("WTSFreeMemory") 303 ) 304 305 func RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) { 306 r0, _, e1 := syscall.Syscall(procRegisterEventSourceW.Addr(), 2, uintptr(unsafe.Pointer(uncServerName)), uintptr(unsafe.Pointer(sourceName)), 0) 307 handle = Handle(r0) 308 if handle == 0 { 309 if e1 != 0 { 310 err = errnoErr(e1) 311 } else { 312 err = syscall.EINVAL 313 } 314 } 315 return 316 } 317 318 func DeregisterEventSource(handle Handle) (err error) { 319 r1, _, e1 := syscall.Syscall(procDeregisterEventSource.Addr(), 1, uintptr(handle), 0, 0) 320 if r1 == 0 { 321 if e1 != 0 { 322 err = errnoErr(e1) 323 } else { 324 err = syscall.EINVAL 325 } 326 } 327 return 328 } 329 330 func ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) { 331 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))) 332 if r1 == 0 { 333 if e1 != 0 { 334 err = errnoErr(e1) 335 } else { 336 err = syscall.EINVAL 337 } 338 } 339 return 340 } 341 342 func OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle Handle, err error) { 343 r0, _, e1 := syscall.Syscall(procOpenSCManagerW.Addr(), 3, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(databaseName)), uintptr(access)) 344 handle = Handle(r0) 345 if handle == 0 { 346 if e1 != 0 { 347 err = errnoErr(e1) 348 } else { 349 err = syscall.EINVAL 350 } 351 } 352 return 353 } 354 355 func CloseServiceHandle(handle Handle) (err error) { 356 r1, _, e1 := syscall.Syscall(procCloseServiceHandle.Addr(), 1, uintptr(handle), 0, 0) 357 if r1 == 0 { 358 if e1 != 0 { 359 err = errnoErr(e1) 360 } else { 361 err = syscall.EINVAL 362 } 363 } 364 return 365 } 366 367 func CreateService(mgr Handle, serviceName *uint16, displayName *uint16, access uint32, srvType uint32, startType uint32, errCtl uint32, pathName *uint16, loadOrderGroup *uint16, tagId *uint32, dependencies *uint16, serviceStartName *uint16, password *uint16) (handle Handle, err error) { 368 r0, _, e1 := syscall.Syscall15(procCreateServiceW.Addr(), 13, uintptr(mgr), uintptr(unsafe.Pointer(serviceName)), uintptr(unsafe.Pointer(displayName)), uintptr(access), uintptr(srvType), uintptr(startType), uintptr(errCtl), uintptr(unsafe.Pointer(pathName)), uintptr(unsafe.Pointer(loadOrderGroup)), uintptr(unsafe.Pointer(tagId)), uintptr(unsafe.Pointer(dependencies)), uintptr(unsafe.Pointer(serviceStartName)), uintptr(unsafe.Pointer(password)), 0, 0) 369 handle = Handle(r0) 370 if handle == 0 { 371 if e1 != 0 { 372 err = errnoErr(e1) 373 } else { 374 err = syscall.EINVAL 375 } 376 } 377 return 378 } 379 380 func OpenService(mgr Handle, serviceName *uint16, access uint32) (handle Handle, err error) { 381 r0, _, e1 := syscall.Syscall(procOpenServiceW.Addr(), 3, uintptr(mgr), uintptr(unsafe.Pointer(serviceName)), uintptr(access)) 382 handle = Handle(r0) 383 if handle == 0 { 384 if e1 != 0 { 385 err = errnoErr(e1) 386 } else { 387 err = syscall.EINVAL 388 } 389 } 390 return 391 } 392 393 func DeleteService(service Handle) (err error) { 394 r1, _, e1 := syscall.Syscall(procDeleteService.Addr(), 1, uintptr(service), 0, 0) 395 if r1 == 0 { 396 if e1 != 0 { 397 err = errnoErr(e1) 398 } else { 399 err = syscall.EINVAL 400 } 401 } 402 return 403 } 404 405 func StartService(service Handle, numArgs uint32, argVectors **uint16) (err error) { 406 r1, _, e1 := syscall.Syscall(procStartServiceW.Addr(), 3, uintptr(service), uintptr(numArgs), uintptr(unsafe.Pointer(argVectors))) 407 if r1 == 0 { 408 if e1 != 0 { 409 err = errnoErr(e1) 410 } else { 411 err = syscall.EINVAL 412 } 413 } 414 return 415 } 416 417 func QueryServiceStatus(service Handle, status *SERVICE_STATUS) (err error) { 418 r1, _, e1 := syscall.Syscall(procQueryServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(status)), 0) 419 if r1 == 0 { 420 if e1 != 0 { 421 err = errnoErr(e1) 422 } else { 423 err = syscall.EINVAL 424 } 425 } 426 return 427 } 428 429 func QueryServiceLockStatus(mgr Handle, lockStatus *QUERY_SERVICE_LOCK_STATUS, bufSize uint32, bytesNeeded *uint32) (err error) { 430 r1, _, e1 := syscall.Syscall6(procQueryServiceLockStatusW.Addr(), 4, uintptr(mgr), uintptr(unsafe.Pointer(lockStatus)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0) 431 if r1 == 0 { 432 if e1 != 0 { 433 err = errnoErr(e1) 434 } else { 435 err = syscall.EINVAL 436 } 437 } 438 return 439 } 440 441 func ControlService(service Handle, control uint32, status *SERVICE_STATUS) (err error) { 442 r1, _, e1 := syscall.Syscall(procControlService.Addr(), 3, uintptr(service), uintptr(control), uintptr(unsafe.Pointer(status))) 443 if r1 == 0 { 444 if e1 != 0 { 445 err = errnoErr(e1) 446 } else { 447 err = syscall.EINVAL 448 } 449 } 450 return 451 } 452 453 func StartServiceCtrlDispatcher(serviceTable *SERVICE_TABLE_ENTRY) (err error) { 454 r1, _, e1 := syscall.Syscall(procStartServiceCtrlDispatcherW.Addr(), 1, uintptr(unsafe.Pointer(serviceTable)), 0, 0) 455 if r1 == 0 { 456 if e1 != 0 { 457 err = errnoErr(e1) 458 } else { 459 err = syscall.EINVAL 460 } 461 } 462 return 463 } 464 465 func SetServiceStatus(service Handle, serviceStatus *SERVICE_STATUS) (err error) { 466 r1, _, e1 := syscall.Syscall(procSetServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(serviceStatus)), 0) 467 if r1 == 0 { 468 if e1 != 0 { 469 err = errnoErr(e1) 470 } else { 471 err = syscall.EINVAL 472 } 473 } 474 return 475 } 476 477 func ChangeServiceConfig(service Handle, serviceType uint32, startType uint32, errorControl uint32, binaryPathName *uint16, loadOrderGroup *uint16, tagId *uint32, dependencies *uint16, serviceStartName *uint16, password *uint16, displayName *uint16) (err error) { 478 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) 479 if r1 == 0 { 480 if e1 != 0 { 481 err = errnoErr(e1) 482 } else { 483 err = syscall.EINVAL 484 } 485 } 486 return 487 } 488 489 func QueryServiceConfig(service Handle, serviceConfig *QUERY_SERVICE_CONFIG, bufSize uint32, bytesNeeded *uint32) (err error) { 490 r1, _, e1 := syscall.Syscall6(procQueryServiceConfigW.Addr(), 4, uintptr(service), uintptr(unsafe.Pointer(serviceConfig)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0) 491 if r1 == 0 { 492 if e1 != 0 { 493 err = errnoErr(e1) 494 } else { 495 err = syscall.EINVAL 496 } 497 } 498 return 499 } 500 501 func ChangeServiceConfig2(service Handle, infoLevel uint32, info *byte) (err error) { 502 r1, _, e1 := syscall.Syscall(procChangeServiceConfig2W.Addr(), 3, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(info))) 503 if r1 == 0 { 504 if e1 != 0 { 505 err = errnoErr(e1) 506 } else { 507 err = syscall.EINVAL 508 } 509 } 510 return 511 } 512 513 func QueryServiceConfig2(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) { 514 r1, _, e1 := syscall.Syscall6(procQueryServiceConfig2W.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0) 515 if r1 == 0 { 516 if e1 != 0 { 517 err = errnoErr(e1) 518 } else { 519 err = syscall.EINVAL 520 } 521 } 522 return 523 } 524 525 func EnumServicesStatusEx(mgr Handle, infoLevel uint32, serviceType uint32, serviceState uint32, services *byte, bufSize uint32, bytesNeeded *uint32, servicesReturned *uint32, resumeHandle *uint32, groupName *uint16) (err error) { 526 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) 527 if r1 == 0 { 528 if e1 != 0 { 529 err = errnoErr(e1) 530 } else { 531 err = syscall.EINVAL 532 } 533 } 534 return 535 } 536 537 func QueryServiceStatusEx(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) { 538 r1, _, e1 := syscall.Syscall6(procQueryServiceStatusEx.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0) 539 if r1 == 0 { 540 if e1 != 0 { 541 err = errnoErr(e1) 542 } else { 543 err = syscall.EINVAL 544 } 545 } 546 return 547 } 548 549 func NotifyServiceStatusChange(service Handle, notifyMask uint32, notifier *SERVICE_NOTIFY) (ret error) { 550 r0, _, _ := syscall.Syscall(procNotifyServiceStatusChangeW.Addr(), 3, uintptr(service), uintptr(notifyMask), uintptr(unsafe.Pointer(notifier))) 551 if r0 != 0 { 552 ret = syscall.Errno(r0) 553 } 554 return 555 } 556 557 func GetLastError() (lasterr error) { 558 r0, _, _ := syscall.Syscall(procGetLastError.Addr(), 0, 0, 0, 0) 559 if r0 != 0 { 560 lasterr = syscall.Errno(r0) 561 } 562 return 563 } 564 565 func LoadLibrary(libname string) (handle Handle, err error) { 566 var _p0 *uint16 567 _p0, err = syscall.UTF16PtrFromString(libname) 568 if err != nil { 569 return 570 } 571 return _LoadLibrary(_p0) 572 } 573 574 func _LoadLibrary(libname *uint16) (handle Handle, err error) { 575 r0, _, e1 := syscall.Syscall(procLoadLibraryW.Addr(), 1, uintptr(unsafe.Pointer(libname)), 0, 0) 576 handle = Handle(r0) 577 if handle == 0 { 578 if e1 != 0 { 579 err = errnoErr(e1) 580 } else { 581 err = syscall.EINVAL 582 } 583 } 584 return 585 } 586 587 func LoadLibraryEx(libname string, zero Handle, flags uintptr) (handle Handle, err error) { 588 var _p0 *uint16 589 _p0, err = syscall.UTF16PtrFromString(libname) 590 if err != nil { 591 return 592 } 593 return _LoadLibraryEx(_p0, zero, flags) 594 } 595 596 func _LoadLibraryEx(libname *uint16, zero Handle, flags uintptr) (handle Handle, err error) { 597 r0, _, e1 := syscall.Syscall(procLoadLibraryExW.Addr(), 3, uintptr(unsafe.Pointer(libname)), uintptr(zero), uintptr(flags)) 598 handle = Handle(r0) 599 if handle == 0 { 600 if e1 != 0 { 601 err = errnoErr(e1) 602 } else { 603 err = syscall.EINVAL 604 } 605 } 606 return 607 } 608 609 func FreeLibrary(handle Handle) (err error) { 610 r1, _, e1 := syscall.Syscall(procFreeLibrary.Addr(), 1, uintptr(handle), 0, 0) 611 if r1 == 0 { 612 if e1 != 0 { 613 err = errnoErr(e1) 614 } else { 615 err = syscall.EINVAL 616 } 617 } 618 return 619 } 620 621 func GetProcAddress(module Handle, procname string) (proc uintptr, err error) { 622 var _p0 *byte 623 _p0, err = syscall.BytePtrFromString(procname) 624 if err != nil { 625 return 626 } 627 return _GetProcAddress(module, _p0) 628 } 629 630 func _GetProcAddress(module Handle, procname *byte) (proc uintptr, err error) { 631 r0, _, e1 := syscall.Syscall(procGetProcAddress.Addr(), 2, uintptr(module), uintptr(unsafe.Pointer(procname)), 0) 632 proc = uintptr(r0) 633 if proc == 0 { 634 if e1 != 0 { 635 err = errnoErr(e1) 636 } else { 637 err = syscall.EINVAL 638 } 639 } 640 return 641 } 642 643 func GetVersion() (ver uint32, err error) { 644 r0, _, e1 := syscall.Syscall(procGetVersion.Addr(), 0, 0, 0, 0) 645 ver = uint32(r0) 646 if ver == 0 { 647 if e1 != 0 { 648 err = errnoErr(e1) 649 } else { 650 err = syscall.EINVAL 651 } 652 } 653 return 654 } 655 656 func FormatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, buf []uint16, args *byte) (n uint32, err error) { 657 var _p0 *uint16 658 if len(buf) > 0 { 659 _p0 = &buf[0] 660 } 661 r0, _, e1 := syscall.Syscall9(procFormatMessageW.Addr(), 7, uintptr(flags), uintptr(msgsrc), uintptr(msgid), uintptr(langid), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(args)), 0, 0) 662 n = uint32(r0) 663 if n == 0 { 664 if e1 != 0 { 665 err = errnoErr(e1) 666 } else { 667 err = syscall.EINVAL 668 } 669 } 670 return 671 } 672 673 func ExitProcess(exitcode uint32) { 674 syscall.Syscall(procExitProcess.Addr(), 1, uintptr(exitcode), 0, 0) 675 return 676 } 677 678 func IsWow64Process(handle Handle, isWow64 *bool) (err error) { 679 r1, _, e1 := syscall.Syscall(procIsWow64Process.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(isWow64)), 0) 680 if r1 == 0 { 681 if e1 != 0 { 682 err = errnoErr(e1) 683 } else { 684 err = syscall.EINVAL 685 } 686 } 687 return 688 } 689 690 func CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile Handle) (handle Handle, err error) { 691 r0, _, e1 := syscall.Syscall9(procCreateFileW.Addr(), 7, uintptr(unsafe.Pointer(name)), uintptr(access), uintptr(mode), uintptr(unsafe.Pointer(sa)), uintptr(createmode), uintptr(attrs), uintptr(templatefile), 0, 0) 692 handle = Handle(r0) 693 if handle == InvalidHandle { 694 if e1 != 0 { 695 err = errnoErr(e1) 696 } else { 697 err = syscall.EINVAL 698 } 699 } 700 return 701 } 702 703 func ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) { 704 var _p0 *byte 705 if len(buf) > 0 { 706 _p0 = &buf[0] 707 } 708 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) 709 if r1 == 0 { 710 if e1 != 0 { 711 err = errnoErr(e1) 712 } else { 713 err = syscall.EINVAL 714 } 715 } 716 return 717 } 718 719 func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) { 720 var _p0 *byte 721 if len(buf) > 0 { 722 _p0 = &buf[0] 723 } 724 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) 725 if r1 == 0 { 726 if e1 != 0 { 727 err = errnoErr(e1) 728 } else { 729 err = syscall.EINVAL 730 } 731 } 732 return 733 } 734 735 func GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error) { 736 var _p0 uint32 737 if wait { 738 _p0 = 1 739 } else { 740 _p0 = 0 741 } 742 r1, _, e1 := syscall.Syscall6(procGetOverlappedResult.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(done)), uintptr(_p0), 0, 0) 743 if r1 == 0 { 744 if e1 != 0 { 745 err = errnoErr(e1) 746 } else { 747 err = syscall.EINVAL 748 } 749 } 750 return 751 } 752 753 func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) { 754 r0, _, e1 := syscall.Syscall6(procSetFilePointer.Addr(), 4, uintptr(handle), uintptr(lowoffset), uintptr(unsafe.Pointer(highoffsetptr)), uintptr(whence), 0, 0) 755 newlowoffset = uint32(r0) 756 if newlowoffset == 0xffffffff { 757 if e1 != 0 { 758 err = errnoErr(e1) 759 } else { 760 err = syscall.EINVAL 761 } 762 } 763 return 764 } 765 766 func CloseHandle(handle Handle) (err error) { 767 r1, _, e1 := syscall.Syscall(procCloseHandle.Addr(), 1, uintptr(handle), 0, 0) 768 if r1 == 0 { 769 if e1 != 0 { 770 err = errnoErr(e1) 771 } else { 772 err = syscall.EINVAL 773 } 774 } 775 return 776 } 777 778 func GetStdHandle(stdhandle uint32) (handle Handle, err error) { 779 r0, _, e1 := syscall.Syscall(procGetStdHandle.Addr(), 1, uintptr(stdhandle), 0, 0) 780 handle = Handle(r0) 781 if handle == InvalidHandle { 782 if e1 != 0 { 783 err = errnoErr(e1) 784 } else { 785 err = syscall.EINVAL 786 } 787 } 788 return 789 } 790 791 func SetStdHandle(stdhandle uint32, handle Handle) (err error) { 792 r1, _, e1 := syscall.Syscall(procSetStdHandle.Addr(), 2, uintptr(stdhandle), uintptr(handle), 0) 793 if r1 == 0 { 794 if e1 != 0 { 795 err = errnoErr(e1) 796 } else { 797 err = syscall.EINVAL 798 } 799 } 800 return 801 } 802 803 func findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err error) { 804 r0, _, e1 := syscall.Syscall(procFindFirstFileW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(data)), 0) 805 handle = Handle(r0) 806 if handle == InvalidHandle { 807 if e1 != 0 { 808 err = errnoErr(e1) 809 } else { 810 err = syscall.EINVAL 811 } 812 } 813 return 814 } 815 816 func findNextFile1(handle Handle, data *win32finddata1) (err error) { 817 r1, _, e1 := syscall.Syscall(procFindNextFileW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0) 818 if r1 == 0 { 819 if e1 != 0 { 820 err = errnoErr(e1) 821 } else { 822 err = syscall.EINVAL 823 } 824 } 825 return 826 } 827 828 func FindClose(handle Handle) (err error) { 829 r1, _, e1 := syscall.Syscall(procFindClose.Addr(), 1, uintptr(handle), 0, 0) 830 if r1 == 0 { 831 if e1 != 0 { 832 err = errnoErr(e1) 833 } else { 834 err = syscall.EINVAL 835 } 836 } 837 return 838 } 839 840 func GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (err error) { 841 r1, _, e1 := syscall.Syscall(procGetFileInformationByHandle.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0) 842 if r1 == 0 { 843 if e1 != 0 { 844 err = errnoErr(e1) 845 } else { 846 err = syscall.EINVAL 847 } 848 } 849 return 850 } 851 852 func GetFileInformationByHandleEx(handle Handle, class uint32, outBuffer *byte, outBufferLen uint32) (err error) { 853 r1, _, e1 := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 4, uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(outBuffer)), uintptr(outBufferLen), 0, 0) 854 if r1 == 0 { 855 if e1 != 0 { 856 err = errnoErr(e1) 857 } else { 858 err = syscall.EINVAL 859 } 860 } 861 return 862 } 863 864 func GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) { 865 r0, _, e1 := syscall.Syscall(procGetCurrentDirectoryW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0) 866 n = uint32(r0) 867 if n == 0 { 868 if e1 != 0 { 869 err = errnoErr(e1) 870 } else { 871 err = syscall.EINVAL 872 } 873 } 874 return 875 } 876 877 func SetCurrentDirectory(path *uint16) (err error) { 878 r1, _, e1 := syscall.Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) 879 if r1 == 0 { 880 if e1 != 0 { 881 err = errnoErr(e1) 882 } else { 883 err = syscall.EINVAL 884 } 885 } 886 return 887 } 888 889 func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) { 890 r1, _, e1 := syscall.Syscall(procCreateDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(sa)), 0) 891 if r1 == 0 { 892 if e1 != 0 { 893 err = errnoErr(e1) 894 } else { 895 err = syscall.EINVAL 896 } 897 } 898 return 899 } 900 901 func RemoveDirectory(path *uint16) (err error) { 902 r1, _, e1 := syscall.Syscall(procRemoveDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) 903 if r1 == 0 { 904 if e1 != 0 { 905 err = errnoErr(e1) 906 } else { 907 err = syscall.EINVAL 908 } 909 } 910 return 911 } 912 913 func DeleteFile(path *uint16) (err error) { 914 r1, _, e1 := syscall.Syscall(procDeleteFileW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) 915 if r1 == 0 { 916 if e1 != 0 { 917 err = errnoErr(e1) 918 } else { 919 err = syscall.EINVAL 920 } 921 } 922 return 923 } 924 925 func MoveFile(from *uint16, to *uint16) (err error) { 926 r1, _, e1 := syscall.Syscall(procMoveFileW.Addr(), 2, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), 0) 927 if r1 == 0 { 928 if e1 != 0 { 929 err = errnoErr(e1) 930 } else { 931 err = syscall.EINVAL 932 } 933 } 934 return 935 } 936 937 func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) { 938 r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags)) 939 if r1 == 0 { 940 if e1 != 0 { 941 err = errnoErr(e1) 942 } else { 943 err = syscall.EINVAL 944 } 945 } 946 return 947 } 948 949 func GetComputerName(buf *uint16, n *uint32) (err error) { 950 r1, _, e1 := syscall.Syscall(procGetComputerNameW.Addr(), 2, uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)), 0) 951 if r1 == 0 { 952 if e1 != 0 { 953 err = errnoErr(e1) 954 } else { 955 err = syscall.EINVAL 956 } 957 } 958 return 959 } 960 961 func GetComputerNameEx(nametype uint32, buf *uint16, n *uint32) (err error) { 962 r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nametype), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n))) 963 if r1 == 0 { 964 if e1 != 0 { 965 err = errnoErr(e1) 966 } else { 967 err = syscall.EINVAL 968 } 969 } 970 return 971 } 972 973 func SetEndOfFile(handle Handle) (err error) { 974 r1, _, e1 := syscall.Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0) 975 if r1 == 0 { 976 if e1 != 0 { 977 err = errnoErr(e1) 978 } else { 979 err = syscall.EINVAL 980 } 981 } 982 return 983 } 984 985 func GetSystemTimeAsFileTime(time *Filetime) { 986 syscall.Syscall(procGetSystemTimeAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0) 987 return 988 } 989 990 func GetSystemTimePreciseAsFileTime(time *Filetime) { 991 syscall.Syscall(procGetSystemTimePreciseAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0) 992 return 993 } 994 995 func GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) { 996 r0, _, e1 := syscall.Syscall(procGetTimeZoneInformation.Addr(), 1, uintptr(unsafe.Pointer(tzi)), 0, 0) 997 rc = uint32(r0) 998 if rc == 0xffffffff { 999 if e1 != 0 { 1000 err = errnoErr(e1) 1001 } else { 1002 err = syscall.EINVAL 1003 } 1004 } 1005 return 1006 } 1007 1008 func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (handle Handle, err error) { 1009 r0, _, e1 := syscall.Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(filehandle), uintptr(cphandle), uintptr(key), uintptr(threadcnt), 0, 0) 1010 handle = Handle(r0) 1011 if handle == 0 { 1012 if e1 != 0 { 1013 err = errnoErr(e1) 1014 } else { 1015 err = syscall.EINVAL 1016 } 1017 } 1018 return 1019 } 1020 1021 func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error) { 1022 r1, _, e1 := syscall.Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(cphandle), uintptr(unsafe.Pointer(qty)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(overlapped)), uintptr(timeout), 0) 1023 if r1 == 0 { 1024 if e1 != 0 { 1025 err = errnoErr(e1) 1026 } else { 1027 err = syscall.EINVAL 1028 } 1029 } 1030 return 1031 } 1032 1033 func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error) { 1034 r1, _, e1 := syscall.Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0) 1035 if r1 == 0 { 1036 if e1 != 0 { 1037 err = errnoErr(e1) 1038 } else { 1039 err = syscall.EINVAL 1040 } 1041 } 1042 return 1043 } 1044 1045 func CancelIo(s Handle) (err error) { 1046 r1, _, e1 := syscall.Syscall(procCancelIo.Addr(), 1, uintptr(s), 0, 0) 1047 if r1 == 0 { 1048 if e1 != 0 { 1049 err = errnoErr(e1) 1050 } else { 1051 err = syscall.EINVAL 1052 } 1053 } 1054 return 1055 } 1056 1057 func CancelIoEx(s Handle, o *Overlapped) (err error) { 1058 r1, _, e1 := syscall.Syscall(procCancelIoEx.Addr(), 2, uintptr(s), uintptr(unsafe.Pointer(o)), 0) 1059 if r1 == 0 { 1060 if e1 != 0 { 1061 err = errnoErr(e1) 1062 } else { 1063 err = syscall.EINVAL 1064 } 1065 } 1066 return 1067 } 1068 1069 func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) { 1070 var _p0 uint32 1071 if inheritHandles { 1072 _p0 = 1 1073 } else { 1074 _p0 = 0 1075 } 1076 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) 1077 if r1 == 0 { 1078 if e1 != 0 { 1079 err = errnoErr(e1) 1080 } else { 1081 err = syscall.EINVAL 1082 } 1083 } 1084 return 1085 } 1086 1087 func OpenProcess(da uint32, inheritHandle bool, pid uint32) (handle Handle, err error) { 1088 var _p0 uint32 1089 if inheritHandle { 1090 _p0 = 1 1091 } else { 1092 _p0 = 0 1093 } 1094 r0, _, e1 := syscall.Syscall(procOpenProcess.Addr(), 3, uintptr(da), uintptr(_p0), uintptr(pid)) 1095 handle = Handle(r0) 1096 if handle == 0 { 1097 if e1 != 0 { 1098 err = errnoErr(e1) 1099 } else { 1100 err = syscall.EINVAL 1101 } 1102 } 1103 return 1104 } 1105 1106 func ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) { 1107 r1, _, e1 := syscall.Syscall6(procShellExecuteW.Addr(), 6, uintptr(hwnd), uintptr(unsafe.Pointer(verb)), uintptr(unsafe.Pointer(file)), uintptr(unsafe.Pointer(args)), uintptr(unsafe.Pointer(cwd)), uintptr(showCmd)) 1108 if r1 == 0 { 1109 if e1 != 0 { 1110 err = errnoErr(e1) 1111 } else { 1112 err = syscall.EINVAL 1113 } 1114 } 1115 return 1116 } 1117 1118 func TerminateProcess(handle Handle, exitcode uint32) (err error) { 1119 r1, _, e1 := syscall.Syscall(procTerminateProcess.Addr(), 2, uintptr(handle), uintptr(exitcode), 0) 1120 if r1 == 0 { 1121 if e1 != 0 { 1122 err = errnoErr(e1) 1123 } else { 1124 err = syscall.EINVAL 1125 } 1126 } 1127 return 1128 } 1129 1130 func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) { 1131 r1, _, e1 := syscall.Syscall(procGetExitCodeProcess.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(exitcode)), 0) 1132 if r1 == 0 { 1133 if e1 != 0 { 1134 err = errnoErr(e1) 1135 } else { 1136 err = syscall.EINVAL 1137 } 1138 } 1139 return 1140 } 1141 1142 func GetStartupInfo(startupInfo *StartupInfo) (err error) { 1143 r1, _, e1 := syscall.Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0) 1144 if r1 == 0 { 1145 if e1 != 0 { 1146 err = errnoErr(e1) 1147 } else { 1148 err = syscall.EINVAL 1149 } 1150 } 1151 return 1152 } 1153 1154 func GetCurrentProcess() (pseudoHandle Handle, err error) { 1155 r0, _, e1 := syscall.Syscall(procGetCurrentProcess.Addr(), 0, 0, 0, 0) 1156 pseudoHandle = Handle(r0) 1157 if pseudoHandle == 0 { 1158 if e1 != 0 { 1159 err = errnoErr(e1) 1160 } else { 1161 err = syscall.EINVAL 1162 } 1163 } 1164 return 1165 } 1166 1167 func GetCurrentThread() (pseudoHandle Handle, err error) { 1168 r0, _, e1 := syscall.Syscall(procGetCurrentThread.Addr(), 0, 0, 0, 0) 1169 pseudoHandle = Handle(r0) 1170 if pseudoHandle == 0 { 1171 if e1 != 0 { 1172 err = errnoErr(e1) 1173 } else { 1174 err = syscall.EINVAL 1175 } 1176 } 1177 return 1178 } 1179 1180 func GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, kernelTime *Filetime, userTime *Filetime) (err error) { 1181 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) 1182 if r1 == 0 { 1183 if e1 != 0 { 1184 err = errnoErr(e1) 1185 } else { 1186 err = syscall.EINVAL 1187 } 1188 } 1189 return 1190 } 1191 1192 func DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetProcessHandle Handle, lpTargetHandle *Handle, dwDesiredAccess uint32, bInheritHandle bool, dwOptions uint32) (err error) { 1193 var _p0 uint32 1194 if bInheritHandle { 1195 _p0 = 1 1196 } else { 1197 _p0 = 0 1198 } 1199 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) 1200 if r1 == 0 { 1201 if e1 != 0 { 1202 err = errnoErr(e1) 1203 } else { 1204 err = syscall.EINVAL 1205 } 1206 } 1207 return 1208 } 1209 1210 func WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32, err error) { 1211 r0, _, e1 := syscall.Syscall(procWaitForSingleObject.Addr(), 2, uintptr(handle), uintptr(waitMilliseconds), 0) 1212 event = uint32(r0) 1213 if event == 0xffffffff { 1214 if e1 != 0 { 1215 err = errnoErr(e1) 1216 } else { 1217 err = syscall.EINVAL 1218 } 1219 } 1220 return 1221 } 1222 1223 func waitForMultipleObjects(count uint32, handles uintptr, waitAll bool, waitMilliseconds uint32) (event uint32, err error) { 1224 var _p0 uint32 1225 if waitAll { 1226 _p0 = 1 1227 } else { 1228 _p0 = 0 1229 } 1230 r0, _, e1 := syscall.Syscall6(procWaitForMultipleObjects.Addr(), 4, uintptr(count), uintptr(handles), uintptr(_p0), uintptr(waitMilliseconds), 0, 0) 1231 event = uint32(r0) 1232 if event == 0xffffffff { 1233 if e1 != 0 { 1234 err = errnoErr(e1) 1235 } else { 1236 err = syscall.EINVAL 1237 } 1238 } 1239 return 1240 } 1241 1242 func GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) { 1243 r0, _, e1 := syscall.Syscall(procGetTempPathW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0) 1244 n = uint32(r0) 1245 if n == 0 { 1246 if e1 != 0 { 1247 err = errnoErr(e1) 1248 } else { 1249 err = syscall.EINVAL 1250 } 1251 } 1252 return 1253 } 1254 1255 func CreatePipe(readhandle *Handle, writehandle *Handle, sa *SecurityAttributes, size uint32) (err error) { 1256 r1, _, e1 := syscall.Syscall6(procCreatePipe.Addr(), 4, uintptr(unsafe.Pointer(readhandle)), uintptr(unsafe.Pointer(writehandle)), uintptr(unsafe.Pointer(sa)), uintptr(size), 0, 0) 1257 if r1 == 0 { 1258 if e1 != 0 { 1259 err = errnoErr(e1) 1260 } else { 1261 err = syscall.EINVAL 1262 } 1263 } 1264 return 1265 } 1266 1267 func GetFileType(filehandle Handle) (n uint32, err error) { 1268 r0, _, e1 := syscall.Syscall(procGetFileType.Addr(), 1, uintptr(filehandle), 0, 0) 1269 n = uint32(r0) 1270 if n == 0 { 1271 if e1 != 0 { 1272 err = errnoErr(e1) 1273 } else { 1274 err = syscall.EINVAL 1275 } 1276 } 1277 return 1278 } 1279 1280 func CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16, provtype uint32, flags uint32) (err error) { 1281 r1, _, e1 := syscall.Syscall6(procCryptAcquireContextW.Addr(), 5, uintptr(unsafe.Pointer(provhandle)), uintptr(unsafe.Pointer(container)), uintptr(unsafe.Pointer(provider)), uintptr(provtype), uintptr(flags), 0) 1282 if r1 == 0 { 1283 if e1 != 0 { 1284 err = errnoErr(e1) 1285 } else { 1286 err = syscall.EINVAL 1287 } 1288 } 1289 return 1290 } 1291 1292 func CryptReleaseContext(provhandle Handle, flags uint32) (err error) { 1293 r1, _, e1 := syscall.Syscall(procCryptReleaseContext.Addr(), 2, uintptr(provhandle), uintptr(flags), 0) 1294 if r1 == 0 { 1295 if e1 != 0 { 1296 err = errnoErr(e1) 1297 } else { 1298 err = syscall.EINVAL 1299 } 1300 } 1301 return 1302 } 1303 1304 func CryptGenRandom(provhandle Handle, buflen uint32, buf *byte) (err error) { 1305 r1, _, e1 := syscall.Syscall(procCryptGenRandom.Addr(), 3, uintptr(provhandle), uintptr(buflen), uintptr(unsafe.Pointer(buf))) 1306 if r1 == 0 { 1307 if e1 != 0 { 1308 err = errnoErr(e1) 1309 } else { 1310 err = syscall.EINVAL 1311 } 1312 } 1313 return 1314 } 1315 1316 func GetEnvironmentStrings() (envs *uint16, err error) { 1317 r0, _, e1 := syscall.Syscall(procGetEnvironmentStringsW.Addr(), 0, 0, 0, 0) 1318 envs = (*uint16)(unsafe.Pointer(r0)) 1319 if envs == nil { 1320 if e1 != 0 { 1321 err = errnoErr(e1) 1322 } else { 1323 err = syscall.EINVAL 1324 } 1325 } 1326 return 1327 } 1328 1329 func FreeEnvironmentStrings(envs *uint16) (err error) { 1330 r1, _, e1 := syscall.Syscall(procFreeEnvironmentStringsW.Addr(), 1, uintptr(unsafe.Pointer(envs)), 0, 0) 1331 if r1 == 0 { 1332 if e1 != 0 { 1333 err = errnoErr(e1) 1334 } else { 1335 err = syscall.EINVAL 1336 } 1337 } 1338 return 1339 } 1340 1341 func GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32, err error) { 1342 r0, _, e1 := syscall.Syscall(procGetEnvironmentVariableW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buffer)), uintptr(size)) 1343 n = uint32(r0) 1344 if n == 0 { 1345 if e1 != 0 { 1346 err = errnoErr(e1) 1347 } else { 1348 err = syscall.EINVAL 1349 } 1350 } 1351 return 1352 } 1353 1354 func SetEnvironmentVariable(name *uint16, value *uint16) (err error) { 1355 r1, _, e1 := syscall.Syscall(procSetEnvironmentVariableW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), 0) 1356 if r1 == 0 { 1357 if e1 != 0 { 1358 err = errnoErr(e1) 1359 } else { 1360 err = syscall.EINVAL 1361 } 1362 } 1363 return 1364 } 1365 1366 func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) { 1367 var _p0 uint32 1368 if inheritExisting { 1369 _p0 = 1 1370 } else { 1371 _p0 = 0 1372 } 1373 r1, _, e1 := syscall.Syscall(procCreateEnvironmentBlock.Addr(), 3, uintptr(unsafe.Pointer(block)), uintptr(token), uintptr(_p0)) 1374 if r1 == 0 { 1375 if e1 != 0 { 1376 err = errnoErr(e1) 1377 } else { 1378 err = syscall.EINVAL 1379 } 1380 } 1381 return 1382 } 1383 1384 func DestroyEnvironmentBlock(block *uint16) (err error) { 1385 r1, _, e1 := syscall.Syscall(procDestroyEnvironmentBlock.Addr(), 1, uintptr(unsafe.Pointer(block)), 0, 0) 1386 if r1 == 0 { 1387 if e1 != 0 { 1388 err = errnoErr(e1) 1389 } else { 1390 err = syscall.EINVAL 1391 } 1392 } 1393 return 1394 } 1395 1396 func getTickCount64() (ms uint64) { 1397 r0, _, _ := syscall.Syscall(procGetTickCount64.Addr(), 0, 0, 0, 0) 1398 ms = uint64(r0) 1399 return 1400 } 1401 1402 func SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error) { 1403 r1, _, e1 := syscall.Syscall6(procSetFileTime.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(ctime)), uintptr(unsafe.Pointer(atime)), uintptr(unsafe.Pointer(wtime)), 0, 0) 1404 if r1 == 0 { 1405 if e1 != 0 { 1406 err = errnoErr(e1) 1407 } else { 1408 err = syscall.EINVAL 1409 } 1410 } 1411 return 1412 } 1413 1414 func GetFileAttributes(name *uint16) (attrs uint32, err error) { 1415 r0, _, e1 := syscall.Syscall(procGetFileAttributesW.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0) 1416 attrs = uint32(r0) 1417 if attrs == INVALID_FILE_ATTRIBUTES { 1418 if e1 != 0 { 1419 err = errnoErr(e1) 1420 } else { 1421 err = syscall.EINVAL 1422 } 1423 } 1424 return 1425 } 1426 1427 func SetFileAttributes(name *uint16, attrs uint32) (err error) { 1428 r1, _, e1 := syscall.Syscall(procSetFileAttributesW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(attrs), 0) 1429 if r1 == 0 { 1430 if e1 != 0 { 1431 err = errnoErr(e1) 1432 } else { 1433 err = syscall.EINVAL 1434 } 1435 } 1436 return 1437 } 1438 1439 func GetFileAttributesEx(name *uint16, level uint32, info *byte) (err error) { 1440 r1, _, e1 := syscall.Syscall(procGetFileAttributesExW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(level), uintptr(unsafe.Pointer(info))) 1441 if r1 == 0 { 1442 if e1 != 0 { 1443 err = errnoErr(e1) 1444 } else { 1445 err = syscall.EINVAL 1446 } 1447 } 1448 return 1449 } 1450 1451 func GetCommandLine() (cmd *uint16) { 1452 r0, _, _ := syscall.Syscall(procGetCommandLineW.Addr(), 0, 0, 0, 0) 1453 cmd = (*uint16)(unsafe.Pointer(r0)) 1454 return 1455 } 1456 1457 func CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err error) { 1458 r0, _, e1 := syscall.Syscall(procCommandLineToArgvW.Addr(), 2, uintptr(unsafe.Pointer(cmd)), uintptr(unsafe.Pointer(argc)), 0) 1459 argv = (*[8192]*[8192]uint16)(unsafe.Pointer(r0)) 1460 if argv == nil { 1461 if e1 != 0 { 1462 err = errnoErr(e1) 1463 } else { 1464 err = syscall.EINVAL 1465 } 1466 } 1467 return 1468 } 1469 1470 func LocalFree(hmem Handle) (handle Handle, err error) { 1471 r0, _, e1 := syscall.Syscall(procLocalFree.Addr(), 1, uintptr(hmem), 0, 0) 1472 handle = Handle(r0) 1473 if handle != 0 { 1474 if e1 != 0 { 1475 err = errnoErr(e1) 1476 } else { 1477 err = syscall.EINVAL 1478 } 1479 } 1480 return 1481 } 1482 1483 func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error) { 1484 r1, _, e1 := syscall.Syscall(procSetHandleInformation.Addr(), 3, uintptr(handle), uintptr(mask), uintptr(flags)) 1485 if r1 == 0 { 1486 if e1 != 0 { 1487 err = errnoErr(e1) 1488 } else { 1489 err = syscall.EINVAL 1490 } 1491 } 1492 return 1493 } 1494 1495 func FlushFileBuffers(handle Handle) (err error) { 1496 r1, _, e1 := syscall.Syscall(procFlushFileBuffers.Addr(), 1, uintptr(handle), 0, 0) 1497 if r1 == 0 { 1498 if e1 != 0 { 1499 err = errnoErr(e1) 1500 } else { 1501 err = syscall.EINVAL 1502 } 1503 } 1504 return 1505 } 1506 1507 func GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) (n uint32, err error) { 1508 r0, _, e1 := syscall.Syscall6(procGetFullPathNameW.Addr(), 4, uintptr(unsafe.Pointer(path)), uintptr(buflen), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(fname)), 0, 0) 1509 n = uint32(r0) 1510 if n == 0 { 1511 if e1 != 0 { 1512 err = errnoErr(e1) 1513 } else { 1514 err = syscall.EINVAL 1515 } 1516 } 1517 return 1518 } 1519 1520 func GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err error) { 1521 r0, _, e1 := syscall.Syscall(procGetLongPathNameW.Addr(), 3, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(buf)), uintptr(buflen)) 1522 n = uint32(r0) 1523 if n == 0 { 1524 if e1 != 0 { 1525 err = errnoErr(e1) 1526 } else { 1527 err = syscall.EINVAL 1528 } 1529 } 1530 return 1531 } 1532 1533 func GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uint32, err error) { 1534 r0, _, e1 := syscall.Syscall(procGetShortPathNameW.Addr(), 3, uintptr(unsafe.Pointer(longpath)), uintptr(unsafe.Pointer(shortpath)), uintptr(buflen)) 1535 n = uint32(r0) 1536 if n == 0 { 1537 if e1 != 0 { 1538 err = errnoErr(e1) 1539 } else { 1540 err = syscall.EINVAL 1541 } 1542 } 1543 return 1544 } 1545 1546 func CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error) { 1547 r0, _, e1 := syscall.Syscall6(procCreateFileMappingW.Addr(), 6, uintptr(fhandle), uintptr(unsafe.Pointer(sa)), uintptr(prot), uintptr(maxSizeHigh), uintptr(maxSizeLow), uintptr(unsafe.Pointer(name))) 1548 handle = Handle(r0) 1549 if handle == 0 { 1550 if e1 != 0 { 1551 err = errnoErr(e1) 1552 } else { 1553 err = syscall.EINVAL 1554 } 1555 } 1556 return 1557 } 1558 1559 func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow uint32, length uintptr) (addr uintptr, err error) { 1560 r0, _, e1 := syscall.Syscall6(procMapViewOfFile.Addr(), 5, uintptr(handle), uintptr(access), uintptr(offsetHigh), uintptr(offsetLow), uintptr(length), 0) 1561 addr = uintptr(r0) 1562 if addr == 0 { 1563 if e1 != 0 { 1564 err = errnoErr(e1) 1565 } else { 1566 err = syscall.EINVAL 1567 } 1568 } 1569 return 1570 } 1571 1572 func UnmapViewOfFile(addr uintptr) (err error) { 1573 r1, _, e1 := syscall.Syscall(procUnmapViewOfFile.Addr(), 1, uintptr(addr), 0, 0) 1574 if r1 == 0 { 1575 if e1 != 0 { 1576 err = errnoErr(e1) 1577 } else { 1578 err = syscall.EINVAL 1579 } 1580 } 1581 return 1582 } 1583 1584 func FlushViewOfFile(addr uintptr, length uintptr) (err error) { 1585 r1, _, e1 := syscall.Syscall(procFlushViewOfFile.Addr(), 2, uintptr(addr), uintptr(length), 0) 1586 if r1 == 0 { 1587 if e1 != 0 { 1588 err = errnoErr(e1) 1589 } else { 1590 err = syscall.EINVAL 1591 } 1592 } 1593 return 1594 } 1595 1596 func VirtualLock(addr uintptr, length uintptr) (err error) { 1597 r1, _, e1 := syscall.Syscall(procVirtualLock.Addr(), 2, uintptr(addr), uintptr(length), 0) 1598 if r1 == 0 { 1599 if e1 != 0 { 1600 err = errnoErr(e1) 1601 } else { 1602 err = syscall.EINVAL 1603 } 1604 } 1605 return 1606 } 1607 1608 func VirtualUnlock(addr uintptr, length uintptr) (err error) { 1609 r1, _, e1 := syscall.Syscall(procVirtualUnlock.Addr(), 2, uintptr(addr), uintptr(length), 0) 1610 if r1 == 0 { 1611 if e1 != 0 { 1612 err = errnoErr(e1) 1613 } else { 1614 err = syscall.EINVAL 1615 } 1616 } 1617 return 1618 } 1619 1620 func VirtualAlloc(address uintptr, size uintptr, alloctype uint32, protect uint32) (value uintptr, err error) { 1621 r0, _, e1 := syscall.Syscall6(procVirtualAlloc.Addr(), 4, uintptr(address), uintptr(size), uintptr(alloctype), uintptr(protect), 0, 0) 1622 value = uintptr(r0) 1623 if value == 0 { 1624 if e1 != 0 { 1625 err = errnoErr(e1) 1626 } else { 1627 err = syscall.EINVAL 1628 } 1629 } 1630 return 1631 } 1632 1633 func VirtualFree(address uintptr, size uintptr, freetype uint32) (err error) { 1634 r1, _, e1 := syscall.Syscall(procVirtualFree.Addr(), 3, uintptr(address), uintptr(size), uintptr(freetype)) 1635 if r1 == 0 { 1636 if e1 != 0 { 1637 err = errnoErr(e1) 1638 } else { 1639 err = syscall.EINVAL 1640 } 1641 } 1642 return 1643 } 1644 1645 func VirtualProtect(address uintptr, size uintptr, newprotect uint32, oldprotect *uint32) (err error) { 1646 r1, _, e1 := syscall.Syscall6(procVirtualProtect.Addr(), 4, uintptr(address), uintptr(size), uintptr(newprotect), uintptr(unsafe.Pointer(oldprotect)), 0, 0) 1647 if r1 == 0 { 1648 if e1 != 0 { 1649 err = errnoErr(e1) 1650 } else { 1651 err = syscall.EINVAL 1652 } 1653 } 1654 return 1655 } 1656 1657 func TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) { 1658 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) 1659 if r1 == 0 { 1660 if e1 != 0 { 1661 err = errnoErr(e1) 1662 } else { 1663 err = syscall.EINVAL 1664 } 1665 } 1666 return 1667 } 1668 1669 func ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) { 1670 var _p0 uint32 1671 if watchSubTree { 1672 _p0 = 1 1673 } else { 1674 _p0 = 0 1675 } 1676 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) 1677 if r1 == 0 { 1678 if e1 != 0 { 1679 err = errnoErr(e1) 1680 } else { 1681 err = syscall.EINVAL 1682 } 1683 } 1684 return 1685 } 1686 1687 func CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) { 1688 r0, _, e1 := syscall.Syscall(procCertOpenSystemStoreW.Addr(), 2, uintptr(hprov), uintptr(unsafe.Pointer(name)), 0) 1689 store = Handle(r0) 1690 if store == 0 { 1691 if e1 != 0 { 1692 err = errnoErr(e1) 1693 } else { 1694 err = syscall.EINVAL 1695 } 1696 } 1697 return 1698 } 1699 1700 func CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) { 1701 r0, _, e1 := syscall.Syscall6(procCertOpenStore.Addr(), 5, uintptr(storeProvider), uintptr(msgAndCertEncodingType), uintptr(cryptProv), uintptr(flags), uintptr(para), 0) 1702 handle = Handle(r0) 1703 if handle == InvalidHandle { 1704 if e1 != 0 { 1705 err = errnoErr(e1) 1706 } else { 1707 err = syscall.EINVAL 1708 } 1709 } 1710 return 1711 } 1712 1713 func CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) { 1714 r0, _, e1 := syscall.Syscall(procCertEnumCertificatesInStore.Addr(), 2, uintptr(store), uintptr(unsafe.Pointer(prevContext)), 0) 1715 context = (*CertContext)(unsafe.Pointer(r0)) 1716 if context == nil { 1717 if e1 != 0 { 1718 err = errnoErr(e1) 1719 } else { 1720 err = syscall.EINVAL 1721 } 1722 } 1723 return 1724 } 1725 1726 func CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) { 1727 r1, _, e1 := syscall.Syscall6(procCertAddCertificateContextToStore.Addr(), 4, uintptr(store), uintptr(unsafe.Pointer(certContext)), uintptr(addDisposition), uintptr(unsafe.Pointer(storeContext)), 0, 0) 1728 if r1 == 0 { 1729 if e1 != 0 { 1730 err = errnoErr(e1) 1731 } else { 1732 err = syscall.EINVAL 1733 } 1734 } 1735 return 1736 } 1737 1738 func CertCloseStore(store Handle, flags uint32) (err error) { 1739 r1, _, e1 := syscall.Syscall(procCertCloseStore.Addr(), 2, uintptr(store), uintptr(flags), 0) 1740 if r1 == 0 { 1741 if e1 != 0 { 1742 err = errnoErr(e1) 1743 } else { 1744 err = syscall.EINVAL 1745 } 1746 } 1747 return 1748 } 1749 1750 func CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) { 1751 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) 1752 if r1 == 0 { 1753 if e1 != 0 { 1754 err = errnoErr(e1) 1755 } else { 1756 err = syscall.EINVAL 1757 } 1758 } 1759 return 1760 } 1761 1762 func CertFreeCertificateChain(ctx *CertChainContext) { 1763 syscall.Syscall(procCertFreeCertificateChain.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0) 1764 return 1765 } 1766 1767 func CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, encodedLen uint32) (context *CertContext, err error) { 1768 r0, _, e1 := syscall.Syscall(procCertCreateCertificateContext.Addr(), 3, uintptr(certEncodingType), uintptr(unsafe.Pointer(certEncoded)), uintptr(encodedLen)) 1769 context = (*CertContext)(unsafe.Pointer(r0)) 1770 if context == nil { 1771 if e1 != 0 { 1772 err = errnoErr(e1) 1773 } else { 1774 err = syscall.EINVAL 1775 } 1776 } 1777 return 1778 } 1779 1780 func CertFreeCertificateContext(ctx *CertContext) (err error) { 1781 r1, _, e1 := syscall.Syscall(procCertFreeCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0) 1782 if r1 == 0 { 1783 if e1 != 0 { 1784 err = errnoErr(e1) 1785 } else { 1786 err = syscall.EINVAL 1787 } 1788 } 1789 return 1790 } 1791 1792 func CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) { 1793 r1, _, e1 := syscall.Syscall6(procCertVerifyCertificateChainPolicy.Addr(), 4, uintptr(policyOID), uintptr(unsafe.Pointer(chain)), uintptr(unsafe.Pointer(para)), uintptr(unsafe.Pointer(status)), 0, 0) 1794 if r1 == 0 { 1795 if e1 != 0 { 1796 err = errnoErr(e1) 1797 } else { 1798 err = syscall.EINVAL 1799 } 1800 } 1801 return 1802 } 1803 1804 func RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno error) { 1805 r0, _, _ := syscall.Syscall6(procRegOpenKeyExW.Addr(), 5, uintptr(key), uintptr(unsafe.Pointer(subkey)), uintptr(options), uintptr(desiredAccess), uintptr(unsafe.Pointer(result)), 0) 1806 if r0 != 0 { 1807 regerrno = syscall.Errno(r0) 1808 } 1809 return 1810 } 1811 1812 func RegCloseKey(key Handle) (regerrno error) { 1813 r0, _, _ := syscall.Syscall(procRegCloseKey.Addr(), 1, uintptr(key), 0, 0) 1814 if r0 != 0 { 1815 regerrno = syscall.Errno(r0) 1816 } 1817 return 1818 } 1819 1820 func RegQueryInfoKey(key Handle, class *uint16, classLen *uint32, reserved *uint32, subkeysLen *uint32, maxSubkeyLen *uint32, maxClassLen *uint32, valuesLen *uint32, maxValueNameLen *uint32, maxValueLen *uint32, saLen *uint32, lastWriteTime *Filetime) (regerrno error) { 1821 r0, _, _ := syscall.Syscall12(procRegQueryInfoKeyW.Addr(), 12, uintptr(key), uintptr(unsafe.Pointer(class)), uintptr(unsafe.Pointer(classLen)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(subkeysLen)), uintptr(unsafe.Pointer(maxSubkeyLen)), uintptr(unsafe.Pointer(maxClassLen)), uintptr(unsafe.Pointer(valuesLen)), uintptr(unsafe.Pointer(maxValueNameLen)), uintptr(unsafe.Pointer(maxValueLen)), uintptr(unsafe.Pointer(saLen)), uintptr(unsafe.Pointer(lastWriteTime))) 1822 if r0 != 0 { 1823 regerrno = syscall.Errno(r0) 1824 } 1825 return 1826 } 1827 1828 func RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) { 1829 r0, _, _ := syscall.Syscall9(procRegEnumKeyExW.Addr(), 8, uintptr(key), uintptr(index), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(class)), uintptr(unsafe.Pointer(classLen)), uintptr(unsafe.Pointer(lastWriteTime)), 0) 1830 if r0 != 0 { 1831 regerrno = syscall.Errno(r0) 1832 } 1833 return 1834 } 1835 1836 func RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) { 1837 r0, _, _ := syscall.Syscall6(procRegQueryValueExW.Addr(), 6, uintptr(key), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(valtype)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(buflen))) 1838 if r0 != 0 { 1839 regerrno = syscall.Errno(r0) 1840 } 1841 return 1842 } 1843 1844 func GetCurrentProcessId() (pid uint32) { 1845 r0, _, _ := syscall.Syscall(procGetCurrentProcessId.Addr(), 0, 0, 0, 0) 1846 pid = uint32(r0) 1847 return 1848 } 1849 1850 func GetConsoleMode(console Handle, mode *uint32) (err error) { 1851 r1, _, e1 := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0) 1852 if r1 == 0 { 1853 if e1 != 0 { 1854 err = errnoErr(e1) 1855 } else { 1856 err = syscall.EINVAL 1857 } 1858 } 1859 return 1860 } 1861 1862 func SetConsoleMode(console Handle, mode uint32) (err error) { 1863 r1, _, e1 := syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(console), uintptr(mode), 0) 1864 if r1 == 0 { 1865 if e1 != 0 { 1866 err = errnoErr(e1) 1867 } else { 1868 err = syscall.EINVAL 1869 } 1870 } 1871 return 1872 } 1873 1874 func GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) { 1875 r1, _, e1 := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(info)), 0) 1876 if r1 == 0 { 1877 if e1 != 0 { 1878 err = errnoErr(e1) 1879 } else { 1880 err = syscall.EINVAL 1881 } 1882 } 1883 return 1884 } 1885 1886 func WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) { 1887 r1, _, e1 := syscall.Syscall6(procWriteConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(towrite), uintptr(unsafe.Pointer(written)), uintptr(unsafe.Pointer(reserved)), 0) 1888 if r1 == 0 { 1889 if e1 != 0 { 1890 err = errnoErr(e1) 1891 } else { 1892 err = syscall.EINVAL 1893 } 1894 } 1895 return 1896 } 1897 1898 func ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) { 1899 r1, _, e1 := syscall.Syscall6(procReadConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(toread), uintptr(unsafe.Pointer(read)), uintptr(unsafe.Pointer(inputControl)), 0) 1900 if r1 == 0 { 1901 if e1 != 0 { 1902 err = errnoErr(e1) 1903 } else { 1904 err = syscall.EINVAL 1905 } 1906 } 1907 return 1908 } 1909 1910 func CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) { 1911 r0, _, e1 := syscall.Syscall(procCreateToolhelp32Snapshot.Addr(), 2, uintptr(flags), uintptr(processId), 0) 1912 handle = Handle(r0) 1913 if handle == InvalidHandle { 1914 if e1 != 0 { 1915 err = errnoErr(e1) 1916 } else { 1917 err = syscall.EINVAL 1918 } 1919 } 1920 return 1921 } 1922 1923 func Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) { 1924 r1, _, e1 := syscall.Syscall(procProcess32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0) 1925 if r1 == 0 { 1926 if e1 != 0 { 1927 err = errnoErr(e1) 1928 } else { 1929 err = syscall.EINVAL 1930 } 1931 } 1932 return 1933 } 1934 1935 func Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) { 1936 r1, _, e1 := syscall.Syscall(procProcess32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0) 1937 if r1 == 0 { 1938 if e1 != 0 { 1939 err = errnoErr(e1) 1940 } else { 1941 err = syscall.EINVAL 1942 } 1943 } 1944 return 1945 } 1946 1947 func Thread32First(snapshot Handle, threadEntry *ThreadEntry32) (err error) { 1948 r1, _, e1 := syscall.Syscall(procThread32First.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(threadEntry)), 0) 1949 if r1 == 0 { 1950 if e1 != 0 { 1951 err = errnoErr(e1) 1952 } else { 1953 err = syscall.EINVAL 1954 } 1955 } 1956 return 1957 } 1958 1959 func Thread32Next(snapshot Handle, threadEntry *ThreadEntry32) (err error) { 1960 r1, _, e1 := syscall.Syscall(procThread32Next.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(threadEntry)), 0) 1961 if r1 == 0 { 1962 if e1 != 0 { 1963 err = errnoErr(e1) 1964 } else { 1965 err = syscall.EINVAL 1966 } 1967 } 1968 return 1969 } 1970 1971 func DeviceIoControl(handle Handle, ioControlCode uint32, inBuffer *byte, inBufferSize uint32, outBuffer *byte, outBufferSize uint32, bytesReturned *uint32, overlapped *Overlapped) (err error) { 1972 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) 1973 if r1 == 0 { 1974 if e1 != 0 { 1975 err = errnoErr(e1) 1976 } else { 1977 err = syscall.EINVAL 1978 } 1979 } 1980 return 1981 } 1982 1983 func CreateSymbolicLink(symlinkfilename *uint16, targetfilename *uint16, flags uint32) (err error) { 1984 r1, _, e1 := syscall.Syscall(procCreateSymbolicLinkW.Addr(), 3, uintptr(unsafe.Pointer(symlinkfilename)), uintptr(unsafe.Pointer(targetfilename)), uintptr(flags)) 1985 if r1&0xff == 0 { 1986 if e1 != 0 { 1987 err = errnoErr(e1) 1988 } else { 1989 err = syscall.EINVAL 1990 } 1991 } 1992 return 1993 } 1994 1995 func CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr) (err error) { 1996 r1, _, e1 := syscall.Syscall(procCreateHardLinkW.Addr(), 3, uintptr(unsafe.Pointer(filename)), uintptr(unsafe.Pointer(existingfilename)), uintptr(reserved)) 1997 if r1&0xff == 0 { 1998 if e1 != 0 { 1999 err = errnoErr(e1) 2000 } else { 2001 err = syscall.EINVAL 2002 } 2003 } 2004 return 2005 } 2006 2007 func GetCurrentThreadId() (id uint32) { 2008 r0, _, _ := syscall.Syscall(procGetCurrentThreadId.Addr(), 0, 0, 0, 0) 2009 id = uint32(r0) 2010 return 2011 } 2012 2013 func CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) { 2014 r0, _, e1 := syscall.Syscall6(procCreateEventW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(manualReset), uintptr(initialState), uintptr(unsafe.Pointer(name)), 0, 0) 2015 handle = Handle(r0) 2016 if handle == 0 { 2017 if e1 != 0 { 2018 err = errnoErr(e1) 2019 } else { 2020 err = syscall.EINVAL 2021 } 2022 } 2023 return 2024 } 2025 2026 func CreateEventEx(eventAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) { 2027 r0, _, e1 := syscall.Syscall6(procCreateEventExW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(desiredAccess), 0, 0) 2028 handle = Handle(r0) 2029 if handle == 0 { 2030 if e1 != 0 { 2031 err = errnoErr(e1) 2032 } else { 2033 err = syscall.EINVAL 2034 } 2035 } 2036 return 2037 } 2038 2039 func OpenEvent(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) { 2040 var _p0 uint32 2041 if inheritHandle { 2042 _p0 = 1 2043 } else { 2044 _p0 = 0 2045 } 2046 r0, _, e1 := syscall.Syscall(procOpenEventW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name))) 2047 handle = Handle(r0) 2048 if handle == 0 { 2049 if e1 != 0 { 2050 err = errnoErr(e1) 2051 } else { 2052 err = syscall.EINVAL 2053 } 2054 } 2055 return 2056 } 2057 2058 func SetEvent(event Handle) (err error) { 2059 r1, _, e1 := syscall.Syscall(procSetEvent.Addr(), 1, uintptr(event), 0, 0) 2060 if r1 == 0 { 2061 if e1 != 0 { 2062 err = errnoErr(e1) 2063 } else { 2064 err = syscall.EINVAL 2065 } 2066 } 2067 return 2068 } 2069 2070 func ResetEvent(event Handle) (err error) { 2071 r1, _, e1 := syscall.Syscall(procResetEvent.Addr(), 1, uintptr(event), 0, 0) 2072 if r1 == 0 { 2073 if e1 != 0 { 2074 err = errnoErr(e1) 2075 } else { 2076 err = syscall.EINVAL 2077 } 2078 } 2079 return 2080 } 2081 2082 func PulseEvent(event Handle) (err error) { 2083 r1, _, e1 := syscall.Syscall(procPulseEvent.Addr(), 1, uintptr(event), 0, 0) 2084 if r1 == 0 { 2085 if e1 != 0 { 2086 err = errnoErr(e1) 2087 } else { 2088 err = syscall.EINVAL 2089 } 2090 } 2091 return 2092 } 2093 2094 func SleepEx(milliseconds uint32, alertable bool) (ret uint32) { 2095 var _p0 uint32 2096 if alertable { 2097 _p0 = 1 2098 } else { 2099 _p0 = 0 2100 } 2101 r0, _, _ := syscall.Syscall(procSleepEx.Addr(), 2, uintptr(milliseconds), uintptr(_p0), 0) 2102 ret = uint32(r0) 2103 return 2104 } 2105 2106 func CreateJobObject(jobAttr *SecurityAttributes, name *uint16) (handle Handle, err error) { 2107 r0, _, e1 := syscall.Syscall(procCreateJobObjectW.Addr(), 2, uintptr(unsafe.Pointer(jobAttr)), uintptr(unsafe.Pointer(name)), 0) 2108 handle = Handle(r0) 2109 if handle == 0 { 2110 if e1 != 0 { 2111 err = errnoErr(e1) 2112 } else { 2113 err = syscall.EINVAL 2114 } 2115 } 2116 return 2117 } 2118 2119 func AssignProcessToJobObject(job Handle, process Handle) (err error) { 2120 r1, _, e1 := syscall.Syscall(procAssignProcessToJobObject.Addr(), 2, uintptr(job), uintptr(process), 0) 2121 if r1 == 0 { 2122 if e1 != 0 { 2123 err = errnoErr(e1) 2124 } else { 2125 err = syscall.EINVAL 2126 } 2127 } 2128 return 2129 } 2130 2131 func TerminateJobObject(job Handle, exitCode uint32) (err error) { 2132 r1, _, e1 := syscall.Syscall(procTerminateJobObject.Addr(), 2, uintptr(job), uintptr(exitCode), 0) 2133 if r1 == 0 { 2134 if e1 != 0 { 2135 err = errnoErr(e1) 2136 } else { 2137 err = syscall.EINVAL 2138 } 2139 } 2140 return 2141 } 2142 2143 func SetErrorMode(mode uint32) (ret uint32) { 2144 r0, _, _ := syscall.Syscall(procSetErrorMode.Addr(), 1, uintptr(mode), 0, 0) 2145 ret = uint32(r0) 2146 return 2147 } 2148 2149 func ResumeThread(thread Handle) (ret uint32, err error) { 2150 r0, _, e1 := syscall.Syscall(procResumeThread.Addr(), 1, uintptr(thread), 0, 0) 2151 ret = uint32(r0) 2152 if ret == 0xffffffff { 2153 if e1 != 0 { 2154 err = errnoErr(e1) 2155 } else { 2156 err = syscall.EINVAL 2157 } 2158 } 2159 return 2160 } 2161 2162 func SetPriorityClass(process Handle, priorityClass uint32) (err error) { 2163 r1, _, e1 := syscall.Syscall(procSetPriorityClass.Addr(), 2, uintptr(process), uintptr(priorityClass), 0) 2164 if r1 == 0 { 2165 if e1 != 0 { 2166 err = errnoErr(e1) 2167 } else { 2168 err = syscall.EINVAL 2169 } 2170 } 2171 return 2172 } 2173 2174 func GetPriorityClass(process Handle) (ret uint32, err error) { 2175 r0, _, e1 := syscall.Syscall(procGetPriorityClass.Addr(), 1, uintptr(process), 0, 0) 2176 ret = uint32(r0) 2177 if ret == 0 { 2178 if e1 != 0 { 2179 err = errnoErr(e1) 2180 } else { 2181 err = syscall.EINVAL 2182 } 2183 } 2184 return 2185 } 2186 2187 func SetInformationJobObject(job Handle, JobObjectInformationClass uint32, JobObjectInformation uintptr, JobObjectInformationLength uint32) (ret int, err error) { 2188 r0, _, e1 := syscall.Syscall6(procSetInformationJobObject.Addr(), 4, uintptr(job), uintptr(JobObjectInformationClass), uintptr(JobObjectInformation), uintptr(JobObjectInformationLength), 0, 0) 2189 ret = int(r0) 2190 if ret == 0 { 2191 if e1 != 0 { 2192 err = errnoErr(e1) 2193 } else { 2194 err = syscall.EINVAL 2195 } 2196 } 2197 return 2198 } 2199 2200 func GenerateConsoleCtrlEvent(ctrlEvent uint32, processGroupID uint32) (err error) { 2201 r1, _, e1 := syscall.Syscall(procGenerateConsoleCtrlEvent.Addr(), 2, uintptr(ctrlEvent), uintptr(processGroupID), 0) 2202 if r1 == 0 { 2203 if e1 != 0 { 2204 err = errnoErr(e1) 2205 } else { 2206 err = syscall.EINVAL 2207 } 2208 } 2209 return 2210 } 2211 2212 func DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) { 2213 r1, _, e1 := syscall.Syscall(procDefineDosDeviceW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath))) 2214 if r1 == 0 { 2215 if e1 != 0 { 2216 err = errnoErr(e1) 2217 } else { 2218 err = syscall.EINVAL 2219 } 2220 } 2221 return 2222 } 2223 2224 func DeleteVolumeMountPoint(volumeMountPoint *uint16) (err error) { 2225 r1, _, e1 := syscall.Syscall(procDeleteVolumeMountPointW.Addr(), 1, uintptr(unsafe.Pointer(volumeMountPoint)), 0, 0) 2226 if r1 == 0 { 2227 if e1 != 0 { 2228 err = errnoErr(e1) 2229 } else { 2230 err = syscall.EINVAL 2231 } 2232 } 2233 return 2234 } 2235 2236 func FindFirstVolume(volumeName *uint16, bufferLength uint32) (handle Handle, err error) { 2237 r0, _, e1 := syscall.Syscall(procFindFirstVolumeW.Addr(), 2, uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength), 0) 2238 handle = Handle(r0) 2239 if handle == InvalidHandle { 2240 if e1 != 0 { 2241 err = errnoErr(e1) 2242 } else { 2243 err = syscall.EINVAL 2244 } 2245 } 2246 return 2247 } 2248 2249 func FindFirstVolumeMountPoint(rootPathName *uint16, volumeMountPoint *uint16, bufferLength uint32) (handle Handle, err error) { 2250 r0, _, e1 := syscall.Syscall(procFindFirstVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength)) 2251 handle = Handle(r0) 2252 if handle == InvalidHandle { 2253 if e1 != 0 { 2254 err = errnoErr(e1) 2255 } else { 2256 err = syscall.EINVAL 2257 } 2258 } 2259 return 2260 } 2261 2262 func FindNextVolume(findVolume Handle, volumeName *uint16, bufferLength uint32) (err error) { 2263 r1, _, e1 := syscall.Syscall(procFindNextVolumeW.Addr(), 3, uintptr(findVolume), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength)) 2264 if r1 == 0 { 2265 if e1 != 0 { 2266 err = errnoErr(e1) 2267 } else { 2268 err = syscall.EINVAL 2269 } 2270 } 2271 return 2272 } 2273 2274 func FindNextVolumeMountPoint(findVolumeMountPoint Handle, volumeMountPoint *uint16, bufferLength uint32) (err error) { 2275 r1, _, e1 := syscall.Syscall(procFindNextVolumeMountPointW.Addr(), 3, uintptr(findVolumeMountPoint), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength)) 2276 if r1 == 0 { 2277 if e1 != 0 { 2278 err = errnoErr(e1) 2279 } else { 2280 err = syscall.EINVAL 2281 } 2282 } 2283 return 2284 } 2285 2286 func FindVolumeClose(findVolume Handle) (err error) { 2287 r1, _, e1 := syscall.Syscall(procFindVolumeClose.Addr(), 1, uintptr(findVolume), 0, 0) 2288 if r1 == 0 { 2289 if e1 != 0 { 2290 err = errnoErr(e1) 2291 } else { 2292 err = syscall.EINVAL 2293 } 2294 } 2295 return 2296 } 2297 2298 func FindVolumeMountPointClose(findVolumeMountPoint Handle) (err error) { 2299 r1, _, e1 := syscall.Syscall(procFindVolumeMountPointClose.Addr(), 1, uintptr(findVolumeMountPoint), 0, 0) 2300 if r1 == 0 { 2301 if e1 != 0 { 2302 err = errnoErr(e1) 2303 } else { 2304 err = syscall.EINVAL 2305 } 2306 } 2307 return 2308 } 2309 2310 func GetDriveType(rootPathName *uint16) (driveType uint32) { 2311 r0, _, _ := syscall.Syscall(procGetDriveTypeW.Addr(), 1, uintptr(unsafe.Pointer(rootPathName)), 0, 0) 2312 driveType = uint32(r0) 2313 return 2314 } 2315 2316 func GetLogicalDrives() (drivesBitMask uint32, err error) { 2317 r0, _, e1 := syscall.Syscall(procGetLogicalDrives.Addr(), 0, 0, 0, 0) 2318 drivesBitMask = uint32(r0) 2319 if drivesBitMask == 0 { 2320 if e1 != 0 { 2321 err = errnoErr(e1) 2322 } else { 2323 err = syscall.EINVAL 2324 } 2325 } 2326 return 2327 } 2328 2329 func GetLogicalDriveStrings(bufferLength uint32, buffer *uint16) (n uint32, err error) { 2330 r0, _, e1 := syscall.Syscall(procGetLogicalDriveStringsW.Addr(), 2, uintptr(bufferLength), uintptr(unsafe.Pointer(buffer)), 0) 2331 n = uint32(r0) 2332 if n == 0 { 2333 if e1 != 0 { 2334 err = errnoErr(e1) 2335 } else { 2336 err = syscall.EINVAL 2337 } 2338 } 2339 return 2340 } 2341 2342 func GetVolumeInformation(rootPathName *uint16, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) { 2343 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) 2344 if r1 == 0 { 2345 if e1 != 0 { 2346 err = errnoErr(e1) 2347 } else { 2348 err = syscall.EINVAL 2349 } 2350 } 2351 return 2352 } 2353 2354 func GetVolumeInformationByHandle(file Handle, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) { 2355 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) 2356 if r1 == 0 { 2357 if e1 != 0 { 2358 err = errnoErr(e1) 2359 } else { 2360 err = syscall.EINVAL 2361 } 2362 } 2363 return 2364 } 2365 2366 func GetVolumeNameForVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16, bufferlength uint32) (err error) { 2367 r1, _, e1 := syscall.Syscall(procGetVolumeNameForVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferlength)) 2368 if r1 == 0 { 2369 if e1 != 0 { 2370 err = errnoErr(e1) 2371 } else { 2372 err = syscall.EINVAL 2373 } 2374 } 2375 return 2376 } 2377 2378 func GetVolumePathName(fileName *uint16, volumePathName *uint16, bufferLength uint32) (err error) { 2379 r1, _, e1 := syscall.Syscall(procGetVolumePathNameW.Addr(), 3, uintptr(unsafe.Pointer(fileName)), uintptr(unsafe.Pointer(volumePathName)), uintptr(bufferLength)) 2380 if r1 == 0 { 2381 if e1 != 0 { 2382 err = errnoErr(e1) 2383 } else { 2384 err = syscall.EINVAL 2385 } 2386 } 2387 return 2388 } 2389 2390 func GetVolumePathNamesForVolumeName(volumeName *uint16, volumePathNames *uint16, bufferLength uint32, returnLength *uint32) (err error) { 2391 r1, _, e1 := syscall.Syscall6(procGetVolumePathNamesForVolumeNameW.Addr(), 4, uintptr(unsafe.Pointer(volumeName)), uintptr(unsafe.Pointer(volumePathNames)), uintptr(bufferLength), uintptr(unsafe.Pointer(returnLength)), 0, 0) 2392 if r1 == 0 { 2393 if e1 != 0 { 2394 err = errnoErr(e1) 2395 } else { 2396 err = syscall.EINVAL 2397 } 2398 } 2399 return 2400 } 2401 2402 func QueryDosDevice(deviceName *uint16, targetPath *uint16, max uint32) (n uint32, err error) { 2403 r0, _, e1 := syscall.Syscall(procQueryDosDeviceW.Addr(), 3, uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)), uintptr(max)) 2404 n = uint32(r0) 2405 if n == 0 { 2406 if e1 != 0 { 2407 err = errnoErr(e1) 2408 } else { 2409 err = syscall.EINVAL 2410 } 2411 } 2412 return 2413 } 2414 2415 func SetVolumeLabel(rootPathName *uint16, volumeName *uint16) (err error) { 2416 r1, _, e1 := syscall.Syscall(procSetVolumeLabelW.Addr(), 2, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeName)), 0) 2417 if r1 == 0 { 2418 if e1 != 0 { 2419 err = errnoErr(e1) 2420 } else { 2421 err = syscall.EINVAL 2422 } 2423 } 2424 return 2425 } 2426 2427 func SetVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16) (err error) { 2428 r1, _, e1 := syscall.Syscall(procSetVolumeMountPointW.Addr(), 2, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), 0) 2429 if r1 == 0 { 2430 if e1 != 0 { 2431 err = errnoErr(e1) 2432 } else { 2433 err = syscall.EINVAL 2434 } 2435 } 2436 return 2437 } 2438 2439 func MessageBox(hwnd Handle, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) { 2440 r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0) 2441 ret = int32(r0) 2442 if ret == 0 { 2443 if e1 != 0 { 2444 err = errnoErr(e1) 2445 } else { 2446 err = syscall.EINVAL 2447 } 2448 } 2449 return 2450 } 2451 2452 func clsidFromString(lpsz *uint16, pclsid *GUID) (ret error) { 2453 r0, _, _ := syscall.Syscall(procCLSIDFromString.Addr(), 2, uintptr(unsafe.Pointer(lpsz)), uintptr(unsafe.Pointer(pclsid)), 0) 2454 if r0 != 0 { 2455 ret = syscall.Errno(r0) 2456 } 2457 return 2458 } 2459 2460 func stringFromGUID2(rguid *GUID, lpsz *uint16, cchMax int32) (chars int32) { 2461 r0, _, _ := syscall.Syscall(procStringFromGUID2.Addr(), 3, uintptr(unsafe.Pointer(rguid)), uintptr(unsafe.Pointer(lpsz)), uintptr(cchMax)) 2462 chars = int32(r0) 2463 return 2464 } 2465 2466 func coCreateGuid(pguid *GUID) (ret error) { 2467 r0, _, _ := syscall.Syscall(procCoCreateGuid.Addr(), 1, uintptr(unsafe.Pointer(pguid)), 0, 0) 2468 if r0 != 0 { 2469 ret = syscall.Errno(r0) 2470 } 2471 return 2472 } 2473 2474 func WSAStartup(verreq uint32, data *WSAData) (sockerr error) { 2475 r0, _, _ := syscall.Syscall(procWSAStartup.Addr(), 2, uintptr(verreq), uintptr(unsafe.Pointer(data)), 0) 2476 if r0 != 0 { 2477 sockerr = syscall.Errno(r0) 2478 } 2479 return 2480 } 2481 2482 func WSACleanup() (err error) { 2483 r1, _, e1 := syscall.Syscall(procWSACleanup.Addr(), 0, 0, 0, 0) 2484 if r1 == socket_error { 2485 if e1 != 0 { 2486 err = errnoErr(e1) 2487 } else { 2488 err = syscall.EINVAL 2489 } 2490 } 2491 return 2492 } 2493 2494 func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) { 2495 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)) 2496 if r1 == socket_error { 2497 if e1 != 0 { 2498 err = errnoErr(e1) 2499 } else { 2500 err = syscall.EINVAL 2501 } 2502 } 2503 return 2504 } 2505 2506 func socket(af int32, typ int32, protocol int32) (handle Handle, err error) { 2507 r0, _, e1 := syscall.Syscall(procsocket.Addr(), 3, uintptr(af), uintptr(typ), uintptr(protocol)) 2508 handle = Handle(r0) 2509 if handle == InvalidHandle { 2510 if e1 != 0 { 2511 err = errnoErr(e1) 2512 } else { 2513 err = syscall.EINVAL 2514 } 2515 } 2516 return 2517 } 2518 2519 func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) { 2520 r1, _, e1 := syscall.Syscall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(optlen), 0) 2521 if r1 == socket_error { 2522 if e1 != 0 { 2523 err = errnoErr(e1) 2524 } else { 2525 err = syscall.EINVAL 2526 } 2527 } 2528 return 2529 } 2530 2531 func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) { 2532 r1, _, e1 := syscall.Syscall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(unsafe.Pointer(optlen)), 0) 2533 if r1 == socket_error { 2534 if e1 != 0 { 2535 err = errnoErr(e1) 2536 } else { 2537 err = syscall.EINVAL 2538 } 2539 } 2540 return 2541 } 2542 2543 func bind(s Handle, name unsafe.Pointer, namelen int32) (err error) { 2544 r1, _, e1 := syscall.Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen)) 2545 if r1 == socket_error { 2546 if e1 != 0 { 2547 err = errnoErr(e1) 2548 } else { 2549 err = syscall.EINVAL 2550 } 2551 } 2552 return 2553 } 2554 2555 func connect(s Handle, name unsafe.Pointer, namelen int32) (err error) { 2556 r1, _, e1 := syscall.Syscall(procconnect.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen)) 2557 if r1 == socket_error { 2558 if e1 != 0 { 2559 err = errnoErr(e1) 2560 } else { 2561 err = syscall.EINVAL 2562 } 2563 } 2564 return 2565 } 2566 2567 func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) { 2568 r1, _, e1 := syscall.Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) 2569 if r1 == socket_error { 2570 if e1 != 0 { 2571 err = errnoErr(e1) 2572 } else { 2573 err = syscall.EINVAL 2574 } 2575 } 2576 return 2577 } 2578 2579 func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) { 2580 r1, _, e1 := syscall.Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) 2581 if r1 == socket_error { 2582 if e1 != 0 { 2583 err = errnoErr(e1) 2584 } else { 2585 err = syscall.EINVAL 2586 } 2587 } 2588 return 2589 } 2590 2591 func listen(s Handle, backlog int32) (err error) { 2592 r1, _, e1 := syscall.Syscall(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0) 2593 if r1 == socket_error { 2594 if e1 != 0 { 2595 err = errnoErr(e1) 2596 } else { 2597 err = syscall.EINVAL 2598 } 2599 } 2600 return 2601 } 2602 2603 func shutdown(s Handle, how int32) (err error) { 2604 r1, _, e1 := syscall.Syscall(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0) 2605 if r1 == socket_error { 2606 if e1 != 0 { 2607 err = errnoErr(e1) 2608 } else { 2609 err = syscall.EINVAL 2610 } 2611 } 2612 return 2613 } 2614 2615 func Closesocket(s Handle) (err error) { 2616 r1, _, e1 := syscall.Syscall(procclosesocket.Addr(), 1, uintptr(s), 0, 0) 2617 if r1 == socket_error { 2618 if e1 != 0 { 2619 err = errnoErr(e1) 2620 } else { 2621 err = syscall.EINVAL 2622 } 2623 } 2624 return 2625 } 2626 2627 func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) { 2628 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) 2629 if r1 == 0 { 2630 if e1 != 0 { 2631 err = errnoErr(e1) 2632 } else { 2633 err = syscall.EINVAL 2634 } 2635 } 2636 return 2637 } 2638 2639 func GetAcceptExSockaddrs(buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, lrsa **RawSockaddrAny, lrsalen *int32, rrsa **RawSockaddrAny, rrsalen *int32) { 2640 syscall.Syscall9(procGetAcceptExSockaddrs.Addr(), 8, uintptr(unsafe.Pointer(buf)), uintptr(rxdatalen), uintptr(laddrlen), uintptr(raddrlen), uintptr(unsafe.Pointer(lrsa)), uintptr(unsafe.Pointer(lrsalen)), uintptr(unsafe.Pointer(rrsa)), uintptr(unsafe.Pointer(rrsalen)), 0) 2641 return 2642 } 2643 2644 func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) { 2645 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) 2646 if r1 == socket_error { 2647 if e1 != 0 { 2648 err = errnoErr(e1) 2649 } else { 2650 err = syscall.EINVAL 2651 } 2652 } 2653 return 2654 } 2655 2656 func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) { 2657 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) 2658 if r1 == socket_error { 2659 if e1 != 0 { 2660 err = errnoErr(e1) 2661 } else { 2662 err = syscall.EINVAL 2663 } 2664 } 2665 return 2666 } 2667 2668 func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) { 2669 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))) 2670 if r1 == socket_error { 2671 if e1 != 0 { 2672 err = errnoErr(e1) 2673 } else { 2674 err = syscall.EINVAL 2675 } 2676 } 2677 return 2678 } 2679 2680 func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) { 2681 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))) 2682 if r1 == socket_error { 2683 if e1 != 0 { 2684 err = errnoErr(e1) 2685 } else { 2686 err = syscall.EINVAL 2687 } 2688 } 2689 return 2690 } 2691 2692 func GetHostByName(name string) (h *Hostent, err error) { 2693 var _p0 *byte 2694 _p0, err = syscall.BytePtrFromString(name) 2695 if err != nil { 2696 return 2697 } 2698 return _GetHostByName(_p0) 2699 } 2700 2701 func _GetHostByName(name *byte) (h *Hostent, err error) { 2702 r0, _, e1 := syscall.Syscall(procgethostbyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0) 2703 h = (*Hostent)(unsafe.Pointer(r0)) 2704 if h == nil { 2705 if e1 != 0 { 2706 err = errnoErr(e1) 2707 } else { 2708 err = syscall.EINVAL 2709 } 2710 } 2711 return 2712 } 2713 2714 func GetServByName(name string, proto string) (s *Servent, err error) { 2715 var _p0 *byte 2716 _p0, err = syscall.BytePtrFromString(name) 2717 if err != nil { 2718 return 2719 } 2720 var _p1 *byte 2721 _p1, err = syscall.BytePtrFromString(proto) 2722 if err != nil { 2723 return 2724 } 2725 return _GetServByName(_p0, _p1) 2726 } 2727 2728 func _GetServByName(name *byte, proto *byte) (s *Servent, err error) { 2729 r0, _, e1 := syscall.Syscall(procgetservbyname.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(proto)), 0) 2730 s = (*Servent)(unsafe.Pointer(r0)) 2731 if s == nil { 2732 if e1 != 0 { 2733 err = errnoErr(e1) 2734 } else { 2735 err = syscall.EINVAL 2736 } 2737 } 2738 return 2739 } 2740 2741 func Ntohs(netshort uint16) (u uint16) { 2742 r0, _, _ := syscall.Syscall(procntohs.Addr(), 1, uintptr(netshort), 0, 0) 2743 u = uint16(r0) 2744 return 2745 } 2746 2747 func GetProtoByName(name string) (p *Protoent, err error) { 2748 var _p0 *byte 2749 _p0, err = syscall.BytePtrFromString(name) 2750 if err != nil { 2751 return 2752 } 2753 return _GetProtoByName(_p0) 2754 } 2755 2756 func _GetProtoByName(name *byte) (p *Protoent, err error) { 2757 r0, _, e1 := syscall.Syscall(procgetprotobyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0) 2758 p = (*Protoent)(unsafe.Pointer(r0)) 2759 if p == nil { 2760 if e1 != 0 { 2761 err = errnoErr(e1) 2762 } else { 2763 err = syscall.EINVAL 2764 } 2765 } 2766 return 2767 } 2768 2769 func DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) { 2770 var _p0 *uint16 2771 _p0, status = syscall.UTF16PtrFromString(name) 2772 if status != nil { 2773 return 2774 } 2775 return _DnsQuery(_p0, qtype, options, extra, qrs, pr) 2776 } 2777 2778 func _DnsQuery(name *uint16, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) { 2779 r0, _, _ := syscall.Syscall6(procDnsQuery_W.Addr(), 6, uintptr(unsafe.Pointer(name)), uintptr(qtype), uintptr(options), uintptr(unsafe.Pointer(extra)), uintptr(unsafe.Pointer(qrs)), uintptr(unsafe.Pointer(pr))) 2780 if r0 != 0 { 2781 status = syscall.Errno(r0) 2782 } 2783 return 2784 } 2785 2786 func DnsRecordListFree(rl *DNSRecord, freetype uint32) { 2787 syscall.Syscall(procDnsRecordListFree.Addr(), 2, uintptr(unsafe.Pointer(rl)), uintptr(freetype), 0) 2788 return 2789 } 2790 2791 func DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) { 2792 r0, _, _ := syscall.Syscall(procDnsNameCompare_W.Addr(), 2, uintptr(unsafe.Pointer(name1)), uintptr(unsafe.Pointer(name2)), 0) 2793 same = r0 != 0 2794 return 2795 } 2796 2797 func GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) { 2798 r0, _, _ := syscall.Syscall6(procGetAddrInfoW.Addr(), 4, uintptr(unsafe.Pointer(nodename)), uintptr(unsafe.Pointer(servicename)), uintptr(unsafe.Pointer(hints)), uintptr(unsafe.Pointer(result)), 0, 0) 2799 if r0 != 0 { 2800 sockerr = syscall.Errno(r0) 2801 } 2802 return 2803 } 2804 2805 func FreeAddrInfoW(addrinfo *AddrinfoW) { 2806 syscall.Syscall(procFreeAddrInfoW.Addr(), 1, uintptr(unsafe.Pointer(addrinfo)), 0, 0) 2807 return 2808 } 2809 2810 func GetIfEntry(pIfRow *MibIfRow) (errcode error) { 2811 r0, _, _ := syscall.Syscall(procGetIfEntry.Addr(), 1, uintptr(unsafe.Pointer(pIfRow)), 0, 0) 2812 if r0 != 0 { 2813 errcode = syscall.Errno(r0) 2814 } 2815 return 2816 } 2817 2818 func GetAdaptersInfo(ai *IpAdapterInfo, ol *uint32) (errcode error) { 2819 r0, _, _ := syscall.Syscall(procGetAdaptersInfo.Addr(), 2, uintptr(unsafe.Pointer(ai)), uintptr(unsafe.Pointer(ol)), 0) 2820 if r0 != 0 { 2821 errcode = syscall.Errno(r0) 2822 } 2823 return 2824 } 2825 2826 func SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) { 2827 r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(handle), uintptr(flags), 0) 2828 if r1 == 0 { 2829 if e1 != 0 { 2830 err = errnoErr(e1) 2831 } else { 2832 err = syscall.EINVAL 2833 } 2834 } 2835 return 2836 } 2837 2838 func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferLength *uint32) (n int32, err error) { 2839 r0, _, e1 := syscall.Syscall(procWSAEnumProtocolsW.Addr(), 3, uintptr(unsafe.Pointer(protocols)), uintptr(unsafe.Pointer(protocolBuffer)), uintptr(unsafe.Pointer(bufferLength))) 2840 n = int32(r0) 2841 if n == -1 { 2842 if e1 != 0 { 2843 err = errnoErr(e1) 2844 } else { 2845 err = syscall.EINVAL 2846 } 2847 } 2848 return 2849 } 2850 2851 func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) { 2852 r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0) 2853 if r0 != 0 { 2854 errcode = syscall.Errno(r0) 2855 } 2856 return 2857 } 2858 2859 func GetACP() (acp uint32) { 2860 r0, _, _ := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0) 2861 acp = uint32(r0) 2862 return 2863 } 2864 2865 func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) { 2866 r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar)) 2867 nwrite = int32(r0) 2868 if nwrite == 0 { 2869 if e1 != 0 { 2870 err = errnoErr(e1) 2871 } else { 2872 err = syscall.EINVAL 2873 } 2874 } 2875 return 2876 } 2877 2878 func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint32, translatedName *uint16, nSize *uint32) (err error) { 2879 r1, _, e1 := syscall.Syscall6(procTranslateNameW.Addr(), 5, uintptr(unsafe.Pointer(accName)), uintptr(accNameFormat), uintptr(desiredNameFormat), uintptr(unsafe.Pointer(translatedName)), uintptr(unsafe.Pointer(nSize)), 0) 2880 if r1&0xff == 0 { 2881 if e1 != 0 { 2882 err = errnoErr(e1) 2883 } else { 2884 err = syscall.EINVAL 2885 } 2886 } 2887 return 2888 } 2889 2890 func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err error) { 2891 r1, _, e1 := syscall.Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize))) 2892 if r1&0xff == 0 { 2893 if e1 != 0 { 2894 err = errnoErr(e1) 2895 } else { 2896 err = syscall.EINVAL 2897 } 2898 } 2899 return 2900 } 2901 2902 func NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **byte) (neterr error) { 2903 r0, _, _ := syscall.Syscall6(procNetUserGetInfo.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(userName)), uintptr(level), uintptr(unsafe.Pointer(buf)), 0, 0) 2904 if r0 != 0 { 2905 neterr = syscall.Errno(r0) 2906 } 2907 return 2908 } 2909 2910 func NetGetJoinInformation(server *uint16, name **uint16, bufType *uint32) (neterr error) { 2911 r0, _, _ := syscall.Syscall(procNetGetJoinInformation.Addr(), 3, uintptr(unsafe.Pointer(server)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(bufType))) 2912 if r0 != 0 { 2913 neterr = syscall.Errno(r0) 2914 } 2915 return 2916 } 2917 2918 func NetApiBufferFree(buf *byte) (neterr error) { 2919 r0, _, _ := syscall.Syscall(procNetApiBufferFree.Addr(), 1, uintptr(unsafe.Pointer(buf)), 0, 0) 2920 if r0 != 0 { 2921 neterr = syscall.Errno(r0) 2922 } 2923 return 2924 } 2925 2926 func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) { 2927 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) 2928 if r1 == 0 { 2929 if e1 != 0 { 2930 err = errnoErr(e1) 2931 } else { 2932 err = syscall.EINVAL 2933 } 2934 } 2935 return 2936 } 2937 2938 func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) { 2939 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) 2940 if r1 == 0 { 2941 if e1 != 0 { 2942 err = errnoErr(e1) 2943 } else { 2944 err = syscall.EINVAL 2945 } 2946 } 2947 return 2948 } 2949 2950 func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) { 2951 r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(stringSid)), 0) 2952 if r1 == 0 { 2953 if e1 != 0 { 2954 err = errnoErr(e1) 2955 } else { 2956 err = syscall.EINVAL 2957 } 2958 } 2959 return 2960 } 2961 2962 func ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) { 2963 r1, _, e1 := syscall.Syscall(procConvertStringSidToSidW.Addr(), 2, uintptr(unsafe.Pointer(stringSid)), uintptr(unsafe.Pointer(sid)), 0) 2964 if r1 == 0 { 2965 if e1 != 0 { 2966 err = errnoErr(e1) 2967 } else { 2968 err = syscall.EINVAL 2969 } 2970 } 2971 return 2972 } 2973 2974 func GetLengthSid(sid *SID) (len uint32) { 2975 r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) 2976 len = uint32(r0) 2977 return 2978 } 2979 2980 func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) { 2981 r1, _, e1 := syscall.Syscall(procCopySid.Addr(), 3, uintptr(destSidLen), uintptr(unsafe.Pointer(destSid)), uintptr(unsafe.Pointer(srcSid))) 2982 if r1 == 0 { 2983 if e1 != 0 { 2984 err = errnoErr(e1) 2985 } else { 2986 err = syscall.EINVAL 2987 } 2988 } 2989 return 2990 } 2991 2992 func AllocateAndInitializeSid(identAuth *SidIdentifierAuthority, subAuth byte, subAuth0 uint32, subAuth1 uint32, subAuth2 uint32, subAuth3 uint32, subAuth4 uint32, subAuth5 uint32, subAuth6 uint32, subAuth7 uint32, sid **SID) (err error) { 2993 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) 2994 if r1 == 0 { 2995 if e1 != 0 { 2996 err = errnoErr(e1) 2997 } else { 2998 err = syscall.EINVAL 2999 } 3000 } 3001 return 3002 } 3003 3004 func createWellKnownSid(sidType WELL_KNOWN_SID_TYPE, domainSid *SID, sid *SID, sizeSid *uint32) (err error) { 3005 r1, _, e1 := syscall.Syscall6(procCreateWellKnownSid.Addr(), 4, uintptr(sidType), uintptr(unsafe.Pointer(domainSid)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sizeSid)), 0, 0) 3006 if r1 == 0 { 3007 if e1 != 0 { 3008 err = errnoErr(e1) 3009 } else { 3010 err = syscall.EINVAL 3011 } 3012 } 3013 return 3014 } 3015 3016 func isWellKnownSid(sid *SID, sidType WELL_KNOWN_SID_TYPE) (isWellKnown bool) { 3017 r0, _, _ := syscall.Syscall(procIsWellKnownSid.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(sidType), 0) 3018 isWellKnown = r0 != 0 3019 return 3020 } 3021 3022 func FreeSid(sid *SID) (err error) { 3023 r1, _, e1 := syscall.Syscall(procFreeSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) 3024 if r1 != 0 { 3025 if e1 != 0 { 3026 err = errnoErr(e1) 3027 } else { 3028 err = syscall.EINVAL 3029 } 3030 } 3031 return 3032 } 3033 3034 func EqualSid(sid1 *SID, sid2 *SID) (isEqual bool) { 3035 r0, _, _ := syscall.Syscall(procEqualSid.Addr(), 2, uintptr(unsafe.Pointer(sid1)), uintptr(unsafe.Pointer(sid2)), 0) 3036 isEqual = r0 != 0 3037 return 3038 } 3039 3040 func getSidIdentifierAuthority(sid *SID) (authority *SidIdentifierAuthority) { 3041 r0, _, _ := syscall.Syscall(procGetSidIdentifierAuthority.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) 3042 authority = (*SidIdentifierAuthority)(unsafe.Pointer(r0)) 3043 return 3044 } 3045 3046 func getSidSubAuthorityCount(sid *SID) (count *uint8) { 3047 r0, _, _ := syscall.Syscall(procGetSidSubAuthorityCount.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) 3048 count = (*uint8)(unsafe.Pointer(r0)) 3049 return 3050 } 3051 3052 func getSidSubAuthority(sid *SID, index uint32) (subAuthority *uint32) { 3053 r0, _, _ := syscall.Syscall(procGetSidSubAuthority.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(index), 0) 3054 subAuthority = (*uint32)(unsafe.Pointer(r0)) 3055 return 3056 } 3057 3058 func isValidSid(sid *SID) (isValid bool) { 3059 r0, _, _ := syscall.Syscall(procIsValidSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) 3060 isValid = r0 != 0 3061 return 3062 } 3063 3064 func checkTokenMembership(tokenHandle Token, sidToCheck *SID, isMember *int32) (err error) { 3065 r1, _, e1 := syscall.Syscall(procCheckTokenMembership.Addr(), 3, uintptr(tokenHandle), uintptr(unsafe.Pointer(sidToCheck)), uintptr(unsafe.Pointer(isMember))) 3066 if r1 == 0 { 3067 if e1 != 0 { 3068 err = errnoErr(e1) 3069 } else { 3070 err = syscall.EINVAL 3071 } 3072 } 3073 return 3074 } 3075 3076 func OpenProcessToken(process Handle, access uint32, token *Token) (err error) { 3077 r1, _, e1 := syscall.Syscall(procOpenProcessToken.Addr(), 3, uintptr(process), uintptr(access), uintptr(unsafe.Pointer(token))) 3078 if r1 == 0 { 3079 if e1 != 0 { 3080 err = errnoErr(e1) 3081 } else { 3082 err = syscall.EINVAL 3083 } 3084 } 3085 return 3086 } 3087 3088 func OpenThreadToken(thread Handle, access uint32, openAsSelf bool, token *Token) (err error) { 3089 var _p0 uint32 3090 if openAsSelf { 3091 _p0 = 1 3092 } else { 3093 _p0 = 0 3094 } 3095 r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(thread), uintptr(access), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0) 3096 if r1 == 0 { 3097 if e1 != 0 { 3098 err = errnoErr(e1) 3099 } else { 3100 err = syscall.EINVAL 3101 } 3102 } 3103 return 3104 } 3105 3106 func ImpersonateSelf(impersonationlevel uint32) (err error) { 3107 r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(impersonationlevel), 0, 0) 3108 if r1 == 0 { 3109 if e1 != 0 { 3110 err = errnoErr(e1) 3111 } else { 3112 err = syscall.EINVAL 3113 } 3114 } 3115 return 3116 } 3117 3118 func RevertToSelf() (err error) { 3119 r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0) 3120 if r1 == 0 { 3121 if e1 != 0 { 3122 err = errnoErr(e1) 3123 } else { 3124 err = syscall.EINVAL 3125 } 3126 } 3127 return 3128 } 3129 3130 func SetThreadToken(thread *Handle, token Token) (err error) { 3131 r1, _, e1 := syscall.Syscall(procSetThreadToken.Addr(), 2, uintptr(unsafe.Pointer(thread)), uintptr(token), 0) 3132 if r1 == 0 { 3133 if e1 != 0 { 3134 err = errnoErr(e1) 3135 } else { 3136 err = syscall.EINVAL 3137 } 3138 } 3139 return 3140 } 3141 3142 func LookupPrivilegeValue(systemname *uint16, name *uint16, luid *LUID) (err error) { 3143 r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemname)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid))) 3144 if r1 == 0 { 3145 if e1 != 0 { 3146 err = errnoErr(e1) 3147 } else { 3148 err = syscall.EINVAL 3149 } 3150 } 3151 return 3152 } 3153 3154 func AdjustTokenPrivileges(token Token, disableAllPrivileges bool, newstate *Tokenprivileges, buflen uint32, prevstate *Tokenprivileges, returnlen *uint32) (err error) { 3155 var _p0 uint32 3156 if disableAllPrivileges { 3157 _p0 = 1 3158 } else { 3159 _p0 = 0 3160 } 3161 r1, _, e1 := syscall.Syscall6(procAdjustTokenPrivileges.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(newstate)), uintptr(buflen), uintptr(unsafe.Pointer(prevstate)), uintptr(unsafe.Pointer(returnlen))) 3162 if r1 == 0 { 3163 if e1 != 0 { 3164 err = errnoErr(e1) 3165 } else { 3166 err = syscall.EINVAL 3167 } 3168 } 3169 return 3170 } 3171 3172 func AdjustTokenGroups(token Token, resetToDefault bool, newstate *Tokengroups, buflen uint32, prevstate *Tokengroups, returnlen *uint32) (err error) { 3173 var _p0 uint32 3174 if resetToDefault { 3175 _p0 = 1 3176 } else { 3177 _p0 = 0 3178 } 3179 r1, _, e1 := syscall.Syscall6(procAdjustTokenGroups.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(newstate)), uintptr(buflen), uintptr(unsafe.Pointer(prevstate)), uintptr(unsafe.Pointer(returnlen))) 3180 if r1 == 0 { 3181 if e1 != 0 { 3182 err = errnoErr(e1) 3183 } else { 3184 err = syscall.EINVAL 3185 } 3186 } 3187 return 3188 } 3189 3190 func GetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint32, returnedLen *uint32) (err error) { 3191 r1, _, e1 := syscall.Syscall6(procGetTokenInformation.Addr(), 5, uintptr(token), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), uintptr(unsafe.Pointer(returnedLen)), 0) 3192 if r1 == 0 { 3193 if e1 != 0 { 3194 err = errnoErr(e1) 3195 } else { 3196 err = syscall.EINVAL 3197 } 3198 } 3199 return 3200 } 3201 3202 func SetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint32) (err error) { 3203 r1, _, e1 := syscall.Syscall6(procSetTokenInformation.Addr(), 4, uintptr(token), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), 0, 0) 3204 if r1 == 0 { 3205 if e1 != 0 { 3206 err = errnoErr(e1) 3207 } else { 3208 err = syscall.EINVAL 3209 } 3210 } 3211 return 3212 } 3213 3214 func DuplicateTokenEx(existingToken Token, desiredAccess uint32, tokenAttributes *SecurityAttributes, impersonationLevel uint32, tokenType uint32, newToken *Token) (err error) { 3215 r1, _, e1 := syscall.Syscall6(procDuplicateTokenEx.Addr(), 6, uintptr(existingToken), uintptr(desiredAccess), uintptr(unsafe.Pointer(tokenAttributes)), uintptr(impersonationLevel), uintptr(tokenType), uintptr(unsafe.Pointer(newToken))) 3216 if r1 == 0 { 3217 if e1 != 0 { 3218 err = errnoErr(e1) 3219 } else { 3220 err = syscall.EINVAL 3221 } 3222 } 3223 return 3224 } 3225 3226 func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) { 3227 r1, _, e1 := syscall.Syscall(procGetUserProfileDirectoryW.Addr(), 3, uintptr(t), uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen))) 3228 if r1 == 0 { 3229 if e1 != 0 { 3230 err = errnoErr(e1) 3231 } else { 3232 err = syscall.EINVAL 3233 } 3234 } 3235 return 3236 } 3237 3238 func getSystemDirectory(dir *uint16, dirLen uint32) (len uint32, err error) { 3239 r0, _, e1 := syscall.Syscall(procGetSystemDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0) 3240 len = uint32(r0) 3241 if len == 0 { 3242 if e1 != 0 { 3243 err = errnoErr(e1) 3244 } else { 3245 err = syscall.EINVAL 3246 } 3247 } 3248 return 3249 } 3250 3251 func WTSQueryUserToken(session uint32, token *Token) (err error) { 3252 r1, _, e1 := syscall.Syscall(procWTSQueryUserToken.Addr(), 2, uintptr(session), uintptr(unsafe.Pointer(token)), 0) 3253 if r1 == 0 { 3254 if e1 != 0 { 3255 err = errnoErr(e1) 3256 } else { 3257 err = syscall.EINVAL 3258 } 3259 } 3260 return 3261 } 3262 3263 func WTSEnumerateSessions(handle Handle, reserved uint32, version uint32, sessions **WTS_SESSION_INFO, count *uint32) (err error) { 3264 r1, _, e1 := syscall.Syscall6(procWTSEnumerateSessionsW.Addr(), 5, uintptr(handle), uintptr(reserved), uintptr(version), uintptr(unsafe.Pointer(sessions)), uintptr(unsafe.Pointer(count)), 0) 3265 if r1 == 0 { 3266 if e1 != 0 { 3267 err = errnoErr(e1) 3268 } else { 3269 err = syscall.EINVAL 3270 } 3271 } 3272 return 3273 } 3274 3275 func WTSFreeMemory(ptr uintptr) { 3276 syscall.Syscall(procWTSFreeMemory.Addr(), 1, uintptr(ptr), 0, 0) 3277 return 3278 }