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