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