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