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