github.com/Andyfoo/golang/x/sys@v0.0.0-20190901054642-57c1bf301704/windows/zsyscall_windows.go (about) 1 // Code generated by 'go generate'; 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 moduserenv = NewLazySystemDLL("userenv.dll") 42 modmswsock = NewLazySystemDLL("mswsock.dll") 43 modcrypt32 = NewLazySystemDLL("crypt32.dll") 44 moduser32 = NewLazySystemDLL("user32.dll") 45 modole32 = NewLazySystemDLL("ole32.dll") 46 modntdll = NewLazySystemDLL("ntdll.dll") 47 modws2_32 = NewLazySystemDLL("ws2_32.dll") 48 moddnsapi = NewLazySystemDLL("dnsapi.dll") 49 modiphlpapi = NewLazySystemDLL("iphlpapi.dll") 50 modsecur32 = NewLazySystemDLL("secur32.dll") 51 modnetapi32 = NewLazySystemDLL("netapi32.dll") 52 modwtsapi32 = NewLazySystemDLL("wtsapi32.dll") 53 54 procRegisterEventSourceW = modadvapi32.NewProc("RegisterEventSourceW") 55 procDeregisterEventSource = modadvapi32.NewProc("DeregisterEventSource") 56 procReportEventW = modadvapi32.NewProc("ReportEventW") 57 procOpenSCManagerW = modadvapi32.NewProc("OpenSCManagerW") 58 procCloseServiceHandle = modadvapi32.NewProc("CloseServiceHandle") 59 procCreateServiceW = modadvapi32.NewProc("CreateServiceW") 60 procOpenServiceW = modadvapi32.NewProc("OpenServiceW") 61 procDeleteService = modadvapi32.NewProc("DeleteService") 62 procStartServiceW = modadvapi32.NewProc("StartServiceW") 63 procQueryServiceStatus = modadvapi32.NewProc("QueryServiceStatus") 64 procQueryServiceLockStatusW = modadvapi32.NewProc("QueryServiceLockStatusW") 65 procControlService = modadvapi32.NewProc("ControlService") 66 procStartServiceCtrlDispatcherW = modadvapi32.NewProc("StartServiceCtrlDispatcherW") 67 procSetServiceStatus = modadvapi32.NewProc("SetServiceStatus") 68 procChangeServiceConfigW = modadvapi32.NewProc("ChangeServiceConfigW") 69 procQueryServiceConfigW = modadvapi32.NewProc("QueryServiceConfigW") 70 procChangeServiceConfig2W = modadvapi32.NewProc("ChangeServiceConfig2W") 71 procQueryServiceConfig2W = modadvapi32.NewProc("QueryServiceConfig2W") 72 procEnumServicesStatusExW = modadvapi32.NewProc("EnumServicesStatusExW") 73 procQueryServiceStatusEx = modadvapi32.NewProc("QueryServiceStatusEx") 74 procNotifyServiceStatusChangeW = modadvapi32.NewProc("NotifyServiceStatusChangeW") 75 procGetLastError = modkernel32.NewProc("GetLastError") 76 procLoadLibraryW = modkernel32.NewProc("LoadLibraryW") 77 procLoadLibraryExW = modkernel32.NewProc("LoadLibraryExW") 78 procFreeLibrary = modkernel32.NewProc("FreeLibrary") 79 procGetProcAddress = modkernel32.NewProc("GetProcAddress") 80 procGetVersion = modkernel32.NewProc("GetVersion") 81 procFormatMessageW = modkernel32.NewProc("FormatMessageW") 82 procExitProcess = modkernel32.NewProc("ExitProcess") 83 procIsWow64Process = modkernel32.NewProc("IsWow64Process") 84 procCreateFileW = modkernel32.NewProc("CreateFileW") 85 procReadFile = modkernel32.NewProc("ReadFile") 86 procWriteFile = modkernel32.NewProc("WriteFile") 87 procGetOverlappedResult = modkernel32.NewProc("GetOverlappedResult") 88 procSetFilePointer = modkernel32.NewProc("SetFilePointer") 89 procCloseHandle = modkernel32.NewProc("CloseHandle") 90 procGetStdHandle = modkernel32.NewProc("GetStdHandle") 91 procSetStdHandle = modkernel32.NewProc("SetStdHandle") 92 procFindFirstFileW = modkernel32.NewProc("FindFirstFileW") 93 procFindNextFileW = modkernel32.NewProc("FindNextFileW") 94 procFindClose = modkernel32.NewProc("FindClose") 95 procGetFileInformationByHandle = modkernel32.NewProc("GetFileInformationByHandle") 96 procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx") 97 procGetCurrentDirectoryW = modkernel32.NewProc("GetCurrentDirectoryW") 98 procSetCurrentDirectoryW = modkernel32.NewProc("SetCurrentDirectoryW") 99 procCreateDirectoryW = modkernel32.NewProc("CreateDirectoryW") 100 procRemoveDirectoryW = modkernel32.NewProc("RemoveDirectoryW") 101 procDeleteFileW = modkernel32.NewProc("DeleteFileW") 102 procMoveFileW = modkernel32.NewProc("MoveFileW") 103 procMoveFileExW = modkernel32.NewProc("MoveFileExW") 104 procGetComputerNameW = modkernel32.NewProc("GetComputerNameW") 105 procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW") 106 procSetEndOfFile = modkernel32.NewProc("SetEndOfFile") 107 procGetSystemTimeAsFileTime = modkernel32.NewProc("GetSystemTimeAsFileTime") 108 procGetSystemTimePreciseAsFileTime = modkernel32.NewProc("GetSystemTimePreciseAsFileTime") 109 procGetTimeZoneInformation = modkernel32.NewProc("GetTimeZoneInformation") 110 procCreateIoCompletionPort = modkernel32.NewProc("CreateIoCompletionPort") 111 procGetQueuedCompletionStatus = modkernel32.NewProc("GetQueuedCompletionStatus") 112 procPostQueuedCompletionStatus = modkernel32.NewProc("PostQueuedCompletionStatus") 113 procCancelIo = modkernel32.NewProc("CancelIo") 114 procCancelIoEx = modkernel32.NewProc("CancelIoEx") 115 procCreateProcessW = modkernel32.NewProc("CreateProcessW") 116 procOpenProcess = modkernel32.NewProc("OpenProcess") 117 procShellExecuteW = modshell32.NewProc("ShellExecuteW") 118 procSHGetKnownFolderPath = modshell32.NewProc("SHGetKnownFolderPath") 119 procTerminateProcess = modkernel32.NewProc("TerminateProcess") 120 procGetExitCodeProcess = modkernel32.NewProc("GetExitCodeProcess") 121 procGetStartupInfoW = modkernel32.NewProc("GetStartupInfoW") 122 procGetCurrentProcess = modkernel32.NewProc("GetCurrentProcess") 123 procGetCurrentThread = modkernel32.NewProc("GetCurrentThread") 124 procGetProcessTimes = modkernel32.NewProc("GetProcessTimes") 125 procDuplicateHandle = modkernel32.NewProc("DuplicateHandle") 126 procWaitForSingleObject = modkernel32.NewProc("WaitForSingleObject") 127 procWaitForMultipleObjects = modkernel32.NewProc("WaitForMultipleObjects") 128 procGetTempPathW = modkernel32.NewProc("GetTempPathW") 129 procCreatePipe = modkernel32.NewProc("CreatePipe") 130 procGetFileType = modkernel32.NewProc("GetFileType") 131 procCryptAcquireContextW = modadvapi32.NewProc("CryptAcquireContextW") 132 procCryptReleaseContext = modadvapi32.NewProc("CryptReleaseContext") 133 procCryptGenRandom = modadvapi32.NewProc("CryptGenRandom") 134 procGetEnvironmentStringsW = modkernel32.NewProc("GetEnvironmentStringsW") 135 procFreeEnvironmentStringsW = modkernel32.NewProc("FreeEnvironmentStringsW") 136 procGetEnvironmentVariableW = modkernel32.NewProc("GetEnvironmentVariableW") 137 procSetEnvironmentVariableW = modkernel32.NewProc("SetEnvironmentVariableW") 138 procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock") 139 procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock") 140 procGetTickCount64 = modkernel32.NewProc("GetTickCount64") 141 procSetFileTime = modkernel32.NewProc("SetFileTime") 142 procGetFileAttributesW = modkernel32.NewProc("GetFileAttributesW") 143 procSetFileAttributesW = modkernel32.NewProc("SetFileAttributesW") 144 procGetFileAttributesExW = modkernel32.NewProc("GetFileAttributesExW") 145 procGetCommandLineW = modkernel32.NewProc("GetCommandLineW") 146 procCommandLineToArgvW = modshell32.NewProc("CommandLineToArgvW") 147 procLocalFree = modkernel32.NewProc("LocalFree") 148 procSetHandleInformation = modkernel32.NewProc("SetHandleInformation") 149 procFlushFileBuffers = modkernel32.NewProc("FlushFileBuffers") 150 procGetFullPathNameW = modkernel32.NewProc("GetFullPathNameW") 151 procGetLongPathNameW = modkernel32.NewProc("GetLongPathNameW") 152 procGetShortPathNameW = modkernel32.NewProc("GetShortPathNameW") 153 procCreateFileMappingW = modkernel32.NewProc("CreateFileMappingW") 154 procMapViewOfFile = modkernel32.NewProc("MapViewOfFile") 155 procUnmapViewOfFile = modkernel32.NewProc("UnmapViewOfFile") 156 procFlushViewOfFile = modkernel32.NewProc("FlushViewOfFile") 157 procVirtualLock = modkernel32.NewProc("VirtualLock") 158 procVirtualUnlock = modkernel32.NewProc("VirtualUnlock") 159 procVirtualAlloc = modkernel32.NewProc("VirtualAlloc") 160 procVirtualFree = modkernel32.NewProc("VirtualFree") 161 procVirtualProtect = modkernel32.NewProc("VirtualProtect") 162 procTransmitFile = modmswsock.NewProc("TransmitFile") 163 procReadDirectoryChangesW = modkernel32.NewProc("ReadDirectoryChangesW") 164 procCertOpenSystemStoreW = modcrypt32.NewProc("CertOpenSystemStoreW") 165 procCertOpenStore = modcrypt32.NewProc("CertOpenStore") 166 procCertEnumCertificatesInStore = modcrypt32.NewProc("CertEnumCertificatesInStore") 167 procCertAddCertificateContextToStore = modcrypt32.NewProc("CertAddCertificateContextToStore") 168 procCertCloseStore = modcrypt32.NewProc("CertCloseStore") 169 procCertGetCertificateChain = modcrypt32.NewProc("CertGetCertificateChain") 170 procCertFreeCertificateChain = modcrypt32.NewProc("CertFreeCertificateChain") 171 procCertCreateCertificateContext = modcrypt32.NewProc("CertCreateCertificateContext") 172 procCertFreeCertificateContext = modcrypt32.NewProc("CertFreeCertificateContext") 173 procCertVerifyCertificateChainPolicy = modcrypt32.NewProc("CertVerifyCertificateChainPolicy") 174 procRegOpenKeyExW = modadvapi32.NewProc("RegOpenKeyExW") 175 procRegCloseKey = modadvapi32.NewProc("RegCloseKey") 176 procRegQueryInfoKeyW = modadvapi32.NewProc("RegQueryInfoKeyW") 177 procRegEnumKeyExW = modadvapi32.NewProc("RegEnumKeyExW") 178 procRegQueryValueExW = modadvapi32.NewProc("RegQueryValueExW") 179 procGetCurrentProcessId = modkernel32.NewProc("GetCurrentProcessId") 180 procGetConsoleMode = modkernel32.NewProc("GetConsoleMode") 181 procSetConsoleMode = modkernel32.NewProc("SetConsoleMode") 182 procGetConsoleScreenBufferInfo = modkernel32.NewProc("GetConsoleScreenBufferInfo") 183 procWriteConsoleW = modkernel32.NewProc("WriteConsoleW") 184 procReadConsoleW = modkernel32.NewProc("ReadConsoleW") 185 procCreateToolhelp32Snapshot = modkernel32.NewProc("CreateToolhelp32Snapshot") 186 procProcess32FirstW = modkernel32.NewProc("Process32FirstW") 187 procProcess32NextW = modkernel32.NewProc("Process32NextW") 188 procThread32First = modkernel32.NewProc("Thread32First") 189 procThread32Next = modkernel32.NewProc("Thread32Next") 190 procDeviceIoControl = modkernel32.NewProc("DeviceIoControl") 191 procCreateSymbolicLinkW = modkernel32.NewProc("CreateSymbolicLinkW") 192 procCreateHardLinkW = modkernel32.NewProc("CreateHardLinkW") 193 procGetCurrentThreadId = modkernel32.NewProc("GetCurrentThreadId") 194 procCreateEventW = modkernel32.NewProc("CreateEventW") 195 procCreateEventExW = modkernel32.NewProc("CreateEventExW") 196 procOpenEventW = modkernel32.NewProc("OpenEventW") 197 procSetEvent = modkernel32.NewProc("SetEvent") 198 procResetEvent = modkernel32.NewProc("ResetEvent") 199 procPulseEvent = modkernel32.NewProc("PulseEvent") 200 procCreateMutexW = modkernel32.NewProc("CreateMutexW") 201 procCreateMutexExW = modkernel32.NewProc("CreateMutexExW") 202 procOpenMutexW = modkernel32.NewProc("OpenMutexW") 203 procReleaseMutex = modkernel32.NewProc("ReleaseMutex") 204 procSleepEx = modkernel32.NewProc("SleepEx") 205 procCreateJobObjectW = modkernel32.NewProc("CreateJobObjectW") 206 procAssignProcessToJobObject = modkernel32.NewProc("AssignProcessToJobObject") 207 procTerminateJobObject = modkernel32.NewProc("TerminateJobObject") 208 procSetErrorMode = modkernel32.NewProc("SetErrorMode") 209 procResumeThread = modkernel32.NewProc("ResumeThread") 210 procSetPriorityClass = modkernel32.NewProc("SetPriorityClass") 211 procGetPriorityClass = modkernel32.NewProc("GetPriorityClass") 212 procSetInformationJobObject = modkernel32.NewProc("SetInformationJobObject") 213 procGenerateConsoleCtrlEvent = modkernel32.NewProc("GenerateConsoleCtrlEvent") 214 procGetProcessId = modkernel32.NewProc("GetProcessId") 215 procOpenThread = modkernel32.NewProc("OpenThread") 216 procSetProcessPriorityBoost = modkernel32.NewProc("SetProcessPriorityBoost") 217 procDefineDosDeviceW = modkernel32.NewProc("DefineDosDeviceW") 218 procDeleteVolumeMountPointW = modkernel32.NewProc("DeleteVolumeMountPointW") 219 procFindFirstVolumeW = modkernel32.NewProc("FindFirstVolumeW") 220 procFindFirstVolumeMountPointW = modkernel32.NewProc("FindFirstVolumeMountPointW") 221 procFindNextVolumeW = modkernel32.NewProc("FindNextVolumeW") 222 procFindNextVolumeMountPointW = modkernel32.NewProc("FindNextVolumeMountPointW") 223 procFindVolumeClose = modkernel32.NewProc("FindVolumeClose") 224 procFindVolumeMountPointClose = modkernel32.NewProc("FindVolumeMountPointClose") 225 procGetDriveTypeW = modkernel32.NewProc("GetDriveTypeW") 226 procGetLogicalDrives = modkernel32.NewProc("GetLogicalDrives") 227 procGetLogicalDriveStringsW = modkernel32.NewProc("GetLogicalDriveStringsW") 228 procGetVolumeInformationW = modkernel32.NewProc("GetVolumeInformationW") 229 procGetVolumeInformationByHandleW = modkernel32.NewProc("GetVolumeInformationByHandleW") 230 procGetVolumeNameForVolumeMountPointW = modkernel32.NewProc("GetVolumeNameForVolumeMountPointW") 231 procGetVolumePathNameW = modkernel32.NewProc("GetVolumePathNameW") 232 procGetVolumePathNamesForVolumeNameW = modkernel32.NewProc("GetVolumePathNamesForVolumeNameW") 233 procQueryDosDeviceW = modkernel32.NewProc("QueryDosDeviceW") 234 procSetVolumeLabelW = modkernel32.NewProc("SetVolumeLabelW") 235 procSetVolumeMountPointW = modkernel32.NewProc("SetVolumeMountPointW") 236 procMessageBoxW = moduser32.NewProc("MessageBoxW") 237 procCLSIDFromString = modole32.NewProc("CLSIDFromString") 238 procStringFromGUID2 = modole32.NewProc("StringFromGUID2") 239 procCoCreateGuid = modole32.NewProc("CoCreateGuid") 240 procCoTaskMemFree = modole32.NewProc("CoTaskMemFree") 241 procRtlGetVersion = modntdll.NewProc("RtlGetVersion") 242 procRtlGetNtVersionNumbers = modntdll.NewProc("RtlGetNtVersionNumbers") 243 procWSAStartup = modws2_32.NewProc("WSAStartup") 244 procWSACleanup = modws2_32.NewProc("WSACleanup") 245 procWSAIoctl = modws2_32.NewProc("WSAIoctl") 246 procsocket = modws2_32.NewProc("socket") 247 procsetsockopt = modws2_32.NewProc("setsockopt") 248 procgetsockopt = modws2_32.NewProc("getsockopt") 249 procbind = modws2_32.NewProc("bind") 250 procconnect = modws2_32.NewProc("connect") 251 procgetsockname = modws2_32.NewProc("getsockname") 252 procgetpeername = modws2_32.NewProc("getpeername") 253 proclisten = modws2_32.NewProc("listen") 254 procshutdown = modws2_32.NewProc("shutdown") 255 procclosesocket = modws2_32.NewProc("closesocket") 256 procAcceptEx = modmswsock.NewProc("AcceptEx") 257 procGetAcceptExSockaddrs = modmswsock.NewProc("GetAcceptExSockaddrs") 258 procWSARecv = modws2_32.NewProc("WSARecv") 259 procWSASend = modws2_32.NewProc("WSASend") 260 procWSARecvFrom = modws2_32.NewProc("WSARecvFrom") 261 procWSASendTo = modws2_32.NewProc("WSASendTo") 262 procgethostbyname = modws2_32.NewProc("gethostbyname") 263 procgetservbyname = modws2_32.NewProc("getservbyname") 264 procntohs = modws2_32.NewProc("ntohs") 265 procgetprotobyname = modws2_32.NewProc("getprotobyname") 266 procDnsQuery_W = moddnsapi.NewProc("DnsQuery_W") 267 procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree") 268 procDnsNameCompare_W = moddnsapi.NewProc("DnsNameCompare_W") 269 procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW") 270 procFreeAddrInfoW = modws2_32.NewProc("FreeAddrInfoW") 271 procGetIfEntry = modiphlpapi.NewProc("GetIfEntry") 272 procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo") 273 procSetFileCompletionNotificationModes = modkernel32.NewProc("SetFileCompletionNotificationModes") 274 procWSAEnumProtocolsW = modws2_32.NewProc("WSAEnumProtocolsW") 275 procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses") 276 procGetACP = modkernel32.NewProc("GetACP") 277 procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar") 278 procTranslateNameW = modsecur32.NewProc("TranslateNameW") 279 procGetUserNameExW = modsecur32.NewProc("GetUserNameExW") 280 procNetUserGetInfo = modnetapi32.NewProc("NetUserGetInfo") 281 procNetGetJoinInformation = modnetapi32.NewProc("NetGetJoinInformation") 282 procNetApiBufferFree = modnetapi32.NewProc("NetApiBufferFree") 283 procLookupAccountSidW = modadvapi32.NewProc("LookupAccountSidW") 284 procLookupAccountNameW = modadvapi32.NewProc("LookupAccountNameW") 285 procConvertSidToStringSidW = modadvapi32.NewProc("ConvertSidToStringSidW") 286 procConvertStringSidToSidW = modadvapi32.NewProc("ConvertStringSidToSidW") 287 procGetLengthSid = modadvapi32.NewProc("GetLengthSid") 288 procCopySid = modadvapi32.NewProc("CopySid") 289 procAllocateAndInitializeSid = modadvapi32.NewProc("AllocateAndInitializeSid") 290 procCreateWellKnownSid = modadvapi32.NewProc("CreateWellKnownSid") 291 procIsWellKnownSid = modadvapi32.NewProc("IsWellKnownSid") 292 procFreeSid = modadvapi32.NewProc("FreeSid") 293 procEqualSid = modadvapi32.NewProc("EqualSid") 294 procGetSidIdentifierAuthority = modadvapi32.NewProc("GetSidIdentifierAuthority") 295 procGetSidSubAuthorityCount = modadvapi32.NewProc("GetSidSubAuthorityCount") 296 procGetSidSubAuthority = modadvapi32.NewProc("GetSidSubAuthority") 297 procIsValidSid = modadvapi32.NewProc("IsValidSid") 298 procCheckTokenMembership = modadvapi32.NewProc("CheckTokenMembership") 299 procOpenProcessToken = modadvapi32.NewProc("OpenProcessToken") 300 procOpenThreadToken = modadvapi32.NewProc("OpenThreadToken") 301 procImpersonateSelf = modadvapi32.NewProc("ImpersonateSelf") 302 procRevertToSelf = modadvapi32.NewProc("RevertToSelf") 303 procSetThreadToken = modadvapi32.NewProc("SetThreadToken") 304 procLookupPrivilegeValueW = modadvapi32.NewProc("LookupPrivilegeValueW") 305 procAdjustTokenPrivileges = modadvapi32.NewProc("AdjustTokenPrivileges") 306 procAdjustTokenGroups = modadvapi32.NewProc("AdjustTokenGroups") 307 procGetTokenInformation = modadvapi32.NewProc("GetTokenInformation") 308 procSetTokenInformation = modadvapi32.NewProc("SetTokenInformation") 309 procDuplicateTokenEx = modadvapi32.NewProc("DuplicateTokenEx") 310 procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW") 311 procGetSystemDirectoryW = modkernel32.NewProc("GetSystemDirectoryW") 312 procGetWindowsDirectoryW = modkernel32.NewProc("GetWindowsDirectoryW") 313 procGetSystemWindowsDirectoryW = modkernel32.NewProc("GetSystemWindowsDirectoryW") 314 procWTSQueryUserToken = modwtsapi32.NewProc("WTSQueryUserToken") 315 procWTSEnumerateSessionsW = modwtsapi32.NewProc("WTSEnumerateSessionsW") 316 procWTSFreeMemory = modwtsapi32.NewProc("WTSFreeMemory") 317 ) 318 319 func RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) { 320 r0, _, e1 := syscall.Syscall(procRegisterEventSourceW.Addr(), 2, uintptr(unsafe.Pointer(uncServerName)), uintptr(unsafe.Pointer(sourceName)), 0) 321 handle = Handle(r0) 322 if handle == 0 { 323 if e1 != 0 { 324 err = errnoErr(e1) 325 } else { 326 err = syscall.EINVAL 327 } 328 } 329 return 330 } 331 332 func DeregisterEventSource(handle Handle) (err error) { 333 r1, _, e1 := syscall.Syscall(procDeregisterEventSource.Addr(), 1, uintptr(handle), 0, 0) 334 if r1 == 0 { 335 if e1 != 0 { 336 err = errnoErr(e1) 337 } else { 338 err = syscall.EINVAL 339 } 340 } 341 return 342 } 343 344 func ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) { 345 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))) 346 if r1 == 0 { 347 if e1 != 0 { 348 err = errnoErr(e1) 349 } else { 350 err = syscall.EINVAL 351 } 352 } 353 return 354 } 355 356 func OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle Handle, err error) { 357 r0, _, e1 := syscall.Syscall(procOpenSCManagerW.Addr(), 3, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(databaseName)), uintptr(access)) 358 handle = Handle(r0) 359 if handle == 0 { 360 if e1 != 0 { 361 err = errnoErr(e1) 362 } else { 363 err = syscall.EINVAL 364 } 365 } 366 return 367 } 368 369 func CloseServiceHandle(handle Handle) (err error) { 370 r1, _, e1 := syscall.Syscall(procCloseServiceHandle.Addr(), 1, uintptr(handle), 0, 0) 371 if r1 == 0 { 372 if e1 != 0 { 373 err = errnoErr(e1) 374 } else { 375 err = syscall.EINVAL 376 } 377 } 378 return 379 } 380 381 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) { 382 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) 383 handle = Handle(r0) 384 if handle == 0 { 385 if e1 != 0 { 386 err = errnoErr(e1) 387 } else { 388 err = syscall.EINVAL 389 } 390 } 391 return 392 } 393 394 func OpenService(mgr Handle, serviceName *uint16, access uint32) (handle Handle, err error) { 395 r0, _, e1 := syscall.Syscall(procOpenServiceW.Addr(), 3, uintptr(mgr), uintptr(unsafe.Pointer(serviceName)), uintptr(access)) 396 handle = Handle(r0) 397 if handle == 0 { 398 if e1 != 0 { 399 err = errnoErr(e1) 400 } else { 401 err = syscall.EINVAL 402 } 403 } 404 return 405 } 406 407 func DeleteService(service Handle) (err error) { 408 r1, _, e1 := syscall.Syscall(procDeleteService.Addr(), 1, uintptr(service), 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 StartService(service Handle, numArgs uint32, argVectors **uint16) (err error) { 420 r1, _, e1 := syscall.Syscall(procStartServiceW.Addr(), 3, uintptr(service), uintptr(numArgs), uintptr(unsafe.Pointer(argVectors))) 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 QueryServiceStatus(service Handle, status *SERVICE_STATUS) (err error) { 432 r1, _, e1 := syscall.Syscall(procQueryServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(status)), 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 QueryServiceLockStatus(mgr Handle, lockStatus *QUERY_SERVICE_LOCK_STATUS, bufSize uint32, bytesNeeded *uint32) (err error) { 444 r1, _, e1 := syscall.Syscall6(procQueryServiceLockStatusW.Addr(), 4, uintptr(mgr), uintptr(unsafe.Pointer(lockStatus)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 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 ControlService(service Handle, control uint32, status *SERVICE_STATUS) (err error) { 456 r1, _, e1 := syscall.Syscall(procControlService.Addr(), 3, uintptr(service), uintptr(control), uintptr(unsafe.Pointer(status))) 457 if r1 == 0 { 458 if e1 != 0 { 459 err = errnoErr(e1) 460 } else { 461 err = syscall.EINVAL 462 } 463 } 464 return 465 } 466 467 func StartServiceCtrlDispatcher(serviceTable *SERVICE_TABLE_ENTRY) (err error) { 468 r1, _, e1 := syscall.Syscall(procStartServiceCtrlDispatcherW.Addr(), 1, uintptr(unsafe.Pointer(serviceTable)), 0, 0) 469 if r1 == 0 { 470 if e1 != 0 { 471 err = errnoErr(e1) 472 } else { 473 err = syscall.EINVAL 474 } 475 } 476 return 477 } 478 479 func SetServiceStatus(service Handle, serviceStatus *SERVICE_STATUS) (err error) { 480 r1, _, e1 := syscall.Syscall(procSetServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(serviceStatus)), 0) 481 if r1 == 0 { 482 if e1 != 0 { 483 err = errnoErr(e1) 484 } else { 485 err = syscall.EINVAL 486 } 487 } 488 return 489 } 490 491 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) { 492 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) 493 if r1 == 0 { 494 if e1 != 0 { 495 err = errnoErr(e1) 496 } else { 497 err = syscall.EINVAL 498 } 499 } 500 return 501 } 502 503 func QueryServiceConfig(service Handle, serviceConfig *QUERY_SERVICE_CONFIG, bufSize uint32, bytesNeeded *uint32) (err error) { 504 r1, _, e1 := syscall.Syscall6(procQueryServiceConfigW.Addr(), 4, uintptr(service), uintptr(unsafe.Pointer(serviceConfig)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0) 505 if r1 == 0 { 506 if e1 != 0 { 507 err = errnoErr(e1) 508 } else { 509 err = syscall.EINVAL 510 } 511 } 512 return 513 } 514 515 func ChangeServiceConfig2(service Handle, infoLevel uint32, info *byte) (err error) { 516 r1, _, e1 := syscall.Syscall(procChangeServiceConfig2W.Addr(), 3, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(info))) 517 if r1 == 0 { 518 if e1 != 0 { 519 err = errnoErr(e1) 520 } else { 521 err = syscall.EINVAL 522 } 523 } 524 return 525 } 526 527 func QueryServiceConfig2(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) { 528 r1, _, e1 := syscall.Syscall6(procQueryServiceConfig2W.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0) 529 if r1 == 0 { 530 if e1 != 0 { 531 err = errnoErr(e1) 532 } else { 533 err = syscall.EINVAL 534 } 535 } 536 return 537 } 538 539 func EnumServicesStatusEx(mgr Handle, infoLevel uint32, serviceType uint32, serviceState uint32, services *byte, bufSize uint32, bytesNeeded *uint32, servicesReturned *uint32, resumeHandle *uint32, groupName *uint16) (err error) { 540 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) 541 if r1 == 0 { 542 if e1 != 0 { 543 err = errnoErr(e1) 544 } else { 545 err = syscall.EINVAL 546 } 547 } 548 return 549 } 550 551 func QueryServiceStatusEx(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) { 552 r1, _, e1 := syscall.Syscall6(procQueryServiceStatusEx.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0) 553 if r1 == 0 { 554 if e1 != 0 { 555 err = errnoErr(e1) 556 } else { 557 err = syscall.EINVAL 558 } 559 } 560 return 561 } 562 563 func NotifyServiceStatusChange(service Handle, notifyMask uint32, notifier *SERVICE_NOTIFY) (ret error) { 564 r0, _, _ := syscall.Syscall(procNotifyServiceStatusChangeW.Addr(), 3, uintptr(service), uintptr(notifyMask), uintptr(unsafe.Pointer(notifier))) 565 if r0 != 0 { 566 ret = syscall.Errno(r0) 567 } 568 return 569 } 570 571 func GetLastError() (lasterr error) { 572 r0, _, _ := syscall.Syscall(procGetLastError.Addr(), 0, 0, 0, 0) 573 if r0 != 0 { 574 lasterr = syscall.Errno(r0) 575 } 576 return 577 } 578 579 func LoadLibrary(libname string) (handle Handle, err error) { 580 var _p0 *uint16 581 _p0, err = syscall.UTF16PtrFromString(libname) 582 if err != nil { 583 return 584 } 585 return _LoadLibrary(_p0) 586 } 587 588 func _LoadLibrary(libname *uint16) (handle Handle, err error) { 589 r0, _, e1 := syscall.Syscall(procLoadLibraryW.Addr(), 1, uintptr(unsafe.Pointer(libname)), 0, 0) 590 handle = Handle(r0) 591 if handle == 0 { 592 if e1 != 0 { 593 err = errnoErr(e1) 594 } else { 595 err = syscall.EINVAL 596 } 597 } 598 return 599 } 600 601 func LoadLibraryEx(libname string, zero Handle, flags uintptr) (handle Handle, err error) { 602 var _p0 *uint16 603 _p0, err = syscall.UTF16PtrFromString(libname) 604 if err != nil { 605 return 606 } 607 return _LoadLibraryEx(_p0, zero, flags) 608 } 609 610 func _LoadLibraryEx(libname *uint16, zero Handle, flags uintptr) (handle Handle, err error) { 611 r0, _, e1 := syscall.Syscall(procLoadLibraryExW.Addr(), 3, uintptr(unsafe.Pointer(libname)), uintptr(zero), uintptr(flags)) 612 handle = Handle(r0) 613 if handle == 0 { 614 if e1 != 0 { 615 err = errnoErr(e1) 616 } else { 617 err = syscall.EINVAL 618 } 619 } 620 return 621 } 622 623 func FreeLibrary(handle Handle) (err error) { 624 r1, _, e1 := syscall.Syscall(procFreeLibrary.Addr(), 1, uintptr(handle), 0, 0) 625 if r1 == 0 { 626 if e1 != 0 { 627 err = errnoErr(e1) 628 } else { 629 err = syscall.EINVAL 630 } 631 } 632 return 633 } 634 635 func GetProcAddress(module Handle, procname string) (proc uintptr, err error) { 636 var _p0 *byte 637 _p0, err = syscall.BytePtrFromString(procname) 638 if err != nil { 639 return 640 } 641 return _GetProcAddress(module, _p0) 642 } 643 644 func _GetProcAddress(module Handle, procname *byte) (proc uintptr, err error) { 645 r0, _, e1 := syscall.Syscall(procGetProcAddress.Addr(), 2, uintptr(module), uintptr(unsafe.Pointer(procname)), 0) 646 proc = uintptr(r0) 647 if proc == 0 { 648 if e1 != 0 { 649 err = errnoErr(e1) 650 } else { 651 err = syscall.EINVAL 652 } 653 } 654 return 655 } 656 657 func GetVersion() (ver uint32, err error) { 658 r0, _, e1 := syscall.Syscall(procGetVersion.Addr(), 0, 0, 0, 0) 659 ver = uint32(r0) 660 if ver == 0 { 661 if e1 != 0 { 662 err = errnoErr(e1) 663 } else { 664 err = syscall.EINVAL 665 } 666 } 667 return 668 } 669 670 func FormatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, buf []uint16, args *byte) (n uint32, err error) { 671 var _p0 *uint16 672 if len(buf) > 0 { 673 _p0 = &buf[0] 674 } 675 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) 676 n = uint32(r0) 677 if n == 0 { 678 if e1 != 0 { 679 err = errnoErr(e1) 680 } else { 681 err = syscall.EINVAL 682 } 683 } 684 return 685 } 686 687 func ExitProcess(exitcode uint32) { 688 syscall.Syscall(procExitProcess.Addr(), 1, uintptr(exitcode), 0, 0) 689 return 690 } 691 692 func IsWow64Process(handle Handle, isWow64 *bool) (err error) { 693 r1, _, e1 := syscall.Syscall(procIsWow64Process.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(isWow64)), 0) 694 if r1 == 0 { 695 if e1 != 0 { 696 err = errnoErr(e1) 697 } else { 698 err = syscall.EINVAL 699 } 700 } 701 return 702 } 703 704 func CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile Handle) (handle Handle, err error) { 705 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) 706 handle = Handle(r0) 707 if handle == InvalidHandle { 708 if e1 != 0 { 709 err = errnoErr(e1) 710 } else { 711 err = syscall.EINVAL 712 } 713 } 714 return 715 } 716 717 func ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) { 718 var _p0 *byte 719 if len(buf) > 0 { 720 _p0 = &buf[0] 721 } 722 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) 723 if r1 == 0 { 724 if e1 != 0 { 725 err = errnoErr(e1) 726 } else { 727 err = syscall.EINVAL 728 } 729 } 730 return 731 } 732 733 func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) { 734 var _p0 *byte 735 if len(buf) > 0 { 736 _p0 = &buf[0] 737 } 738 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) 739 if r1 == 0 { 740 if e1 != 0 { 741 err = errnoErr(e1) 742 } else { 743 err = syscall.EINVAL 744 } 745 } 746 return 747 } 748 749 func GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error) { 750 var _p0 uint32 751 if wait { 752 _p0 = 1 753 } else { 754 _p0 = 0 755 } 756 r1, _, e1 := syscall.Syscall6(procGetOverlappedResult.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(done)), uintptr(_p0), 0, 0) 757 if r1 == 0 { 758 if e1 != 0 { 759 err = errnoErr(e1) 760 } else { 761 err = syscall.EINVAL 762 } 763 } 764 return 765 } 766 767 func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) { 768 r0, _, e1 := syscall.Syscall6(procSetFilePointer.Addr(), 4, uintptr(handle), uintptr(lowoffset), uintptr(unsafe.Pointer(highoffsetptr)), uintptr(whence), 0, 0) 769 newlowoffset = uint32(r0) 770 if newlowoffset == 0xffffffff { 771 if e1 != 0 { 772 err = errnoErr(e1) 773 } else { 774 err = syscall.EINVAL 775 } 776 } 777 return 778 } 779 780 func CloseHandle(handle Handle) (err error) { 781 r1, _, e1 := syscall.Syscall(procCloseHandle.Addr(), 1, uintptr(handle), 0, 0) 782 if r1 == 0 { 783 if e1 != 0 { 784 err = errnoErr(e1) 785 } else { 786 err = syscall.EINVAL 787 } 788 } 789 return 790 } 791 792 func GetStdHandle(stdhandle uint32) (handle Handle, err error) { 793 r0, _, e1 := syscall.Syscall(procGetStdHandle.Addr(), 1, uintptr(stdhandle), 0, 0) 794 handle = Handle(r0) 795 if handle == InvalidHandle { 796 if e1 != 0 { 797 err = errnoErr(e1) 798 } else { 799 err = syscall.EINVAL 800 } 801 } 802 return 803 } 804 805 func SetStdHandle(stdhandle uint32, handle Handle) (err error) { 806 r1, _, e1 := syscall.Syscall(procSetStdHandle.Addr(), 2, uintptr(stdhandle), uintptr(handle), 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 findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err error) { 818 r0, _, e1 := syscall.Syscall(procFindFirstFileW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(data)), 0) 819 handle = Handle(r0) 820 if handle == InvalidHandle { 821 if e1 != 0 { 822 err = errnoErr(e1) 823 } else { 824 err = syscall.EINVAL 825 } 826 } 827 return 828 } 829 830 func findNextFile1(handle Handle, data *win32finddata1) (err error) { 831 r1, _, e1 := syscall.Syscall(procFindNextFileW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0) 832 if r1 == 0 { 833 if e1 != 0 { 834 err = errnoErr(e1) 835 } else { 836 err = syscall.EINVAL 837 } 838 } 839 return 840 } 841 842 func FindClose(handle Handle) (err error) { 843 r1, _, e1 := syscall.Syscall(procFindClose.Addr(), 1, uintptr(handle), 0, 0) 844 if r1 == 0 { 845 if e1 != 0 { 846 err = errnoErr(e1) 847 } else { 848 err = syscall.EINVAL 849 } 850 } 851 return 852 } 853 854 func GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (err error) { 855 r1, _, e1 := syscall.Syscall(procGetFileInformationByHandle.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0) 856 if r1 == 0 { 857 if e1 != 0 { 858 err = errnoErr(e1) 859 } else { 860 err = syscall.EINVAL 861 } 862 } 863 return 864 } 865 866 func GetFileInformationByHandleEx(handle Handle, class uint32, outBuffer *byte, outBufferLen uint32) (err error) { 867 r1, _, e1 := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 4, uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(outBuffer)), uintptr(outBufferLen), 0, 0) 868 if r1 == 0 { 869 if e1 != 0 { 870 err = errnoErr(e1) 871 } else { 872 err = syscall.EINVAL 873 } 874 } 875 return 876 } 877 878 func GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) { 879 r0, _, e1 := syscall.Syscall(procGetCurrentDirectoryW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0) 880 n = uint32(r0) 881 if n == 0 { 882 if e1 != 0 { 883 err = errnoErr(e1) 884 } else { 885 err = syscall.EINVAL 886 } 887 } 888 return 889 } 890 891 func SetCurrentDirectory(path *uint16) (err error) { 892 r1, _, e1 := syscall.Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) 893 if r1 == 0 { 894 if e1 != 0 { 895 err = errnoErr(e1) 896 } else { 897 err = syscall.EINVAL 898 } 899 } 900 return 901 } 902 903 func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) { 904 r1, _, e1 := syscall.Syscall(procCreateDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(sa)), 0) 905 if r1 == 0 { 906 if e1 != 0 { 907 err = errnoErr(e1) 908 } else { 909 err = syscall.EINVAL 910 } 911 } 912 return 913 } 914 915 func RemoveDirectory(path *uint16) (err error) { 916 r1, _, e1 := syscall.Syscall(procRemoveDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) 917 if r1 == 0 { 918 if e1 != 0 { 919 err = errnoErr(e1) 920 } else { 921 err = syscall.EINVAL 922 } 923 } 924 return 925 } 926 927 func DeleteFile(path *uint16) (err error) { 928 r1, _, e1 := syscall.Syscall(procDeleteFileW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) 929 if r1 == 0 { 930 if e1 != 0 { 931 err = errnoErr(e1) 932 } else { 933 err = syscall.EINVAL 934 } 935 } 936 return 937 } 938 939 func MoveFile(from *uint16, to *uint16) (err error) { 940 r1, _, e1 := syscall.Syscall(procMoveFileW.Addr(), 2, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), 0) 941 if r1 == 0 { 942 if e1 != 0 { 943 err = errnoErr(e1) 944 } else { 945 err = syscall.EINVAL 946 } 947 } 948 return 949 } 950 951 func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) { 952 r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags)) 953 if r1 == 0 { 954 if e1 != 0 { 955 err = errnoErr(e1) 956 } else { 957 err = syscall.EINVAL 958 } 959 } 960 return 961 } 962 963 func GetComputerName(buf *uint16, n *uint32) (err error) { 964 r1, _, e1 := syscall.Syscall(procGetComputerNameW.Addr(), 2, uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)), 0) 965 if r1 == 0 { 966 if e1 != 0 { 967 err = errnoErr(e1) 968 } else { 969 err = syscall.EINVAL 970 } 971 } 972 return 973 } 974 975 func GetComputerNameEx(nametype uint32, buf *uint16, n *uint32) (err error) { 976 r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nametype), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n))) 977 if r1 == 0 { 978 if e1 != 0 { 979 err = errnoErr(e1) 980 } else { 981 err = syscall.EINVAL 982 } 983 } 984 return 985 } 986 987 func SetEndOfFile(handle Handle) (err error) { 988 r1, _, e1 := syscall.Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0) 989 if r1 == 0 { 990 if e1 != 0 { 991 err = errnoErr(e1) 992 } else { 993 err = syscall.EINVAL 994 } 995 } 996 return 997 } 998 999 func GetSystemTimeAsFileTime(time *Filetime) { 1000 syscall.Syscall(procGetSystemTimeAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0) 1001 return 1002 } 1003 1004 func GetSystemTimePreciseAsFileTime(time *Filetime) { 1005 syscall.Syscall(procGetSystemTimePreciseAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0) 1006 return 1007 } 1008 1009 func GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) { 1010 r0, _, e1 := syscall.Syscall(procGetTimeZoneInformation.Addr(), 1, uintptr(unsafe.Pointer(tzi)), 0, 0) 1011 rc = uint32(r0) 1012 if rc == 0xffffffff { 1013 if e1 != 0 { 1014 err = errnoErr(e1) 1015 } else { 1016 err = syscall.EINVAL 1017 } 1018 } 1019 return 1020 } 1021 1022 func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (handle Handle, err error) { 1023 r0, _, e1 := syscall.Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(filehandle), uintptr(cphandle), uintptr(key), uintptr(threadcnt), 0, 0) 1024 handle = Handle(r0) 1025 if handle == 0 { 1026 if e1 != 0 { 1027 err = errnoErr(e1) 1028 } else { 1029 err = syscall.EINVAL 1030 } 1031 } 1032 return 1033 } 1034 1035 func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error) { 1036 r1, _, e1 := syscall.Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(cphandle), uintptr(unsafe.Pointer(qty)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(overlapped)), uintptr(timeout), 0) 1037 if r1 == 0 { 1038 if e1 != 0 { 1039 err = errnoErr(e1) 1040 } else { 1041 err = syscall.EINVAL 1042 } 1043 } 1044 return 1045 } 1046 1047 func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error) { 1048 r1, _, e1 := syscall.Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0) 1049 if r1 == 0 { 1050 if e1 != 0 { 1051 err = errnoErr(e1) 1052 } else { 1053 err = syscall.EINVAL 1054 } 1055 } 1056 return 1057 } 1058 1059 func CancelIo(s Handle) (err error) { 1060 r1, _, e1 := syscall.Syscall(procCancelIo.Addr(), 1, uintptr(s), 0, 0) 1061 if r1 == 0 { 1062 if e1 != 0 { 1063 err = errnoErr(e1) 1064 } else { 1065 err = syscall.EINVAL 1066 } 1067 } 1068 return 1069 } 1070 1071 func CancelIoEx(s Handle, o *Overlapped) (err error) { 1072 r1, _, e1 := syscall.Syscall(procCancelIoEx.Addr(), 2, uintptr(s), uintptr(unsafe.Pointer(o)), 0) 1073 if r1 == 0 { 1074 if e1 != 0 { 1075 err = errnoErr(e1) 1076 } else { 1077 err = syscall.EINVAL 1078 } 1079 } 1080 return 1081 } 1082 1083 func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) { 1084 var _p0 uint32 1085 if inheritHandles { 1086 _p0 = 1 1087 } else { 1088 _p0 = 0 1089 } 1090 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) 1091 if r1 == 0 { 1092 if e1 != 0 { 1093 err = errnoErr(e1) 1094 } else { 1095 err = syscall.EINVAL 1096 } 1097 } 1098 return 1099 } 1100 1101 func OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error) { 1102 var _p0 uint32 1103 if inheritHandle { 1104 _p0 = 1 1105 } else { 1106 _p0 = 0 1107 } 1108 r0, _, e1 := syscall.Syscall(procOpenProcess.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(processId)) 1109 handle = Handle(r0) 1110 if handle == 0 { 1111 if e1 != 0 { 1112 err = errnoErr(e1) 1113 } else { 1114 err = syscall.EINVAL 1115 } 1116 } 1117 return 1118 } 1119 1120 func ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) { 1121 r1, _, e1 := syscall.Syscall6(procShellExecuteW.Addr(), 6, uintptr(hwnd), uintptr(unsafe.Pointer(verb)), uintptr(unsafe.Pointer(file)), uintptr(unsafe.Pointer(args)), uintptr(unsafe.Pointer(cwd)), uintptr(showCmd)) 1122 if r1 == 0 { 1123 if e1 != 0 { 1124 err = errnoErr(e1) 1125 } else { 1126 err = syscall.EINVAL 1127 } 1128 } 1129 return 1130 } 1131 1132 func shGetKnownFolderPath(id *KNOWNFOLDERID, flags uint32, token Token, path **uint16) (ret error) { 1133 r0, _, _ := syscall.Syscall6(procSHGetKnownFolderPath.Addr(), 4, uintptr(unsafe.Pointer(id)), uintptr(flags), uintptr(token), uintptr(unsafe.Pointer(path)), 0, 0) 1134 if r0 != 0 { 1135 ret = syscall.Errno(r0) 1136 } 1137 return 1138 } 1139 1140 func TerminateProcess(handle Handle, exitcode uint32) (err error) { 1141 r1, _, e1 := syscall.Syscall(procTerminateProcess.Addr(), 2, uintptr(handle), uintptr(exitcode), 0) 1142 if r1 == 0 { 1143 if e1 != 0 { 1144 err = errnoErr(e1) 1145 } else { 1146 err = syscall.EINVAL 1147 } 1148 } 1149 return 1150 } 1151 1152 func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) { 1153 r1, _, e1 := syscall.Syscall(procGetExitCodeProcess.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(exitcode)), 0) 1154 if r1 == 0 { 1155 if e1 != 0 { 1156 err = errnoErr(e1) 1157 } else { 1158 err = syscall.EINVAL 1159 } 1160 } 1161 return 1162 } 1163 1164 func GetStartupInfo(startupInfo *StartupInfo) (err error) { 1165 r1, _, e1 := syscall.Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0) 1166 if r1 == 0 { 1167 if e1 != 0 { 1168 err = errnoErr(e1) 1169 } else { 1170 err = syscall.EINVAL 1171 } 1172 } 1173 return 1174 } 1175 1176 func GetCurrentProcess() (pseudoHandle Handle, err error) { 1177 r0, _, e1 := syscall.Syscall(procGetCurrentProcess.Addr(), 0, 0, 0, 0) 1178 pseudoHandle = Handle(r0) 1179 if pseudoHandle == 0 { 1180 if e1 != 0 { 1181 err = errnoErr(e1) 1182 } else { 1183 err = syscall.EINVAL 1184 } 1185 } 1186 return 1187 } 1188 1189 func GetCurrentThread() (pseudoHandle Handle, err error) { 1190 r0, _, e1 := syscall.Syscall(procGetCurrentThread.Addr(), 0, 0, 0, 0) 1191 pseudoHandle = Handle(r0) 1192 if pseudoHandle == 0 { 1193 if e1 != 0 { 1194 err = errnoErr(e1) 1195 } else { 1196 err = syscall.EINVAL 1197 } 1198 } 1199 return 1200 } 1201 1202 func GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, kernelTime *Filetime, userTime *Filetime) (err error) { 1203 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) 1204 if r1 == 0 { 1205 if e1 != 0 { 1206 err = errnoErr(e1) 1207 } else { 1208 err = syscall.EINVAL 1209 } 1210 } 1211 return 1212 } 1213 1214 func DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetProcessHandle Handle, lpTargetHandle *Handle, dwDesiredAccess uint32, bInheritHandle bool, dwOptions uint32) (err error) { 1215 var _p0 uint32 1216 if bInheritHandle { 1217 _p0 = 1 1218 } else { 1219 _p0 = 0 1220 } 1221 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) 1222 if r1 == 0 { 1223 if e1 != 0 { 1224 err = errnoErr(e1) 1225 } else { 1226 err = syscall.EINVAL 1227 } 1228 } 1229 return 1230 } 1231 1232 func WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32, err error) { 1233 r0, _, e1 := syscall.Syscall(procWaitForSingleObject.Addr(), 2, uintptr(handle), uintptr(waitMilliseconds), 0) 1234 event = uint32(r0) 1235 if event == 0xffffffff { 1236 if e1 != 0 { 1237 err = errnoErr(e1) 1238 } else { 1239 err = syscall.EINVAL 1240 } 1241 } 1242 return 1243 } 1244 1245 func waitForMultipleObjects(count uint32, handles uintptr, waitAll bool, waitMilliseconds uint32) (event uint32, err error) { 1246 var _p0 uint32 1247 if waitAll { 1248 _p0 = 1 1249 } else { 1250 _p0 = 0 1251 } 1252 r0, _, e1 := syscall.Syscall6(procWaitForMultipleObjects.Addr(), 4, uintptr(count), uintptr(handles), uintptr(_p0), uintptr(waitMilliseconds), 0, 0) 1253 event = uint32(r0) 1254 if event == 0xffffffff { 1255 if e1 != 0 { 1256 err = errnoErr(e1) 1257 } else { 1258 err = syscall.EINVAL 1259 } 1260 } 1261 return 1262 } 1263 1264 func GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) { 1265 r0, _, e1 := syscall.Syscall(procGetTempPathW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0) 1266 n = uint32(r0) 1267 if n == 0 { 1268 if e1 != 0 { 1269 err = errnoErr(e1) 1270 } else { 1271 err = syscall.EINVAL 1272 } 1273 } 1274 return 1275 } 1276 1277 func CreatePipe(readhandle *Handle, writehandle *Handle, sa *SecurityAttributes, size uint32) (err error) { 1278 r1, _, e1 := syscall.Syscall6(procCreatePipe.Addr(), 4, uintptr(unsafe.Pointer(readhandle)), uintptr(unsafe.Pointer(writehandle)), uintptr(unsafe.Pointer(sa)), uintptr(size), 0, 0) 1279 if r1 == 0 { 1280 if e1 != 0 { 1281 err = errnoErr(e1) 1282 } else { 1283 err = syscall.EINVAL 1284 } 1285 } 1286 return 1287 } 1288 1289 func GetFileType(filehandle Handle) (n uint32, err error) { 1290 r0, _, e1 := syscall.Syscall(procGetFileType.Addr(), 1, uintptr(filehandle), 0, 0) 1291 n = uint32(r0) 1292 if n == 0 { 1293 if e1 != 0 { 1294 err = errnoErr(e1) 1295 } else { 1296 err = syscall.EINVAL 1297 } 1298 } 1299 return 1300 } 1301 1302 func CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16, provtype uint32, flags uint32) (err error) { 1303 r1, _, e1 := syscall.Syscall6(procCryptAcquireContextW.Addr(), 5, uintptr(unsafe.Pointer(provhandle)), uintptr(unsafe.Pointer(container)), uintptr(unsafe.Pointer(provider)), uintptr(provtype), uintptr(flags), 0) 1304 if r1 == 0 { 1305 if e1 != 0 { 1306 err = errnoErr(e1) 1307 } else { 1308 err = syscall.EINVAL 1309 } 1310 } 1311 return 1312 } 1313 1314 func CryptReleaseContext(provhandle Handle, flags uint32) (err error) { 1315 r1, _, e1 := syscall.Syscall(procCryptReleaseContext.Addr(), 2, uintptr(provhandle), uintptr(flags), 0) 1316 if r1 == 0 { 1317 if e1 != 0 { 1318 err = errnoErr(e1) 1319 } else { 1320 err = syscall.EINVAL 1321 } 1322 } 1323 return 1324 } 1325 1326 func CryptGenRandom(provhandle Handle, buflen uint32, buf *byte) (err error) { 1327 r1, _, e1 := syscall.Syscall(procCryptGenRandom.Addr(), 3, uintptr(provhandle), uintptr(buflen), uintptr(unsafe.Pointer(buf))) 1328 if r1 == 0 { 1329 if e1 != 0 { 1330 err = errnoErr(e1) 1331 } else { 1332 err = syscall.EINVAL 1333 } 1334 } 1335 return 1336 } 1337 1338 func GetEnvironmentStrings() (envs *uint16, err error) { 1339 r0, _, e1 := syscall.Syscall(procGetEnvironmentStringsW.Addr(), 0, 0, 0, 0) 1340 envs = (*uint16)(unsafe.Pointer(r0)) 1341 if envs == nil { 1342 if e1 != 0 { 1343 err = errnoErr(e1) 1344 } else { 1345 err = syscall.EINVAL 1346 } 1347 } 1348 return 1349 } 1350 1351 func FreeEnvironmentStrings(envs *uint16) (err error) { 1352 r1, _, e1 := syscall.Syscall(procFreeEnvironmentStringsW.Addr(), 1, uintptr(unsafe.Pointer(envs)), 0, 0) 1353 if r1 == 0 { 1354 if e1 != 0 { 1355 err = errnoErr(e1) 1356 } else { 1357 err = syscall.EINVAL 1358 } 1359 } 1360 return 1361 } 1362 1363 func GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32, err error) { 1364 r0, _, e1 := syscall.Syscall(procGetEnvironmentVariableW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buffer)), uintptr(size)) 1365 n = uint32(r0) 1366 if n == 0 { 1367 if e1 != 0 { 1368 err = errnoErr(e1) 1369 } else { 1370 err = syscall.EINVAL 1371 } 1372 } 1373 return 1374 } 1375 1376 func SetEnvironmentVariable(name *uint16, value *uint16) (err error) { 1377 r1, _, e1 := syscall.Syscall(procSetEnvironmentVariableW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), 0) 1378 if r1 == 0 { 1379 if e1 != 0 { 1380 err = errnoErr(e1) 1381 } else { 1382 err = syscall.EINVAL 1383 } 1384 } 1385 return 1386 } 1387 1388 func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) { 1389 var _p0 uint32 1390 if inheritExisting { 1391 _p0 = 1 1392 } else { 1393 _p0 = 0 1394 } 1395 r1, _, e1 := syscall.Syscall(procCreateEnvironmentBlock.Addr(), 3, uintptr(unsafe.Pointer(block)), uintptr(token), uintptr(_p0)) 1396 if r1 == 0 { 1397 if e1 != 0 { 1398 err = errnoErr(e1) 1399 } else { 1400 err = syscall.EINVAL 1401 } 1402 } 1403 return 1404 } 1405 1406 func DestroyEnvironmentBlock(block *uint16) (err error) { 1407 r1, _, e1 := syscall.Syscall(procDestroyEnvironmentBlock.Addr(), 1, uintptr(unsafe.Pointer(block)), 0, 0) 1408 if r1 == 0 { 1409 if e1 != 0 { 1410 err = errnoErr(e1) 1411 } else { 1412 err = syscall.EINVAL 1413 } 1414 } 1415 return 1416 } 1417 1418 func getTickCount64() (ms uint64) { 1419 r0, _, _ := syscall.Syscall(procGetTickCount64.Addr(), 0, 0, 0, 0) 1420 ms = uint64(r0) 1421 return 1422 } 1423 1424 func SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error) { 1425 r1, _, e1 := syscall.Syscall6(procSetFileTime.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(ctime)), uintptr(unsafe.Pointer(atime)), uintptr(unsafe.Pointer(wtime)), 0, 0) 1426 if r1 == 0 { 1427 if e1 != 0 { 1428 err = errnoErr(e1) 1429 } else { 1430 err = syscall.EINVAL 1431 } 1432 } 1433 return 1434 } 1435 1436 func GetFileAttributes(name *uint16) (attrs uint32, err error) { 1437 r0, _, e1 := syscall.Syscall(procGetFileAttributesW.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0) 1438 attrs = uint32(r0) 1439 if attrs == INVALID_FILE_ATTRIBUTES { 1440 if e1 != 0 { 1441 err = errnoErr(e1) 1442 } else { 1443 err = syscall.EINVAL 1444 } 1445 } 1446 return 1447 } 1448 1449 func SetFileAttributes(name *uint16, attrs uint32) (err error) { 1450 r1, _, e1 := syscall.Syscall(procSetFileAttributesW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(attrs), 0) 1451 if r1 == 0 { 1452 if e1 != 0 { 1453 err = errnoErr(e1) 1454 } else { 1455 err = syscall.EINVAL 1456 } 1457 } 1458 return 1459 } 1460 1461 func GetFileAttributesEx(name *uint16, level uint32, info *byte) (err error) { 1462 r1, _, e1 := syscall.Syscall(procGetFileAttributesExW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(level), uintptr(unsafe.Pointer(info))) 1463 if r1 == 0 { 1464 if e1 != 0 { 1465 err = errnoErr(e1) 1466 } else { 1467 err = syscall.EINVAL 1468 } 1469 } 1470 return 1471 } 1472 1473 func GetCommandLine() (cmd *uint16) { 1474 r0, _, _ := syscall.Syscall(procGetCommandLineW.Addr(), 0, 0, 0, 0) 1475 cmd = (*uint16)(unsafe.Pointer(r0)) 1476 return 1477 } 1478 1479 func CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err error) { 1480 r0, _, e1 := syscall.Syscall(procCommandLineToArgvW.Addr(), 2, uintptr(unsafe.Pointer(cmd)), uintptr(unsafe.Pointer(argc)), 0) 1481 argv = (*[8192]*[8192]uint16)(unsafe.Pointer(r0)) 1482 if argv == nil { 1483 if e1 != 0 { 1484 err = errnoErr(e1) 1485 } else { 1486 err = syscall.EINVAL 1487 } 1488 } 1489 return 1490 } 1491 1492 func LocalFree(hmem Handle) (handle Handle, err error) { 1493 r0, _, e1 := syscall.Syscall(procLocalFree.Addr(), 1, uintptr(hmem), 0, 0) 1494 handle = Handle(r0) 1495 if handle != 0 { 1496 if e1 != 0 { 1497 err = errnoErr(e1) 1498 } else { 1499 err = syscall.EINVAL 1500 } 1501 } 1502 return 1503 } 1504 1505 func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error) { 1506 r1, _, e1 := syscall.Syscall(procSetHandleInformation.Addr(), 3, uintptr(handle), uintptr(mask), uintptr(flags)) 1507 if r1 == 0 { 1508 if e1 != 0 { 1509 err = errnoErr(e1) 1510 } else { 1511 err = syscall.EINVAL 1512 } 1513 } 1514 return 1515 } 1516 1517 func FlushFileBuffers(handle Handle) (err error) { 1518 r1, _, e1 := syscall.Syscall(procFlushFileBuffers.Addr(), 1, uintptr(handle), 0, 0) 1519 if r1 == 0 { 1520 if e1 != 0 { 1521 err = errnoErr(e1) 1522 } else { 1523 err = syscall.EINVAL 1524 } 1525 } 1526 return 1527 } 1528 1529 func GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) (n uint32, err error) { 1530 r0, _, e1 := syscall.Syscall6(procGetFullPathNameW.Addr(), 4, uintptr(unsafe.Pointer(path)), uintptr(buflen), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(fname)), 0, 0) 1531 n = uint32(r0) 1532 if n == 0 { 1533 if e1 != 0 { 1534 err = errnoErr(e1) 1535 } else { 1536 err = syscall.EINVAL 1537 } 1538 } 1539 return 1540 } 1541 1542 func GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err error) { 1543 r0, _, e1 := syscall.Syscall(procGetLongPathNameW.Addr(), 3, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(buf)), uintptr(buflen)) 1544 n = uint32(r0) 1545 if n == 0 { 1546 if e1 != 0 { 1547 err = errnoErr(e1) 1548 } else { 1549 err = syscall.EINVAL 1550 } 1551 } 1552 return 1553 } 1554 1555 func GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uint32, err error) { 1556 r0, _, e1 := syscall.Syscall(procGetShortPathNameW.Addr(), 3, uintptr(unsafe.Pointer(longpath)), uintptr(unsafe.Pointer(shortpath)), uintptr(buflen)) 1557 n = uint32(r0) 1558 if n == 0 { 1559 if e1 != 0 { 1560 err = errnoErr(e1) 1561 } else { 1562 err = syscall.EINVAL 1563 } 1564 } 1565 return 1566 } 1567 1568 func CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error) { 1569 r0, _, e1 := syscall.Syscall6(procCreateFileMappingW.Addr(), 6, uintptr(fhandle), uintptr(unsafe.Pointer(sa)), uintptr(prot), uintptr(maxSizeHigh), uintptr(maxSizeLow), uintptr(unsafe.Pointer(name))) 1570 handle = Handle(r0) 1571 if handle == 0 { 1572 if e1 != 0 { 1573 err = errnoErr(e1) 1574 } else { 1575 err = syscall.EINVAL 1576 } 1577 } 1578 return 1579 } 1580 1581 func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow uint32, length uintptr) (addr uintptr, err error) { 1582 r0, _, e1 := syscall.Syscall6(procMapViewOfFile.Addr(), 5, uintptr(handle), uintptr(access), uintptr(offsetHigh), uintptr(offsetLow), uintptr(length), 0) 1583 addr = uintptr(r0) 1584 if addr == 0 { 1585 if e1 != 0 { 1586 err = errnoErr(e1) 1587 } else { 1588 err = syscall.EINVAL 1589 } 1590 } 1591 return 1592 } 1593 1594 func UnmapViewOfFile(addr uintptr) (err error) { 1595 r1, _, e1 := syscall.Syscall(procUnmapViewOfFile.Addr(), 1, uintptr(addr), 0, 0) 1596 if r1 == 0 { 1597 if e1 != 0 { 1598 err = errnoErr(e1) 1599 } else { 1600 err = syscall.EINVAL 1601 } 1602 } 1603 return 1604 } 1605 1606 func FlushViewOfFile(addr uintptr, length uintptr) (err error) { 1607 r1, _, e1 := syscall.Syscall(procFlushViewOfFile.Addr(), 2, uintptr(addr), uintptr(length), 0) 1608 if r1 == 0 { 1609 if e1 != 0 { 1610 err = errnoErr(e1) 1611 } else { 1612 err = syscall.EINVAL 1613 } 1614 } 1615 return 1616 } 1617 1618 func VirtualLock(addr uintptr, length uintptr) (err error) { 1619 r1, _, e1 := syscall.Syscall(procVirtualLock.Addr(), 2, uintptr(addr), uintptr(length), 0) 1620 if r1 == 0 { 1621 if e1 != 0 { 1622 err = errnoErr(e1) 1623 } else { 1624 err = syscall.EINVAL 1625 } 1626 } 1627 return 1628 } 1629 1630 func VirtualUnlock(addr uintptr, length uintptr) (err error) { 1631 r1, _, e1 := syscall.Syscall(procVirtualUnlock.Addr(), 2, uintptr(addr), uintptr(length), 0) 1632 if r1 == 0 { 1633 if e1 != 0 { 1634 err = errnoErr(e1) 1635 } else { 1636 err = syscall.EINVAL 1637 } 1638 } 1639 return 1640 } 1641 1642 func VirtualAlloc(address uintptr, size uintptr, alloctype uint32, protect uint32) (value uintptr, err error) { 1643 r0, _, e1 := syscall.Syscall6(procVirtualAlloc.Addr(), 4, uintptr(address), uintptr(size), uintptr(alloctype), uintptr(protect), 0, 0) 1644 value = uintptr(r0) 1645 if value == 0 { 1646 if e1 != 0 { 1647 err = errnoErr(e1) 1648 } else { 1649 err = syscall.EINVAL 1650 } 1651 } 1652 return 1653 } 1654 1655 func VirtualFree(address uintptr, size uintptr, freetype uint32) (err error) { 1656 r1, _, e1 := syscall.Syscall(procVirtualFree.Addr(), 3, uintptr(address), uintptr(size), uintptr(freetype)) 1657 if r1 == 0 { 1658 if e1 != 0 { 1659 err = errnoErr(e1) 1660 } else { 1661 err = syscall.EINVAL 1662 } 1663 } 1664 return 1665 } 1666 1667 func VirtualProtect(address uintptr, size uintptr, newprotect uint32, oldprotect *uint32) (err error) { 1668 r1, _, e1 := syscall.Syscall6(procVirtualProtect.Addr(), 4, uintptr(address), uintptr(size), uintptr(newprotect), uintptr(unsafe.Pointer(oldprotect)), 0, 0) 1669 if r1 == 0 { 1670 if e1 != 0 { 1671 err = errnoErr(e1) 1672 } else { 1673 err = syscall.EINVAL 1674 } 1675 } 1676 return 1677 } 1678 1679 func TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) { 1680 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) 1681 if r1 == 0 { 1682 if e1 != 0 { 1683 err = errnoErr(e1) 1684 } else { 1685 err = syscall.EINVAL 1686 } 1687 } 1688 return 1689 } 1690 1691 func ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) { 1692 var _p0 uint32 1693 if watchSubTree { 1694 _p0 = 1 1695 } else { 1696 _p0 = 0 1697 } 1698 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) 1699 if r1 == 0 { 1700 if e1 != 0 { 1701 err = errnoErr(e1) 1702 } else { 1703 err = syscall.EINVAL 1704 } 1705 } 1706 return 1707 } 1708 1709 func CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) { 1710 r0, _, e1 := syscall.Syscall(procCertOpenSystemStoreW.Addr(), 2, uintptr(hprov), uintptr(unsafe.Pointer(name)), 0) 1711 store = Handle(r0) 1712 if store == 0 { 1713 if e1 != 0 { 1714 err = errnoErr(e1) 1715 } else { 1716 err = syscall.EINVAL 1717 } 1718 } 1719 return 1720 } 1721 1722 func CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) { 1723 r0, _, e1 := syscall.Syscall6(procCertOpenStore.Addr(), 5, uintptr(storeProvider), uintptr(msgAndCertEncodingType), uintptr(cryptProv), uintptr(flags), uintptr(para), 0) 1724 handle = Handle(r0) 1725 if handle == InvalidHandle { 1726 if e1 != 0 { 1727 err = errnoErr(e1) 1728 } else { 1729 err = syscall.EINVAL 1730 } 1731 } 1732 return 1733 } 1734 1735 func CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) { 1736 r0, _, e1 := syscall.Syscall(procCertEnumCertificatesInStore.Addr(), 2, uintptr(store), uintptr(unsafe.Pointer(prevContext)), 0) 1737 context = (*CertContext)(unsafe.Pointer(r0)) 1738 if context == nil { 1739 if e1 != 0 { 1740 err = errnoErr(e1) 1741 } else { 1742 err = syscall.EINVAL 1743 } 1744 } 1745 return 1746 } 1747 1748 func CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) { 1749 r1, _, e1 := syscall.Syscall6(procCertAddCertificateContextToStore.Addr(), 4, uintptr(store), uintptr(unsafe.Pointer(certContext)), uintptr(addDisposition), uintptr(unsafe.Pointer(storeContext)), 0, 0) 1750 if r1 == 0 { 1751 if e1 != 0 { 1752 err = errnoErr(e1) 1753 } else { 1754 err = syscall.EINVAL 1755 } 1756 } 1757 return 1758 } 1759 1760 func CertCloseStore(store Handle, flags uint32) (err error) { 1761 r1, _, e1 := syscall.Syscall(procCertCloseStore.Addr(), 2, uintptr(store), uintptr(flags), 0) 1762 if r1 == 0 { 1763 if e1 != 0 { 1764 err = errnoErr(e1) 1765 } else { 1766 err = syscall.EINVAL 1767 } 1768 } 1769 return 1770 } 1771 1772 func CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) { 1773 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) 1774 if r1 == 0 { 1775 if e1 != 0 { 1776 err = errnoErr(e1) 1777 } else { 1778 err = syscall.EINVAL 1779 } 1780 } 1781 return 1782 } 1783 1784 func CertFreeCertificateChain(ctx *CertChainContext) { 1785 syscall.Syscall(procCertFreeCertificateChain.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0) 1786 return 1787 } 1788 1789 func CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, encodedLen uint32) (context *CertContext, err error) { 1790 r0, _, e1 := syscall.Syscall(procCertCreateCertificateContext.Addr(), 3, uintptr(certEncodingType), uintptr(unsafe.Pointer(certEncoded)), uintptr(encodedLen)) 1791 context = (*CertContext)(unsafe.Pointer(r0)) 1792 if context == nil { 1793 if e1 != 0 { 1794 err = errnoErr(e1) 1795 } else { 1796 err = syscall.EINVAL 1797 } 1798 } 1799 return 1800 } 1801 1802 func CertFreeCertificateContext(ctx *CertContext) (err error) { 1803 r1, _, e1 := syscall.Syscall(procCertFreeCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0) 1804 if r1 == 0 { 1805 if e1 != 0 { 1806 err = errnoErr(e1) 1807 } else { 1808 err = syscall.EINVAL 1809 } 1810 } 1811 return 1812 } 1813 1814 func CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) { 1815 r1, _, e1 := syscall.Syscall6(procCertVerifyCertificateChainPolicy.Addr(), 4, uintptr(policyOID), uintptr(unsafe.Pointer(chain)), uintptr(unsafe.Pointer(para)), uintptr(unsafe.Pointer(status)), 0, 0) 1816 if r1 == 0 { 1817 if e1 != 0 { 1818 err = errnoErr(e1) 1819 } else { 1820 err = syscall.EINVAL 1821 } 1822 } 1823 return 1824 } 1825 1826 func RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno error) { 1827 r0, _, _ := syscall.Syscall6(procRegOpenKeyExW.Addr(), 5, uintptr(key), uintptr(unsafe.Pointer(subkey)), uintptr(options), uintptr(desiredAccess), uintptr(unsafe.Pointer(result)), 0) 1828 if r0 != 0 { 1829 regerrno = syscall.Errno(r0) 1830 } 1831 return 1832 } 1833 1834 func RegCloseKey(key Handle) (regerrno error) { 1835 r0, _, _ := syscall.Syscall(procRegCloseKey.Addr(), 1, uintptr(key), 0, 0) 1836 if r0 != 0 { 1837 regerrno = syscall.Errno(r0) 1838 } 1839 return 1840 } 1841 1842 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) { 1843 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))) 1844 if r0 != 0 { 1845 regerrno = syscall.Errno(r0) 1846 } 1847 return 1848 } 1849 1850 func RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) { 1851 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) 1852 if r0 != 0 { 1853 regerrno = syscall.Errno(r0) 1854 } 1855 return 1856 } 1857 1858 func RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) { 1859 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))) 1860 if r0 != 0 { 1861 regerrno = syscall.Errno(r0) 1862 } 1863 return 1864 } 1865 1866 func GetCurrentProcessId() (pid uint32) { 1867 r0, _, _ := syscall.Syscall(procGetCurrentProcessId.Addr(), 0, 0, 0, 0) 1868 pid = uint32(r0) 1869 return 1870 } 1871 1872 func GetConsoleMode(console Handle, mode *uint32) (err error) { 1873 r1, _, e1 := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0) 1874 if r1 == 0 { 1875 if e1 != 0 { 1876 err = errnoErr(e1) 1877 } else { 1878 err = syscall.EINVAL 1879 } 1880 } 1881 return 1882 } 1883 1884 func SetConsoleMode(console Handle, mode uint32) (err error) { 1885 r1, _, e1 := syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(console), uintptr(mode), 0) 1886 if r1 == 0 { 1887 if e1 != 0 { 1888 err = errnoErr(e1) 1889 } else { 1890 err = syscall.EINVAL 1891 } 1892 } 1893 return 1894 } 1895 1896 func GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) { 1897 r1, _, e1 := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(info)), 0) 1898 if r1 == 0 { 1899 if e1 != 0 { 1900 err = errnoErr(e1) 1901 } else { 1902 err = syscall.EINVAL 1903 } 1904 } 1905 return 1906 } 1907 1908 func WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) { 1909 r1, _, e1 := syscall.Syscall6(procWriteConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(towrite), uintptr(unsafe.Pointer(written)), uintptr(unsafe.Pointer(reserved)), 0) 1910 if r1 == 0 { 1911 if e1 != 0 { 1912 err = errnoErr(e1) 1913 } else { 1914 err = syscall.EINVAL 1915 } 1916 } 1917 return 1918 } 1919 1920 func ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) { 1921 r1, _, e1 := syscall.Syscall6(procReadConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(toread), uintptr(unsafe.Pointer(read)), uintptr(unsafe.Pointer(inputControl)), 0) 1922 if r1 == 0 { 1923 if e1 != 0 { 1924 err = errnoErr(e1) 1925 } else { 1926 err = syscall.EINVAL 1927 } 1928 } 1929 return 1930 } 1931 1932 func CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) { 1933 r0, _, e1 := syscall.Syscall(procCreateToolhelp32Snapshot.Addr(), 2, uintptr(flags), uintptr(processId), 0) 1934 handle = Handle(r0) 1935 if handle == InvalidHandle { 1936 if e1 != 0 { 1937 err = errnoErr(e1) 1938 } else { 1939 err = syscall.EINVAL 1940 } 1941 } 1942 return 1943 } 1944 1945 func Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) { 1946 r1, _, e1 := syscall.Syscall(procProcess32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0) 1947 if r1 == 0 { 1948 if e1 != 0 { 1949 err = errnoErr(e1) 1950 } else { 1951 err = syscall.EINVAL 1952 } 1953 } 1954 return 1955 } 1956 1957 func Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) { 1958 r1, _, e1 := syscall.Syscall(procProcess32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0) 1959 if r1 == 0 { 1960 if e1 != 0 { 1961 err = errnoErr(e1) 1962 } else { 1963 err = syscall.EINVAL 1964 } 1965 } 1966 return 1967 } 1968 1969 func Thread32First(snapshot Handle, threadEntry *ThreadEntry32) (err error) { 1970 r1, _, e1 := syscall.Syscall(procThread32First.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(threadEntry)), 0) 1971 if r1 == 0 { 1972 if e1 != 0 { 1973 err = errnoErr(e1) 1974 } else { 1975 err = syscall.EINVAL 1976 } 1977 } 1978 return 1979 } 1980 1981 func Thread32Next(snapshot Handle, threadEntry *ThreadEntry32) (err error) { 1982 r1, _, e1 := syscall.Syscall(procThread32Next.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(threadEntry)), 0) 1983 if r1 == 0 { 1984 if e1 != 0 { 1985 err = errnoErr(e1) 1986 } else { 1987 err = syscall.EINVAL 1988 } 1989 } 1990 return 1991 } 1992 1993 func DeviceIoControl(handle Handle, ioControlCode uint32, inBuffer *byte, inBufferSize uint32, outBuffer *byte, outBufferSize uint32, bytesReturned *uint32, overlapped *Overlapped) (err error) { 1994 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) 1995 if r1 == 0 { 1996 if e1 != 0 { 1997 err = errnoErr(e1) 1998 } else { 1999 err = syscall.EINVAL 2000 } 2001 } 2002 return 2003 } 2004 2005 func CreateSymbolicLink(symlinkfilename *uint16, targetfilename *uint16, flags uint32) (err error) { 2006 r1, _, e1 := syscall.Syscall(procCreateSymbolicLinkW.Addr(), 3, uintptr(unsafe.Pointer(symlinkfilename)), uintptr(unsafe.Pointer(targetfilename)), uintptr(flags)) 2007 if r1&0xff == 0 { 2008 if e1 != 0 { 2009 err = errnoErr(e1) 2010 } else { 2011 err = syscall.EINVAL 2012 } 2013 } 2014 return 2015 } 2016 2017 func CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr) (err error) { 2018 r1, _, e1 := syscall.Syscall(procCreateHardLinkW.Addr(), 3, uintptr(unsafe.Pointer(filename)), uintptr(unsafe.Pointer(existingfilename)), uintptr(reserved)) 2019 if r1&0xff == 0 { 2020 if e1 != 0 { 2021 err = errnoErr(e1) 2022 } else { 2023 err = syscall.EINVAL 2024 } 2025 } 2026 return 2027 } 2028 2029 func GetCurrentThreadId() (id uint32) { 2030 r0, _, _ := syscall.Syscall(procGetCurrentThreadId.Addr(), 0, 0, 0, 0) 2031 id = uint32(r0) 2032 return 2033 } 2034 2035 func CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) { 2036 r0, _, e1 := syscall.Syscall6(procCreateEventW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(manualReset), uintptr(initialState), uintptr(unsafe.Pointer(name)), 0, 0) 2037 handle = Handle(r0) 2038 if handle == 0 { 2039 if e1 != 0 { 2040 err = errnoErr(e1) 2041 } else { 2042 err = syscall.EINVAL 2043 } 2044 } 2045 return 2046 } 2047 2048 func CreateEventEx(eventAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) { 2049 r0, _, e1 := syscall.Syscall6(procCreateEventExW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(desiredAccess), 0, 0) 2050 handle = Handle(r0) 2051 if handle == 0 { 2052 if e1 != 0 { 2053 err = errnoErr(e1) 2054 } else { 2055 err = syscall.EINVAL 2056 } 2057 } 2058 return 2059 } 2060 2061 func OpenEvent(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) { 2062 var _p0 uint32 2063 if inheritHandle { 2064 _p0 = 1 2065 } else { 2066 _p0 = 0 2067 } 2068 r0, _, e1 := syscall.Syscall(procOpenEventW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name))) 2069 handle = Handle(r0) 2070 if handle == 0 { 2071 if e1 != 0 { 2072 err = errnoErr(e1) 2073 } else { 2074 err = syscall.EINVAL 2075 } 2076 } 2077 return 2078 } 2079 2080 func SetEvent(event Handle) (err error) { 2081 r1, _, e1 := syscall.Syscall(procSetEvent.Addr(), 1, uintptr(event), 0, 0) 2082 if r1 == 0 { 2083 if e1 != 0 { 2084 err = errnoErr(e1) 2085 } else { 2086 err = syscall.EINVAL 2087 } 2088 } 2089 return 2090 } 2091 2092 func ResetEvent(event Handle) (err error) { 2093 r1, _, e1 := syscall.Syscall(procResetEvent.Addr(), 1, uintptr(event), 0, 0) 2094 if r1 == 0 { 2095 if e1 != 0 { 2096 err = errnoErr(e1) 2097 } else { 2098 err = syscall.EINVAL 2099 } 2100 } 2101 return 2102 } 2103 2104 func PulseEvent(event Handle) (err error) { 2105 r1, _, e1 := syscall.Syscall(procPulseEvent.Addr(), 1, uintptr(event), 0, 0) 2106 if r1 == 0 { 2107 if e1 != 0 { 2108 err = errnoErr(e1) 2109 } else { 2110 err = syscall.EINVAL 2111 } 2112 } 2113 return 2114 } 2115 2116 func CreateMutex(mutexAttrs *SecurityAttributes, initialOwner bool, name *uint16) (handle Handle, err error) { 2117 var _p0 uint32 2118 if initialOwner { 2119 _p0 = 1 2120 } else { 2121 _p0 = 0 2122 } 2123 r0, _, e1 := syscall.Syscall(procCreateMutexW.Addr(), 3, uintptr(unsafe.Pointer(mutexAttrs)), uintptr(_p0), uintptr(unsafe.Pointer(name))) 2124 handle = Handle(r0) 2125 if handle == 0 { 2126 if e1 != 0 { 2127 err = errnoErr(e1) 2128 } else { 2129 err = syscall.EINVAL 2130 } 2131 } 2132 return 2133 } 2134 2135 func CreateMutexEx(mutexAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) { 2136 r0, _, e1 := syscall.Syscall6(procCreateMutexExW.Addr(), 4, uintptr(unsafe.Pointer(mutexAttrs)), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(desiredAccess), 0, 0) 2137 handle = Handle(r0) 2138 if handle == 0 { 2139 if e1 != 0 { 2140 err = errnoErr(e1) 2141 } else { 2142 err = syscall.EINVAL 2143 } 2144 } 2145 return 2146 } 2147 2148 func OpenMutex(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) { 2149 var _p0 uint32 2150 if inheritHandle { 2151 _p0 = 1 2152 } else { 2153 _p0 = 0 2154 } 2155 r0, _, e1 := syscall.Syscall(procOpenMutexW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name))) 2156 handle = Handle(r0) 2157 if handle == 0 { 2158 if e1 != 0 { 2159 err = errnoErr(e1) 2160 } else { 2161 err = syscall.EINVAL 2162 } 2163 } 2164 return 2165 } 2166 2167 func ReleaseMutex(mutex Handle) (err error) { 2168 r1, _, e1 := syscall.Syscall(procReleaseMutex.Addr(), 1, uintptr(mutex), 0, 0) 2169 if r1 == 0 { 2170 if e1 != 0 { 2171 err = errnoErr(e1) 2172 } else { 2173 err = syscall.EINVAL 2174 } 2175 } 2176 return 2177 } 2178 2179 func SleepEx(milliseconds uint32, alertable bool) (ret uint32) { 2180 var _p0 uint32 2181 if alertable { 2182 _p0 = 1 2183 } else { 2184 _p0 = 0 2185 } 2186 r0, _, _ := syscall.Syscall(procSleepEx.Addr(), 2, uintptr(milliseconds), uintptr(_p0), 0) 2187 ret = uint32(r0) 2188 return 2189 } 2190 2191 func CreateJobObject(jobAttr *SecurityAttributes, name *uint16) (handle Handle, err error) { 2192 r0, _, e1 := syscall.Syscall(procCreateJobObjectW.Addr(), 2, uintptr(unsafe.Pointer(jobAttr)), uintptr(unsafe.Pointer(name)), 0) 2193 handle = Handle(r0) 2194 if handle == 0 { 2195 if e1 != 0 { 2196 err = errnoErr(e1) 2197 } else { 2198 err = syscall.EINVAL 2199 } 2200 } 2201 return 2202 } 2203 2204 func AssignProcessToJobObject(job Handle, process Handle) (err error) { 2205 r1, _, e1 := syscall.Syscall(procAssignProcessToJobObject.Addr(), 2, uintptr(job), uintptr(process), 0) 2206 if r1 == 0 { 2207 if e1 != 0 { 2208 err = errnoErr(e1) 2209 } else { 2210 err = syscall.EINVAL 2211 } 2212 } 2213 return 2214 } 2215 2216 func TerminateJobObject(job Handle, exitCode uint32) (err error) { 2217 r1, _, e1 := syscall.Syscall(procTerminateJobObject.Addr(), 2, uintptr(job), uintptr(exitCode), 0) 2218 if r1 == 0 { 2219 if e1 != 0 { 2220 err = errnoErr(e1) 2221 } else { 2222 err = syscall.EINVAL 2223 } 2224 } 2225 return 2226 } 2227 2228 func SetErrorMode(mode uint32) (ret uint32) { 2229 r0, _, _ := syscall.Syscall(procSetErrorMode.Addr(), 1, uintptr(mode), 0, 0) 2230 ret = uint32(r0) 2231 return 2232 } 2233 2234 func ResumeThread(thread Handle) (ret uint32, err error) { 2235 r0, _, e1 := syscall.Syscall(procResumeThread.Addr(), 1, uintptr(thread), 0, 0) 2236 ret = uint32(r0) 2237 if ret == 0xffffffff { 2238 if e1 != 0 { 2239 err = errnoErr(e1) 2240 } else { 2241 err = syscall.EINVAL 2242 } 2243 } 2244 return 2245 } 2246 2247 func SetPriorityClass(process Handle, priorityClass uint32) (err error) { 2248 r1, _, e1 := syscall.Syscall(procSetPriorityClass.Addr(), 2, uintptr(process), uintptr(priorityClass), 0) 2249 if r1 == 0 { 2250 if e1 != 0 { 2251 err = errnoErr(e1) 2252 } else { 2253 err = syscall.EINVAL 2254 } 2255 } 2256 return 2257 } 2258 2259 func GetPriorityClass(process Handle) (ret uint32, err error) { 2260 r0, _, e1 := syscall.Syscall(procGetPriorityClass.Addr(), 1, uintptr(process), 0, 0) 2261 ret = uint32(r0) 2262 if ret == 0 { 2263 if e1 != 0 { 2264 err = errnoErr(e1) 2265 } else { 2266 err = syscall.EINVAL 2267 } 2268 } 2269 return 2270 } 2271 2272 func SetInformationJobObject(job Handle, JobObjectInformationClass uint32, JobObjectInformation uintptr, JobObjectInformationLength uint32) (ret int, err error) { 2273 r0, _, e1 := syscall.Syscall6(procSetInformationJobObject.Addr(), 4, uintptr(job), uintptr(JobObjectInformationClass), uintptr(JobObjectInformation), uintptr(JobObjectInformationLength), 0, 0) 2274 ret = int(r0) 2275 if ret == 0 { 2276 if e1 != 0 { 2277 err = errnoErr(e1) 2278 } else { 2279 err = syscall.EINVAL 2280 } 2281 } 2282 return 2283 } 2284 2285 func GenerateConsoleCtrlEvent(ctrlEvent uint32, processGroupID uint32) (err error) { 2286 r1, _, e1 := syscall.Syscall(procGenerateConsoleCtrlEvent.Addr(), 2, uintptr(ctrlEvent), uintptr(processGroupID), 0) 2287 if r1 == 0 { 2288 if e1 != 0 { 2289 err = errnoErr(e1) 2290 } else { 2291 err = syscall.EINVAL 2292 } 2293 } 2294 return 2295 } 2296 2297 func GetProcessId(process Handle) (id uint32, err error) { 2298 r0, _, e1 := syscall.Syscall(procGetProcessId.Addr(), 1, uintptr(process), 0, 0) 2299 id = uint32(r0) 2300 if id == 0 { 2301 if e1 != 0 { 2302 err = errnoErr(e1) 2303 } else { 2304 err = syscall.EINVAL 2305 } 2306 } 2307 return 2308 } 2309 2310 func OpenThread(desiredAccess uint32, inheritHandle bool, threadId uint32) (handle Handle, err error) { 2311 var _p0 uint32 2312 if inheritHandle { 2313 _p0 = 1 2314 } else { 2315 _p0 = 0 2316 } 2317 r0, _, e1 := syscall.Syscall(procOpenThread.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(threadId)) 2318 handle = Handle(r0) 2319 if handle == 0 { 2320 if e1 != 0 { 2321 err = errnoErr(e1) 2322 } else { 2323 err = syscall.EINVAL 2324 } 2325 } 2326 return 2327 } 2328 2329 func SetProcessPriorityBoost(process Handle, disable bool) (err error) { 2330 var _p0 uint32 2331 if disable { 2332 _p0 = 1 2333 } else { 2334 _p0 = 0 2335 } 2336 r1, _, e1 := syscall.Syscall(procSetProcessPriorityBoost.Addr(), 2, uintptr(process), uintptr(_p0), 0) 2337 if r1 == 0 { 2338 if e1 != 0 { 2339 err = errnoErr(e1) 2340 } else { 2341 err = syscall.EINVAL 2342 } 2343 } 2344 return 2345 } 2346 2347 func DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) { 2348 r1, _, e1 := syscall.Syscall(procDefineDosDeviceW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath))) 2349 if r1 == 0 { 2350 if e1 != 0 { 2351 err = errnoErr(e1) 2352 } else { 2353 err = syscall.EINVAL 2354 } 2355 } 2356 return 2357 } 2358 2359 func DeleteVolumeMountPoint(volumeMountPoint *uint16) (err error) { 2360 r1, _, e1 := syscall.Syscall(procDeleteVolumeMountPointW.Addr(), 1, uintptr(unsafe.Pointer(volumeMountPoint)), 0, 0) 2361 if r1 == 0 { 2362 if e1 != 0 { 2363 err = errnoErr(e1) 2364 } else { 2365 err = syscall.EINVAL 2366 } 2367 } 2368 return 2369 } 2370 2371 func FindFirstVolume(volumeName *uint16, bufferLength uint32) (handle Handle, err error) { 2372 r0, _, e1 := syscall.Syscall(procFindFirstVolumeW.Addr(), 2, uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength), 0) 2373 handle = Handle(r0) 2374 if handle == InvalidHandle { 2375 if e1 != 0 { 2376 err = errnoErr(e1) 2377 } else { 2378 err = syscall.EINVAL 2379 } 2380 } 2381 return 2382 } 2383 2384 func FindFirstVolumeMountPoint(rootPathName *uint16, volumeMountPoint *uint16, bufferLength uint32) (handle Handle, err error) { 2385 r0, _, e1 := syscall.Syscall(procFindFirstVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength)) 2386 handle = Handle(r0) 2387 if handle == InvalidHandle { 2388 if e1 != 0 { 2389 err = errnoErr(e1) 2390 } else { 2391 err = syscall.EINVAL 2392 } 2393 } 2394 return 2395 } 2396 2397 func FindNextVolume(findVolume Handle, volumeName *uint16, bufferLength uint32) (err error) { 2398 r1, _, e1 := syscall.Syscall(procFindNextVolumeW.Addr(), 3, uintptr(findVolume), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength)) 2399 if r1 == 0 { 2400 if e1 != 0 { 2401 err = errnoErr(e1) 2402 } else { 2403 err = syscall.EINVAL 2404 } 2405 } 2406 return 2407 } 2408 2409 func FindNextVolumeMountPoint(findVolumeMountPoint Handle, volumeMountPoint *uint16, bufferLength uint32) (err error) { 2410 r1, _, e1 := syscall.Syscall(procFindNextVolumeMountPointW.Addr(), 3, uintptr(findVolumeMountPoint), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength)) 2411 if r1 == 0 { 2412 if e1 != 0 { 2413 err = errnoErr(e1) 2414 } else { 2415 err = syscall.EINVAL 2416 } 2417 } 2418 return 2419 } 2420 2421 func FindVolumeClose(findVolume Handle) (err error) { 2422 r1, _, e1 := syscall.Syscall(procFindVolumeClose.Addr(), 1, uintptr(findVolume), 0, 0) 2423 if r1 == 0 { 2424 if e1 != 0 { 2425 err = errnoErr(e1) 2426 } else { 2427 err = syscall.EINVAL 2428 } 2429 } 2430 return 2431 } 2432 2433 func FindVolumeMountPointClose(findVolumeMountPoint Handle) (err error) { 2434 r1, _, e1 := syscall.Syscall(procFindVolumeMountPointClose.Addr(), 1, uintptr(findVolumeMountPoint), 0, 0) 2435 if r1 == 0 { 2436 if e1 != 0 { 2437 err = errnoErr(e1) 2438 } else { 2439 err = syscall.EINVAL 2440 } 2441 } 2442 return 2443 } 2444 2445 func GetDriveType(rootPathName *uint16) (driveType uint32) { 2446 r0, _, _ := syscall.Syscall(procGetDriveTypeW.Addr(), 1, uintptr(unsafe.Pointer(rootPathName)), 0, 0) 2447 driveType = uint32(r0) 2448 return 2449 } 2450 2451 func GetLogicalDrives() (drivesBitMask uint32, err error) { 2452 r0, _, e1 := syscall.Syscall(procGetLogicalDrives.Addr(), 0, 0, 0, 0) 2453 drivesBitMask = uint32(r0) 2454 if drivesBitMask == 0 { 2455 if e1 != 0 { 2456 err = errnoErr(e1) 2457 } else { 2458 err = syscall.EINVAL 2459 } 2460 } 2461 return 2462 } 2463 2464 func GetLogicalDriveStrings(bufferLength uint32, buffer *uint16) (n uint32, err error) { 2465 r0, _, e1 := syscall.Syscall(procGetLogicalDriveStringsW.Addr(), 2, uintptr(bufferLength), uintptr(unsafe.Pointer(buffer)), 0) 2466 n = uint32(r0) 2467 if n == 0 { 2468 if e1 != 0 { 2469 err = errnoErr(e1) 2470 } else { 2471 err = syscall.EINVAL 2472 } 2473 } 2474 return 2475 } 2476 2477 func GetVolumeInformation(rootPathName *uint16, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) { 2478 r1, _, e1 := syscall.Syscall9(procGetVolumeInformationW.Addr(), 8, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeNameBuffer)), uintptr(volumeNameSize), uintptr(unsafe.Pointer(volumeNameSerialNumber)), uintptr(unsafe.Pointer(maximumComponentLength)), uintptr(unsafe.Pointer(fileSystemFlags)), uintptr(unsafe.Pointer(fileSystemNameBuffer)), uintptr(fileSystemNameSize), 0) 2479 if r1 == 0 { 2480 if e1 != 0 { 2481 err = errnoErr(e1) 2482 } else { 2483 err = syscall.EINVAL 2484 } 2485 } 2486 return 2487 } 2488 2489 func GetVolumeInformationByHandle(file Handle, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) { 2490 r1, _, e1 := syscall.Syscall9(procGetVolumeInformationByHandleW.Addr(), 8, uintptr(file), uintptr(unsafe.Pointer(volumeNameBuffer)), uintptr(volumeNameSize), uintptr(unsafe.Pointer(volumeNameSerialNumber)), uintptr(unsafe.Pointer(maximumComponentLength)), uintptr(unsafe.Pointer(fileSystemFlags)), uintptr(unsafe.Pointer(fileSystemNameBuffer)), uintptr(fileSystemNameSize), 0) 2491 if r1 == 0 { 2492 if e1 != 0 { 2493 err = errnoErr(e1) 2494 } else { 2495 err = syscall.EINVAL 2496 } 2497 } 2498 return 2499 } 2500 2501 func GetVolumeNameForVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16, bufferlength uint32) (err error) { 2502 r1, _, e1 := syscall.Syscall(procGetVolumeNameForVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferlength)) 2503 if r1 == 0 { 2504 if e1 != 0 { 2505 err = errnoErr(e1) 2506 } else { 2507 err = syscall.EINVAL 2508 } 2509 } 2510 return 2511 } 2512 2513 func GetVolumePathName(fileName *uint16, volumePathName *uint16, bufferLength uint32) (err error) { 2514 r1, _, e1 := syscall.Syscall(procGetVolumePathNameW.Addr(), 3, uintptr(unsafe.Pointer(fileName)), uintptr(unsafe.Pointer(volumePathName)), uintptr(bufferLength)) 2515 if r1 == 0 { 2516 if e1 != 0 { 2517 err = errnoErr(e1) 2518 } else { 2519 err = syscall.EINVAL 2520 } 2521 } 2522 return 2523 } 2524 2525 func GetVolumePathNamesForVolumeName(volumeName *uint16, volumePathNames *uint16, bufferLength uint32, returnLength *uint32) (err error) { 2526 r1, _, e1 := syscall.Syscall6(procGetVolumePathNamesForVolumeNameW.Addr(), 4, uintptr(unsafe.Pointer(volumeName)), uintptr(unsafe.Pointer(volumePathNames)), uintptr(bufferLength), uintptr(unsafe.Pointer(returnLength)), 0, 0) 2527 if r1 == 0 { 2528 if e1 != 0 { 2529 err = errnoErr(e1) 2530 } else { 2531 err = syscall.EINVAL 2532 } 2533 } 2534 return 2535 } 2536 2537 func QueryDosDevice(deviceName *uint16, targetPath *uint16, max uint32) (n uint32, err error) { 2538 r0, _, e1 := syscall.Syscall(procQueryDosDeviceW.Addr(), 3, uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)), uintptr(max)) 2539 n = uint32(r0) 2540 if n == 0 { 2541 if e1 != 0 { 2542 err = errnoErr(e1) 2543 } else { 2544 err = syscall.EINVAL 2545 } 2546 } 2547 return 2548 } 2549 2550 func SetVolumeLabel(rootPathName *uint16, volumeName *uint16) (err error) { 2551 r1, _, e1 := syscall.Syscall(procSetVolumeLabelW.Addr(), 2, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeName)), 0) 2552 if r1 == 0 { 2553 if e1 != 0 { 2554 err = errnoErr(e1) 2555 } else { 2556 err = syscall.EINVAL 2557 } 2558 } 2559 return 2560 } 2561 2562 func SetVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16) (err error) { 2563 r1, _, e1 := syscall.Syscall(procSetVolumeMountPointW.Addr(), 2, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), 0) 2564 if r1 == 0 { 2565 if e1 != 0 { 2566 err = errnoErr(e1) 2567 } else { 2568 err = syscall.EINVAL 2569 } 2570 } 2571 return 2572 } 2573 2574 func MessageBox(hwnd Handle, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) { 2575 r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0) 2576 ret = int32(r0) 2577 if ret == 0 { 2578 if e1 != 0 { 2579 err = errnoErr(e1) 2580 } else { 2581 err = syscall.EINVAL 2582 } 2583 } 2584 return 2585 } 2586 2587 func clsidFromString(lpsz *uint16, pclsid *GUID) (ret error) { 2588 r0, _, _ := syscall.Syscall(procCLSIDFromString.Addr(), 2, uintptr(unsafe.Pointer(lpsz)), uintptr(unsafe.Pointer(pclsid)), 0) 2589 if r0 != 0 { 2590 ret = syscall.Errno(r0) 2591 } 2592 return 2593 } 2594 2595 func stringFromGUID2(rguid *GUID, lpsz *uint16, cchMax int32) (chars int32) { 2596 r0, _, _ := syscall.Syscall(procStringFromGUID2.Addr(), 3, uintptr(unsafe.Pointer(rguid)), uintptr(unsafe.Pointer(lpsz)), uintptr(cchMax)) 2597 chars = int32(r0) 2598 return 2599 } 2600 2601 func coCreateGuid(pguid *GUID) (ret error) { 2602 r0, _, _ := syscall.Syscall(procCoCreateGuid.Addr(), 1, uintptr(unsafe.Pointer(pguid)), 0, 0) 2603 if r0 != 0 { 2604 ret = syscall.Errno(r0) 2605 } 2606 return 2607 } 2608 2609 func CoTaskMemFree(address unsafe.Pointer) { 2610 syscall.Syscall(procCoTaskMemFree.Addr(), 1, uintptr(address), 0, 0) 2611 return 2612 } 2613 2614 func rtlGetVersion(info *OsVersionInfoEx) (ret error) { 2615 r0, _, _ := syscall.Syscall(procRtlGetVersion.Addr(), 1, uintptr(unsafe.Pointer(info)), 0, 0) 2616 if r0 != 0 { 2617 ret = syscall.Errno(r0) 2618 } 2619 return 2620 } 2621 2622 func rtlGetNtVersionNumbers(majorVersion *uint32, minorVersion *uint32, buildNumber *uint32) { 2623 syscall.Syscall(procRtlGetNtVersionNumbers.Addr(), 3, uintptr(unsafe.Pointer(majorVersion)), uintptr(unsafe.Pointer(minorVersion)), uintptr(unsafe.Pointer(buildNumber))) 2624 return 2625 } 2626 2627 func WSAStartup(verreq uint32, data *WSAData) (sockerr error) { 2628 r0, _, _ := syscall.Syscall(procWSAStartup.Addr(), 2, uintptr(verreq), uintptr(unsafe.Pointer(data)), 0) 2629 if r0 != 0 { 2630 sockerr = syscall.Errno(r0) 2631 } 2632 return 2633 } 2634 2635 func WSACleanup() (err error) { 2636 r1, _, e1 := syscall.Syscall(procWSACleanup.Addr(), 0, 0, 0, 0) 2637 if r1 == socket_error { 2638 if e1 != 0 { 2639 err = errnoErr(e1) 2640 } else { 2641 err = syscall.EINVAL 2642 } 2643 } 2644 return 2645 } 2646 2647 func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) { 2648 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)) 2649 if r1 == socket_error { 2650 if e1 != 0 { 2651 err = errnoErr(e1) 2652 } else { 2653 err = syscall.EINVAL 2654 } 2655 } 2656 return 2657 } 2658 2659 func socket(af int32, typ int32, protocol int32) (handle Handle, err error) { 2660 r0, _, e1 := syscall.Syscall(procsocket.Addr(), 3, uintptr(af), uintptr(typ), uintptr(protocol)) 2661 handle = Handle(r0) 2662 if handle == InvalidHandle { 2663 if e1 != 0 { 2664 err = errnoErr(e1) 2665 } else { 2666 err = syscall.EINVAL 2667 } 2668 } 2669 return 2670 } 2671 2672 func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) { 2673 r1, _, e1 := syscall.Syscall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(optlen), 0) 2674 if r1 == socket_error { 2675 if e1 != 0 { 2676 err = errnoErr(e1) 2677 } else { 2678 err = syscall.EINVAL 2679 } 2680 } 2681 return 2682 } 2683 2684 func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) { 2685 r1, _, e1 := syscall.Syscall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(unsafe.Pointer(optlen)), 0) 2686 if r1 == socket_error { 2687 if e1 != 0 { 2688 err = errnoErr(e1) 2689 } else { 2690 err = syscall.EINVAL 2691 } 2692 } 2693 return 2694 } 2695 2696 func bind(s Handle, name unsafe.Pointer, namelen int32) (err error) { 2697 r1, _, e1 := syscall.Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen)) 2698 if r1 == socket_error { 2699 if e1 != 0 { 2700 err = errnoErr(e1) 2701 } else { 2702 err = syscall.EINVAL 2703 } 2704 } 2705 return 2706 } 2707 2708 func connect(s Handle, name unsafe.Pointer, namelen int32) (err error) { 2709 r1, _, e1 := syscall.Syscall(procconnect.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen)) 2710 if r1 == socket_error { 2711 if e1 != 0 { 2712 err = errnoErr(e1) 2713 } else { 2714 err = syscall.EINVAL 2715 } 2716 } 2717 return 2718 } 2719 2720 func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) { 2721 r1, _, e1 := syscall.Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) 2722 if r1 == socket_error { 2723 if e1 != 0 { 2724 err = errnoErr(e1) 2725 } else { 2726 err = syscall.EINVAL 2727 } 2728 } 2729 return 2730 } 2731 2732 func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) { 2733 r1, _, e1 := syscall.Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) 2734 if r1 == socket_error { 2735 if e1 != 0 { 2736 err = errnoErr(e1) 2737 } else { 2738 err = syscall.EINVAL 2739 } 2740 } 2741 return 2742 } 2743 2744 func listen(s Handle, backlog int32) (err error) { 2745 r1, _, e1 := syscall.Syscall(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0) 2746 if r1 == socket_error { 2747 if e1 != 0 { 2748 err = errnoErr(e1) 2749 } else { 2750 err = syscall.EINVAL 2751 } 2752 } 2753 return 2754 } 2755 2756 func shutdown(s Handle, how int32) (err error) { 2757 r1, _, e1 := syscall.Syscall(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0) 2758 if r1 == socket_error { 2759 if e1 != 0 { 2760 err = errnoErr(e1) 2761 } else { 2762 err = syscall.EINVAL 2763 } 2764 } 2765 return 2766 } 2767 2768 func Closesocket(s Handle) (err error) { 2769 r1, _, e1 := syscall.Syscall(procclosesocket.Addr(), 1, uintptr(s), 0, 0) 2770 if r1 == socket_error { 2771 if e1 != 0 { 2772 err = errnoErr(e1) 2773 } else { 2774 err = syscall.EINVAL 2775 } 2776 } 2777 return 2778 } 2779 2780 func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) { 2781 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) 2782 if r1 == 0 { 2783 if e1 != 0 { 2784 err = errnoErr(e1) 2785 } else { 2786 err = syscall.EINVAL 2787 } 2788 } 2789 return 2790 } 2791 2792 func GetAcceptExSockaddrs(buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, lrsa **RawSockaddrAny, lrsalen *int32, rrsa **RawSockaddrAny, rrsalen *int32) { 2793 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) 2794 return 2795 } 2796 2797 func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) { 2798 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) 2799 if r1 == socket_error { 2800 if e1 != 0 { 2801 err = errnoErr(e1) 2802 } else { 2803 err = syscall.EINVAL 2804 } 2805 } 2806 return 2807 } 2808 2809 func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) { 2810 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) 2811 if r1 == socket_error { 2812 if e1 != 0 { 2813 err = errnoErr(e1) 2814 } else { 2815 err = syscall.EINVAL 2816 } 2817 } 2818 return 2819 } 2820 2821 func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) { 2822 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))) 2823 if r1 == socket_error { 2824 if e1 != 0 { 2825 err = errnoErr(e1) 2826 } else { 2827 err = syscall.EINVAL 2828 } 2829 } 2830 return 2831 } 2832 2833 func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) { 2834 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))) 2835 if r1 == socket_error { 2836 if e1 != 0 { 2837 err = errnoErr(e1) 2838 } else { 2839 err = syscall.EINVAL 2840 } 2841 } 2842 return 2843 } 2844 2845 func GetHostByName(name string) (h *Hostent, err error) { 2846 var _p0 *byte 2847 _p0, err = syscall.BytePtrFromString(name) 2848 if err != nil { 2849 return 2850 } 2851 return _GetHostByName(_p0) 2852 } 2853 2854 func _GetHostByName(name *byte) (h *Hostent, err error) { 2855 r0, _, e1 := syscall.Syscall(procgethostbyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0) 2856 h = (*Hostent)(unsafe.Pointer(r0)) 2857 if h == nil { 2858 if e1 != 0 { 2859 err = errnoErr(e1) 2860 } else { 2861 err = syscall.EINVAL 2862 } 2863 } 2864 return 2865 } 2866 2867 func GetServByName(name string, proto string) (s *Servent, err error) { 2868 var _p0 *byte 2869 _p0, err = syscall.BytePtrFromString(name) 2870 if err != nil { 2871 return 2872 } 2873 var _p1 *byte 2874 _p1, err = syscall.BytePtrFromString(proto) 2875 if err != nil { 2876 return 2877 } 2878 return _GetServByName(_p0, _p1) 2879 } 2880 2881 func _GetServByName(name *byte, proto *byte) (s *Servent, err error) { 2882 r0, _, e1 := syscall.Syscall(procgetservbyname.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(proto)), 0) 2883 s = (*Servent)(unsafe.Pointer(r0)) 2884 if s == nil { 2885 if e1 != 0 { 2886 err = errnoErr(e1) 2887 } else { 2888 err = syscall.EINVAL 2889 } 2890 } 2891 return 2892 } 2893 2894 func Ntohs(netshort uint16) (u uint16) { 2895 r0, _, _ := syscall.Syscall(procntohs.Addr(), 1, uintptr(netshort), 0, 0) 2896 u = uint16(r0) 2897 return 2898 } 2899 2900 func GetProtoByName(name string) (p *Protoent, err error) { 2901 var _p0 *byte 2902 _p0, err = syscall.BytePtrFromString(name) 2903 if err != nil { 2904 return 2905 } 2906 return _GetProtoByName(_p0) 2907 } 2908 2909 func _GetProtoByName(name *byte) (p *Protoent, err error) { 2910 r0, _, e1 := syscall.Syscall(procgetprotobyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0) 2911 p = (*Protoent)(unsafe.Pointer(r0)) 2912 if p == nil { 2913 if e1 != 0 { 2914 err = errnoErr(e1) 2915 } else { 2916 err = syscall.EINVAL 2917 } 2918 } 2919 return 2920 } 2921 2922 func DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) { 2923 var _p0 *uint16 2924 _p0, status = syscall.UTF16PtrFromString(name) 2925 if status != nil { 2926 return 2927 } 2928 return _DnsQuery(_p0, qtype, options, extra, qrs, pr) 2929 } 2930 2931 func _DnsQuery(name *uint16, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) { 2932 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))) 2933 if r0 != 0 { 2934 status = syscall.Errno(r0) 2935 } 2936 return 2937 } 2938 2939 func DnsRecordListFree(rl *DNSRecord, freetype uint32) { 2940 syscall.Syscall(procDnsRecordListFree.Addr(), 2, uintptr(unsafe.Pointer(rl)), uintptr(freetype), 0) 2941 return 2942 } 2943 2944 func DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) { 2945 r0, _, _ := syscall.Syscall(procDnsNameCompare_W.Addr(), 2, uintptr(unsafe.Pointer(name1)), uintptr(unsafe.Pointer(name2)), 0) 2946 same = r0 != 0 2947 return 2948 } 2949 2950 func GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) { 2951 r0, _, _ := syscall.Syscall6(procGetAddrInfoW.Addr(), 4, uintptr(unsafe.Pointer(nodename)), uintptr(unsafe.Pointer(servicename)), uintptr(unsafe.Pointer(hints)), uintptr(unsafe.Pointer(result)), 0, 0) 2952 if r0 != 0 { 2953 sockerr = syscall.Errno(r0) 2954 } 2955 return 2956 } 2957 2958 func FreeAddrInfoW(addrinfo *AddrinfoW) { 2959 syscall.Syscall(procFreeAddrInfoW.Addr(), 1, uintptr(unsafe.Pointer(addrinfo)), 0, 0) 2960 return 2961 } 2962 2963 func GetIfEntry(pIfRow *MibIfRow) (errcode error) { 2964 r0, _, _ := syscall.Syscall(procGetIfEntry.Addr(), 1, uintptr(unsafe.Pointer(pIfRow)), 0, 0) 2965 if r0 != 0 { 2966 errcode = syscall.Errno(r0) 2967 } 2968 return 2969 } 2970 2971 func GetAdaptersInfo(ai *IpAdapterInfo, ol *uint32) (errcode error) { 2972 r0, _, _ := syscall.Syscall(procGetAdaptersInfo.Addr(), 2, uintptr(unsafe.Pointer(ai)), uintptr(unsafe.Pointer(ol)), 0) 2973 if r0 != 0 { 2974 errcode = syscall.Errno(r0) 2975 } 2976 return 2977 } 2978 2979 func SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) { 2980 r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(handle), uintptr(flags), 0) 2981 if r1 == 0 { 2982 if e1 != 0 { 2983 err = errnoErr(e1) 2984 } else { 2985 err = syscall.EINVAL 2986 } 2987 } 2988 return 2989 } 2990 2991 func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferLength *uint32) (n int32, err error) { 2992 r0, _, e1 := syscall.Syscall(procWSAEnumProtocolsW.Addr(), 3, uintptr(unsafe.Pointer(protocols)), uintptr(unsafe.Pointer(protocolBuffer)), uintptr(unsafe.Pointer(bufferLength))) 2993 n = int32(r0) 2994 if n == -1 { 2995 if e1 != 0 { 2996 err = errnoErr(e1) 2997 } else { 2998 err = syscall.EINVAL 2999 } 3000 } 3001 return 3002 } 3003 3004 func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) { 3005 r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0) 3006 if r0 != 0 { 3007 errcode = syscall.Errno(r0) 3008 } 3009 return 3010 } 3011 3012 func GetACP() (acp uint32) { 3013 r0, _, _ := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0) 3014 acp = uint32(r0) 3015 return 3016 } 3017 3018 func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) { 3019 r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar)) 3020 nwrite = int32(r0) 3021 if nwrite == 0 { 3022 if e1 != 0 { 3023 err = errnoErr(e1) 3024 } else { 3025 err = syscall.EINVAL 3026 } 3027 } 3028 return 3029 } 3030 3031 func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint32, translatedName *uint16, nSize *uint32) (err error) { 3032 r1, _, e1 := syscall.Syscall6(procTranslateNameW.Addr(), 5, uintptr(unsafe.Pointer(accName)), uintptr(accNameFormat), uintptr(desiredNameFormat), uintptr(unsafe.Pointer(translatedName)), uintptr(unsafe.Pointer(nSize)), 0) 3033 if r1&0xff == 0 { 3034 if e1 != 0 { 3035 err = errnoErr(e1) 3036 } else { 3037 err = syscall.EINVAL 3038 } 3039 } 3040 return 3041 } 3042 3043 func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err error) { 3044 r1, _, e1 := syscall.Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize))) 3045 if r1&0xff == 0 { 3046 if e1 != 0 { 3047 err = errnoErr(e1) 3048 } else { 3049 err = syscall.EINVAL 3050 } 3051 } 3052 return 3053 } 3054 3055 func NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **byte) (neterr error) { 3056 r0, _, _ := syscall.Syscall6(procNetUserGetInfo.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(userName)), uintptr(level), uintptr(unsafe.Pointer(buf)), 0, 0) 3057 if r0 != 0 { 3058 neterr = syscall.Errno(r0) 3059 } 3060 return 3061 } 3062 3063 func NetGetJoinInformation(server *uint16, name **uint16, bufType *uint32) (neterr error) { 3064 r0, _, _ := syscall.Syscall(procNetGetJoinInformation.Addr(), 3, uintptr(unsafe.Pointer(server)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(bufType))) 3065 if r0 != 0 { 3066 neterr = syscall.Errno(r0) 3067 } 3068 return 3069 } 3070 3071 func NetApiBufferFree(buf *byte) (neterr error) { 3072 r0, _, _ := syscall.Syscall(procNetApiBufferFree.Addr(), 1, uintptr(unsafe.Pointer(buf)), 0, 0) 3073 if r0 != 0 { 3074 neterr = syscall.Errno(r0) 3075 } 3076 return 3077 } 3078 3079 func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) { 3080 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) 3081 if r1 == 0 { 3082 if e1 != 0 { 3083 err = errnoErr(e1) 3084 } else { 3085 err = syscall.EINVAL 3086 } 3087 } 3088 return 3089 } 3090 3091 func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) { 3092 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) 3093 if r1 == 0 { 3094 if e1 != 0 { 3095 err = errnoErr(e1) 3096 } else { 3097 err = syscall.EINVAL 3098 } 3099 } 3100 return 3101 } 3102 3103 func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) { 3104 r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(stringSid)), 0) 3105 if r1 == 0 { 3106 if e1 != 0 { 3107 err = errnoErr(e1) 3108 } else { 3109 err = syscall.EINVAL 3110 } 3111 } 3112 return 3113 } 3114 3115 func ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) { 3116 r1, _, e1 := syscall.Syscall(procConvertStringSidToSidW.Addr(), 2, uintptr(unsafe.Pointer(stringSid)), uintptr(unsafe.Pointer(sid)), 0) 3117 if r1 == 0 { 3118 if e1 != 0 { 3119 err = errnoErr(e1) 3120 } else { 3121 err = syscall.EINVAL 3122 } 3123 } 3124 return 3125 } 3126 3127 func GetLengthSid(sid *SID) (len uint32) { 3128 r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) 3129 len = uint32(r0) 3130 return 3131 } 3132 3133 func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) { 3134 r1, _, e1 := syscall.Syscall(procCopySid.Addr(), 3, uintptr(destSidLen), uintptr(unsafe.Pointer(destSid)), uintptr(unsafe.Pointer(srcSid))) 3135 if r1 == 0 { 3136 if e1 != 0 { 3137 err = errnoErr(e1) 3138 } else { 3139 err = syscall.EINVAL 3140 } 3141 } 3142 return 3143 } 3144 3145 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) { 3146 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) 3147 if r1 == 0 { 3148 if e1 != 0 { 3149 err = errnoErr(e1) 3150 } else { 3151 err = syscall.EINVAL 3152 } 3153 } 3154 return 3155 } 3156 3157 func createWellKnownSid(sidType WELL_KNOWN_SID_TYPE, domainSid *SID, sid *SID, sizeSid *uint32) (err error) { 3158 r1, _, e1 := syscall.Syscall6(procCreateWellKnownSid.Addr(), 4, uintptr(sidType), uintptr(unsafe.Pointer(domainSid)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sizeSid)), 0, 0) 3159 if r1 == 0 { 3160 if e1 != 0 { 3161 err = errnoErr(e1) 3162 } else { 3163 err = syscall.EINVAL 3164 } 3165 } 3166 return 3167 } 3168 3169 func isWellKnownSid(sid *SID, sidType WELL_KNOWN_SID_TYPE) (isWellKnown bool) { 3170 r0, _, _ := syscall.Syscall(procIsWellKnownSid.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(sidType), 0) 3171 isWellKnown = r0 != 0 3172 return 3173 } 3174 3175 func FreeSid(sid *SID) (err error) { 3176 r1, _, e1 := syscall.Syscall(procFreeSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) 3177 if r1 != 0 { 3178 if e1 != 0 { 3179 err = errnoErr(e1) 3180 } else { 3181 err = syscall.EINVAL 3182 } 3183 } 3184 return 3185 } 3186 3187 func EqualSid(sid1 *SID, sid2 *SID) (isEqual bool) { 3188 r0, _, _ := syscall.Syscall(procEqualSid.Addr(), 2, uintptr(unsafe.Pointer(sid1)), uintptr(unsafe.Pointer(sid2)), 0) 3189 isEqual = r0 != 0 3190 return 3191 } 3192 3193 func getSidIdentifierAuthority(sid *SID) (authority *SidIdentifierAuthority) { 3194 r0, _, _ := syscall.Syscall(procGetSidIdentifierAuthority.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) 3195 authority = (*SidIdentifierAuthority)(unsafe.Pointer(r0)) 3196 return 3197 } 3198 3199 func getSidSubAuthorityCount(sid *SID) (count *uint8) { 3200 r0, _, _ := syscall.Syscall(procGetSidSubAuthorityCount.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) 3201 count = (*uint8)(unsafe.Pointer(r0)) 3202 return 3203 } 3204 3205 func getSidSubAuthority(sid *SID, index uint32) (subAuthority *uint32) { 3206 r0, _, _ := syscall.Syscall(procGetSidSubAuthority.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(index), 0) 3207 subAuthority = (*uint32)(unsafe.Pointer(r0)) 3208 return 3209 } 3210 3211 func isValidSid(sid *SID) (isValid bool) { 3212 r0, _, _ := syscall.Syscall(procIsValidSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) 3213 isValid = r0 != 0 3214 return 3215 } 3216 3217 func checkTokenMembership(tokenHandle Token, sidToCheck *SID, isMember *int32) (err error) { 3218 r1, _, e1 := syscall.Syscall(procCheckTokenMembership.Addr(), 3, uintptr(tokenHandle), uintptr(unsafe.Pointer(sidToCheck)), uintptr(unsafe.Pointer(isMember))) 3219 if r1 == 0 { 3220 if e1 != 0 { 3221 err = errnoErr(e1) 3222 } else { 3223 err = syscall.EINVAL 3224 } 3225 } 3226 return 3227 } 3228 3229 func OpenProcessToken(process Handle, access uint32, token *Token) (err error) { 3230 r1, _, e1 := syscall.Syscall(procOpenProcessToken.Addr(), 3, uintptr(process), uintptr(access), uintptr(unsafe.Pointer(token))) 3231 if r1 == 0 { 3232 if e1 != 0 { 3233 err = errnoErr(e1) 3234 } else { 3235 err = syscall.EINVAL 3236 } 3237 } 3238 return 3239 } 3240 3241 func OpenThreadToken(thread Handle, access uint32, openAsSelf bool, token *Token) (err error) { 3242 var _p0 uint32 3243 if openAsSelf { 3244 _p0 = 1 3245 } else { 3246 _p0 = 0 3247 } 3248 r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(thread), uintptr(access), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0) 3249 if r1 == 0 { 3250 if e1 != 0 { 3251 err = errnoErr(e1) 3252 } else { 3253 err = syscall.EINVAL 3254 } 3255 } 3256 return 3257 } 3258 3259 func ImpersonateSelf(impersonationlevel uint32) (err error) { 3260 r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(impersonationlevel), 0, 0) 3261 if r1 == 0 { 3262 if e1 != 0 { 3263 err = errnoErr(e1) 3264 } else { 3265 err = syscall.EINVAL 3266 } 3267 } 3268 return 3269 } 3270 3271 func RevertToSelf() (err error) { 3272 r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0) 3273 if r1 == 0 { 3274 if e1 != 0 { 3275 err = errnoErr(e1) 3276 } else { 3277 err = syscall.EINVAL 3278 } 3279 } 3280 return 3281 } 3282 3283 func SetThreadToken(thread *Handle, token Token) (err error) { 3284 r1, _, e1 := syscall.Syscall(procSetThreadToken.Addr(), 2, uintptr(unsafe.Pointer(thread)), uintptr(token), 0) 3285 if r1 == 0 { 3286 if e1 != 0 { 3287 err = errnoErr(e1) 3288 } else { 3289 err = syscall.EINVAL 3290 } 3291 } 3292 return 3293 } 3294 3295 func LookupPrivilegeValue(systemname *uint16, name *uint16, luid *LUID) (err error) { 3296 r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemname)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid))) 3297 if r1 == 0 { 3298 if e1 != 0 { 3299 err = errnoErr(e1) 3300 } else { 3301 err = syscall.EINVAL 3302 } 3303 } 3304 return 3305 } 3306 3307 func AdjustTokenPrivileges(token Token, disableAllPrivileges bool, newstate *Tokenprivileges, buflen uint32, prevstate *Tokenprivileges, returnlen *uint32) (err error) { 3308 var _p0 uint32 3309 if disableAllPrivileges { 3310 _p0 = 1 3311 } else { 3312 _p0 = 0 3313 } 3314 r1, _, e1 := syscall.Syscall6(procAdjustTokenPrivileges.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(newstate)), uintptr(buflen), uintptr(unsafe.Pointer(prevstate)), uintptr(unsafe.Pointer(returnlen))) 3315 if r1 == 0 { 3316 if e1 != 0 { 3317 err = errnoErr(e1) 3318 } else { 3319 err = syscall.EINVAL 3320 } 3321 } 3322 return 3323 } 3324 3325 func AdjustTokenGroups(token Token, resetToDefault bool, newstate *Tokengroups, buflen uint32, prevstate *Tokengroups, returnlen *uint32) (err error) { 3326 var _p0 uint32 3327 if resetToDefault { 3328 _p0 = 1 3329 } else { 3330 _p0 = 0 3331 } 3332 r1, _, e1 := syscall.Syscall6(procAdjustTokenGroups.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(newstate)), uintptr(buflen), uintptr(unsafe.Pointer(prevstate)), uintptr(unsafe.Pointer(returnlen))) 3333 if r1 == 0 { 3334 if e1 != 0 { 3335 err = errnoErr(e1) 3336 } else { 3337 err = syscall.EINVAL 3338 } 3339 } 3340 return 3341 } 3342 3343 func GetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint32, returnedLen *uint32) (err error) { 3344 r1, _, e1 := syscall.Syscall6(procGetTokenInformation.Addr(), 5, uintptr(token), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), uintptr(unsafe.Pointer(returnedLen)), 0) 3345 if r1 == 0 { 3346 if e1 != 0 { 3347 err = errnoErr(e1) 3348 } else { 3349 err = syscall.EINVAL 3350 } 3351 } 3352 return 3353 } 3354 3355 func SetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint32) (err error) { 3356 r1, _, e1 := syscall.Syscall6(procSetTokenInformation.Addr(), 4, uintptr(token), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), 0, 0) 3357 if r1 == 0 { 3358 if e1 != 0 { 3359 err = errnoErr(e1) 3360 } else { 3361 err = syscall.EINVAL 3362 } 3363 } 3364 return 3365 } 3366 3367 func DuplicateTokenEx(existingToken Token, desiredAccess uint32, tokenAttributes *SecurityAttributes, impersonationLevel uint32, tokenType uint32, newToken *Token) (err error) { 3368 r1, _, e1 := syscall.Syscall6(procDuplicateTokenEx.Addr(), 6, uintptr(existingToken), uintptr(desiredAccess), uintptr(unsafe.Pointer(tokenAttributes)), uintptr(impersonationLevel), uintptr(tokenType), uintptr(unsafe.Pointer(newToken))) 3369 if r1 == 0 { 3370 if e1 != 0 { 3371 err = errnoErr(e1) 3372 } else { 3373 err = syscall.EINVAL 3374 } 3375 } 3376 return 3377 } 3378 3379 func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) { 3380 r1, _, e1 := syscall.Syscall(procGetUserProfileDirectoryW.Addr(), 3, uintptr(t), uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen))) 3381 if r1 == 0 { 3382 if e1 != 0 { 3383 err = errnoErr(e1) 3384 } else { 3385 err = syscall.EINVAL 3386 } 3387 } 3388 return 3389 } 3390 3391 func getSystemDirectory(dir *uint16, dirLen uint32) (len uint32, err error) { 3392 r0, _, e1 := syscall.Syscall(procGetSystemDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0) 3393 len = uint32(r0) 3394 if len == 0 { 3395 if e1 != 0 { 3396 err = errnoErr(e1) 3397 } else { 3398 err = syscall.EINVAL 3399 } 3400 } 3401 return 3402 } 3403 3404 func getWindowsDirectory(dir *uint16, dirLen uint32) (len uint32, err error) { 3405 r0, _, e1 := syscall.Syscall(procGetWindowsDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0) 3406 len = uint32(r0) 3407 if len == 0 { 3408 if e1 != 0 { 3409 err = errnoErr(e1) 3410 } else { 3411 err = syscall.EINVAL 3412 } 3413 } 3414 return 3415 } 3416 3417 func getSystemWindowsDirectory(dir *uint16, dirLen uint32) (len uint32, err error) { 3418 r0, _, e1 := syscall.Syscall(procGetSystemWindowsDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0) 3419 len = uint32(r0) 3420 if len == 0 { 3421 if e1 != 0 { 3422 err = errnoErr(e1) 3423 } else { 3424 err = syscall.EINVAL 3425 } 3426 } 3427 return 3428 } 3429 3430 func WTSQueryUserToken(session uint32, token *Token) (err error) { 3431 r1, _, e1 := syscall.Syscall(procWTSQueryUserToken.Addr(), 2, uintptr(session), uintptr(unsafe.Pointer(token)), 0) 3432 if r1 == 0 { 3433 if e1 != 0 { 3434 err = errnoErr(e1) 3435 } else { 3436 err = syscall.EINVAL 3437 } 3438 } 3439 return 3440 } 3441 3442 func WTSEnumerateSessions(handle Handle, reserved uint32, version uint32, sessions **WTS_SESSION_INFO, count *uint32) (err error) { 3443 r1, _, e1 := syscall.Syscall6(procWTSEnumerateSessionsW.Addr(), 5, uintptr(handle), uintptr(reserved), uintptr(version), uintptr(unsafe.Pointer(sessions)), uintptr(unsafe.Pointer(count)), 0) 3444 if r1 == 0 { 3445 if e1 != 0 { 3446 err = errnoErr(e1) 3447 } else { 3448 err = syscall.EINVAL 3449 } 3450 } 3451 return 3452 } 3453 3454 func WTSFreeMemory(ptr uintptr) { 3455 syscall.Syscall(procWTSFreeMemory.Addr(), 1, uintptr(ptr), 0, 0) 3456 return 3457 }