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