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