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