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