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