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