github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/sys/windows/zsyscall_windows.go (about) 1 // MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT 2 3 package windows 4 5 import "unsafe" 6 import "syscall" 7 8 var _ unsafe.Pointer 9 10 var ( 11 modadvapi32 = syscall.NewLazyDLL("advapi32.dll") 12 modkernel32 = syscall.NewLazyDLL("kernel32.dll") 13 modshell32 = syscall.NewLazyDLL("shell32.dll") 14 modmswsock = syscall.NewLazyDLL("mswsock.dll") 15 modcrypt32 = syscall.NewLazyDLL("crypt32.dll") 16 modws2_32 = syscall.NewLazyDLL("ws2_32.dll") 17 moddnsapi = syscall.NewLazyDLL("dnsapi.dll") 18 modiphlpapi = syscall.NewLazyDLL("iphlpapi.dll") 19 modsecur32 = syscall.NewLazyDLL("secur32.dll") 20 modnetapi32 = syscall.NewLazyDLL("netapi32.dll") 21 moduserenv = syscall.NewLazyDLL("userenv.dll") 22 23 procRegisterEventSourceW = modadvapi32.NewProc("RegisterEventSourceW") 24 procDeregisterEventSource = modadvapi32.NewProc("DeregisterEventSource") 25 procReportEventW = modadvapi32.NewProc("ReportEventW") 26 procOpenSCManagerW = modadvapi32.NewProc("OpenSCManagerW") 27 procCloseServiceHandle = modadvapi32.NewProc("CloseServiceHandle") 28 procCreateServiceW = modadvapi32.NewProc("CreateServiceW") 29 procOpenServiceW = modadvapi32.NewProc("OpenServiceW") 30 procDeleteService = modadvapi32.NewProc("DeleteService") 31 procStartServiceW = modadvapi32.NewProc("StartServiceW") 32 procQueryServiceStatus = modadvapi32.NewProc("QueryServiceStatus") 33 procControlService = modadvapi32.NewProc("ControlService") 34 procStartServiceCtrlDispatcherW = modadvapi32.NewProc("StartServiceCtrlDispatcherW") 35 procSetServiceStatus = modadvapi32.NewProc("SetServiceStatus") 36 procChangeServiceConfigW = modadvapi32.NewProc("ChangeServiceConfigW") 37 procQueryServiceConfigW = modadvapi32.NewProc("QueryServiceConfigW") 38 procChangeServiceConfig2W = modadvapi32.NewProc("ChangeServiceConfig2W") 39 procQueryServiceConfig2W = modadvapi32.NewProc("QueryServiceConfig2W") 40 procGetLastError = modkernel32.NewProc("GetLastError") 41 procLoadLibraryW = modkernel32.NewProc("LoadLibraryW") 42 procFreeLibrary = modkernel32.NewProc("FreeLibrary") 43 procGetProcAddress = modkernel32.NewProc("GetProcAddress") 44 procGetVersion = modkernel32.NewProc("GetVersion") 45 procFormatMessageW = modkernel32.NewProc("FormatMessageW") 46 procExitProcess = modkernel32.NewProc("ExitProcess") 47 procCreateFileW = modkernel32.NewProc("CreateFileW") 48 procReadFile = modkernel32.NewProc("ReadFile") 49 procWriteFile = modkernel32.NewProc("WriteFile") 50 procSetFilePointer = modkernel32.NewProc("SetFilePointer") 51 procCloseHandle = modkernel32.NewProc("CloseHandle") 52 procGetStdHandle = modkernel32.NewProc("GetStdHandle") 53 procFindFirstFileW = modkernel32.NewProc("FindFirstFileW") 54 procFindNextFileW = modkernel32.NewProc("FindNextFileW") 55 procFindClose = modkernel32.NewProc("FindClose") 56 procGetFileInformationByHandle = modkernel32.NewProc("GetFileInformationByHandle") 57 procGetCurrentDirectoryW = modkernel32.NewProc("GetCurrentDirectoryW") 58 procSetCurrentDirectoryW = modkernel32.NewProc("SetCurrentDirectoryW") 59 procCreateDirectoryW = modkernel32.NewProc("CreateDirectoryW") 60 procRemoveDirectoryW = modkernel32.NewProc("RemoveDirectoryW") 61 procDeleteFileW = modkernel32.NewProc("DeleteFileW") 62 procMoveFileW = modkernel32.NewProc("MoveFileW") 63 procGetComputerNameW = modkernel32.NewProc("GetComputerNameW") 64 procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW") 65 procSetEndOfFile = modkernel32.NewProc("SetEndOfFile") 66 procGetSystemTimeAsFileTime = modkernel32.NewProc("GetSystemTimeAsFileTime") 67 procGetTimeZoneInformation = modkernel32.NewProc("GetTimeZoneInformation") 68 procCreateIoCompletionPort = modkernel32.NewProc("CreateIoCompletionPort") 69 procGetQueuedCompletionStatus = modkernel32.NewProc("GetQueuedCompletionStatus") 70 procPostQueuedCompletionStatus = modkernel32.NewProc("PostQueuedCompletionStatus") 71 procCancelIo = modkernel32.NewProc("CancelIo") 72 procCancelIoEx = modkernel32.NewProc("CancelIoEx") 73 procCreateProcessW = modkernel32.NewProc("CreateProcessW") 74 procOpenProcess = modkernel32.NewProc("OpenProcess") 75 procTerminateProcess = modkernel32.NewProc("TerminateProcess") 76 procGetExitCodeProcess = modkernel32.NewProc("GetExitCodeProcess") 77 procGetStartupInfoW = modkernel32.NewProc("GetStartupInfoW") 78 procGetCurrentProcess = modkernel32.NewProc("GetCurrentProcess") 79 procGetProcessTimes = modkernel32.NewProc("GetProcessTimes") 80 procDuplicateHandle = modkernel32.NewProc("DuplicateHandle") 81 procWaitForSingleObject = modkernel32.NewProc("WaitForSingleObject") 82 procGetTempPathW = modkernel32.NewProc("GetTempPathW") 83 procCreatePipe = modkernel32.NewProc("CreatePipe") 84 procGetFileType = modkernel32.NewProc("GetFileType") 85 procCryptAcquireContextW = modadvapi32.NewProc("CryptAcquireContextW") 86 procCryptReleaseContext = modadvapi32.NewProc("CryptReleaseContext") 87 procCryptGenRandom = modadvapi32.NewProc("CryptGenRandom") 88 procGetEnvironmentStringsW = modkernel32.NewProc("GetEnvironmentStringsW") 89 procFreeEnvironmentStringsW = modkernel32.NewProc("FreeEnvironmentStringsW") 90 procGetEnvironmentVariableW = modkernel32.NewProc("GetEnvironmentVariableW") 91 procSetEnvironmentVariableW = modkernel32.NewProc("SetEnvironmentVariableW") 92 procSetFileTime = modkernel32.NewProc("SetFileTime") 93 procGetFileAttributesW = modkernel32.NewProc("GetFileAttributesW") 94 procSetFileAttributesW = modkernel32.NewProc("SetFileAttributesW") 95 procGetFileAttributesExW = modkernel32.NewProc("GetFileAttributesExW") 96 procGetCommandLineW = modkernel32.NewProc("GetCommandLineW") 97 procCommandLineToArgvW = modshell32.NewProc("CommandLineToArgvW") 98 procLocalFree = modkernel32.NewProc("LocalFree") 99 procSetHandleInformation = modkernel32.NewProc("SetHandleInformation") 100 procFlushFileBuffers = modkernel32.NewProc("FlushFileBuffers") 101 procGetFullPathNameW = modkernel32.NewProc("GetFullPathNameW") 102 procGetLongPathNameW = modkernel32.NewProc("GetLongPathNameW") 103 procGetShortPathNameW = modkernel32.NewProc("GetShortPathNameW") 104 procCreateFileMappingW = modkernel32.NewProc("CreateFileMappingW") 105 procMapViewOfFile = modkernel32.NewProc("MapViewOfFile") 106 procUnmapViewOfFile = modkernel32.NewProc("UnmapViewOfFile") 107 procFlushViewOfFile = modkernel32.NewProc("FlushViewOfFile") 108 procVirtualLock = modkernel32.NewProc("VirtualLock") 109 procVirtualUnlock = modkernel32.NewProc("VirtualUnlock") 110 procTransmitFile = modmswsock.NewProc("TransmitFile") 111 procReadDirectoryChangesW = modkernel32.NewProc("ReadDirectoryChangesW") 112 procCertOpenSystemStoreW = modcrypt32.NewProc("CertOpenSystemStoreW") 113 procCertOpenStore = modcrypt32.NewProc("CertOpenStore") 114 procCertEnumCertificatesInStore = modcrypt32.NewProc("CertEnumCertificatesInStore") 115 procCertAddCertificateContextToStore = modcrypt32.NewProc("CertAddCertificateContextToStore") 116 procCertCloseStore = modcrypt32.NewProc("CertCloseStore") 117 procCertGetCertificateChain = modcrypt32.NewProc("CertGetCertificateChain") 118 procCertFreeCertificateChain = modcrypt32.NewProc("CertFreeCertificateChain") 119 procCertCreateCertificateContext = modcrypt32.NewProc("CertCreateCertificateContext") 120 procCertFreeCertificateContext = modcrypt32.NewProc("CertFreeCertificateContext") 121 procCertVerifyCertificateChainPolicy = modcrypt32.NewProc("CertVerifyCertificateChainPolicy") 122 procRegOpenKeyExW = modadvapi32.NewProc("RegOpenKeyExW") 123 procRegCloseKey = modadvapi32.NewProc("RegCloseKey") 124 procRegQueryInfoKeyW = modadvapi32.NewProc("RegQueryInfoKeyW") 125 procRegEnumKeyExW = modadvapi32.NewProc("RegEnumKeyExW") 126 procRegQueryValueExW = modadvapi32.NewProc("RegQueryValueExW") 127 procGetCurrentProcessId = modkernel32.NewProc("GetCurrentProcessId") 128 procGetConsoleMode = modkernel32.NewProc("GetConsoleMode") 129 procWriteConsoleW = modkernel32.NewProc("WriteConsoleW") 130 procReadConsoleW = modkernel32.NewProc("ReadConsoleW") 131 procCreateToolhelp32Snapshot = modkernel32.NewProc("CreateToolhelp32Snapshot") 132 procProcess32FirstW = modkernel32.NewProc("Process32FirstW") 133 procProcess32NextW = modkernel32.NewProc("Process32NextW") 134 procDeviceIoControl = modkernel32.NewProc("DeviceIoControl") 135 procCreateSymbolicLinkW = modkernel32.NewProc("CreateSymbolicLinkW") 136 procCreateHardLinkW = modkernel32.NewProc("CreateHardLinkW") 137 procGetCurrentThreadId = modkernel32.NewProc("GetCurrentThreadId") 138 procCreateEventW = modkernel32.NewProc("CreateEventW") 139 procSetEvent = modkernel32.NewProc("SetEvent") 140 procWSAStartup = modws2_32.NewProc("WSAStartup") 141 procWSACleanup = modws2_32.NewProc("WSACleanup") 142 procWSAIoctl = modws2_32.NewProc("WSAIoctl") 143 procsocket = modws2_32.NewProc("socket") 144 procsetsockopt = modws2_32.NewProc("setsockopt") 145 procgetsockopt = modws2_32.NewProc("getsockopt") 146 procbind = modws2_32.NewProc("bind") 147 procconnect = modws2_32.NewProc("connect") 148 procgetsockname = modws2_32.NewProc("getsockname") 149 procgetpeername = modws2_32.NewProc("getpeername") 150 proclisten = modws2_32.NewProc("listen") 151 procshutdown = modws2_32.NewProc("shutdown") 152 procclosesocket = modws2_32.NewProc("closesocket") 153 procAcceptEx = modmswsock.NewProc("AcceptEx") 154 procGetAcceptExSockaddrs = modmswsock.NewProc("GetAcceptExSockaddrs") 155 procWSARecv = modws2_32.NewProc("WSARecv") 156 procWSASend = modws2_32.NewProc("WSASend") 157 procWSARecvFrom = modws2_32.NewProc("WSARecvFrom") 158 procWSASendTo = modws2_32.NewProc("WSASendTo") 159 procgethostbyname = modws2_32.NewProc("gethostbyname") 160 procgetservbyname = modws2_32.NewProc("getservbyname") 161 procntohs = modws2_32.NewProc("ntohs") 162 procgetprotobyname = modws2_32.NewProc("getprotobyname") 163 procDnsQuery_W = moddnsapi.NewProc("DnsQuery_W") 164 procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree") 165 procDnsNameCompare_W = moddnsapi.NewProc("DnsNameCompare_W") 166 procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW") 167 procFreeAddrInfoW = modws2_32.NewProc("FreeAddrInfoW") 168 procGetIfEntry = modiphlpapi.NewProc("GetIfEntry") 169 procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo") 170 procSetFileCompletionNotificationModes = modkernel32.NewProc("SetFileCompletionNotificationModes") 171 procWSAEnumProtocolsW = modws2_32.NewProc("WSAEnumProtocolsW") 172 procTranslateNameW = modsecur32.NewProc("TranslateNameW") 173 procGetUserNameExW = modsecur32.NewProc("GetUserNameExW") 174 procNetUserGetInfo = modnetapi32.NewProc("NetUserGetInfo") 175 procNetGetJoinInformation = modnetapi32.NewProc("NetGetJoinInformation") 176 procNetApiBufferFree = modnetapi32.NewProc("NetApiBufferFree") 177 procLookupAccountSidW = modadvapi32.NewProc("LookupAccountSidW") 178 procLookupAccountNameW = modadvapi32.NewProc("LookupAccountNameW") 179 procConvertSidToStringSidW = modadvapi32.NewProc("ConvertSidToStringSidW") 180 procConvertStringSidToSidW = modadvapi32.NewProc("ConvertStringSidToSidW") 181 procGetLengthSid = modadvapi32.NewProc("GetLengthSid") 182 procCopySid = modadvapi32.NewProc("CopySid") 183 procAllocateAndInitializeSid = modadvapi32.NewProc("AllocateAndInitializeSid") 184 procFreeSid = modadvapi32.NewProc("FreeSid") 185 procEqualSid = modadvapi32.NewProc("EqualSid") 186 procOpenProcessToken = modadvapi32.NewProc("OpenProcessToken") 187 procGetTokenInformation = modadvapi32.NewProc("GetTokenInformation") 188 procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW") 189 ) 190 191 func RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) { 192 r0, _, e1 := syscall.Syscall(procRegisterEventSourceW.Addr(), 2, uintptr(unsafe.Pointer(uncServerName)), uintptr(unsafe.Pointer(sourceName)), 0) 193 handle = Handle(r0) 194 if handle == 0 { 195 if e1 != 0 { 196 err = error(e1) 197 } else { 198 err = syscall.EINVAL 199 } 200 } 201 return 202 } 203 204 func DeregisterEventSource(handle Handle) (err error) { 205 r1, _, e1 := syscall.Syscall(procDeregisterEventSource.Addr(), 1, uintptr(handle), 0, 0) 206 if r1 == 0 { 207 if e1 != 0 { 208 err = error(e1) 209 } else { 210 err = syscall.EINVAL 211 } 212 } 213 return 214 } 215 216 func ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) { 217 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))) 218 if r1 == 0 { 219 if e1 != 0 { 220 err = error(e1) 221 } else { 222 err = syscall.EINVAL 223 } 224 } 225 return 226 } 227 228 func OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle Handle, err error) { 229 r0, _, e1 := syscall.Syscall(procOpenSCManagerW.Addr(), 3, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(databaseName)), uintptr(access)) 230 handle = Handle(r0) 231 if handle == 0 { 232 if e1 != 0 { 233 err = error(e1) 234 } else { 235 err = syscall.EINVAL 236 } 237 } 238 return 239 } 240 241 func CloseServiceHandle(handle Handle) (err error) { 242 r1, _, e1 := syscall.Syscall(procCloseServiceHandle.Addr(), 1, uintptr(handle), 0, 0) 243 if r1 == 0 { 244 if e1 != 0 { 245 err = error(e1) 246 } else { 247 err = syscall.EINVAL 248 } 249 } 250 return 251 } 252 253 func CreateService(mgr Handle, serviceName *uint16, displayName *uint16, access uint32, srvType uint32, startType uint32, errCtl uint32, pathName *uint16, loadOrderGroup *uint16, tagId *uint32, dependencies *uint16, serviceStartName *uint16, password *uint16) (handle Handle, err error) { 254 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) 255 handle = Handle(r0) 256 if handle == 0 { 257 if e1 != 0 { 258 err = error(e1) 259 } else { 260 err = syscall.EINVAL 261 } 262 } 263 return 264 } 265 266 func OpenService(mgr Handle, serviceName *uint16, access uint32) (handle Handle, err error) { 267 r0, _, e1 := syscall.Syscall(procOpenServiceW.Addr(), 3, uintptr(mgr), uintptr(unsafe.Pointer(serviceName)), uintptr(access)) 268 handle = Handle(r0) 269 if handle == 0 { 270 if e1 != 0 { 271 err = error(e1) 272 } else { 273 err = syscall.EINVAL 274 } 275 } 276 return 277 } 278 279 func DeleteService(service Handle) (err error) { 280 r1, _, e1 := syscall.Syscall(procDeleteService.Addr(), 1, uintptr(service), 0, 0) 281 if r1 == 0 { 282 if e1 != 0 { 283 err = error(e1) 284 } else { 285 err = syscall.EINVAL 286 } 287 } 288 return 289 } 290 291 func StartService(service Handle, numArgs uint32, argVectors **uint16) (err error) { 292 r1, _, e1 := syscall.Syscall(procStartServiceW.Addr(), 3, uintptr(service), uintptr(numArgs), uintptr(unsafe.Pointer(argVectors))) 293 if r1 == 0 { 294 if e1 != 0 { 295 err = error(e1) 296 } else { 297 err = syscall.EINVAL 298 } 299 } 300 return 301 } 302 303 func QueryServiceStatus(service Handle, status *SERVICE_STATUS) (err error) { 304 r1, _, e1 := syscall.Syscall(procQueryServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(status)), 0) 305 if r1 == 0 { 306 if e1 != 0 { 307 err = error(e1) 308 } else { 309 err = syscall.EINVAL 310 } 311 } 312 return 313 } 314 315 func ControlService(service Handle, control uint32, status *SERVICE_STATUS) (err error) { 316 r1, _, e1 := syscall.Syscall(procControlService.Addr(), 3, uintptr(service), uintptr(control), uintptr(unsafe.Pointer(status))) 317 if r1 == 0 { 318 if e1 != 0 { 319 err = error(e1) 320 } else { 321 err = syscall.EINVAL 322 } 323 } 324 return 325 } 326 327 func StartServiceCtrlDispatcher(serviceTable *SERVICE_TABLE_ENTRY) (err error) { 328 r1, _, e1 := syscall.Syscall(procStartServiceCtrlDispatcherW.Addr(), 1, uintptr(unsafe.Pointer(serviceTable)), 0, 0) 329 if r1 == 0 { 330 if e1 != 0 { 331 err = error(e1) 332 } else { 333 err = syscall.EINVAL 334 } 335 } 336 return 337 } 338 339 func SetServiceStatus(service Handle, serviceStatus *SERVICE_STATUS) (err error) { 340 r1, _, e1 := syscall.Syscall(procSetServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(serviceStatus)), 0) 341 if r1 == 0 { 342 if e1 != 0 { 343 err = error(e1) 344 } else { 345 err = syscall.EINVAL 346 } 347 } 348 return 349 } 350 351 func ChangeServiceConfig(service Handle, serviceType uint32, startType uint32, errorControl uint32, binaryPathName *uint16, loadOrderGroup *uint16, tagId *uint32, dependencies *uint16, serviceStartName *uint16, password *uint16, displayName *uint16) (err error) { 352 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) 353 if r1 == 0 { 354 if e1 != 0 { 355 err = error(e1) 356 } else { 357 err = syscall.EINVAL 358 } 359 } 360 return 361 } 362 363 func QueryServiceConfig(service Handle, serviceConfig *QUERY_SERVICE_CONFIG, bufSize uint32, bytesNeeded *uint32) (err error) { 364 r1, _, e1 := syscall.Syscall6(procQueryServiceConfigW.Addr(), 4, uintptr(service), uintptr(unsafe.Pointer(serviceConfig)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0) 365 if r1 == 0 { 366 if e1 != 0 { 367 err = error(e1) 368 } else { 369 err = syscall.EINVAL 370 } 371 } 372 return 373 } 374 375 func ChangeServiceConfig2(service Handle, infoLevel uint32, info *byte) (err error) { 376 r1, _, e1 := syscall.Syscall(procChangeServiceConfig2W.Addr(), 3, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(info))) 377 if r1 == 0 { 378 if e1 != 0 { 379 err = error(e1) 380 } else { 381 err = syscall.EINVAL 382 } 383 } 384 return 385 } 386 387 func QueryServiceConfig2(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) { 388 r1, _, e1 := syscall.Syscall6(procQueryServiceConfig2W.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0) 389 if r1 == 0 { 390 if e1 != 0 { 391 err = error(e1) 392 } else { 393 err = syscall.EINVAL 394 } 395 } 396 return 397 } 398 399 func GetLastError() (lasterr error) { 400 r0, _, _ := syscall.Syscall(procGetLastError.Addr(), 0, 0, 0, 0) 401 if r0 != 0 { 402 lasterr = syscall.Errno(r0) 403 } 404 return 405 } 406 407 func LoadLibrary(libname string) (handle Handle, err error) { 408 var _p0 *uint16 409 _p0, err = syscall.UTF16PtrFromString(libname) 410 if err != nil { 411 return 412 } 413 return _LoadLibrary(_p0) 414 } 415 416 func _LoadLibrary(libname *uint16) (handle Handle, err error) { 417 r0, _, e1 := syscall.Syscall(procLoadLibraryW.Addr(), 1, uintptr(unsafe.Pointer(libname)), 0, 0) 418 handle = Handle(r0) 419 if handle == 0 { 420 if e1 != 0 { 421 err = error(e1) 422 } else { 423 err = syscall.EINVAL 424 } 425 } 426 return 427 } 428 429 func FreeLibrary(handle Handle) (err error) { 430 r1, _, e1 := syscall.Syscall(procFreeLibrary.Addr(), 1, uintptr(handle), 0, 0) 431 if r1 == 0 { 432 if e1 != 0 { 433 err = error(e1) 434 } else { 435 err = syscall.EINVAL 436 } 437 } 438 return 439 } 440 441 func GetProcAddress(module Handle, procname string) (proc uintptr, err error) { 442 var _p0 *byte 443 _p0, err = syscall.BytePtrFromString(procname) 444 if err != nil { 445 return 446 } 447 return _GetProcAddress(module, _p0) 448 } 449 450 func _GetProcAddress(module Handle, procname *byte) (proc uintptr, err error) { 451 r0, _, e1 := syscall.Syscall(procGetProcAddress.Addr(), 2, uintptr(module), uintptr(unsafe.Pointer(procname)), 0) 452 proc = uintptr(r0) 453 if proc == 0 { 454 if e1 != 0 { 455 err = error(e1) 456 } else { 457 err = syscall.EINVAL 458 } 459 } 460 return 461 } 462 463 func GetVersion() (ver uint32, err error) { 464 r0, _, e1 := syscall.Syscall(procGetVersion.Addr(), 0, 0, 0, 0) 465 ver = uint32(r0) 466 if ver == 0 { 467 if e1 != 0 { 468 err = error(e1) 469 } else { 470 err = syscall.EINVAL 471 } 472 } 473 return 474 } 475 476 func FormatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, buf []uint16, args *byte) (n uint32, err error) { 477 var _p0 *uint16 478 if len(buf) > 0 { 479 _p0 = &buf[0] 480 } 481 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) 482 n = uint32(r0) 483 if n == 0 { 484 if e1 != 0 { 485 err = error(e1) 486 } else { 487 err = syscall.EINVAL 488 } 489 } 490 return 491 } 492 493 func ExitProcess(exitcode uint32) { 494 syscall.Syscall(procExitProcess.Addr(), 1, uintptr(exitcode), 0, 0) 495 return 496 } 497 498 func CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile int32) (handle Handle, err error) { 499 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) 500 handle = Handle(r0) 501 if handle == InvalidHandle { 502 if e1 != 0 { 503 err = error(e1) 504 } else { 505 err = syscall.EINVAL 506 } 507 } 508 return 509 } 510 511 func ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) { 512 var _p0 *byte 513 if len(buf) > 0 { 514 _p0 = &buf[0] 515 } 516 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) 517 if r1 == 0 { 518 if e1 != 0 { 519 err = error(e1) 520 } else { 521 err = syscall.EINVAL 522 } 523 } 524 return 525 } 526 527 func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) { 528 var _p0 *byte 529 if len(buf) > 0 { 530 _p0 = &buf[0] 531 } 532 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) 533 if r1 == 0 { 534 if e1 != 0 { 535 err = error(e1) 536 } else { 537 err = syscall.EINVAL 538 } 539 } 540 return 541 } 542 543 func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) { 544 r0, _, e1 := syscall.Syscall6(procSetFilePointer.Addr(), 4, uintptr(handle), uintptr(lowoffset), uintptr(unsafe.Pointer(highoffsetptr)), uintptr(whence), 0, 0) 545 newlowoffset = uint32(r0) 546 if newlowoffset == 0xffffffff { 547 if e1 != 0 { 548 err = error(e1) 549 } else { 550 err = syscall.EINVAL 551 } 552 } 553 return 554 } 555 556 func CloseHandle(handle Handle) (err error) { 557 r1, _, e1 := syscall.Syscall(procCloseHandle.Addr(), 1, uintptr(handle), 0, 0) 558 if r1 == 0 { 559 if e1 != 0 { 560 err = error(e1) 561 } else { 562 err = syscall.EINVAL 563 } 564 } 565 return 566 } 567 568 func GetStdHandle(stdhandle int) (handle Handle, err error) { 569 r0, _, e1 := syscall.Syscall(procGetStdHandle.Addr(), 1, uintptr(stdhandle), 0, 0) 570 handle = Handle(r0) 571 if handle == InvalidHandle { 572 if e1 != 0 { 573 err = error(e1) 574 } else { 575 err = syscall.EINVAL 576 } 577 } 578 return 579 } 580 581 func findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err error) { 582 r0, _, e1 := syscall.Syscall(procFindFirstFileW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(data)), 0) 583 handle = Handle(r0) 584 if handle == InvalidHandle { 585 if e1 != 0 { 586 err = error(e1) 587 } else { 588 err = syscall.EINVAL 589 } 590 } 591 return 592 } 593 594 func findNextFile1(handle Handle, data *win32finddata1) (err error) { 595 r1, _, e1 := syscall.Syscall(procFindNextFileW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0) 596 if r1 == 0 { 597 if e1 != 0 { 598 err = error(e1) 599 } else { 600 err = syscall.EINVAL 601 } 602 } 603 return 604 } 605 606 func FindClose(handle Handle) (err error) { 607 r1, _, e1 := syscall.Syscall(procFindClose.Addr(), 1, uintptr(handle), 0, 0) 608 if r1 == 0 { 609 if e1 != 0 { 610 err = error(e1) 611 } else { 612 err = syscall.EINVAL 613 } 614 } 615 return 616 } 617 618 func GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (err error) { 619 r1, _, e1 := syscall.Syscall(procGetFileInformationByHandle.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0) 620 if r1 == 0 { 621 if e1 != 0 { 622 err = error(e1) 623 } else { 624 err = syscall.EINVAL 625 } 626 } 627 return 628 } 629 630 func GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) { 631 r0, _, e1 := syscall.Syscall(procGetCurrentDirectoryW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0) 632 n = uint32(r0) 633 if n == 0 { 634 if e1 != 0 { 635 err = error(e1) 636 } else { 637 err = syscall.EINVAL 638 } 639 } 640 return 641 } 642 643 func SetCurrentDirectory(path *uint16) (err error) { 644 r1, _, e1 := syscall.Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) 645 if r1 == 0 { 646 if e1 != 0 { 647 err = error(e1) 648 } else { 649 err = syscall.EINVAL 650 } 651 } 652 return 653 } 654 655 func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) { 656 r1, _, e1 := syscall.Syscall(procCreateDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(sa)), 0) 657 if r1 == 0 { 658 if e1 != 0 { 659 err = error(e1) 660 } else { 661 err = syscall.EINVAL 662 } 663 } 664 return 665 } 666 667 func RemoveDirectory(path *uint16) (err error) { 668 r1, _, e1 := syscall.Syscall(procRemoveDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) 669 if r1 == 0 { 670 if e1 != 0 { 671 err = error(e1) 672 } else { 673 err = syscall.EINVAL 674 } 675 } 676 return 677 } 678 679 func DeleteFile(path *uint16) (err error) { 680 r1, _, e1 := syscall.Syscall(procDeleteFileW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) 681 if r1 == 0 { 682 if e1 != 0 { 683 err = error(e1) 684 } else { 685 err = syscall.EINVAL 686 } 687 } 688 return 689 } 690 691 func MoveFile(from *uint16, to *uint16) (err error) { 692 r1, _, e1 := syscall.Syscall(procMoveFileW.Addr(), 2, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), 0) 693 if r1 == 0 { 694 if e1 != 0 { 695 err = error(e1) 696 } else { 697 err = syscall.EINVAL 698 } 699 } 700 return 701 } 702 703 func GetComputerName(buf *uint16, n *uint32) (err error) { 704 r1, _, e1 := syscall.Syscall(procGetComputerNameW.Addr(), 2, uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)), 0) 705 if r1 == 0 { 706 if e1 != 0 { 707 err = error(e1) 708 } else { 709 err = syscall.EINVAL 710 } 711 } 712 return 713 } 714 715 func GetComputerNameEx(nametype uint32, buf *uint16, n *uint32) (err error) { 716 r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nametype), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n))) 717 if r1 == 0 { 718 if e1 != 0 { 719 err = error(e1) 720 } else { 721 err = syscall.EINVAL 722 } 723 } 724 return 725 } 726 727 func SetEndOfFile(handle Handle) (err error) { 728 r1, _, e1 := syscall.Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0) 729 if r1 == 0 { 730 if e1 != 0 { 731 err = error(e1) 732 } else { 733 err = syscall.EINVAL 734 } 735 } 736 return 737 } 738 739 func GetSystemTimeAsFileTime(time *Filetime) { 740 syscall.Syscall(procGetSystemTimeAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0) 741 return 742 } 743 744 func GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) { 745 r0, _, e1 := syscall.Syscall(procGetTimeZoneInformation.Addr(), 1, uintptr(unsafe.Pointer(tzi)), 0, 0) 746 rc = uint32(r0) 747 if rc == 0xffffffff { 748 if e1 != 0 { 749 err = error(e1) 750 } else { 751 err = syscall.EINVAL 752 } 753 } 754 return 755 } 756 757 func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (handle Handle, err error) { 758 r0, _, e1 := syscall.Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(filehandle), uintptr(cphandle), uintptr(key), uintptr(threadcnt), 0, 0) 759 handle = Handle(r0) 760 if handle == 0 { 761 if e1 != 0 { 762 err = error(e1) 763 } else { 764 err = syscall.EINVAL 765 } 766 } 767 return 768 } 769 770 func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error) { 771 r1, _, e1 := syscall.Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(cphandle), uintptr(unsafe.Pointer(qty)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(overlapped)), uintptr(timeout), 0) 772 if r1 == 0 { 773 if e1 != 0 { 774 err = error(e1) 775 } else { 776 err = syscall.EINVAL 777 } 778 } 779 return 780 } 781 782 func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error) { 783 r1, _, e1 := syscall.Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0) 784 if r1 == 0 { 785 if e1 != 0 { 786 err = error(e1) 787 } else { 788 err = syscall.EINVAL 789 } 790 } 791 return 792 } 793 794 func CancelIo(s Handle) (err error) { 795 r1, _, e1 := syscall.Syscall(procCancelIo.Addr(), 1, uintptr(s), 0, 0) 796 if r1 == 0 { 797 if e1 != 0 { 798 err = error(e1) 799 } else { 800 err = syscall.EINVAL 801 } 802 } 803 return 804 } 805 806 func CancelIoEx(s Handle, o *Overlapped) (err error) { 807 r1, _, e1 := syscall.Syscall(procCancelIoEx.Addr(), 2, uintptr(s), uintptr(unsafe.Pointer(o)), 0) 808 if r1 == 0 { 809 if e1 != 0 { 810 err = error(e1) 811 } else { 812 err = syscall.EINVAL 813 } 814 } 815 return 816 } 817 818 func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) { 819 var _p0 uint32 820 if inheritHandles { 821 _p0 = 1 822 } else { 823 _p0 = 0 824 } 825 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) 826 if r1 == 0 { 827 if e1 != 0 { 828 err = error(e1) 829 } else { 830 err = syscall.EINVAL 831 } 832 } 833 return 834 } 835 836 func OpenProcess(da uint32, inheritHandle bool, pid uint32) (handle Handle, err error) { 837 var _p0 uint32 838 if inheritHandle { 839 _p0 = 1 840 } else { 841 _p0 = 0 842 } 843 r0, _, e1 := syscall.Syscall(procOpenProcess.Addr(), 3, uintptr(da), uintptr(_p0), uintptr(pid)) 844 handle = Handle(r0) 845 if handle == 0 { 846 if e1 != 0 { 847 err = error(e1) 848 } else { 849 err = syscall.EINVAL 850 } 851 } 852 return 853 } 854 855 func TerminateProcess(handle Handle, exitcode uint32) (err error) { 856 r1, _, e1 := syscall.Syscall(procTerminateProcess.Addr(), 2, uintptr(handle), uintptr(exitcode), 0) 857 if r1 == 0 { 858 if e1 != 0 { 859 err = error(e1) 860 } else { 861 err = syscall.EINVAL 862 } 863 } 864 return 865 } 866 867 func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) { 868 r1, _, e1 := syscall.Syscall(procGetExitCodeProcess.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(exitcode)), 0) 869 if r1 == 0 { 870 if e1 != 0 { 871 err = error(e1) 872 } else { 873 err = syscall.EINVAL 874 } 875 } 876 return 877 } 878 879 func GetStartupInfo(startupInfo *StartupInfo) (err error) { 880 r1, _, e1 := syscall.Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0) 881 if r1 == 0 { 882 if e1 != 0 { 883 err = error(e1) 884 } else { 885 err = syscall.EINVAL 886 } 887 } 888 return 889 } 890 891 func GetCurrentProcess() (pseudoHandle Handle, err error) { 892 r0, _, e1 := syscall.Syscall(procGetCurrentProcess.Addr(), 0, 0, 0, 0) 893 pseudoHandle = Handle(r0) 894 if pseudoHandle == 0 { 895 if e1 != 0 { 896 err = error(e1) 897 } else { 898 err = syscall.EINVAL 899 } 900 } 901 return 902 } 903 904 func GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, kernelTime *Filetime, userTime *Filetime) (err error) { 905 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) 906 if r1 == 0 { 907 if e1 != 0 { 908 err = error(e1) 909 } else { 910 err = syscall.EINVAL 911 } 912 } 913 return 914 } 915 916 func DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetProcessHandle Handle, lpTargetHandle *Handle, dwDesiredAccess uint32, bInheritHandle bool, dwOptions uint32) (err error) { 917 var _p0 uint32 918 if bInheritHandle { 919 _p0 = 1 920 } else { 921 _p0 = 0 922 } 923 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) 924 if r1 == 0 { 925 if e1 != 0 { 926 err = error(e1) 927 } else { 928 err = syscall.EINVAL 929 } 930 } 931 return 932 } 933 934 func WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32, err error) { 935 r0, _, e1 := syscall.Syscall(procWaitForSingleObject.Addr(), 2, uintptr(handle), uintptr(waitMilliseconds), 0) 936 event = uint32(r0) 937 if event == 0xffffffff { 938 if e1 != 0 { 939 err = error(e1) 940 } else { 941 err = syscall.EINVAL 942 } 943 } 944 return 945 } 946 947 func GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) { 948 r0, _, e1 := syscall.Syscall(procGetTempPathW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0) 949 n = uint32(r0) 950 if n == 0 { 951 if e1 != 0 { 952 err = error(e1) 953 } else { 954 err = syscall.EINVAL 955 } 956 } 957 return 958 } 959 960 func CreatePipe(readhandle *Handle, writehandle *Handle, sa *SecurityAttributes, size uint32) (err error) { 961 r1, _, e1 := syscall.Syscall6(procCreatePipe.Addr(), 4, uintptr(unsafe.Pointer(readhandle)), uintptr(unsafe.Pointer(writehandle)), uintptr(unsafe.Pointer(sa)), uintptr(size), 0, 0) 962 if r1 == 0 { 963 if e1 != 0 { 964 err = error(e1) 965 } else { 966 err = syscall.EINVAL 967 } 968 } 969 return 970 } 971 972 func GetFileType(filehandle Handle) (n uint32, err error) { 973 r0, _, e1 := syscall.Syscall(procGetFileType.Addr(), 1, uintptr(filehandle), 0, 0) 974 n = uint32(r0) 975 if n == 0 { 976 if e1 != 0 { 977 err = error(e1) 978 } else { 979 err = syscall.EINVAL 980 } 981 } 982 return 983 } 984 985 func CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16, provtype uint32, flags uint32) (err error) { 986 r1, _, e1 := syscall.Syscall6(procCryptAcquireContextW.Addr(), 5, uintptr(unsafe.Pointer(provhandle)), uintptr(unsafe.Pointer(container)), uintptr(unsafe.Pointer(provider)), uintptr(provtype), uintptr(flags), 0) 987 if r1 == 0 { 988 if e1 != 0 { 989 err = error(e1) 990 } else { 991 err = syscall.EINVAL 992 } 993 } 994 return 995 } 996 997 func CryptReleaseContext(provhandle Handle, flags uint32) (err error) { 998 r1, _, e1 := syscall.Syscall(procCryptReleaseContext.Addr(), 2, uintptr(provhandle), uintptr(flags), 0) 999 if r1 == 0 { 1000 if e1 != 0 { 1001 err = error(e1) 1002 } else { 1003 err = syscall.EINVAL 1004 } 1005 } 1006 return 1007 } 1008 1009 func CryptGenRandom(provhandle Handle, buflen uint32, buf *byte) (err error) { 1010 r1, _, e1 := syscall.Syscall(procCryptGenRandom.Addr(), 3, uintptr(provhandle), uintptr(buflen), uintptr(unsafe.Pointer(buf))) 1011 if r1 == 0 { 1012 if e1 != 0 { 1013 err = error(e1) 1014 } else { 1015 err = syscall.EINVAL 1016 } 1017 } 1018 return 1019 } 1020 1021 func GetEnvironmentStrings() (envs *uint16, err error) { 1022 r0, _, e1 := syscall.Syscall(procGetEnvironmentStringsW.Addr(), 0, 0, 0, 0) 1023 envs = (*uint16)(unsafe.Pointer(r0)) 1024 if envs == nil { 1025 if e1 != 0 { 1026 err = error(e1) 1027 } else { 1028 err = syscall.EINVAL 1029 } 1030 } 1031 return 1032 } 1033 1034 func FreeEnvironmentStrings(envs *uint16) (err error) { 1035 r1, _, e1 := syscall.Syscall(procFreeEnvironmentStringsW.Addr(), 1, uintptr(unsafe.Pointer(envs)), 0, 0) 1036 if r1 == 0 { 1037 if e1 != 0 { 1038 err = error(e1) 1039 } else { 1040 err = syscall.EINVAL 1041 } 1042 } 1043 return 1044 } 1045 1046 func GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32, err error) { 1047 r0, _, e1 := syscall.Syscall(procGetEnvironmentVariableW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buffer)), uintptr(size)) 1048 n = uint32(r0) 1049 if n == 0 { 1050 if e1 != 0 { 1051 err = error(e1) 1052 } else { 1053 err = syscall.EINVAL 1054 } 1055 } 1056 return 1057 } 1058 1059 func SetEnvironmentVariable(name *uint16, value *uint16) (err error) { 1060 r1, _, e1 := syscall.Syscall(procSetEnvironmentVariableW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), 0) 1061 if r1 == 0 { 1062 if e1 != 0 { 1063 err = error(e1) 1064 } else { 1065 err = syscall.EINVAL 1066 } 1067 } 1068 return 1069 } 1070 1071 func SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error) { 1072 r1, _, e1 := syscall.Syscall6(procSetFileTime.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(ctime)), uintptr(unsafe.Pointer(atime)), uintptr(unsafe.Pointer(wtime)), 0, 0) 1073 if r1 == 0 { 1074 if e1 != 0 { 1075 err = error(e1) 1076 } else { 1077 err = syscall.EINVAL 1078 } 1079 } 1080 return 1081 } 1082 1083 func GetFileAttributes(name *uint16) (attrs uint32, err error) { 1084 r0, _, e1 := syscall.Syscall(procGetFileAttributesW.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0) 1085 attrs = uint32(r0) 1086 if attrs == INVALID_FILE_ATTRIBUTES { 1087 if e1 != 0 { 1088 err = error(e1) 1089 } else { 1090 err = syscall.EINVAL 1091 } 1092 } 1093 return 1094 } 1095 1096 func SetFileAttributes(name *uint16, attrs uint32) (err error) { 1097 r1, _, e1 := syscall.Syscall(procSetFileAttributesW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(attrs), 0) 1098 if r1 == 0 { 1099 if e1 != 0 { 1100 err = error(e1) 1101 } else { 1102 err = syscall.EINVAL 1103 } 1104 } 1105 return 1106 } 1107 1108 func GetFileAttributesEx(name *uint16, level uint32, info *byte) (err error) { 1109 r1, _, e1 := syscall.Syscall(procGetFileAttributesExW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(level), uintptr(unsafe.Pointer(info))) 1110 if r1 == 0 { 1111 if e1 != 0 { 1112 err = error(e1) 1113 } else { 1114 err = syscall.EINVAL 1115 } 1116 } 1117 return 1118 } 1119 1120 func GetCommandLine() (cmd *uint16) { 1121 r0, _, _ := syscall.Syscall(procGetCommandLineW.Addr(), 0, 0, 0, 0) 1122 cmd = (*uint16)(unsafe.Pointer(r0)) 1123 return 1124 } 1125 1126 func CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err error) { 1127 r0, _, e1 := syscall.Syscall(procCommandLineToArgvW.Addr(), 2, uintptr(unsafe.Pointer(cmd)), uintptr(unsafe.Pointer(argc)), 0) 1128 argv = (*[8192]*[8192]uint16)(unsafe.Pointer(r0)) 1129 if argv == nil { 1130 if e1 != 0 { 1131 err = error(e1) 1132 } else { 1133 err = syscall.EINVAL 1134 } 1135 } 1136 return 1137 } 1138 1139 func LocalFree(hmem Handle) (handle Handle, err error) { 1140 r0, _, e1 := syscall.Syscall(procLocalFree.Addr(), 1, uintptr(hmem), 0, 0) 1141 handle = Handle(r0) 1142 if handle != 0 { 1143 if e1 != 0 { 1144 err = error(e1) 1145 } else { 1146 err = syscall.EINVAL 1147 } 1148 } 1149 return 1150 } 1151 1152 func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error) { 1153 r1, _, e1 := syscall.Syscall(procSetHandleInformation.Addr(), 3, uintptr(handle), uintptr(mask), uintptr(flags)) 1154 if r1 == 0 { 1155 if e1 != 0 { 1156 err = error(e1) 1157 } else { 1158 err = syscall.EINVAL 1159 } 1160 } 1161 return 1162 } 1163 1164 func FlushFileBuffers(handle Handle) (err error) { 1165 r1, _, e1 := syscall.Syscall(procFlushFileBuffers.Addr(), 1, uintptr(handle), 0, 0) 1166 if r1 == 0 { 1167 if e1 != 0 { 1168 err = error(e1) 1169 } else { 1170 err = syscall.EINVAL 1171 } 1172 } 1173 return 1174 } 1175 1176 func GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) (n uint32, err error) { 1177 r0, _, e1 := syscall.Syscall6(procGetFullPathNameW.Addr(), 4, uintptr(unsafe.Pointer(path)), uintptr(buflen), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(fname)), 0, 0) 1178 n = uint32(r0) 1179 if n == 0 { 1180 if e1 != 0 { 1181 err = error(e1) 1182 } else { 1183 err = syscall.EINVAL 1184 } 1185 } 1186 return 1187 } 1188 1189 func GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err error) { 1190 r0, _, e1 := syscall.Syscall(procGetLongPathNameW.Addr(), 3, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(buf)), uintptr(buflen)) 1191 n = uint32(r0) 1192 if n == 0 { 1193 if e1 != 0 { 1194 err = error(e1) 1195 } else { 1196 err = syscall.EINVAL 1197 } 1198 } 1199 return 1200 } 1201 1202 func GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uint32, err error) { 1203 r0, _, e1 := syscall.Syscall(procGetShortPathNameW.Addr(), 3, uintptr(unsafe.Pointer(longpath)), uintptr(unsafe.Pointer(shortpath)), uintptr(buflen)) 1204 n = uint32(r0) 1205 if n == 0 { 1206 if e1 != 0 { 1207 err = error(e1) 1208 } else { 1209 err = syscall.EINVAL 1210 } 1211 } 1212 return 1213 } 1214 1215 func CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error) { 1216 r0, _, e1 := syscall.Syscall6(procCreateFileMappingW.Addr(), 6, uintptr(fhandle), uintptr(unsafe.Pointer(sa)), uintptr(prot), uintptr(maxSizeHigh), uintptr(maxSizeLow), uintptr(unsafe.Pointer(name))) 1217 handle = Handle(r0) 1218 if handle == 0 { 1219 if e1 != 0 { 1220 err = error(e1) 1221 } else { 1222 err = syscall.EINVAL 1223 } 1224 } 1225 return 1226 } 1227 1228 func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow uint32, length uintptr) (addr uintptr, err error) { 1229 r0, _, e1 := syscall.Syscall6(procMapViewOfFile.Addr(), 5, uintptr(handle), uintptr(access), uintptr(offsetHigh), uintptr(offsetLow), uintptr(length), 0) 1230 addr = uintptr(r0) 1231 if addr == 0 { 1232 if e1 != 0 { 1233 err = error(e1) 1234 } else { 1235 err = syscall.EINVAL 1236 } 1237 } 1238 return 1239 } 1240 1241 func UnmapViewOfFile(addr uintptr) (err error) { 1242 r1, _, e1 := syscall.Syscall(procUnmapViewOfFile.Addr(), 1, uintptr(addr), 0, 0) 1243 if r1 == 0 { 1244 if e1 != 0 { 1245 err = error(e1) 1246 } else { 1247 err = syscall.EINVAL 1248 } 1249 } 1250 return 1251 } 1252 1253 func FlushViewOfFile(addr uintptr, length uintptr) (err error) { 1254 r1, _, e1 := syscall.Syscall(procFlushViewOfFile.Addr(), 2, uintptr(addr), uintptr(length), 0) 1255 if r1 == 0 { 1256 if e1 != 0 { 1257 err = error(e1) 1258 } else { 1259 err = syscall.EINVAL 1260 } 1261 } 1262 return 1263 } 1264 1265 func VirtualLock(addr uintptr, length uintptr) (err error) { 1266 r1, _, e1 := syscall.Syscall(procVirtualLock.Addr(), 2, uintptr(addr), uintptr(length), 0) 1267 if r1 == 0 { 1268 if e1 != 0 { 1269 err = error(e1) 1270 } else { 1271 err = syscall.EINVAL 1272 } 1273 } 1274 return 1275 } 1276 1277 func VirtualUnlock(addr uintptr, length uintptr) (err error) { 1278 r1, _, e1 := syscall.Syscall(procVirtualUnlock.Addr(), 2, uintptr(addr), uintptr(length), 0) 1279 if r1 == 0 { 1280 if e1 != 0 { 1281 err = error(e1) 1282 } else { 1283 err = syscall.EINVAL 1284 } 1285 } 1286 return 1287 } 1288 1289 func TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) { 1290 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) 1291 if r1 == 0 { 1292 if e1 != 0 { 1293 err = error(e1) 1294 } else { 1295 err = syscall.EINVAL 1296 } 1297 } 1298 return 1299 } 1300 1301 func ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) { 1302 var _p0 uint32 1303 if watchSubTree { 1304 _p0 = 1 1305 } else { 1306 _p0 = 0 1307 } 1308 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) 1309 if r1 == 0 { 1310 if e1 != 0 { 1311 err = error(e1) 1312 } else { 1313 err = syscall.EINVAL 1314 } 1315 } 1316 return 1317 } 1318 1319 func CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) { 1320 r0, _, e1 := syscall.Syscall(procCertOpenSystemStoreW.Addr(), 2, uintptr(hprov), uintptr(unsafe.Pointer(name)), 0) 1321 store = Handle(r0) 1322 if store == 0 { 1323 if e1 != 0 { 1324 err = error(e1) 1325 } else { 1326 err = syscall.EINVAL 1327 } 1328 } 1329 return 1330 } 1331 1332 func CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) { 1333 r0, _, e1 := syscall.Syscall6(procCertOpenStore.Addr(), 5, uintptr(storeProvider), uintptr(msgAndCertEncodingType), uintptr(cryptProv), uintptr(flags), uintptr(para), 0) 1334 handle = Handle(r0) 1335 if handle == InvalidHandle { 1336 if e1 != 0 { 1337 err = error(e1) 1338 } else { 1339 err = syscall.EINVAL 1340 } 1341 } 1342 return 1343 } 1344 1345 func CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) { 1346 r0, _, e1 := syscall.Syscall(procCertEnumCertificatesInStore.Addr(), 2, uintptr(store), uintptr(unsafe.Pointer(prevContext)), 0) 1347 context = (*CertContext)(unsafe.Pointer(r0)) 1348 if context == nil { 1349 if e1 != 0 { 1350 err = error(e1) 1351 } else { 1352 err = syscall.EINVAL 1353 } 1354 } 1355 return 1356 } 1357 1358 func CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) { 1359 r1, _, e1 := syscall.Syscall6(procCertAddCertificateContextToStore.Addr(), 4, uintptr(store), uintptr(unsafe.Pointer(certContext)), uintptr(addDisposition), uintptr(unsafe.Pointer(storeContext)), 0, 0) 1360 if r1 == 0 { 1361 if e1 != 0 { 1362 err = error(e1) 1363 } else { 1364 err = syscall.EINVAL 1365 } 1366 } 1367 return 1368 } 1369 1370 func CertCloseStore(store Handle, flags uint32) (err error) { 1371 r1, _, e1 := syscall.Syscall(procCertCloseStore.Addr(), 2, uintptr(store), uintptr(flags), 0) 1372 if r1 == 0 { 1373 if e1 != 0 { 1374 err = error(e1) 1375 } else { 1376 err = syscall.EINVAL 1377 } 1378 } 1379 return 1380 } 1381 1382 func CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) { 1383 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) 1384 if r1 == 0 { 1385 if e1 != 0 { 1386 err = error(e1) 1387 } else { 1388 err = syscall.EINVAL 1389 } 1390 } 1391 return 1392 } 1393 1394 func CertFreeCertificateChain(ctx *CertChainContext) { 1395 syscall.Syscall(procCertFreeCertificateChain.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0) 1396 return 1397 } 1398 1399 func CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, encodedLen uint32) (context *CertContext, err error) { 1400 r0, _, e1 := syscall.Syscall(procCertCreateCertificateContext.Addr(), 3, uintptr(certEncodingType), uintptr(unsafe.Pointer(certEncoded)), uintptr(encodedLen)) 1401 context = (*CertContext)(unsafe.Pointer(r0)) 1402 if context == nil { 1403 if e1 != 0 { 1404 err = error(e1) 1405 } else { 1406 err = syscall.EINVAL 1407 } 1408 } 1409 return 1410 } 1411 1412 func CertFreeCertificateContext(ctx *CertContext) (err error) { 1413 r1, _, e1 := syscall.Syscall(procCertFreeCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0) 1414 if r1 == 0 { 1415 if e1 != 0 { 1416 err = error(e1) 1417 } else { 1418 err = syscall.EINVAL 1419 } 1420 } 1421 return 1422 } 1423 1424 func CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) { 1425 r1, _, e1 := syscall.Syscall6(procCertVerifyCertificateChainPolicy.Addr(), 4, uintptr(policyOID), uintptr(unsafe.Pointer(chain)), uintptr(unsafe.Pointer(para)), uintptr(unsafe.Pointer(status)), 0, 0) 1426 if r1 == 0 { 1427 if e1 != 0 { 1428 err = error(e1) 1429 } else { 1430 err = syscall.EINVAL 1431 } 1432 } 1433 return 1434 } 1435 1436 func RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno error) { 1437 r0, _, _ := syscall.Syscall6(procRegOpenKeyExW.Addr(), 5, uintptr(key), uintptr(unsafe.Pointer(subkey)), uintptr(options), uintptr(desiredAccess), uintptr(unsafe.Pointer(result)), 0) 1438 if r0 != 0 { 1439 regerrno = syscall.Errno(r0) 1440 } 1441 return 1442 } 1443 1444 func RegCloseKey(key Handle) (regerrno error) { 1445 r0, _, _ := syscall.Syscall(procRegCloseKey.Addr(), 1, uintptr(key), 0, 0) 1446 if r0 != 0 { 1447 regerrno = syscall.Errno(r0) 1448 } 1449 return 1450 } 1451 1452 func RegQueryInfoKey(key Handle, class *uint16, classLen *uint32, reserved *uint32, subkeysLen *uint32, maxSubkeyLen *uint32, maxClassLen *uint32, valuesLen *uint32, maxValueNameLen *uint32, maxValueLen *uint32, saLen *uint32, lastWriteTime *Filetime) (regerrno error) { 1453 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))) 1454 if r0 != 0 { 1455 regerrno = syscall.Errno(r0) 1456 } 1457 return 1458 } 1459 1460 func RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) { 1461 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) 1462 if r0 != 0 { 1463 regerrno = syscall.Errno(r0) 1464 } 1465 return 1466 } 1467 1468 func RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) { 1469 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))) 1470 if r0 != 0 { 1471 regerrno = syscall.Errno(r0) 1472 } 1473 return 1474 } 1475 1476 func getCurrentProcessId() (pid uint32) { 1477 r0, _, _ := syscall.Syscall(procGetCurrentProcessId.Addr(), 0, 0, 0, 0) 1478 pid = uint32(r0) 1479 return 1480 } 1481 1482 func GetConsoleMode(console Handle, mode *uint32) (err error) { 1483 r1, _, e1 := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0) 1484 if r1 == 0 { 1485 if e1 != 0 { 1486 err = error(e1) 1487 } else { 1488 err = syscall.EINVAL 1489 } 1490 } 1491 return 1492 } 1493 1494 func WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) { 1495 r1, _, e1 := syscall.Syscall6(procWriteConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(towrite), uintptr(unsafe.Pointer(written)), uintptr(unsafe.Pointer(reserved)), 0) 1496 if r1 == 0 { 1497 if e1 != 0 { 1498 err = error(e1) 1499 } else { 1500 err = syscall.EINVAL 1501 } 1502 } 1503 return 1504 } 1505 1506 func ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) { 1507 r1, _, e1 := syscall.Syscall6(procReadConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(toread), uintptr(unsafe.Pointer(read)), uintptr(unsafe.Pointer(inputControl)), 0) 1508 if r1 == 0 { 1509 if e1 != 0 { 1510 err = error(e1) 1511 } else { 1512 err = syscall.EINVAL 1513 } 1514 } 1515 return 1516 } 1517 1518 func CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) { 1519 r0, _, e1 := syscall.Syscall(procCreateToolhelp32Snapshot.Addr(), 2, uintptr(flags), uintptr(processId), 0) 1520 handle = Handle(r0) 1521 if handle == InvalidHandle { 1522 if e1 != 0 { 1523 err = error(e1) 1524 } else { 1525 err = syscall.EINVAL 1526 } 1527 } 1528 return 1529 } 1530 1531 func Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) { 1532 r1, _, e1 := syscall.Syscall(procProcess32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0) 1533 if r1 == 0 { 1534 if e1 != 0 { 1535 err = error(e1) 1536 } else { 1537 err = syscall.EINVAL 1538 } 1539 } 1540 return 1541 } 1542 1543 func Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) { 1544 r1, _, e1 := syscall.Syscall(procProcess32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0) 1545 if r1 == 0 { 1546 if e1 != 0 { 1547 err = error(e1) 1548 } else { 1549 err = syscall.EINVAL 1550 } 1551 } 1552 return 1553 } 1554 1555 func DeviceIoControl(handle Handle, ioControlCode uint32, inBuffer *byte, inBufferSize uint32, outBuffer *byte, outBufferSize uint32, bytesReturned *uint32, overlapped *Overlapped) (err error) { 1556 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) 1557 if r1 == 0 { 1558 if e1 != 0 { 1559 err = error(e1) 1560 } else { 1561 err = syscall.EINVAL 1562 } 1563 } 1564 return 1565 } 1566 1567 func CreateSymbolicLink(symlinkfilename *uint16, targetfilename *uint16, flags uint32) (err error) { 1568 r1, _, e1 := syscall.Syscall(procCreateSymbolicLinkW.Addr(), 3, uintptr(unsafe.Pointer(symlinkfilename)), uintptr(unsafe.Pointer(targetfilename)), uintptr(flags)) 1569 if r1&0xff == 0 { 1570 if e1 != 0 { 1571 err = error(e1) 1572 } else { 1573 err = syscall.EINVAL 1574 } 1575 } 1576 return 1577 } 1578 1579 func CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr) (err error) { 1580 r1, _, e1 := syscall.Syscall(procCreateHardLinkW.Addr(), 3, uintptr(unsafe.Pointer(filename)), uintptr(unsafe.Pointer(existingfilename)), uintptr(reserved)) 1581 if r1&0xff == 0 { 1582 if e1 != 0 { 1583 err = error(e1) 1584 } else { 1585 err = syscall.EINVAL 1586 } 1587 } 1588 return 1589 } 1590 1591 func GetCurrentThreadId() (id uint32) { 1592 r0, _, _ := syscall.Syscall(procGetCurrentThreadId.Addr(), 0, 0, 0, 0) 1593 id = uint32(r0) 1594 return 1595 } 1596 1597 func CreateEvent(eventAttrs *syscall.SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) { 1598 r0, _, e1 := syscall.Syscall6(procCreateEventW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(manualReset), uintptr(initialState), uintptr(unsafe.Pointer(name)), 0, 0) 1599 handle = Handle(r0) 1600 if handle == 0 { 1601 if e1 != 0 { 1602 err = error(e1) 1603 } else { 1604 err = syscall.EINVAL 1605 } 1606 } 1607 return 1608 } 1609 1610 func SetEvent(event Handle) (err error) { 1611 r1, _, e1 := syscall.Syscall(procSetEvent.Addr(), 1, uintptr(event), 0, 0) 1612 if r1 == 0 { 1613 if e1 != 0 { 1614 err = error(e1) 1615 } else { 1616 err = syscall.EINVAL 1617 } 1618 } 1619 return 1620 } 1621 1622 func WSAStartup(verreq uint32, data *WSAData) (sockerr error) { 1623 r0, _, _ := syscall.Syscall(procWSAStartup.Addr(), 2, uintptr(verreq), uintptr(unsafe.Pointer(data)), 0) 1624 if r0 != 0 { 1625 sockerr = syscall.Errno(r0) 1626 } 1627 return 1628 } 1629 1630 func WSACleanup() (err error) { 1631 r1, _, e1 := syscall.Syscall(procWSACleanup.Addr(), 0, 0, 0, 0) 1632 if r1 == socket_error { 1633 if e1 != 0 { 1634 err = error(e1) 1635 } else { 1636 err = syscall.EINVAL 1637 } 1638 } 1639 return 1640 } 1641 1642 func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) { 1643 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)) 1644 if r1 == socket_error { 1645 if e1 != 0 { 1646 err = error(e1) 1647 } else { 1648 err = syscall.EINVAL 1649 } 1650 } 1651 return 1652 } 1653 1654 func socket(af int32, typ int32, protocol int32) (handle Handle, err error) { 1655 r0, _, e1 := syscall.Syscall(procsocket.Addr(), 3, uintptr(af), uintptr(typ), uintptr(protocol)) 1656 handle = Handle(r0) 1657 if handle == InvalidHandle { 1658 if e1 != 0 { 1659 err = error(e1) 1660 } else { 1661 err = syscall.EINVAL 1662 } 1663 } 1664 return 1665 } 1666 1667 func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) { 1668 r1, _, e1 := syscall.Syscall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(optlen), 0) 1669 if r1 == socket_error { 1670 if e1 != 0 { 1671 err = error(e1) 1672 } else { 1673 err = syscall.EINVAL 1674 } 1675 } 1676 return 1677 } 1678 1679 func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) { 1680 r1, _, e1 := syscall.Syscall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(unsafe.Pointer(optlen)), 0) 1681 if r1 == socket_error { 1682 if e1 != 0 { 1683 err = error(e1) 1684 } else { 1685 err = syscall.EINVAL 1686 } 1687 } 1688 return 1689 } 1690 1691 func bind(s Handle, name unsafe.Pointer, namelen int32) (err error) { 1692 r1, _, e1 := syscall.Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen)) 1693 if r1 == socket_error { 1694 if e1 != 0 { 1695 err = error(e1) 1696 } else { 1697 err = syscall.EINVAL 1698 } 1699 } 1700 return 1701 } 1702 1703 func connect(s Handle, name unsafe.Pointer, namelen int32) (err error) { 1704 r1, _, e1 := syscall.Syscall(procconnect.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen)) 1705 if r1 == socket_error { 1706 if e1 != 0 { 1707 err = error(e1) 1708 } else { 1709 err = syscall.EINVAL 1710 } 1711 } 1712 return 1713 } 1714 1715 func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) { 1716 r1, _, e1 := syscall.Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) 1717 if r1 == socket_error { 1718 if e1 != 0 { 1719 err = error(e1) 1720 } else { 1721 err = syscall.EINVAL 1722 } 1723 } 1724 return 1725 } 1726 1727 func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) { 1728 r1, _, e1 := syscall.Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) 1729 if r1 == socket_error { 1730 if e1 != 0 { 1731 err = error(e1) 1732 } else { 1733 err = syscall.EINVAL 1734 } 1735 } 1736 return 1737 } 1738 1739 func listen(s Handle, backlog int32) (err error) { 1740 r1, _, e1 := syscall.Syscall(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0) 1741 if r1 == socket_error { 1742 if e1 != 0 { 1743 err = error(e1) 1744 } else { 1745 err = syscall.EINVAL 1746 } 1747 } 1748 return 1749 } 1750 1751 func shutdown(s Handle, how int32) (err error) { 1752 r1, _, e1 := syscall.Syscall(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0) 1753 if r1 == socket_error { 1754 if e1 != 0 { 1755 err = error(e1) 1756 } else { 1757 err = syscall.EINVAL 1758 } 1759 } 1760 return 1761 } 1762 1763 func Closesocket(s Handle) (err error) { 1764 r1, _, e1 := syscall.Syscall(procclosesocket.Addr(), 1, uintptr(s), 0, 0) 1765 if r1 == socket_error { 1766 if e1 != 0 { 1767 err = error(e1) 1768 } else { 1769 err = syscall.EINVAL 1770 } 1771 } 1772 return 1773 } 1774 1775 func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) { 1776 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) 1777 if r1 == 0 { 1778 if e1 != 0 { 1779 err = error(e1) 1780 } else { 1781 err = syscall.EINVAL 1782 } 1783 } 1784 return 1785 } 1786 1787 func GetAcceptExSockaddrs(buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, lrsa **RawSockaddrAny, lrsalen *int32, rrsa **RawSockaddrAny, rrsalen *int32) { 1788 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) 1789 return 1790 } 1791 1792 func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) { 1793 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) 1794 if r1 == socket_error { 1795 if e1 != 0 { 1796 err = error(e1) 1797 } else { 1798 err = syscall.EINVAL 1799 } 1800 } 1801 return 1802 } 1803 1804 func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) { 1805 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) 1806 if r1 == socket_error { 1807 if e1 != 0 { 1808 err = error(e1) 1809 } else { 1810 err = syscall.EINVAL 1811 } 1812 } 1813 return 1814 } 1815 1816 func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) { 1817 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))) 1818 if r1 == socket_error { 1819 if e1 != 0 { 1820 err = error(e1) 1821 } else { 1822 err = syscall.EINVAL 1823 } 1824 } 1825 return 1826 } 1827 1828 func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) { 1829 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))) 1830 if r1 == socket_error { 1831 if e1 != 0 { 1832 err = error(e1) 1833 } else { 1834 err = syscall.EINVAL 1835 } 1836 } 1837 return 1838 } 1839 1840 func GetHostByName(name string) (h *Hostent, err error) { 1841 var _p0 *byte 1842 _p0, err = syscall.BytePtrFromString(name) 1843 if err != nil { 1844 return 1845 } 1846 return _GetHostByName(_p0) 1847 } 1848 1849 func _GetHostByName(name *byte) (h *Hostent, err error) { 1850 r0, _, e1 := syscall.Syscall(procgethostbyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0) 1851 h = (*Hostent)(unsafe.Pointer(r0)) 1852 if h == nil { 1853 if e1 != 0 { 1854 err = error(e1) 1855 } else { 1856 err = syscall.EINVAL 1857 } 1858 } 1859 return 1860 } 1861 1862 func GetServByName(name string, proto string) (s *Servent, err error) { 1863 var _p0 *byte 1864 _p0, err = syscall.BytePtrFromString(name) 1865 if err != nil { 1866 return 1867 } 1868 var _p1 *byte 1869 _p1, err = syscall.BytePtrFromString(proto) 1870 if err != nil { 1871 return 1872 } 1873 return _GetServByName(_p0, _p1) 1874 } 1875 1876 func _GetServByName(name *byte, proto *byte) (s *Servent, err error) { 1877 r0, _, e1 := syscall.Syscall(procgetservbyname.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(proto)), 0) 1878 s = (*Servent)(unsafe.Pointer(r0)) 1879 if s == nil { 1880 if e1 != 0 { 1881 err = error(e1) 1882 } else { 1883 err = syscall.EINVAL 1884 } 1885 } 1886 return 1887 } 1888 1889 func Ntohs(netshort uint16) (u uint16) { 1890 r0, _, _ := syscall.Syscall(procntohs.Addr(), 1, uintptr(netshort), 0, 0) 1891 u = uint16(r0) 1892 return 1893 } 1894 1895 func GetProtoByName(name string) (p *Protoent, err error) { 1896 var _p0 *byte 1897 _p0, err = syscall.BytePtrFromString(name) 1898 if err != nil { 1899 return 1900 } 1901 return _GetProtoByName(_p0) 1902 } 1903 1904 func _GetProtoByName(name *byte) (p *Protoent, err error) { 1905 r0, _, e1 := syscall.Syscall(procgetprotobyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0) 1906 p = (*Protoent)(unsafe.Pointer(r0)) 1907 if p == nil { 1908 if e1 != 0 { 1909 err = error(e1) 1910 } else { 1911 err = syscall.EINVAL 1912 } 1913 } 1914 return 1915 } 1916 1917 func DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) { 1918 var _p0 *uint16 1919 _p0, status = syscall.UTF16PtrFromString(name) 1920 if status != nil { 1921 return 1922 } 1923 return _DnsQuery(_p0, qtype, options, extra, qrs, pr) 1924 } 1925 1926 func _DnsQuery(name *uint16, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) { 1927 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))) 1928 if r0 != 0 { 1929 status = syscall.Errno(r0) 1930 } 1931 return 1932 } 1933 1934 func DnsRecordListFree(rl *DNSRecord, freetype uint32) { 1935 syscall.Syscall(procDnsRecordListFree.Addr(), 2, uintptr(unsafe.Pointer(rl)), uintptr(freetype), 0) 1936 return 1937 } 1938 1939 func DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) { 1940 r0, _, _ := syscall.Syscall(procDnsNameCompare_W.Addr(), 2, uintptr(unsafe.Pointer(name1)), uintptr(unsafe.Pointer(name2)), 0) 1941 same = r0 != 0 1942 return 1943 } 1944 1945 func GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) { 1946 r0, _, _ := syscall.Syscall6(procGetAddrInfoW.Addr(), 4, uintptr(unsafe.Pointer(nodename)), uintptr(unsafe.Pointer(servicename)), uintptr(unsafe.Pointer(hints)), uintptr(unsafe.Pointer(result)), 0, 0) 1947 if r0 != 0 { 1948 sockerr = syscall.Errno(r0) 1949 } 1950 return 1951 } 1952 1953 func FreeAddrInfoW(addrinfo *AddrinfoW) { 1954 syscall.Syscall(procFreeAddrInfoW.Addr(), 1, uintptr(unsafe.Pointer(addrinfo)), 0, 0) 1955 return 1956 } 1957 1958 func GetIfEntry(pIfRow *MibIfRow) (errcode error) { 1959 r0, _, _ := syscall.Syscall(procGetIfEntry.Addr(), 1, uintptr(unsafe.Pointer(pIfRow)), 0, 0) 1960 if r0 != 0 { 1961 errcode = syscall.Errno(r0) 1962 } 1963 return 1964 } 1965 1966 func GetAdaptersInfo(ai *IpAdapterInfo, ol *uint32) (errcode error) { 1967 r0, _, _ := syscall.Syscall(procGetAdaptersInfo.Addr(), 2, uintptr(unsafe.Pointer(ai)), uintptr(unsafe.Pointer(ol)), 0) 1968 if r0 != 0 { 1969 errcode = syscall.Errno(r0) 1970 } 1971 return 1972 } 1973 1974 func SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) { 1975 r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(handle), uintptr(flags), 0) 1976 if r1 == 0 { 1977 if e1 != 0 { 1978 err = error(e1) 1979 } else { 1980 err = syscall.EINVAL 1981 } 1982 } 1983 return 1984 } 1985 1986 func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferLength *uint32) (n int32, err error) { 1987 r0, _, e1 := syscall.Syscall(procWSAEnumProtocolsW.Addr(), 3, uintptr(unsafe.Pointer(protocols)), uintptr(unsafe.Pointer(protocolBuffer)), uintptr(unsafe.Pointer(bufferLength))) 1988 n = int32(r0) 1989 if n == -1 { 1990 if e1 != 0 { 1991 err = error(e1) 1992 } else { 1993 err = syscall.EINVAL 1994 } 1995 } 1996 return 1997 } 1998 1999 func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint32, translatedName *uint16, nSize *uint32) (err error) { 2000 r1, _, e1 := syscall.Syscall6(procTranslateNameW.Addr(), 5, uintptr(unsafe.Pointer(accName)), uintptr(accNameFormat), uintptr(desiredNameFormat), uintptr(unsafe.Pointer(translatedName)), uintptr(unsafe.Pointer(nSize)), 0) 2001 if r1&0xff == 0 { 2002 if e1 != 0 { 2003 err = error(e1) 2004 } else { 2005 err = syscall.EINVAL 2006 } 2007 } 2008 return 2009 } 2010 2011 func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err error) { 2012 r1, _, e1 := syscall.Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize))) 2013 if r1&0xff == 0 { 2014 if e1 != 0 { 2015 err = error(e1) 2016 } else { 2017 err = syscall.EINVAL 2018 } 2019 } 2020 return 2021 } 2022 2023 func NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **byte) (neterr error) { 2024 r0, _, _ := syscall.Syscall6(procNetUserGetInfo.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(userName)), uintptr(level), uintptr(unsafe.Pointer(buf)), 0, 0) 2025 if r0 != 0 { 2026 neterr = syscall.Errno(r0) 2027 } 2028 return 2029 } 2030 2031 func NetGetJoinInformation(server *uint16, name **uint16, bufType *uint32) (neterr error) { 2032 r0, _, _ := syscall.Syscall(procNetGetJoinInformation.Addr(), 3, uintptr(unsafe.Pointer(server)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(bufType))) 2033 if r0 != 0 { 2034 neterr = syscall.Errno(r0) 2035 } 2036 return 2037 } 2038 2039 func NetApiBufferFree(buf *byte) (neterr error) { 2040 r0, _, _ := syscall.Syscall(procNetApiBufferFree.Addr(), 1, uintptr(unsafe.Pointer(buf)), 0, 0) 2041 if r0 != 0 { 2042 neterr = syscall.Errno(r0) 2043 } 2044 return 2045 } 2046 2047 func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) { 2048 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) 2049 if r1 == 0 { 2050 if e1 != 0 { 2051 err = error(e1) 2052 } else { 2053 err = syscall.EINVAL 2054 } 2055 } 2056 return 2057 } 2058 2059 func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) { 2060 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) 2061 if r1 == 0 { 2062 if e1 != 0 { 2063 err = error(e1) 2064 } else { 2065 err = syscall.EINVAL 2066 } 2067 } 2068 return 2069 } 2070 2071 func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) { 2072 r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(stringSid)), 0) 2073 if r1 == 0 { 2074 if e1 != 0 { 2075 err = error(e1) 2076 } else { 2077 err = syscall.EINVAL 2078 } 2079 } 2080 return 2081 } 2082 2083 func ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) { 2084 r1, _, e1 := syscall.Syscall(procConvertStringSidToSidW.Addr(), 2, uintptr(unsafe.Pointer(stringSid)), uintptr(unsafe.Pointer(sid)), 0) 2085 if r1 == 0 { 2086 if e1 != 0 { 2087 err = error(e1) 2088 } else { 2089 err = syscall.EINVAL 2090 } 2091 } 2092 return 2093 } 2094 2095 func GetLengthSid(sid *SID) (len uint32) { 2096 r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) 2097 len = uint32(r0) 2098 return 2099 } 2100 2101 func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) { 2102 r1, _, e1 := syscall.Syscall(procCopySid.Addr(), 3, uintptr(destSidLen), uintptr(unsafe.Pointer(destSid)), uintptr(unsafe.Pointer(srcSid))) 2103 if r1 == 0 { 2104 if e1 != 0 { 2105 err = error(e1) 2106 } else { 2107 err = syscall.EINVAL 2108 } 2109 } 2110 return 2111 } 2112 2113 func AllocateAndInitializeSid(identAuth *SidIdentifierAuthority, subAuth byte, subAuth0 uint32, subAuth1 uint32, subAuth2 uint32, subAuth3 uint32, subAuth4 uint32, subAuth5 uint32, subAuth6 uint32, subAuth7 uint32, sid **SID) (err error) { 2114 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) 2115 if r1 == 0 { 2116 if e1 != 0 { 2117 err = error(e1) 2118 } else { 2119 err = syscall.EINVAL 2120 } 2121 } 2122 return 2123 } 2124 2125 func FreeSid(sid *SID) (err error) { 2126 r1, _, e1 := syscall.Syscall(procFreeSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) 2127 if r1 != 0 { 2128 if e1 != 0 { 2129 err = error(e1) 2130 } else { 2131 err = syscall.EINVAL 2132 } 2133 } 2134 return 2135 } 2136 2137 func EqualSid(sid1 *SID, sid2 *SID) (isEqual bool) { 2138 r0, _, _ := syscall.Syscall(procEqualSid.Addr(), 2, uintptr(unsafe.Pointer(sid1)), uintptr(unsafe.Pointer(sid2)), 0) 2139 isEqual = r0 != 0 2140 return 2141 } 2142 2143 func OpenProcessToken(h Handle, access uint32, token *Token) (err error) { 2144 r1, _, e1 := syscall.Syscall(procOpenProcessToken.Addr(), 3, uintptr(h), uintptr(access), uintptr(unsafe.Pointer(token))) 2145 if r1 == 0 { 2146 if e1 != 0 { 2147 err = error(e1) 2148 } else { 2149 err = syscall.EINVAL 2150 } 2151 } 2152 return 2153 } 2154 2155 func GetTokenInformation(t Token, infoClass uint32, info *byte, infoLen uint32, returnedLen *uint32) (err error) { 2156 r1, _, e1 := syscall.Syscall6(procGetTokenInformation.Addr(), 5, uintptr(t), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), uintptr(unsafe.Pointer(returnedLen)), 0) 2157 if r1 == 0 { 2158 if e1 != 0 { 2159 err = error(e1) 2160 } else { 2161 err = syscall.EINVAL 2162 } 2163 } 2164 return 2165 } 2166 2167 func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) { 2168 r1, _, e1 := syscall.Syscall(procGetUserProfileDirectoryW.Addr(), 3, uintptr(t), uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen))) 2169 if r1 == 0 { 2170 if e1 != 0 { 2171 err = error(e1) 2172 } else { 2173 err = syscall.EINVAL 2174 } 2175 } 2176 return 2177 }