blob: 407d2709faa84680a9c3b65ab189675ffa8f65a1 [file] [log] [blame]
Tobias Klauser8014b7b2018-06-14 09:37:16 +02001// Code generated by 'go generate'; DO NOT EDIT.
Rob Pike20acc5c2014-08-11 14:48:46 -07002
Rob Pike8442dd22014-08-11 15:58:26 -07003package windows
Rob Pike20acc5c2014-08-11 14:48:46 -07004
Brad Fitzpatrick3dff6e12016-04-01 04:10:49 +00005import (
6 "syscall"
7 "unsafe"
8)
Rob Pike20acc5c2014-08-11 14:48:46 -07009
Carlos Castillo5b683252015-02-27 04:46:26 -080010var _ unsafe.Pointer
11
Alex Brainmanca83bd22016-12-02 16:54:46 +110012// 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
Rob Pike20acc5c2014-08-11 14:48:46 -070037var (
Alex Brainman042a8f52016-04-06 15:52:57 +100038 modadvapi32 = NewLazySystemDLL("advapi32.dll")
39 modkernel32 = NewLazySystemDLL("kernel32.dll")
40 modshell32 = NewLazySystemDLL("shell32.dll")
Jason A. Donenfeld56c252d2019-05-25 15:17:43 +020041 moduserenv = NewLazySystemDLL("userenv.dll")
Alex Brainman042a8f52016-04-06 15:52:57 +100042 modmswsock = NewLazySystemDLL("mswsock.dll")
43 modcrypt32 = NewLazySystemDLL("crypt32.dll")
Jason A. Donenfeldea4c4252019-05-25 15:27:23 +020044 moduser32 = NewLazySystemDLL("user32.dll")
Jason A. Donenfeld7fc4e5e2019-06-06 19:29:06 +020045 modole32 = NewLazySystemDLL("ole32.dll")
Jason A. Donenfeld516e3c22019-06-18 12:54:32 +020046 modntdll = NewLazySystemDLL("ntdll.dll")
Alex Brainman042a8f52016-04-06 15:52:57 +100047 modws2_32 = NewLazySystemDLL("ws2_32.dll")
48 moddnsapi = NewLazySystemDLL("dnsapi.dll")
49 modiphlpapi = NewLazySystemDLL("iphlpapi.dll")
50 modsecur32 = NewLazySystemDLL("secur32.dll")
51 modnetapi32 = NewLazySystemDLL("netapi32.dll")
Jason A. Donenfeldf91f9b32019-05-13 10:42:08 +020052 modwtsapi32 = NewLazySystemDLL("wtsapi32.dll")
Rob Pike20acc5c2014-08-11 14:48:46 -070053
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -060054 procRegisterEventSourceW = modadvapi32.NewProc("RegisterEventSourceW")
55 procDeregisterEventSource = modadvapi32.NewProc("DeregisterEventSource")
56 procReportEventW = modadvapi32.NewProc("ReportEventW")
57 procOpenSCManagerW = modadvapi32.NewProc("OpenSCManagerW")
58 procCloseServiceHandle = modadvapi32.NewProc("CloseServiceHandle")
59 procCreateServiceW = modadvapi32.NewProc("CreateServiceW")
60 procOpenServiceW = modadvapi32.NewProc("OpenServiceW")
61 procDeleteService = modadvapi32.NewProc("DeleteService")
62 procStartServiceW = modadvapi32.NewProc("StartServiceW")
63 procQueryServiceStatus = modadvapi32.NewProc("QueryServiceStatus")
64 procQueryServiceLockStatusW = modadvapi32.NewProc("QueryServiceLockStatusW")
65 procControlService = modadvapi32.NewProc("ControlService")
66 procStartServiceCtrlDispatcherW = modadvapi32.NewProc("StartServiceCtrlDispatcherW")
67 procSetServiceStatus = modadvapi32.NewProc("SetServiceStatus")
68 procChangeServiceConfigW = modadvapi32.NewProc("ChangeServiceConfigW")
69 procQueryServiceConfigW = modadvapi32.NewProc("QueryServiceConfigW")
70 procChangeServiceConfig2W = modadvapi32.NewProc("ChangeServiceConfig2W")
71 procQueryServiceConfig2W = modadvapi32.NewProc("QueryServiceConfig2W")
72 procEnumServicesStatusExW = modadvapi32.NewProc("EnumServicesStatusExW")
73 procQueryServiceStatusEx = modadvapi32.NewProc("QueryServiceStatusEx")
74 procNotifyServiceStatusChangeW = modadvapi32.NewProc("NotifyServiceStatusChangeW")
75 procGetLastError = modkernel32.NewProc("GetLastError")
76 procLoadLibraryW = modkernel32.NewProc("LoadLibraryW")
77 procLoadLibraryExW = modkernel32.NewProc("LoadLibraryExW")
78 procFreeLibrary = modkernel32.NewProc("FreeLibrary")
79 procGetProcAddress = modkernel32.NewProc("GetProcAddress")
80 procGetVersion = modkernel32.NewProc("GetVersion")
81 procFormatMessageW = modkernel32.NewProc("FormatMessageW")
82 procExitProcess = modkernel32.NewProc("ExitProcess")
83 procIsWow64Process = modkernel32.NewProc("IsWow64Process")
84 procCreateFileW = modkernel32.NewProc("CreateFileW")
85 procReadFile = modkernel32.NewProc("ReadFile")
86 procWriteFile = modkernel32.NewProc("WriteFile")
87 procGetOverlappedResult = modkernel32.NewProc("GetOverlappedResult")
88 procSetFilePointer = modkernel32.NewProc("SetFilePointer")
89 procCloseHandle = modkernel32.NewProc("CloseHandle")
90 procGetStdHandle = modkernel32.NewProc("GetStdHandle")
91 procSetStdHandle = modkernel32.NewProc("SetStdHandle")
92 procFindFirstFileW = modkernel32.NewProc("FindFirstFileW")
93 procFindNextFileW = modkernel32.NewProc("FindNextFileW")
94 procFindClose = modkernel32.NewProc("FindClose")
95 procGetFileInformationByHandle = modkernel32.NewProc("GetFileInformationByHandle")
96 procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx")
97 procGetCurrentDirectoryW = modkernel32.NewProc("GetCurrentDirectoryW")
98 procSetCurrentDirectoryW = modkernel32.NewProc("SetCurrentDirectoryW")
99 procCreateDirectoryW = modkernel32.NewProc("CreateDirectoryW")
100 procRemoveDirectoryW = modkernel32.NewProc("RemoveDirectoryW")
101 procDeleteFileW = modkernel32.NewProc("DeleteFileW")
102 procMoveFileW = modkernel32.NewProc("MoveFileW")
103 procMoveFileExW = modkernel32.NewProc("MoveFileExW")
104 procGetComputerNameW = modkernel32.NewProc("GetComputerNameW")
105 procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
106 procSetEndOfFile = modkernel32.NewProc("SetEndOfFile")
107 procGetSystemTimeAsFileTime = modkernel32.NewProc("GetSystemTimeAsFileTime")
108 procGetSystemTimePreciseAsFileTime = modkernel32.NewProc("GetSystemTimePreciseAsFileTime")
109 procGetTimeZoneInformation = modkernel32.NewProc("GetTimeZoneInformation")
110 procCreateIoCompletionPort = modkernel32.NewProc("CreateIoCompletionPort")
111 procGetQueuedCompletionStatus = modkernel32.NewProc("GetQueuedCompletionStatus")
112 procPostQueuedCompletionStatus = modkernel32.NewProc("PostQueuedCompletionStatus")
113 procCancelIo = modkernel32.NewProc("CancelIo")
114 procCancelIoEx = modkernel32.NewProc("CancelIoEx")
115 procCreateProcessW = modkernel32.NewProc("CreateProcessW")
116 procOpenProcess = modkernel32.NewProc("OpenProcess")
117 procShellExecuteW = modshell32.NewProc("ShellExecuteW")
118 procSHGetKnownFolderPath = modshell32.NewProc("SHGetKnownFolderPath")
119 procTerminateProcess = modkernel32.NewProc("TerminateProcess")
120 procGetExitCodeProcess = modkernel32.NewProc("GetExitCodeProcess")
121 procGetStartupInfoW = modkernel32.NewProc("GetStartupInfoW")
122 procGetCurrentProcess = modkernel32.NewProc("GetCurrentProcess")
123 procGetCurrentThread = modkernel32.NewProc("GetCurrentThread")
124 procGetProcessTimes = modkernel32.NewProc("GetProcessTimes")
125 procDuplicateHandle = modkernel32.NewProc("DuplicateHandle")
126 procWaitForSingleObject = modkernel32.NewProc("WaitForSingleObject")
127 procWaitForMultipleObjects = modkernel32.NewProc("WaitForMultipleObjects")
128 procGetTempPathW = modkernel32.NewProc("GetTempPathW")
129 procCreatePipe = modkernel32.NewProc("CreatePipe")
130 procGetFileType = modkernel32.NewProc("GetFileType")
131 procCryptAcquireContextW = modadvapi32.NewProc("CryptAcquireContextW")
132 procCryptReleaseContext = modadvapi32.NewProc("CryptReleaseContext")
133 procCryptGenRandom = modadvapi32.NewProc("CryptGenRandom")
134 procGetEnvironmentStringsW = modkernel32.NewProc("GetEnvironmentStringsW")
135 procFreeEnvironmentStringsW = modkernel32.NewProc("FreeEnvironmentStringsW")
136 procGetEnvironmentVariableW = modkernel32.NewProc("GetEnvironmentVariableW")
137 procSetEnvironmentVariableW = modkernel32.NewProc("SetEnvironmentVariableW")
138 procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock")
139 procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock")
140 procGetTickCount64 = modkernel32.NewProc("GetTickCount64")
141 procSetFileTime = modkernel32.NewProc("SetFileTime")
142 procGetFileAttributesW = modkernel32.NewProc("GetFileAttributesW")
143 procSetFileAttributesW = modkernel32.NewProc("SetFileAttributesW")
144 procGetFileAttributesExW = modkernel32.NewProc("GetFileAttributesExW")
145 procGetCommandLineW = modkernel32.NewProc("GetCommandLineW")
146 procCommandLineToArgvW = modshell32.NewProc("CommandLineToArgvW")
147 procLocalFree = modkernel32.NewProc("LocalFree")
148 procSetHandleInformation = modkernel32.NewProc("SetHandleInformation")
149 procFlushFileBuffers = modkernel32.NewProc("FlushFileBuffers")
150 procGetFullPathNameW = modkernel32.NewProc("GetFullPathNameW")
151 procGetLongPathNameW = modkernel32.NewProc("GetLongPathNameW")
152 procGetShortPathNameW = modkernel32.NewProc("GetShortPathNameW")
153 procCreateFileMappingW = modkernel32.NewProc("CreateFileMappingW")
154 procMapViewOfFile = modkernel32.NewProc("MapViewOfFile")
155 procUnmapViewOfFile = modkernel32.NewProc("UnmapViewOfFile")
156 procFlushViewOfFile = modkernel32.NewProc("FlushViewOfFile")
157 procVirtualLock = modkernel32.NewProc("VirtualLock")
158 procVirtualUnlock = modkernel32.NewProc("VirtualUnlock")
159 procVirtualAlloc = modkernel32.NewProc("VirtualAlloc")
160 procVirtualFree = modkernel32.NewProc("VirtualFree")
161 procVirtualProtect = modkernel32.NewProc("VirtualProtect")
162 procTransmitFile = modmswsock.NewProc("TransmitFile")
163 procReadDirectoryChangesW = modkernel32.NewProc("ReadDirectoryChangesW")
164 procCertOpenSystemStoreW = modcrypt32.NewProc("CertOpenSystemStoreW")
165 procCertOpenStore = modcrypt32.NewProc("CertOpenStore")
166 procCertEnumCertificatesInStore = modcrypt32.NewProc("CertEnumCertificatesInStore")
167 procCertAddCertificateContextToStore = modcrypt32.NewProc("CertAddCertificateContextToStore")
168 procCertCloseStore = modcrypt32.NewProc("CertCloseStore")
169 procCertGetCertificateChain = modcrypt32.NewProc("CertGetCertificateChain")
170 procCertFreeCertificateChain = modcrypt32.NewProc("CertFreeCertificateChain")
171 procCertCreateCertificateContext = modcrypt32.NewProc("CertCreateCertificateContext")
172 procCertFreeCertificateContext = modcrypt32.NewProc("CertFreeCertificateContext")
173 procCertVerifyCertificateChainPolicy = modcrypt32.NewProc("CertVerifyCertificateChainPolicy")
174 procRegOpenKeyExW = modadvapi32.NewProc("RegOpenKeyExW")
175 procRegCloseKey = modadvapi32.NewProc("RegCloseKey")
176 procRegQueryInfoKeyW = modadvapi32.NewProc("RegQueryInfoKeyW")
177 procRegEnumKeyExW = modadvapi32.NewProc("RegEnumKeyExW")
178 procRegQueryValueExW = modadvapi32.NewProc("RegQueryValueExW")
179 procGetCurrentProcessId = modkernel32.NewProc("GetCurrentProcessId")
180 procGetConsoleMode = modkernel32.NewProc("GetConsoleMode")
181 procSetConsoleMode = modkernel32.NewProc("SetConsoleMode")
182 procGetConsoleScreenBufferInfo = modkernel32.NewProc("GetConsoleScreenBufferInfo")
183 procWriteConsoleW = modkernel32.NewProc("WriteConsoleW")
184 procReadConsoleW = modkernel32.NewProc("ReadConsoleW")
185 procCreateToolhelp32Snapshot = modkernel32.NewProc("CreateToolhelp32Snapshot")
186 procProcess32FirstW = modkernel32.NewProc("Process32FirstW")
187 procProcess32NextW = modkernel32.NewProc("Process32NextW")
188 procThread32First = modkernel32.NewProc("Thread32First")
189 procThread32Next = modkernel32.NewProc("Thread32Next")
190 procDeviceIoControl = modkernel32.NewProc("DeviceIoControl")
191 procCreateSymbolicLinkW = modkernel32.NewProc("CreateSymbolicLinkW")
192 procCreateHardLinkW = modkernel32.NewProc("CreateHardLinkW")
193 procGetCurrentThreadId = modkernel32.NewProc("GetCurrentThreadId")
194 procCreateEventW = modkernel32.NewProc("CreateEventW")
195 procCreateEventExW = modkernel32.NewProc("CreateEventExW")
196 procOpenEventW = modkernel32.NewProc("OpenEventW")
197 procSetEvent = modkernel32.NewProc("SetEvent")
198 procResetEvent = modkernel32.NewProc("ResetEvent")
199 procPulseEvent = modkernel32.NewProc("PulseEvent")
200 procCreateMutexW = modkernel32.NewProc("CreateMutexW")
201 procCreateMutexExW = modkernel32.NewProc("CreateMutexExW")
202 procOpenMutexW = modkernel32.NewProc("OpenMutexW")
203 procReleaseMutex = modkernel32.NewProc("ReleaseMutex")
204 procSleepEx = modkernel32.NewProc("SleepEx")
205 procCreateJobObjectW = modkernel32.NewProc("CreateJobObjectW")
206 procAssignProcessToJobObject = modkernel32.NewProc("AssignProcessToJobObject")
207 procTerminateJobObject = modkernel32.NewProc("TerminateJobObject")
208 procSetErrorMode = modkernel32.NewProc("SetErrorMode")
209 procResumeThread = modkernel32.NewProc("ResumeThread")
210 procSetPriorityClass = modkernel32.NewProc("SetPriorityClass")
211 procGetPriorityClass = modkernel32.NewProc("GetPriorityClass")
212 procSetInformationJobObject = modkernel32.NewProc("SetInformationJobObject")
213 procGenerateConsoleCtrlEvent = modkernel32.NewProc("GenerateConsoleCtrlEvent")
214 procGetProcessId = modkernel32.NewProc("GetProcessId")
215 procOpenThread = modkernel32.NewProc("OpenThread")
216 procSetProcessPriorityBoost = modkernel32.NewProc("SetProcessPriorityBoost")
217 procDefineDosDeviceW = modkernel32.NewProc("DefineDosDeviceW")
218 procDeleteVolumeMountPointW = modkernel32.NewProc("DeleteVolumeMountPointW")
219 procFindFirstVolumeW = modkernel32.NewProc("FindFirstVolumeW")
220 procFindFirstVolumeMountPointW = modkernel32.NewProc("FindFirstVolumeMountPointW")
221 procFindNextVolumeW = modkernel32.NewProc("FindNextVolumeW")
222 procFindNextVolumeMountPointW = modkernel32.NewProc("FindNextVolumeMountPointW")
223 procFindVolumeClose = modkernel32.NewProc("FindVolumeClose")
224 procFindVolumeMountPointClose = modkernel32.NewProc("FindVolumeMountPointClose")
225 procGetDriveTypeW = modkernel32.NewProc("GetDriveTypeW")
226 procGetLogicalDrives = modkernel32.NewProc("GetLogicalDrives")
227 procGetLogicalDriveStringsW = modkernel32.NewProc("GetLogicalDriveStringsW")
228 procGetVolumeInformationW = modkernel32.NewProc("GetVolumeInformationW")
229 procGetVolumeInformationByHandleW = modkernel32.NewProc("GetVolumeInformationByHandleW")
230 procGetVolumeNameForVolumeMountPointW = modkernel32.NewProc("GetVolumeNameForVolumeMountPointW")
231 procGetVolumePathNameW = modkernel32.NewProc("GetVolumePathNameW")
232 procGetVolumePathNamesForVolumeNameW = modkernel32.NewProc("GetVolumePathNamesForVolumeNameW")
233 procQueryDosDeviceW = modkernel32.NewProc("QueryDosDeviceW")
234 procSetVolumeLabelW = modkernel32.NewProc("SetVolumeLabelW")
235 procSetVolumeMountPointW = modkernel32.NewProc("SetVolumeMountPointW")
236 procMessageBoxW = moduser32.NewProc("MessageBoxW")
237 procExitWindowsEx = moduser32.NewProc("ExitWindowsEx")
238 procInitiateSystemShutdownExW = modadvapi32.NewProc("InitiateSystemShutdownExW")
239 procSetProcessShutdownParameters = modkernel32.NewProc("SetProcessShutdownParameters")
240 procGetProcessShutdownParameters = modkernel32.NewProc("GetProcessShutdownParameters")
241 procCLSIDFromString = modole32.NewProc("CLSIDFromString")
242 procStringFromGUID2 = modole32.NewProc("StringFromGUID2")
243 procCoCreateGuid = modole32.NewProc("CoCreateGuid")
244 procCoTaskMemFree = modole32.NewProc("CoTaskMemFree")
245 procRtlGetVersion = modntdll.NewProc("RtlGetVersion")
246 procRtlGetNtVersionNumbers = modntdll.NewProc("RtlGetNtVersionNumbers")
247 procWSAStartup = modws2_32.NewProc("WSAStartup")
248 procWSACleanup = modws2_32.NewProc("WSACleanup")
249 procWSAIoctl = modws2_32.NewProc("WSAIoctl")
250 procsocket = modws2_32.NewProc("socket")
251 procsetsockopt = modws2_32.NewProc("setsockopt")
252 procgetsockopt = modws2_32.NewProc("getsockopt")
253 procbind = modws2_32.NewProc("bind")
254 procconnect = modws2_32.NewProc("connect")
255 procgetsockname = modws2_32.NewProc("getsockname")
256 procgetpeername = modws2_32.NewProc("getpeername")
257 proclisten = modws2_32.NewProc("listen")
258 procshutdown = modws2_32.NewProc("shutdown")
259 procclosesocket = modws2_32.NewProc("closesocket")
260 procAcceptEx = modmswsock.NewProc("AcceptEx")
261 procGetAcceptExSockaddrs = modmswsock.NewProc("GetAcceptExSockaddrs")
262 procWSARecv = modws2_32.NewProc("WSARecv")
263 procWSASend = modws2_32.NewProc("WSASend")
264 procWSARecvFrom = modws2_32.NewProc("WSARecvFrom")
265 procWSASendTo = modws2_32.NewProc("WSASendTo")
266 procgethostbyname = modws2_32.NewProc("gethostbyname")
267 procgetservbyname = modws2_32.NewProc("getservbyname")
268 procntohs = modws2_32.NewProc("ntohs")
269 procgetprotobyname = modws2_32.NewProc("getprotobyname")
270 procDnsQuery_W = moddnsapi.NewProc("DnsQuery_W")
271 procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree")
272 procDnsNameCompare_W = moddnsapi.NewProc("DnsNameCompare_W")
273 procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW")
274 procFreeAddrInfoW = modws2_32.NewProc("FreeAddrInfoW")
275 procGetIfEntry = modiphlpapi.NewProc("GetIfEntry")
276 procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo")
277 procSetFileCompletionNotificationModes = modkernel32.NewProc("SetFileCompletionNotificationModes")
278 procWSAEnumProtocolsW = modws2_32.NewProc("WSAEnumProtocolsW")
279 procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses")
280 procGetACP = modkernel32.NewProc("GetACP")
281 procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar")
282 procTranslateNameW = modsecur32.NewProc("TranslateNameW")
283 procGetUserNameExW = modsecur32.NewProc("GetUserNameExW")
284 procNetUserGetInfo = modnetapi32.NewProc("NetUserGetInfo")
285 procNetGetJoinInformation = modnetapi32.NewProc("NetGetJoinInformation")
286 procNetApiBufferFree = modnetapi32.NewProc("NetApiBufferFree")
287 procLookupAccountSidW = modadvapi32.NewProc("LookupAccountSidW")
288 procLookupAccountNameW = modadvapi32.NewProc("LookupAccountNameW")
289 procConvertSidToStringSidW = modadvapi32.NewProc("ConvertSidToStringSidW")
290 procConvertStringSidToSidW = modadvapi32.NewProc("ConvertStringSidToSidW")
291 procGetLengthSid = modadvapi32.NewProc("GetLengthSid")
292 procCopySid = modadvapi32.NewProc("CopySid")
293 procAllocateAndInitializeSid = modadvapi32.NewProc("AllocateAndInitializeSid")
294 procCreateWellKnownSid = modadvapi32.NewProc("CreateWellKnownSid")
295 procIsWellKnownSid = modadvapi32.NewProc("IsWellKnownSid")
296 procFreeSid = modadvapi32.NewProc("FreeSid")
297 procEqualSid = modadvapi32.NewProc("EqualSid")
298 procGetSidIdentifierAuthority = modadvapi32.NewProc("GetSidIdentifierAuthority")
299 procGetSidSubAuthorityCount = modadvapi32.NewProc("GetSidSubAuthorityCount")
300 procGetSidSubAuthority = modadvapi32.NewProc("GetSidSubAuthority")
301 procIsValidSid = modadvapi32.NewProc("IsValidSid")
302 procCheckTokenMembership = modadvapi32.NewProc("CheckTokenMembership")
303 procOpenProcessToken = modadvapi32.NewProc("OpenProcessToken")
304 procOpenThreadToken = modadvapi32.NewProc("OpenThreadToken")
305 procImpersonateSelf = modadvapi32.NewProc("ImpersonateSelf")
306 procRevertToSelf = modadvapi32.NewProc("RevertToSelf")
307 procSetThreadToken = modadvapi32.NewProc("SetThreadToken")
308 procLookupPrivilegeValueW = modadvapi32.NewProc("LookupPrivilegeValueW")
309 procAdjustTokenPrivileges = modadvapi32.NewProc("AdjustTokenPrivileges")
310 procAdjustTokenGroups = modadvapi32.NewProc("AdjustTokenGroups")
311 procGetTokenInformation = modadvapi32.NewProc("GetTokenInformation")
312 procSetTokenInformation = modadvapi32.NewProc("SetTokenInformation")
313 procDuplicateTokenEx = modadvapi32.NewProc("DuplicateTokenEx")
314 procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW")
315 procGetSystemDirectoryW = modkernel32.NewProc("GetSystemDirectoryW")
316 procGetWindowsDirectoryW = modkernel32.NewProc("GetWindowsDirectoryW")
317 procGetSystemWindowsDirectoryW = modkernel32.NewProc("GetSystemWindowsDirectoryW")
318 procWTSQueryUserToken = modwtsapi32.NewProc("WTSQueryUserToken")
319 procWTSEnumerateSessionsW = modwtsapi32.NewProc("WTSEnumerateSessionsW")
320 procWTSFreeMemory = modwtsapi32.NewProc("WTSFreeMemory")
321 procGetSecurityInfo = modadvapi32.NewProc("GetSecurityInfo")
322 procSetSecurityInfo = modadvapi32.NewProc("SetSecurityInfo")
323 procGetNamedSecurityInfoW = modadvapi32.NewProc("GetNamedSecurityInfoW")
324 procSetNamedSecurityInfoW = modadvapi32.NewProc("SetNamedSecurityInfoW")
325 procBuildSecurityDescriptorW = modadvapi32.NewProc("BuildSecurityDescriptorW")
326 procInitializeSecurityDescriptor = modadvapi32.NewProc("InitializeSecurityDescriptor")
327 procGetSecurityDescriptorControl = modadvapi32.NewProc("GetSecurityDescriptorControl")
328 procGetSecurityDescriptorDacl = modadvapi32.NewProc("GetSecurityDescriptorDacl")
329 procGetSecurityDescriptorSacl = modadvapi32.NewProc("GetSecurityDescriptorSacl")
330 procGetSecurityDescriptorOwner = modadvapi32.NewProc("GetSecurityDescriptorOwner")
331 procGetSecurityDescriptorGroup = modadvapi32.NewProc("GetSecurityDescriptorGroup")
332 procGetSecurityDescriptorLength = modadvapi32.NewProc("GetSecurityDescriptorLength")
333 procGetSecurityDescriptorRMControl = modadvapi32.NewProc("GetSecurityDescriptorRMControl")
334 procIsValidSecurityDescriptor = modadvapi32.NewProc("IsValidSecurityDescriptor")
335 procSetSecurityDescriptorControl = modadvapi32.NewProc("SetSecurityDescriptorControl")
336 procSetSecurityDescriptorDacl = modadvapi32.NewProc("SetSecurityDescriptorDacl")
337 procSetSecurityDescriptorSacl = modadvapi32.NewProc("SetSecurityDescriptorSacl")
338 procSetSecurityDescriptorOwner = modadvapi32.NewProc("SetSecurityDescriptorOwner")
339 procSetSecurityDescriptorGroup = modadvapi32.NewProc("SetSecurityDescriptorGroup")
340 procSetSecurityDescriptorRMControl = modadvapi32.NewProc("SetSecurityDescriptorRMControl")
341 procConvertStringSecurityDescriptorToSecurityDescriptorW = modadvapi32.NewProc("ConvertStringSecurityDescriptorToSecurityDescriptorW")
342 procConvertSecurityDescriptorToStringSecurityDescriptorW = modadvapi32.NewProc("ConvertSecurityDescriptorToStringSecurityDescriptorW")
343 procMakeAbsoluteSD = modadvapi32.NewProc("MakeAbsoluteSD")
344 procMakeSelfRelativeSD = modadvapi32.NewProc("MakeSelfRelativeSD")
345 procSetEntriesInAclW = modadvapi32.NewProc("SetEntriesInAclW")
Rob Pike20acc5c2014-08-11 14:48:46 -0700346)
347
Alex Brainman65705ef2015-04-17 16:35:40 +1000348func RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) {
349 r0, _, e1 := syscall.Syscall(procRegisterEventSourceW.Addr(), 2, uintptr(unsafe.Pointer(uncServerName)), uintptr(unsafe.Pointer(sourceName)), 0)
350 handle = Handle(r0)
351 if handle == 0 {
352 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100353 err = errnoErr(e1)
Alex Brainman65705ef2015-04-17 16:35:40 +1000354 } else {
355 err = syscall.EINVAL
356 }
357 }
358 return
359}
360
361func DeregisterEventSource(handle Handle) (err error) {
362 r1, _, e1 := syscall.Syscall(procDeregisterEventSource.Addr(), 1, uintptr(handle), 0, 0)
363 if r1 == 0 {
364 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100365 err = errnoErr(e1)
Alex Brainman65705ef2015-04-17 16:35:40 +1000366 } else {
367 err = syscall.EINVAL
368 }
369 }
370 return
371}
372
373func ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) {
374 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)))
375 if r1 == 0 {
376 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100377 err = errnoErr(e1)
Alex Brainman65705ef2015-04-17 16:35:40 +1000378 } else {
379 err = syscall.EINVAL
380 }
381 }
382 return
383}
384
385func OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle Handle, err error) {
386 r0, _, e1 := syscall.Syscall(procOpenSCManagerW.Addr(), 3, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(databaseName)), uintptr(access))
387 handle = Handle(r0)
388 if handle == 0 {
389 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100390 err = errnoErr(e1)
Alex Brainman65705ef2015-04-17 16:35:40 +1000391 } else {
392 err = syscall.EINVAL
393 }
394 }
395 return
396}
397
398func CloseServiceHandle(handle Handle) (err error) {
399 r1, _, e1 := syscall.Syscall(procCloseServiceHandle.Addr(), 1, uintptr(handle), 0, 0)
400 if r1 == 0 {
401 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100402 err = errnoErr(e1)
Alex Brainman65705ef2015-04-17 16:35:40 +1000403 } else {
404 err = syscall.EINVAL
405 }
406 }
407 return
408}
409
410func 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) {
411 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)
412 handle = Handle(r0)
413 if handle == 0 {
414 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100415 err = errnoErr(e1)
Alex Brainman65705ef2015-04-17 16:35:40 +1000416 } else {
417 err = syscall.EINVAL
418 }
419 }
420 return
421}
422
423func OpenService(mgr Handle, serviceName *uint16, access uint32) (handle Handle, err error) {
424 r0, _, e1 := syscall.Syscall(procOpenServiceW.Addr(), 3, uintptr(mgr), uintptr(unsafe.Pointer(serviceName)), uintptr(access))
425 handle = Handle(r0)
426 if handle == 0 {
427 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100428 err = errnoErr(e1)
Alex Brainman65705ef2015-04-17 16:35:40 +1000429 } else {
430 err = syscall.EINVAL
431 }
432 }
433 return
434}
435
436func DeleteService(service Handle) (err error) {
437 r1, _, e1 := syscall.Syscall(procDeleteService.Addr(), 1, uintptr(service), 0, 0)
438 if r1 == 0 {
439 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100440 err = errnoErr(e1)
Alex Brainman65705ef2015-04-17 16:35:40 +1000441 } else {
442 err = syscall.EINVAL
443 }
444 }
445 return
446}
447
448func StartService(service Handle, numArgs uint32, argVectors **uint16) (err error) {
449 r1, _, e1 := syscall.Syscall(procStartServiceW.Addr(), 3, uintptr(service), uintptr(numArgs), uintptr(unsafe.Pointer(argVectors)))
450 if r1 == 0 {
451 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100452 err = errnoErr(e1)
Alex Brainman65705ef2015-04-17 16:35:40 +1000453 } else {
454 err = syscall.EINVAL
455 }
456 }
457 return
458}
459
460func QueryServiceStatus(service Handle, status *SERVICE_STATUS) (err error) {
461 r1, _, e1 := syscall.Syscall(procQueryServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(status)), 0)
462 if r1 == 0 {
463 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100464 err = errnoErr(e1)
Alex Brainman65705ef2015-04-17 16:35:40 +1000465 } else {
466 err = syscall.EINVAL
467 }
468 }
469 return
470}
471
Jason A. Donenfeld301114b2019-06-06 17:27:41 +0200472func QueryServiceLockStatus(mgr Handle, lockStatus *QUERY_SERVICE_LOCK_STATUS, bufSize uint32, bytesNeeded *uint32) (err error) {
473 r1, _, e1 := syscall.Syscall6(procQueryServiceLockStatusW.Addr(), 4, uintptr(mgr), uintptr(unsafe.Pointer(lockStatus)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0)
474 if r1 == 0 {
475 if e1 != 0 {
476 err = errnoErr(e1)
477 } else {
478 err = syscall.EINVAL
479 }
480 }
481 return
482}
483
Alex Brainman65705ef2015-04-17 16:35:40 +1000484func ControlService(service Handle, control uint32, status *SERVICE_STATUS) (err error) {
485 r1, _, e1 := syscall.Syscall(procControlService.Addr(), 3, uintptr(service), uintptr(control), uintptr(unsafe.Pointer(status)))
486 if r1 == 0 {
487 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100488 err = errnoErr(e1)
Alex Brainman65705ef2015-04-17 16:35:40 +1000489 } else {
490 err = syscall.EINVAL
491 }
492 }
493 return
494}
495
496func StartServiceCtrlDispatcher(serviceTable *SERVICE_TABLE_ENTRY) (err error) {
497 r1, _, e1 := syscall.Syscall(procStartServiceCtrlDispatcherW.Addr(), 1, uintptr(unsafe.Pointer(serviceTable)), 0, 0)
498 if r1 == 0 {
499 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100500 err = errnoErr(e1)
Alex Brainman65705ef2015-04-17 16:35:40 +1000501 } else {
502 err = syscall.EINVAL
503 }
504 }
505 return
506}
507
508func SetServiceStatus(service Handle, serviceStatus *SERVICE_STATUS) (err error) {
509 r1, _, e1 := syscall.Syscall(procSetServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(serviceStatus)), 0)
510 if r1 == 0 {
511 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100512 err = errnoErr(e1)
Alex Brainman65705ef2015-04-17 16:35:40 +1000513 } else {
514 err = syscall.EINVAL
515 }
516 }
517 return
518}
519
520func 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) {
521 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)
522 if r1 == 0 {
523 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100524 err = errnoErr(e1)
Alex Brainman65705ef2015-04-17 16:35:40 +1000525 } else {
526 err = syscall.EINVAL
527 }
528 }
529 return
530}
531
532func QueryServiceConfig(service Handle, serviceConfig *QUERY_SERVICE_CONFIG, bufSize uint32, bytesNeeded *uint32) (err error) {
533 r1, _, e1 := syscall.Syscall6(procQueryServiceConfigW.Addr(), 4, uintptr(service), uintptr(unsafe.Pointer(serviceConfig)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0)
534 if r1 == 0 {
535 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100536 err = errnoErr(e1)
Alex Brainman65705ef2015-04-17 16:35:40 +1000537 } else {
538 err = syscall.EINVAL
539 }
540 }
541 return
542}
543
544func ChangeServiceConfig2(service Handle, infoLevel uint32, info *byte) (err error) {
545 r1, _, e1 := syscall.Syscall(procChangeServiceConfig2W.Addr(), 3, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(info)))
546 if r1 == 0 {
547 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100548 err = errnoErr(e1)
Alex Brainman65705ef2015-04-17 16:35:40 +1000549 } else {
550 err = syscall.EINVAL
551 }
552 }
553 return
554}
555
556func QueryServiceConfig2(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) {
557 r1, _, e1 := syscall.Syscall6(procQueryServiceConfig2W.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0)
558 if r1 == 0 {
559 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100560 err = errnoErr(e1)
Alex Brainman65705ef2015-04-17 16:35:40 +1000561 } else {
562 err = syscall.EINVAL
563 }
564 }
565 return
566}
567
Alex Brainmanfb4cac32017-06-14 16:48:48 +1000568func EnumServicesStatusEx(mgr Handle, infoLevel uint32, serviceType uint32, serviceState uint32, services *byte, bufSize uint32, bytesNeeded *uint32, servicesReturned *uint32, resumeHandle *uint32, groupName *uint16) (err error) {
569 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)
570 if r1 == 0 {
571 if e1 != 0 {
572 err = errnoErr(e1)
573 } else {
574 err = syscall.EINVAL
575 }
576 }
577 return
578}
579
pytimer56ad15c2018-05-23 10:12:58 +0800580func QueryServiceStatusEx(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) {
581 r1, _, e1 := syscall.Syscall6(procQueryServiceStatusEx.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0)
582 if r1 == 0 {
583 if e1 != 0 {
584 err = errnoErr(e1)
585 } else {
586 err = syscall.EINVAL
587 }
588 }
589 return
590}
591
Jason A. Donenfeld24a5b222019-05-13 11:27:51 +0200592func NotifyServiceStatusChange(service Handle, notifyMask uint32, notifier *SERVICE_NOTIFY) (ret error) {
593 r0, _, _ := syscall.Syscall(procNotifyServiceStatusChangeW.Addr(), 3, uintptr(service), uintptr(notifyMask), uintptr(unsafe.Pointer(notifier)))
594 if r0 != 0 {
595 ret = syscall.Errno(r0)
596 }
597 return
598}
599
Rob Pike20acc5c2014-08-11 14:48:46 -0700600func GetLastError() (lasterr error) {
Rob Pike71181952014-08-13 14:08:39 -0700601 r0, _, _ := syscall.Syscall(procGetLastError.Addr(), 0, 0, 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -0700602 if r0 != 0 {
Rob Pike4faa3362014-08-14 10:28:19 -0700603 lasterr = syscall.Errno(r0)
Rob Pike20acc5c2014-08-11 14:48:46 -0700604 }
605 return
606}
607
608func LoadLibrary(libname string) (handle Handle, err error) {
609 var _p0 *uint16
Alex Brainman7d091bf2014-08-19 15:20:17 +1000610 _p0, err = syscall.UTF16PtrFromString(libname)
Rob Pike20acc5c2014-08-11 14:48:46 -0700611 if err != nil {
612 return
613 }
Alex Brainmanc17938b2014-10-06 10:48:58 +1100614 return _LoadLibrary(_p0)
615}
616
617func _LoadLibrary(libname *uint16) (handle Handle, err error) {
618 r0, _, e1 := syscall.Syscall(procLoadLibraryW.Addr(), 1, uintptr(unsafe.Pointer(libname)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -0700619 handle = Handle(r0)
620 if handle == 0 {
621 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100622 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700623 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +1000624 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -0700625 }
626 }
627 return
628}
629
Brad Fitzpatrick3dff6e12016-04-01 04:10:49 +0000630func LoadLibraryEx(libname string, zero Handle, flags uintptr) (handle Handle, err error) {
631 var _p0 *uint16
632 _p0, err = syscall.UTF16PtrFromString(libname)
633 if err != nil {
634 return
635 }
636 return _LoadLibraryEx(_p0, zero, flags)
637}
638
639func _LoadLibraryEx(libname *uint16, zero Handle, flags uintptr) (handle Handle, err error) {
640 r0, _, e1 := syscall.Syscall(procLoadLibraryExW.Addr(), 3, uintptr(unsafe.Pointer(libname)), uintptr(zero), uintptr(flags))
641 handle = Handle(r0)
642 if handle == 0 {
643 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100644 err = errnoErr(e1)
Brad Fitzpatrick3dff6e12016-04-01 04:10:49 +0000645 } else {
646 err = syscall.EINVAL
647 }
648 }
649 return
650}
651
Rob Pike20acc5c2014-08-11 14:48:46 -0700652func FreeLibrary(handle Handle) (err error) {
Rob Pike71181952014-08-13 14:08:39 -0700653 r1, _, e1 := syscall.Syscall(procFreeLibrary.Addr(), 1, uintptr(handle), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -0700654 if r1 == 0 {
655 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100656 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700657 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +1000658 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -0700659 }
660 }
661 return
662}
663
664func GetProcAddress(module Handle, procname string) (proc uintptr, err error) {
665 var _p0 *byte
Alex Brainman7d091bf2014-08-19 15:20:17 +1000666 _p0, err = syscall.BytePtrFromString(procname)
Rob Pike20acc5c2014-08-11 14:48:46 -0700667 if err != nil {
668 return
669 }
Alex Brainmanc17938b2014-10-06 10:48:58 +1100670 return _GetProcAddress(module, _p0)
671}
672
673func _GetProcAddress(module Handle, procname *byte) (proc uintptr, err error) {
674 r0, _, e1 := syscall.Syscall(procGetProcAddress.Addr(), 2, uintptr(module), uintptr(unsafe.Pointer(procname)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -0700675 proc = uintptr(r0)
676 if proc == 0 {
677 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100678 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700679 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +1000680 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -0700681 }
682 }
683 return
684}
685
686func GetVersion() (ver uint32, err error) {
Rob Pike71181952014-08-13 14:08:39 -0700687 r0, _, e1 := syscall.Syscall(procGetVersion.Addr(), 0, 0, 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -0700688 ver = uint32(r0)
689 if ver == 0 {
690 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100691 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700692 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +1000693 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -0700694 }
695 }
696 return
697}
698
Alex Brainman2019c8d2015-06-17 15:36:00 +1000699func FormatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, buf []uint16, args *byte) (n uint32, err error) {
Rob Pike20acc5c2014-08-11 14:48:46 -0700700 var _p0 *uint16
701 if len(buf) > 0 {
702 _p0 = &buf[0]
703 }
Rob Pike71181952014-08-13 14:08:39 -0700704 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)
Rob Pike20acc5c2014-08-11 14:48:46 -0700705 n = uint32(r0)
706 if n == 0 {
707 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100708 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700709 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +1000710 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -0700711 }
712 }
713 return
714}
715
716func ExitProcess(exitcode uint32) {
Rob Pike71181952014-08-13 14:08:39 -0700717 syscall.Syscall(procExitProcess.Addr(), 1, uintptr(exitcode), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -0700718 return
719}
720
Jason A. Donenfeld791d8a02019-05-25 15:13:12 +0200721func IsWow64Process(handle Handle, isWow64 *bool) (err error) {
Jason A. Donenfeld0c1ff782019-09-18 00:14:46 -0600722 var _p0 uint32
723 if *isWow64 {
724 _p0 = 1
725 } else {
726 _p0 = 0
727 }
728 r1, _, e1 := syscall.Syscall(procIsWow64Process.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(&_p0)), 0)
729 *isWow64 = _p0 != 0
Jason A. Donenfeld791d8a02019-05-25 15:13:12 +0200730 if r1 == 0 {
731 if e1 != 0 {
732 err = errnoErr(e1)
733 } else {
734 err = syscall.EINVAL
735 }
736 }
737 return
738}
739
Jason A. Donenfeldca7f33d2019-05-06 11:56:55 +0200740func CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile Handle) (handle Handle, err error) {
Rob Pike71181952014-08-13 14:08:39 -0700741 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)
Rob Pike20acc5c2014-08-11 14:48:46 -0700742 handle = Handle(r0)
743 if handle == InvalidHandle {
744 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100745 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700746 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +1000747 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -0700748 }
749 }
750 return
751}
752
753func ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) {
754 var _p0 *byte
755 if len(buf) > 0 {
756 _p0 = &buf[0]
757 }
Rob Pike71181952014-08-13 14:08:39 -0700758 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)
Rob Pike20acc5c2014-08-11 14:48:46 -0700759 if r1 == 0 {
760 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100761 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700762 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +1000763 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -0700764 }
765 }
766 return
767}
768
769func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) {
770 var _p0 *byte
771 if len(buf) > 0 {
772 _p0 = &buf[0]
773 }
Rob Pike71181952014-08-13 14:08:39 -0700774 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)
Rob Pike20acc5c2014-08-11 14:48:46 -0700775 if r1 == 0 {
776 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100777 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700778 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +1000779 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -0700780 }
781 }
782 return
783}
784
Jason A. Donenfeldf49334f2019-03-20 23:14:46 -0600785func GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error) {
786 var _p0 uint32
787 if wait {
788 _p0 = 1
789 } else {
790 _p0 = 0
791 }
792 r1, _, e1 := syscall.Syscall6(procGetOverlappedResult.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(done)), uintptr(_p0), 0, 0)
793 if r1 == 0 {
794 if e1 != 0 {
795 err = errnoErr(e1)
796 } else {
797 err = syscall.EINVAL
798 }
799 }
800 return
801}
802
Rob Pike20acc5c2014-08-11 14:48:46 -0700803func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) {
Rob Pike71181952014-08-13 14:08:39 -0700804 r0, _, e1 := syscall.Syscall6(procSetFilePointer.Addr(), 4, uintptr(handle), uintptr(lowoffset), uintptr(unsafe.Pointer(highoffsetptr)), uintptr(whence), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -0700805 newlowoffset = uint32(r0)
806 if newlowoffset == 0xffffffff {
807 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100808 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700809 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +1000810 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -0700811 }
812 }
813 return
814}
815
816func CloseHandle(handle Handle) (err error) {
Rob Pike71181952014-08-13 14:08:39 -0700817 r1, _, e1 := syscall.Syscall(procCloseHandle.Addr(), 1, uintptr(handle), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -0700818 if r1 == 0 {
819 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100820 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700821 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +1000822 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -0700823 }
824 }
825 return
826}
827
Tamir Dubersteinff24cb32017-04-05 12:54:02 -0400828func GetStdHandle(stdhandle uint32) (handle Handle, err error) {
Rob Pike71181952014-08-13 14:08:39 -0700829 r0, _, e1 := syscall.Syscall(procGetStdHandle.Addr(), 1, uintptr(stdhandle), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -0700830 handle = Handle(r0)
831 if handle == InvalidHandle {
832 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100833 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700834 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +1000835 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -0700836 }
837 }
838 return
839}
840
Tamir Dubersteinf3918c32017-04-05 12:58:12 -0400841func SetStdHandle(stdhandle uint32, handle Handle) (err error) {
842 r1, _, e1 := syscall.Syscall(procSetStdHandle.Addr(), 2, uintptr(stdhandle), uintptr(handle), 0)
843 if r1 == 0 {
844 if e1 != 0 {
845 err = errnoErr(e1)
846 } else {
847 err = syscall.EINVAL
848 }
849 }
850 return
851}
852
Rob Pike20acc5c2014-08-11 14:48:46 -0700853func findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err error) {
Rob Pike71181952014-08-13 14:08:39 -0700854 r0, _, e1 := syscall.Syscall(procFindFirstFileW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(data)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -0700855 handle = Handle(r0)
856 if handle == InvalidHandle {
857 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100858 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700859 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +1000860 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -0700861 }
862 }
863 return
864}
865
866func findNextFile1(handle Handle, data *win32finddata1) (err error) {
Rob Pike71181952014-08-13 14:08:39 -0700867 r1, _, e1 := syscall.Syscall(procFindNextFileW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -0700868 if r1 == 0 {
869 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100870 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700871 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +1000872 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -0700873 }
874 }
875 return
876}
877
878func FindClose(handle Handle) (err error) {
Rob Pike71181952014-08-13 14:08:39 -0700879 r1, _, e1 := syscall.Syscall(procFindClose.Addr(), 1, uintptr(handle), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -0700880 if r1 == 0 {
881 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100882 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700883 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +1000884 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -0700885 }
886 }
887 return
888}
889
890func GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (err error) {
Rob Pike71181952014-08-13 14:08:39 -0700891 r1, _, e1 := syscall.Syscall(procGetFileInformationByHandle.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -0700892 if r1 == 0 {
893 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100894 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700895 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +1000896 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -0700897 }
898 }
899 return
900}
901
James Nugent16da32b2019-04-14 19:23:05 +0000902func GetFileInformationByHandleEx(handle Handle, class uint32, outBuffer *byte, outBufferLen uint32) (err error) {
903 r1, _, e1 := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 4, uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(outBuffer)), uintptr(outBufferLen), 0, 0)
904 if r1 == 0 {
905 if e1 != 0 {
906 err = errnoErr(e1)
907 } else {
908 err = syscall.EINVAL
909 }
910 }
911 return
912}
913
Rob Pike20acc5c2014-08-11 14:48:46 -0700914func GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) {
Rob Pike71181952014-08-13 14:08:39 -0700915 r0, _, e1 := syscall.Syscall(procGetCurrentDirectoryW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -0700916 n = uint32(r0)
917 if n == 0 {
918 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100919 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700920 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +1000921 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -0700922 }
923 }
924 return
925}
926
927func SetCurrentDirectory(path *uint16) (err error) {
Rob Pike71181952014-08-13 14:08:39 -0700928 r1, _, e1 := syscall.Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -0700929 if r1 == 0 {
930 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100931 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700932 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +1000933 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -0700934 }
935 }
936 return
937}
938
939func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) {
Rob Pike71181952014-08-13 14:08:39 -0700940 r1, _, e1 := syscall.Syscall(procCreateDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(sa)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -0700941 if r1 == 0 {
942 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100943 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700944 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +1000945 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -0700946 }
947 }
948 return
949}
950
951func RemoveDirectory(path *uint16) (err error) {
Rob Pike71181952014-08-13 14:08:39 -0700952 r1, _, e1 := syscall.Syscall(procRemoveDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -0700953 if r1 == 0 {
954 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100955 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700956 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +1000957 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -0700958 }
959 }
960 return
961}
962
963func DeleteFile(path *uint16) (err error) {
Rob Pike71181952014-08-13 14:08:39 -0700964 r1, _, e1 := syscall.Syscall(procDeleteFileW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -0700965 if r1 == 0 {
966 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100967 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700968 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +1000969 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -0700970 }
971 }
972 return
973}
974
975func MoveFile(from *uint16, to *uint16) (err error) {
Rob Pike71181952014-08-13 14:08:39 -0700976 r1, _, e1 := syscall.Syscall(procMoveFileW.Addr(), 2, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -0700977 if r1 == 0 {
978 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100979 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -0700980 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +1000981 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -0700982 }
983 }
984 return
985}
986
Alex Brainman442cd602016-01-13 11:01:27 +1100987func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) {
988 r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags))
989 if r1 == 0 {
990 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +1100991 err = errnoErr(e1)
Alex Brainman442cd602016-01-13 11:01:27 +1100992 } else {
993 err = syscall.EINVAL
994 }
995 }
996 return
997}
998
Rob Pike20acc5c2014-08-11 14:48:46 -0700999func GetComputerName(buf *uint16, n *uint32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001000 r1, _, e1 := syscall.Syscall(procGetComputerNameW.Addr(), 2, uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001001 if r1 == 0 {
1002 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001003 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001004 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001005 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001006 }
1007 }
1008 return
1009}
1010
Carlos Castillo5b683252015-02-27 04:46:26 -08001011func GetComputerNameEx(nametype uint32, buf *uint16, n *uint32) (err error) {
1012 r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nametype), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)))
1013 if r1 == 0 {
1014 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001015 err = errnoErr(e1)
Carlos Castillo5b683252015-02-27 04:46:26 -08001016 } else {
1017 err = syscall.EINVAL
1018 }
1019 }
1020 return
1021}
1022
Rob Pike20acc5c2014-08-11 14:48:46 -07001023func SetEndOfFile(handle Handle) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001024 r1, _, e1 := syscall.Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001025 if r1 == 0 {
1026 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001027 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001028 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001029 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001030 }
1031 }
1032 return
1033}
1034
1035func GetSystemTimeAsFileTime(time *Filetime) {
Rob Pike71181952014-08-13 14:08:39 -07001036 syscall.Syscall(procGetSystemTimeAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001037 return
1038}
1039
Tamir Duberstein39e3dc22017-04-05 13:01:15 -04001040func GetSystemTimePreciseAsFileTime(time *Filetime) {
1041 syscall.Syscall(procGetSystemTimePreciseAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0)
1042 return
1043}
1044
Rob Pike20acc5c2014-08-11 14:48:46 -07001045func GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) {
Rob Pike71181952014-08-13 14:08:39 -07001046 r0, _, e1 := syscall.Syscall(procGetTimeZoneInformation.Addr(), 1, uintptr(unsafe.Pointer(tzi)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001047 rc = uint32(r0)
1048 if rc == 0xffffffff {
1049 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001050 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001051 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001052 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001053 }
1054 }
1055 return
1056}
1057
1058func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (handle Handle, err error) {
Rob Pike71181952014-08-13 14:08:39 -07001059 r0, _, e1 := syscall.Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(filehandle), uintptr(cphandle), uintptr(key), uintptr(threadcnt), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001060 handle = Handle(r0)
1061 if handle == 0 {
1062 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001063 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001064 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001065 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001066 }
1067 }
1068 return
1069}
1070
1071func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001072 r1, _, e1 := syscall.Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(cphandle), uintptr(unsafe.Pointer(qty)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(overlapped)), uintptr(timeout), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001073 if r1 == 0 {
1074 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001075 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001076 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001077 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001078 }
1079 }
1080 return
1081}
1082
1083func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001084 r1, _, e1 := syscall.Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001085 if r1 == 0 {
1086 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001087 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001088 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001089 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001090 }
1091 }
1092 return
1093}
1094
1095func CancelIo(s Handle) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001096 r1, _, e1 := syscall.Syscall(procCancelIo.Addr(), 1, uintptr(s), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001097 if r1 == 0 {
1098 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001099 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001100 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001101 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001102 }
1103 }
1104 return
1105}
1106
1107func CancelIoEx(s Handle, o *Overlapped) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001108 r1, _, e1 := syscall.Syscall(procCancelIoEx.Addr(), 2, uintptr(s), uintptr(unsafe.Pointer(o)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001109 if r1 == 0 {
1110 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001111 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001112 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001113 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001114 }
1115 }
1116 return
1117}
1118
1119func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) {
1120 var _p0 uint32
1121 if inheritHandles {
1122 _p0 = 1
1123 } else {
1124 _p0 = 0
1125 }
Rob Pike71181952014-08-13 14:08:39 -07001126 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)
Rob Pike20acc5c2014-08-11 14:48:46 -07001127 if r1 == 0 {
1128 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001129 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001130 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001131 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001132 }
1133 }
1134 return
1135}
1136
Takuto Ikutad442b752019-06-14 11:10:50 +09001137func OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error) {
Rob Pike20acc5c2014-08-11 14:48:46 -07001138 var _p0 uint32
1139 if inheritHandle {
1140 _p0 = 1
1141 } else {
1142 _p0 = 0
1143 }
Takuto Ikutad442b752019-06-14 11:10:50 +09001144 r0, _, e1 := syscall.Syscall(procOpenProcess.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(processId))
Rob Pike20acc5c2014-08-11 14:48:46 -07001145 handle = Handle(r0)
1146 if handle == 0 {
1147 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001148 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001149 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001150 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001151 }
1152 }
1153 return
1154}
1155
Jason A. Donenfeld56c252d2019-05-25 15:17:43 +02001156func ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) {
1157 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))
1158 if r1 == 0 {
1159 if e1 != 0 {
1160 err = errnoErr(e1)
1161 } else {
1162 err = syscall.EINVAL
1163 }
1164 }
1165 return
1166}
1167
Jason A. Donenfeld5ed27942019-06-11 14:57:48 +02001168func shGetKnownFolderPath(id *KNOWNFOLDERID, flags uint32, token Token, path **uint16) (ret error) {
1169 r0, _, _ := syscall.Syscall6(procSHGetKnownFolderPath.Addr(), 4, uintptr(unsafe.Pointer(id)), uintptr(flags), uintptr(token), uintptr(unsafe.Pointer(path)), 0, 0)
1170 if r0 != 0 {
1171 ret = syscall.Errno(r0)
1172 }
1173 return
1174}
1175
Rob Pike20acc5c2014-08-11 14:48:46 -07001176func TerminateProcess(handle Handle, exitcode uint32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001177 r1, _, e1 := syscall.Syscall(procTerminateProcess.Addr(), 2, uintptr(handle), uintptr(exitcode), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001178 if r1 == 0 {
1179 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001180 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001181 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001182 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001183 }
1184 }
1185 return
1186}
1187
1188func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001189 r1, _, e1 := syscall.Syscall(procGetExitCodeProcess.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(exitcode)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001190 if r1 == 0 {
1191 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001192 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001193 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001194 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001195 }
1196 }
1197 return
1198}
1199
1200func GetStartupInfo(startupInfo *StartupInfo) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001201 r1, _, e1 := syscall.Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001202 if r1 == 0 {
1203 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001204 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001205 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001206 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001207 }
1208 }
1209 return
1210}
1211
1212func GetCurrentProcess() (pseudoHandle Handle, err error) {
Rob Pike71181952014-08-13 14:08:39 -07001213 r0, _, e1 := syscall.Syscall(procGetCurrentProcess.Addr(), 0, 0, 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001214 pseudoHandle = Handle(r0)
1215 if pseudoHandle == 0 {
1216 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001217 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001218 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001219 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001220 }
1221 }
1222 return
1223}
1224
Jason A. Donenfeld3a4b5fb2019-05-13 11:46:50 +02001225func GetCurrentThread() (pseudoHandle Handle, err error) {
1226 r0, _, e1 := syscall.Syscall(procGetCurrentThread.Addr(), 0, 0, 0, 0)
1227 pseudoHandle = Handle(r0)
1228 if pseudoHandle == 0 {
1229 if e1 != 0 {
1230 err = errnoErr(e1)
1231 } else {
1232 err = syscall.EINVAL
1233 }
1234 }
1235 return
1236}
1237
Rob Pike20acc5c2014-08-11 14:48:46 -07001238func GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, kernelTime *Filetime, userTime *Filetime) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001239 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)
Rob Pike20acc5c2014-08-11 14:48:46 -07001240 if r1 == 0 {
1241 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001242 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001243 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001244 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001245 }
1246 }
1247 return
1248}
1249
1250func DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetProcessHandle Handle, lpTargetHandle *Handle, dwDesiredAccess uint32, bInheritHandle bool, dwOptions uint32) (err error) {
1251 var _p0 uint32
1252 if bInheritHandle {
1253 _p0 = 1
1254 } else {
1255 _p0 = 0
1256 }
Rob Pike71181952014-08-13 14:08:39 -07001257 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)
Rob Pike20acc5c2014-08-11 14:48:46 -07001258 if r1 == 0 {
1259 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001260 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001261 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001262 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001263 }
1264 }
1265 return
1266}
1267
1268func WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32, err error) {
Rob Pike71181952014-08-13 14:08:39 -07001269 r0, _, e1 := syscall.Syscall(procWaitForSingleObject.Addr(), 2, uintptr(handle), uintptr(waitMilliseconds), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001270 event = uint32(r0)
1271 if event == 0xffffffff {
1272 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001273 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001274 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001275 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001276 }
1277 }
1278 return
1279}
1280
Jason A. Donenfeld980327f2019-02-03 02:44:23 +01001281func waitForMultipleObjects(count uint32, handles uintptr, waitAll bool, waitMilliseconds uint32) (event uint32, err error) {
1282 var _p0 uint32
1283 if waitAll {
1284 _p0 = 1
1285 } else {
1286 _p0 = 0
1287 }
1288 r0, _, e1 := syscall.Syscall6(procWaitForMultipleObjects.Addr(), 4, uintptr(count), uintptr(handles), uintptr(_p0), uintptr(waitMilliseconds), 0, 0)
1289 event = uint32(r0)
1290 if event == 0xffffffff {
1291 if e1 != 0 {
1292 err = errnoErr(e1)
1293 } else {
1294 err = syscall.EINVAL
1295 }
1296 }
1297 return
1298}
1299
Rob Pike20acc5c2014-08-11 14:48:46 -07001300func GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) {
Rob Pike71181952014-08-13 14:08:39 -07001301 r0, _, e1 := syscall.Syscall(procGetTempPathW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001302 n = uint32(r0)
1303 if n == 0 {
1304 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001305 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001306 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001307 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001308 }
1309 }
1310 return
1311}
1312
1313func CreatePipe(readhandle *Handle, writehandle *Handle, sa *SecurityAttributes, size uint32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001314 r1, _, e1 := syscall.Syscall6(procCreatePipe.Addr(), 4, uintptr(unsafe.Pointer(readhandle)), uintptr(unsafe.Pointer(writehandle)), uintptr(unsafe.Pointer(sa)), uintptr(size), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001315 if r1 == 0 {
1316 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001317 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001318 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001319 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001320 }
1321 }
1322 return
1323}
1324
1325func GetFileType(filehandle Handle) (n uint32, err error) {
Rob Pike71181952014-08-13 14:08:39 -07001326 r0, _, e1 := syscall.Syscall(procGetFileType.Addr(), 1, uintptr(filehandle), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001327 n = uint32(r0)
1328 if n == 0 {
1329 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001330 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001331 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001332 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001333 }
1334 }
1335 return
1336}
1337
1338func CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16, provtype uint32, flags uint32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001339 r1, _, e1 := syscall.Syscall6(procCryptAcquireContextW.Addr(), 5, uintptr(unsafe.Pointer(provhandle)), uintptr(unsafe.Pointer(container)), uintptr(unsafe.Pointer(provider)), uintptr(provtype), uintptr(flags), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001340 if r1 == 0 {
1341 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001342 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001343 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001344 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001345 }
1346 }
1347 return
1348}
1349
1350func CryptReleaseContext(provhandle Handle, flags uint32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001351 r1, _, e1 := syscall.Syscall(procCryptReleaseContext.Addr(), 2, uintptr(provhandle), uintptr(flags), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001352 if r1 == 0 {
1353 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001354 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001355 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001356 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001357 }
1358 }
1359 return
1360}
1361
1362func CryptGenRandom(provhandle Handle, buflen uint32, buf *byte) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001363 r1, _, e1 := syscall.Syscall(procCryptGenRandom.Addr(), 3, uintptr(provhandle), uintptr(buflen), uintptr(unsafe.Pointer(buf)))
Rob Pike20acc5c2014-08-11 14:48:46 -07001364 if r1 == 0 {
1365 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001366 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001367 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001368 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001369 }
1370 }
1371 return
1372}
1373
1374func GetEnvironmentStrings() (envs *uint16, err error) {
Rob Pike71181952014-08-13 14:08:39 -07001375 r0, _, e1 := syscall.Syscall(procGetEnvironmentStringsW.Addr(), 0, 0, 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001376 envs = (*uint16)(unsafe.Pointer(r0))
1377 if envs == nil {
1378 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001379 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001380 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001381 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001382 }
1383 }
1384 return
1385}
1386
1387func FreeEnvironmentStrings(envs *uint16) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001388 r1, _, e1 := syscall.Syscall(procFreeEnvironmentStringsW.Addr(), 1, uintptr(unsafe.Pointer(envs)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001389 if r1 == 0 {
1390 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001391 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001392 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001393 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001394 }
1395 }
1396 return
1397}
1398
1399func GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32, err error) {
Rob Pike71181952014-08-13 14:08:39 -07001400 r0, _, e1 := syscall.Syscall(procGetEnvironmentVariableW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buffer)), uintptr(size))
Rob Pike20acc5c2014-08-11 14:48:46 -07001401 n = uint32(r0)
1402 if n == 0 {
1403 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001404 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001405 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001406 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001407 }
1408 }
1409 return
1410}
1411
1412func SetEnvironmentVariable(name *uint16, value *uint16) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001413 r1, _, e1 := syscall.Syscall(procSetEnvironmentVariableW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001414 if r1 == 0 {
1415 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001416 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001417 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001418 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001419 }
1420 }
1421 return
1422}
1423
Jason A. Donenfeld06a5c492019-05-12 16:41:16 +02001424func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) {
1425 var _p0 uint32
1426 if inheritExisting {
1427 _p0 = 1
1428 } else {
1429 _p0 = 0
1430 }
1431 r1, _, e1 := syscall.Syscall(procCreateEnvironmentBlock.Addr(), 3, uintptr(unsafe.Pointer(block)), uintptr(token), uintptr(_p0))
1432 if r1 == 0 {
1433 if e1 != 0 {
1434 err = errnoErr(e1)
1435 } else {
1436 err = syscall.EINVAL
1437 }
1438 }
1439 return
1440}
1441
1442func DestroyEnvironmentBlock(block *uint16) (err error) {
1443 r1, _, e1 := syscall.Syscall(procDestroyEnvironmentBlock.Addr(), 1, uintptr(unsafe.Pointer(block)), 0, 0)
1444 if r1 == 0 {
1445 if e1 != 0 {
1446 err = errnoErr(e1)
1447 } else {
1448 err = syscall.EINVAL
1449 }
1450 }
1451 return
1452}
1453
Jason A. Donenfeld5da28582019-06-06 15:35:02 +02001454func getTickCount64() (ms uint64) {
1455 r0, _, _ := syscall.Syscall(procGetTickCount64.Addr(), 0, 0, 0, 0)
1456 ms = uint64(r0)
1457 return
1458}
1459
Rob Pike20acc5c2014-08-11 14:48:46 -07001460func SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001461 r1, _, e1 := syscall.Syscall6(procSetFileTime.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(ctime)), uintptr(unsafe.Pointer(atime)), uintptr(unsafe.Pointer(wtime)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001462 if r1 == 0 {
1463 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001464 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001465 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001466 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001467 }
1468 }
1469 return
1470}
1471
1472func GetFileAttributes(name *uint16) (attrs uint32, err error) {
Rob Pike71181952014-08-13 14:08:39 -07001473 r0, _, e1 := syscall.Syscall(procGetFileAttributesW.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001474 attrs = uint32(r0)
1475 if attrs == INVALID_FILE_ATTRIBUTES {
1476 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001477 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001478 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001479 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001480 }
1481 }
1482 return
1483}
1484
1485func SetFileAttributes(name *uint16, attrs uint32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001486 r1, _, e1 := syscall.Syscall(procSetFileAttributesW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(attrs), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001487 if r1 == 0 {
1488 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001489 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001490 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001491 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001492 }
1493 }
1494 return
1495}
1496
1497func GetFileAttributesEx(name *uint16, level uint32, info *byte) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001498 r1, _, e1 := syscall.Syscall(procGetFileAttributesExW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(level), uintptr(unsafe.Pointer(info)))
Rob Pike20acc5c2014-08-11 14:48:46 -07001499 if r1 == 0 {
1500 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001501 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001502 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001503 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001504 }
1505 }
1506 return
1507}
1508
1509func GetCommandLine() (cmd *uint16) {
Rob Pike71181952014-08-13 14:08:39 -07001510 r0, _, _ := syscall.Syscall(procGetCommandLineW.Addr(), 0, 0, 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001511 cmd = (*uint16)(unsafe.Pointer(r0))
1512 return
1513}
1514
1515func CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err error) {
Rob Pike71181952014-08-13 14:08:39 -07001516 r0, _, e1 := syscall.Syscall(procCommandLineToArgvW.Addr(), 2, uintptr(unsafe.Pointer(cmd)), uintptr(unsafe.Pointer(argc)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001517 argv = (*[8192]*[8192]uint16)(unsafe.Pointer(r0))
1518 if argv == nil {
1519 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001520 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001521 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001522 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001523 }
1524 }
1525 return
1526}
1527
1528func LocalFree(hmem Handle) (handle Handle, err error) {
Rob Pike71181952014-08-13 14:08:39 -07001529 r0, _, e1 := syscall.Syscall(procLocalFree.Addr(), 1, uintptr(hmem), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001530 handle = Handle(r0)
1531 if handle != 0 {
1532 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001533 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001534 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001535 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001536 }
1537 }
1538 return
1539}
1540
1541func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001542 r1, _, e1 := syscall.Syscall(procSetHandleInformation.Addr(), 3, uintptr(handle), uintptr(mask), uintptr(flags))
Rob Pike20acc5c2014-08-11 14:48:46 -07001543 if r1 == 0 {
1544 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001545 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001546 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001547 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001548 }
1549 }
1550 return
1551}
1552
1553func FlushFileBuffers(handle Handle) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001554 r1, _, e1 := syscall.Syscall(procFlushFileBuffers.Addr(), 1, uintptr(handle), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001555 if r1 == 0 {
1556 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001557 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001558 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001559 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001560 }
1561 }
1562 return
1563}
1564
1565func GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) (n uint32, err error) {
Rob Pike71181952014-08-13 14:08:39 -07001566 r0, _, e1 := syscall.Syscall6(procGetFullPathNameW.Addr(), 4, uintptr(unsafe.Pointer(path)), uintptr(buflen), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(fname)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001567 n = uint32(r0)
1568 if n == 0 {
1569 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001570 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001571 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001572 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001573 }
1574 }
1575 return
1576}
1577
1578func GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err error) {
Rob Pike71181952014-08-13 14:08:39 -07001579 r0, _, e1 := syscall.Syscall(procGetLongPathNameW.Addr(), 3, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(buf)), uintptr(buflen))
Rob Pike20acc5c2014-08-11 14:48:46 -07001580 n = uint32(r0)
1581 if n == 0 {
1582 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001583 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001584 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001585 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001586 }
1587 }
1588 return
1589}
1590
1591func GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uint32, err error) {
Rob Pike71181952014-08-13 14:08:39 -07001592 r0, _, e1 := syscall.Syscall(procGetShortPathNameW.Addr(), 3, uintptr(unsafe.Pointer(longpath)), uintptr(unsafe.Pointer(shortpath)), uintptr(buflen))
Rob Pike20acc5c2014-08-11 14:48:46 -07001593 n = uint32(r0)
1594 if n == 0 {
1595 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001596 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001597 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001598 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001599 }
1600 }
1601 return
1602}
1603
1604func CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error) {
Rob Pike71181952014-08-13 14:08:39 -07001605 r0, _, e1 := syscall.Syscall6(procCreateFileMappingW.Addr(), 6, uintptr(fhandle), uintptr(unsafe.Pointer(sa)), uintptr(prot), uintptr(maxSizeHigh), uintptr(maxSizeLow), uintptr(unsafe.Pointer(name)))
Rob Pike20acc5c2014-08-11 14:48:46 -07001606 handle = Handle(r0)
1607 if handle == 0 {
1608 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001609 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001610 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001611 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001612 }
1613 }
1614 return
1615}
1616
1617func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow uint32, length uintptr) (addr uintptr, err error) {
Rob Pike71181952014-08-13 14:08:39 -07001618 r0, _, e1 := syscall.Syscall6(procMapViewOfFile.Addr(), 5, uintptr(handle), uintptr(access), uintptr(offsetHigh), uintptr(offsetLow), uintptr(length), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001619 addr = uintptr(r0)
1620 if addr == 0 {
1621 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001622 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001623 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001624 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001625 }
1626 }
1627 return
1628}
1629
1630func UnmapViewOfFile(addr uintptr) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001631 r1, _, e1 := syscall.Syscall(procUnmapViewOfFile.Addr(), 1, uintptr(addr), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001632 if r1 == 0 {
1633 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001634 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001635 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001636 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001637 }
1638 }
1639 return
1640}
1641
1642func FlushViewOfFile(addr uintptr, length uintptr) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001643 r1, _, e1 := syscall.Syscall(procFlushViewOfFile.Addr(), 2, uintptr(addr), uintptr(length), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001644 if r1 == 0 {
1645 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001646 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001647 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001648 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001649 }
1650 }
1651 return
1652}
1653
1654func VirtualLock(addr uintptr, length uintptr) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001655 r1, _, e1 := syscall.Syscall(procVirtualLock.Addr(), 2, uintptr(addr), uintptr(length), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001656 if r1 == 0 {
1657 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001658 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001659 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001660 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001661 }
1662 }
1663 return
1664}
1665
1666func VirtualUnlock(addr uintptr, length uintptr) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001667 r1, _, e1 := syscall.Syscall(procVirtualUnlock.Addr(), 2, uintptr(addr), uintptr(length), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001668 if r1 == 0 {
1669 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001670 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001671 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001672 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001673 }
1674 }
1675 return
1676}
1677
Awnd18155c2017-07-01 07:14:08 +01001678func VirtualAlloc(address uintptr, size uintptr, alloctype uint32, protect uint32) (value uintptr, err error) {
1679 r0, _, e1 := syscall.Syscall6(procVirtualAlloc.Addr(), 4, uintptr(address), uintptr(size), uintptr(alloctype), uintptr(protect), 0, 0)
1680 value = uintptr(r0)
1681 if value == 0 {
1682 if e1 != 0 {
1683 err = errnoErr(e1)
1684 } else {
1685 err = syscall.EINVAL
1686 }
1687 }
1688 return
1689}
1690
1691func VirtualFree(address uintptr, size uintptr, freetype uint32) (err error) {
1692 r1, _, e1 := syscall.Syscall(procVirtualFree.Addr(), 3, uintptr(address), uintptr(size), uintptr(freetype))
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 VirtualProtect(address uintptr, size uintptr, newprotect uint32, oldprotect *uint32) (err error) {
1704 r1, _, e1 := syscall.Syscall6(procVirtualProtect.Addr(), 4, uintptr(address), uintptr(size), uintptr(newprotect), uintptr(unsafe.Pointer(oldprotect)), 0, 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
Rob Pike20acc5c2014-08-11 14:48:46 -07001715func TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001716 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)
Rob Pike20acc5c2014-08-11 14:48:46 -07001717 if r1 == 0 {
1718 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001719 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001720 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001721 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001722 }
1723 }
1724 return
1725}
1726
1727func ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
1728 var _p0 uint32
1729 if watchSubTree {
1730 _p0 = 1
1731 } else {
1732 _p0 = 0
1733 }
Rob Pike71181952014-08-13 14:08:39 -07001734 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)
Rob Pike20acc5c2014-08-11 14:48:46 -07001735 if r1 == 0 {
1736 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001737 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001738 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001739 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001740 }
1741 }
1742 return
1743}
1744
1745func CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) {
Rob Pike71181952014-08-13 14:08:39 -07001746 r0, _, e1 := syscall.Syscall(procCertOpenSystemStoreW.Addr(), 2, uintptr(hprov), uintptr(unsafe.Pointer(name)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001747 store = Handle(r0)
1748 if store == 0 {
1749 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001750 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001751 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001752 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001753 }
1754 }
1755 return
1756}
1757
1758func CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) {
Rob Pike71181952014-08-13 14:08:39 -07001759 r0, _, e1 := syscall.Syscall6(procCertOpenStore.Addr(), 5, uintptr(storeProvider), uintptr(msgAndCertEncodingType), uintptr(cryptProv), uintptr(flags), uintptr(para), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001760 handle = Handle(r0)
1761 if handle == InvalidHandle {
1762 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001763 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001764 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001765 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001766 }
1767 }
1768 return
1769}
1770
1771func CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) {
Rob Pike71181952014-08-13 14:08:39 -07001772 r0, _, e1 := syscall.Syscall(procCertEnumCertificatesInStore.Addr(), 2, uintptr(store), uintptr(unsafe.Pointer(prevContext)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001773 context = (*CertContext)(unsafe.Pointer(r0))
1774 if context == nil {
1775 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001776 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001777 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001778 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001779 }
1780 }
1781 return
1782}
1783
1784func CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001785 r1, _, e1 := syscall.Syscall6(procCertAddCertificateContextToStore.Addr(), 4, uintptr(store), uintptr(unsafe.Pointer(certContext)), uintptr(addDisposition), uintptr(unsafe.Pointer(storeContext)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001786 if r1 == 0 {
1787 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001788 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001789 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001790 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001791 }
1792 }
1793 return
1794}
1795
1796func CertCloseStore(store Handle, flags uint32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001797 r1, _, e1 := syscall.Syscall(procCertCloseStore.Addr(), 2, uintptr(store), uintptr(flags), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001798 if r1 == 0 {
1799 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001800 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001801 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001802 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001803 }
1804 }
1805 return
1806}
1807
1808func CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001809 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)
Rob Pike20acc5c2014-08-11 14:48:46 -07001810 if r1 == 0 {
1811 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001812 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001813 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001814 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001815 }
1816 }
1817 return
1818}
1819
1820func CertFreeCertificateChain(ctx *CertChainContext) {
Rob Pike71181952014-08-13 14:08:39 -07001821 syscall.Syscall(procCertFreeCertificateChain.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001822 return
1823}
1824
1825func CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, encodedLen uint32) (context *CertContext, err error) {
Rob Pike71181952014-08-13 14:08:39 -07001826 r0, _, e1 := syscall.Syscall(procCertCreateCertificateContext.Addr(), 3, uintptr(certEncodingType), uintptr(unsafe.Pointer(certEncoded)), uintptr(encodedLen))
Rob Pike20acc5c2014-08-11 14:48:46 -07001827 context = (*CertContext)(unsafe.Pointer(r0))
1828 if context == nil {
1829 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001830 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001831 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001832 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001833 }
1834 }
1835 return
1836}
1837
1838func CertFreeCertificateContext(ctx *CertContext) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001839 r1, _, e1 := syscall.Syscall(procCertFreeCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001840 if r1 == 0 {
1841 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001842 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001843 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001844 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001845 }
1846 }
1847 return
1848}
1849
1850func CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001851 r1, _, e1 := syscall.Syscall6(procCertVerifyCertificateChainPolicy.Addr(), 4, uintptr(policyOID), uintptr(unsafe.Pointer(chain)), uintptr(unsafe.Pointer(para)), uintptr(unsafe.Pointer(status)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001852 if r1 == 0 {
1853 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001854 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001855 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001856 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001857 }
1858 }
1859 return
1860}
1861
1862func RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno error) {
Rob Pike71181952014-08-13 14:08:39 -07001863 r0, _, _ := syscall.Syscall6(procRegOpenKeyExW.Addr(), 5, uintptr(key), uintptr(unsafe.Pointer(subkey)), uintptr(options), uintptr(desiredAccess), uintptr(unsafe.Pointer(result)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001864 if r0 != 0 {
Rob Pike4faa3362014-08-14 10:28:19 -07001865 regerrno = syscall.Errno(r0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001866 }
1867 return
1868}
1869
1870func RegCloseKey(key Handle) (regerrno error) {
Rob Pike71181952014-08-13 14:08:39 -07001871 r0, _, _ := syscall.Syscall(procRegCloseKey.Addr(), 1, uintptr(key), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001872 if r0 != 0 {
Rob Pike4faa3362014-08-14 10:28:19 -07001873 regerrno = syscall.Errno(r0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001874 }
1875 return
1876}
1877
1878func 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) {
Rob Pike71181952014-08-13 14:08:39 -07001879 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)))
Rob Pike20acc5c2014-08-11 14:48:46 -07001880 if r0 != 0 {
Rob Pike4faa3362014-08-14 10:28:19 -07001881 regerrno = syscall.Errno(r0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001882 }
1883 return
1884}
1885
1886func RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) {
Rob Pike71181952014-08-13 14:08:39 -07001887 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)
Rob Pike20acc5c2014-08-11 14:48:46 -07001888 if r0 != 0 {
Rob Pike4faa3362014-08-14 10:28:19 -07001889 regerrno = syscall.Errno(r0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001890 }
1891 return
1892}
1893
1894func RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) {
Rob Pike71181952014-08-13 14:08:39 -07001895 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)))
Rob Pike20acc5c2014-08-11 14:48:46 -07001896 if r0 != 0 {
Rob Pike4faa3362014-08-14 10:28:19 -07001897 regerrno = syscall.Errno(r0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001898 }
1899 return
1900}
1901
Takuto Ikuta1e42afe2019-06-10 16:20:03 +09001902func GetCurrentProcessId() (pid uint32) {
Rob Pike71181952014-08-13 14:08:39 -07001903 r0, _, _ := syscall.Syscall(procGetCurrentProcessId.Addr(), 0, 0, 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001904 pid = uint32(r0)
1905 return
1906}
1907
1908func GetConsoleMode(console Handle, mode *uint32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001909 r1, _, e1 := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001910 if r1 == 0 {
1911 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001912 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001913 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001914 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001915 }
1916 }
1917 return
1918}
1919
Tobias Klauserd6c3f2b2017-08-02 09:46:05 +02001920func SetConsoleMode(console Handle, mode uint32) (err error) {
1921 r1, _, e1 := syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(console), uintptr(mode), 0)
1922 if r1 == 0 {
1923 if e1 != 0 {
1924 err = errnoErr(e1)
1925 } else {
1926 err = syscall.EINVAL
1927 }
1928 }
1929 return
1930}
1931
1932func GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) {
Tobias Klauser07c18292017-08-16 14:26:40 +02001933 r1, _, e1 := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(info)), 0)
Tobias Klauserd6c3f2b2017-08-02 09:46:05 +02001934 if r1 == 0 {
1935 if e1 != 0 {
1936 err = errnoErr(e1)
1937 } else {
1938 err = syscall.EINVAL
1939 }
1940 }
1941 return
1942}
1943
Rob Pike20acc5c2014-08-11 14:48:46 -07001944func WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001945 r1, _, e1 := syscall.Syscall6(procWriteConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(towrite), uintptr(unsafe.Pointer(written)), uintptr(unsafe.Pointer(reserved)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001946 if r1 == 0 {
1947 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001948 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001949 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001950 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001951 }
1952 }
1953 return
1954}
1955
1956func ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001957 r1, _, e1 := syscall.Syscall6(procReadConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(toread), uintptr(unsafe.Pointer(read)), uintptr(unsafe.Pointer(inputControl)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001958 if r1 == 0 {
1959 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001960 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001961 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001962 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001963 }
1964 }
1965 return
1966}
1967
1968func CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) {
Rob Pike71181952014-08-13 14:08:39 -07001969 r0, _, e1 := syscall.Syscall(procCreateToolhelp32Snapshot.Addr(), 2, uintptr(flags), uintptr(processId), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001970 handle = Handle(r0)
1971 if handle == InvalidHandle {
1972 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001973 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001974 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001975 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001976 }
1977 }
1978 return
1979}
1980
1981func Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001982 r1, _, e1 := syscall.Syscall(procProcess32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001983 if r1 == 0 {
1984 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001985 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001986 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001987 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07001988 }
1989 }
1990 return
1991}
1992
1993func Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07001994 r1, _, e1 := syscall.Syscall(procProcess32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07001995 if r1 == 0 {
1996 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11001997 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07001998 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10001999 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002000 }
2001 }
2002 return
2003}
2004
Takuto Ikuta5b154302019-06-07 18:03:35 +09002005func Thread32First(snapshot Handle, threadEntry *ThreadEntry32) (err error) {
2006 r1, _, e1 := syscall.Syscall(procThread32First.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(threadEntry)), 0)
2007 if r1 == 0 {
2008 if e1 != 0 {
2009 err = errnoErr(e1)
2010 } else {
2011 err = syscall.EINVAL
2012 }
2013 }
2014 return
2015}
2016
2017func Thread32Next(snapshot Handle, threadEntry *ThreadEntry32) (err error) {
2018 r1, _, e1 := syscall.Syscall(procThread32Next.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(threadEntry)), 0)
2019 if r1 == 0 {
2020 if e1 != 0 {
2021 err = errnoErr(e1)
2022 } else {
2023 err = syscall.EINVAL
2024 }
2025 }
2026 return
2027}
2028
Rob Pike20acc5c2014-08-11 14:48:46 -07002029func DeviceIoControl(handle Handle, ioControlCode uint32, inBuffer *byte, inBufferSize uint32, outBuffer *byte, outBufferSize uint32, bytesReturned *uint32, overlapped *Overlapped) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07002030 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)
Rob Pike20acc5c2014-08-11 14:48:46 -07002031 if r1 == 0 {
2032 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002033 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07002034 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10002035 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002036 }
2037 }
2038 return
2039}
2040
2041func CreateSymbolicLink(symlinkfilename *uint16, targetfilename *uint16, flags uint32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07002042 r1, _, e1 := syscall.Syscall(procCreateSymbolicLinkW.Addr(), 3, uintptr(unsafe.Pointer(symlinkfilename)), uintptr(unsafe.Pointer(targetfilename)), uintptr(flags))
Rob Pike20acc5c2014-08-11 14:48:46 -07002043 if r1&0xff == 0 {
2044 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002045 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07002046 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10002047 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002048 }
2049 }
2050 return
2051}
2052
2053func CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07002054 r1, _, e1 := syscall.Syscall(procCreateHardLinkW.Addr(), 3, uintptr(unsafe.Pointer(filename)), uintptr(unsafe.Pointer(existingfilename)), uintptr(reserved))
Rob Pike20acc5c2014-08-11 14:48:46 -07002055 if r1&0xff == 0 {
2056 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002057 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07002058 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10002059 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002060 }
2061 }
2062 return
2063}
2064
Alex Brainman65705ef2015-04-17 16:35:40 +10002065func GetCurrentThreadId() (id uint32) {
2066 r0, _, _ := syscall.Syscall(procGetCurrentThreadId.Addr(), 0, 0, 0, 0)
2067 id = uint32(r0)
2068 return
2069}
2070
Tobias Klauser07c18292017-08-16 14:26:40 +02002071func CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) {
Alex Brainman65705ef2015-04-17 16:35:40 +10002072 r0, _, e1 := syscall.Syscall6(procCreateEventW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(manualReset), uintptr(initialState), uintptr(unsafe.Pointer(name)), 0, 0)
2073 handle = Handle(r0)
2074 if handle == 0 {
2075 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002076 err = errnoErr(e1)
Alex Brainman65705ef2015-04-17 16:35:40 +10002077 } else {
2078 err = syscall.EINVAL
2079 }
2080 }
2081 return
2082}
2083
Tobias Klauser07c18292017-08-16 14:26:40 +02002084func CreateEventEx(eventAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) {
2085 r0, _, e1 := syscall.Syscall6(procCreateEventExW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(desiredAccess), 0, 0)
2086 handle = Handle(r0)
2087 if handle == 0 {
2088 if e1 != 0 {
2089 err = errnoErr(e1)
2090 } else {
2091 err = syscall.EINVAL
2092 }
2093 }
2094 return
2095}
2096
2097func OpenEvent(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) {
2098 var _p0 uint32
2099 if inheritHandle {
2100 _p0 = 1
2101 } else {
2102 _p0 = 0
2103 }
2104 r0, _, e1 := syscall.Syscall(procOpenEventW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name)))
2105 handle = Handle(r0)
2106 if handle == 0 {
2107 if e1 != 0 {
2108 err = errnoErr(e1)
2109 } else {
2110 err = syscall.EINVAL
2111 }
2112 }
2113 return
2114}
2115
Alex Brainman65705ef2015-04-17 16:35:40 +10002116func SetEvent(event Handle) (err error) {
2117 r1, _, e1 := syscall.Syscall(procSetEvent.Addr(), 1, uintptr(event), 0, 0)
2118 if r1 == 0 {
2119 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002120 err = errnoErr(e1)
Alex Brainman65705ef2015-04-17 16:35:40 +10002121 } else {
2122 err = syscall.EINVAL
2123 }
2124 }
2125 return
2126}
2127
Tobias Klauser07c18292017-08-16 14:26:40 +02002128func ResetEvent(event Handle) (err error) {
2129 r1, _, e1 := syscall.Syscall(procResetEvent.Addr(), 1, uintptr(event), 0, 0)
2130 if r1 == 0 {
2131 if e1 != 0 {
2132 err = errnoErr(e1)
2133 } else {
2134 err = syscall.EINVAL
2135 }
2136 }
2137 return
2138}
2139
2140func PulseEvent(event Handle) (err error) {
2141 r1, _, e1 := syscall.Syscall(procPulseEvent.Addr(), 1, uintptr(event), 0, 0)
2142 if r1 == 0 {
2143 if e1 != 0 {
2144 err = errnoErr(e1)
2145 } else {
2146 err = syscall.EINVAL
2147 }
2148 }
2149 return
2150}
2151
Jason A. Donenfeld19e00fa2019-08-29 17:20:26 -06002152func CreateMutex(mutexAttrs *SecurityAttributes, initialOwner bool, name *uint16) (handle Handle, err error) {
2153 var _p0 uint32
2154 if initialOwner {
2155 _p0 = 1
2156 } else {
2157 _p0 = 0
2158 }
2159 r0, _, e1 := syscall.Syscall(procCreateMutexW.Addr(), 3, uintptr(unsafe.Pointer(mutexAttrs)), uintptr(_p0), uintptr(unsafe.Pointer(name)))
2160 handle = Handle(r0)
2161 if handle == 0 {
2162 if e1 != 0 {
2163 err = errnoErr(e1)
2164 } else {
2165 err = syscall.EINVAL
2166 }
2167 }
2168 return
2169}
2170
2171func CreateMutexEx(mutexAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) {
2172 r0, _, e1 := syscall.Syscall6(procCreateMutexExW.Addr(), 4, uintptr(unsafe.Pointer(mutexAttrs)), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(desiredAccess), 0, 0)
2173 handle = Handle(r0)
2174 if handle == 0 {
2175 if e1 != 0 {
2176 err = errnoErr(e1)
2177 } else {
2178 err = syscall.EINVAL
2179 }
2180 }
2181 return
2182}
2183
2184func OpenMutex(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) {
2185 var _p0 uint32
2186 if inheritHandle {
2187 _p0 = 1
2188 } else {
2189 _p0 = 0
2190 }
2191 r0, _, e1 := syscall.Syscall(procOpenMutexW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name)))
2192 handle = Handle(r0)
2193 if handle == 0 {
2194 if e1 != 0 {
2195 err = errnoErr(e1)
2196 } else {
2197 err = syscall.EINVAL
2198 }
2199 }
2200 return
2201}
2202
2203func ReleaseMutex(mutex Handle) (err error) {
2204 r1, _, e1 := syscall.Syscall(procReleaseMutex.Addr(), 1, uintptr(mutex), 0, 0)
2205 if r1 == 0 {
2206 if e1 != 0 {
2207 err = errnoErr(e1)
2208 } else {
2209 err = syscall.EINVAL
2210 }
2211 }
2212 return
2213}
2214
Jason A. Donenfeld24a5b222019-05-13 11:27:51 +02002215func SleepEx(milliseconds uint32, alertable bool) (ret uint32) {
2216 var _p0 uint32
2217 if alertable {
2218 _p0 = 1
2219 } else {
2220 _p0 = 0
2221 }
2222 r0, _, _ := syscall.Syscall(procSleepEx.Addr(), 2, uintptr(milliseconds), uintptr(_p0), 0)
2223 ret = uint32(r0)
2224 return
2225}
2226
Takuto Ikutac3d486d2019-05-24 21:41:07 +09002227func CreateJobObject(jobAttr *SecurityAttributes, name *uint16) (handle Handle, err error) {
2228 r0, _, e1 := syscall.Syscall(procCreateJobObjectW.Addr(), 2, uintptr(unsafe.Pointer(jobAttr)), uintptr(unsafe.Pointer(name)), 0)
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 AssignProcessToJobObject(job Handle, process Handle) (err error) {
2241 r1, _, e1 := syscall.Syscall(procAssignProcessToJobObject.Addr(), 2, uintptr(job), uintptr(process), 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 TerminateJobObject(job Handle, exitCode uint32) (err error) {
2253 r1, _, e1 := syscall.Syscall(procTerminateJobObject.Addr(), 2, uintptr(job), uintptr(exitCode), 0)
2254 if r1 == 0 {
2255 if e1 != 0 {
2256 err = errnoErr(e1)
2257 } else {
2258 err = syscall.EINVAL
2259 }
2260 }
2261 return
2262}
2263
Takuto Ikutae44a3b52019-05-24 19:23:22 +09002264func SetErrorMode(mode uint32) (ret uint32) {
2265 r0, _, _ := syscall.Syscall(procSetErrorMode.Addr(), 1, uintptr(mode), 0, 0)
2266 ret = uint32(r0)
2267 return
2268}
2269
Takuto Ikuta9cd64302019-05-27 14:19:46 +09002270func ResumeThread(thread Handle) (ret uint32, err error) {
2271 r0, _, e1 := syscall.Syscall(procResumeThread.Addr(), 1, uintptr(thread), 0, 0)
2272 ret = uint32(r0)
2273 if ret == 0xffffffff {
2274 if e1 != 0 {
2275 err = errnoErr(e1)
2276 } else {
2277 err = syscall.EINVAL
2278 }
2279 }
2280 return
2281}
2282
Takuto Ikuta854af272019-05-28 17:17:54 +09002283func SetPriorityClass(process Handle, priorityClass uint32) (err error) {
2284 r1, _, e1 := syscall.Syscall(procSetPriorityClass.Addr(), 2, uintptr(process), uintptr(priorityClass), 0)
2285 if r1 == 0 {
2286 if e1 != 0 {
2287 err = errnoErr(e1)
2288 } else {
2289 err = syscall.EINVAL
2290 }
2291 }
2292 return
2293}
2294
2295func GetPriorityClass(process Handle) (ret uint32, err error) {
2296 r0, _, e1 := syscall.Syscall(procGetPriorityClass.Addr(), 1, uintptr(process), 0, 0)
2297 ret = uint32(r0)
2298 if ret == 0 {
2299 if e1 != 0 {
2300 err = errnoErr(e1)
2301 } else {
2302 err = syscall.EINVAL
2303 }
2304 }
2305 return
2306}
2307
Takuto Ikutacc920272019-05-28 19:11:08 +09002308func SetInformationJobObject(job Handle, JobObjectInformationClass uint32, JobObjectInformation uintptr, JobObjectInformationLength uint32) (ret int, err error) {
2309 r0, _, e1 := syscall.Syscall6(procSetInformationJobObject.Addr(), 4, uintptr(job), uintptr(JobObjectInformationClass), uintptr(JobObjectInformation), uintptr(JobObjectInformationLength), 0, 0)
2310 ret = int(r0)
2311 if ret == 0 {
2312 if e1 != 0 {
2313 err = errnoErr(e1)
2314 } else {
2315 err = syscall.EINVAL
2316 }
2317 }
2318 return
2319}
2320
Takuto Ikuta95d888e2019-05-30 18:10:03 +09002321func GenerateConsoleCtrlEvent(ctrlEvent uint32, processGroupID uint32) (err error) {
2322 r1, _, e1 := syscall.Syscall(procGenerateConsoleCtrlEvent.Addr(), 2, uintptr(ctrlEvent), uintptr(processGroupID), 0)
2323 if r1 == 0 {
2324 if e1 != 0 {
2325 err = errnoErr(e1)
2326 } else {
2327 err = syscall.EINVAL
2328 }
2329 }
2330 return
2331}
2332
Takuto Ikuta914ada52019-06-11 17:37:06 +09002333func GetProcessId(process Handle) (id uint32, err error) {
2334 r0, _, e1 := syscall.Syscall(procGetProcessId.Addr(), 1, uintptr(process), 0, 0)
2335 id = uint32(r0)
2336 if id == 0 {
2337 if e1 != 0 {
2338 err = errnoErr(e1)
2339 } else {
2340 err = syscall.EINVAL
2341 }
2342 }
2343 return
2344}
2345
Takuto Ikutad442b752019-06-14 11:10:50 +09002346func OpenThread(desiredAccess uint32, inheritHandle bool, threadId uint32) (handle Handle, err error) {
Takuto Ikutaab3f67e2019-06-13 17:41:06 +09002347 var _p0 uint32
2348 if inheritHandle {
2349 _p0 = 1
2350 } else {
2351 _p0 = 0
2352 }
Takuto Ikutad442b752019-06-14 11:10:50 +09002353 r0, _, e1 := syscall.Syscall(procOpenThread.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(threadId))
Takuto Ikutaab3f67e2019-06-13 17:41:06 +09002354 handle = Handle(r0)
2355 if handle == 0 {
2356 if e1 != 0 {
2357 err = errnoErr(e1)
2358 } else {
2359 err = syscall.EINVAL
2360 }
2361 }
2362 return
2363}
2364
Jason A. Donenfeldacd9dae2019-08-26 06:50:32 -06002365func SetProcessPriorityBoost(process Handle, disable bool) (err error) {
2366 var _p0 uint32
2367 if disable {
2368 _p0 = 1
2369 } else {
2370 _p0 = 0
2371 }
2372 r1, _, e1 := syscall.Syscall(procSetProcessPriorityBoost.Addr(), 2, uintptr(process), uintptr(_p0), 0)
2373 if r1 == 0 {
2374 if e1 != 0 {
2375 err = errnoErr(e1)
2376 } else {
2377 err = syscall.EINVAL
2378 }
2379 }
2380 return
2381}
2382
Scott Crunkleton0dd5e192017-11-15 23:26:13 -08002383func DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) {
2384 r1, _, e1 := syscall.Syscall(procDefineDosDeviceW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)))
2385 if r1 == 0 {
2386 if e1 != 0 {
2387 err = errnoErr(e1)
2388 } else {
2389 err = syscall.EINVAL
2390 }
2391 }
2392 return
2393}
2394
2395func DeleteVolumeMountPoint(volumeMountPoint *uint16) (err error) {
2396 r1, _, e1 := syscall.Syscall(procDeleteVolumeMountPointW.Addr(), 1, uintptr(unsafe.Pointer(volumeMountPoint)), 0, 0)
2397 if r1 == 0 {
2398 if e1 != 0 {
2399 err = errnoErr(e1)
2400 } else {
2401 err = syscall.EINVAL
2402 }
2403 }
2404 return
2405}
2406
2407func FindFirstVolume(volumeName *uint16, bufferLength uint32) (handle Handle, err error) {
2408 r0, _, e1 := syscall.Syscall(procFindFirstVolumeW.Addr(), 2, uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength), 0)
2409 handle = Handle(r0)
2410 if handle == InvalidHandle {
2411 if e1 != 0 {
2412 err = errnoErr(e1)
2413 } else {
2414 err = syscall.EINVAL
2415 }
2416 }
2417 return
2418}
2419
2420func FindFirstVolumeMountPoint(rootPathName *uint16, volumeMountPoint *uint16, bufferLength uint32) (handle Handle, err error) {
2421 r0, _, e1 := syscall.Syscall(procFindFirstVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength))
2422 handle = Handle(r0)
2423 if handle == InvalidHandle {
2424 if e1 != 0 {
2425 err = errnoErr(e1)
2426 } else {
2427 err = syscall.EINVAL
2428 }
2429 }
2430 return
2431}
2432
2433func FindNextVolume(findVolume Handle, volumeName *uint16, bufferLength uint32) (err error) {
2434 r1, _, e1 := syscall.Syscall(procFindNextVolumeW.Addr(), 3, uintptr(findVolume), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength))
2435 if r1 == 0 {
2436 if e1 != 0 {
2437 err = errnoErr(e1)
2438 } else {
2439 err = syscall.EINVAL
2440 }
2441 }
2442 return
2443}
2444
2445func FindNextVolumeMountPoint(findVolumeMountPoint Handle, volumeMountPoint *uint16, bufferLength uint32) (err error) {
2446 r1, _, e1 := syscall.Syscall(procFindNextVolumeMountPointW.Addr(), 3, uintptr(findVolumeMountPoint), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength))
2447 if r1 == 0 {
2448 if e1 != 0 {
2449 err = errnoErr(e1)
2450 } else {
2451 err = syscall.EINVAL
2452 }
2453 }
2454 return
2455}
2456
2457func FindVolumeClose(findVolume Handle) (err error) {
2458 r1, _, e1 := syscall.Syscall(procFindVolumeClose.Addr(), 1, uintptr(findVolume), 0, 0)
2459 if r1 == 0 {
2460 if e1 != 0 {
2461 err = errnoErr(e1)
2462 } else {
2463 err = syscall.EINVAL
2464 }
2465 }
2466 return
2467}
2468
2469func FindVolumeMountPointClose(findVolumeMountPoint Handle) (err error) {
2470 r1, _, e1 := syscall.Syscall(procFindVolumeMountPointClose.Addr(), 1, uintptr(findVolumeMountPoint), 0, 0)
2471 if r1 == 0 {
2472 if e1 != 0 {
2473 err = errnoErr(e1)
2474 } else {
2475 err = syscall.EINVAL
2476 }
2477 }
2478 return
2479}
2480
2481func GetDriveType(rootPathName *uint16) (driveType uint32) {
Brad Fitzpatrick0131e682017-12-13 20:31:17 +00002482 r0, _, _ := syscall.Syscall(procGetDriveTypeW.Addr(), 1, uintptr(unsafe.Pointer(rootPathName)), 0, 0)
Scott Crunkleton0dd5e192017-11-15 23:26:13 -08002483 driveType = uint32(r0)
2484 return
2485}
2486
2487func GetLogicalDrives() (drivesBitMask uint32, err error) {
2488 r0, _, e1 := syscall.Syscall(procGetLogicalDrives.Addr(), 0, 0, 0, 0)
2489 drivesBitMask = uint32(r0)
2490 if drivesBitMask == 0 {
2491 if e1 != 0 {
2492 err = errnoErr(e1)
2493 } else {
2494 err = syscall.EINVAL
2495 }
2496 }
2497 return
2498}
2499
2500func GetLogicalDriveStrings(bufferLength uint32, buffer *uint16) (n uint32, err error) {
2501 r0, _, e1 := syscall.Syscall(procGetLogicalDriveStringsW.Addr(), 2, uintptr(bufferLength), uintptr(unsafe.Pointer(buffer)), 0)
2502 n = uint32(r0)
2503 if n == 0 {
2504 if e1 != 0 {
2505 err = errnoErr(e1)
2506 } else {
2507 err = syscall.EINVAL
2508 }
2509 }
2510 return
2511}
2512
2513func GetVolumeInformation(rootPathName *uint16, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) {
2514 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)
2515 if r1 == 0 {
2516 if e1 != 0 {
2517 err = errnoErr(e1)
2518 } else {
2519 err = syscall.EINVAL
2520 }
2521 }
2522 return
2523}
2524
2525func GetVolumeInformationByHandle(file Handle, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) {
2526 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)
2527 if r1 == 0 {
2528 if e1 != 0 {
2529 err = errnoErr(e1)
2530 } else {
2531 err = syscall.EINVAL
2532 }
2533 }
2534 return
2535}
2536
2537func GetVolumeNameForVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16, bufferlength uint32) (err error) {
2538 r1, _, e1 := syscall.Syscall(procGetVolumeNameForVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferlength))
2539 if r1 == 0 {
2540 if e1 != 0 {
2541 err = errnoErr(e1)
2542 } else {
2543 err = syscall.EINVAL
2544 }
2545 }
2546 return
2547}
2548
2549func GetVolumePathName(fileName *uint16, volumePathName *uint16, bufferLength uint32) (err error) {
2550 r1, _, e1 := syscall.Syscall(procGetVolumePathNameW.Addr(), 3, uintptr(unsafe.Pointer(fileName)), uintptr(unsafe.Pointer(volumePathName)), uintptr(bufferLength))
2551 if r1 == 0 {
2552 if e1 != 0 {
2553 err = errnoErr(e1)
2554 } else {
2555 err = syscall.EINVAL
2556 }
2557 }
2558 return
2559}
2560
2561func GetVolumePathNamesForVolumeName(volumeName *uint16, volumePathNames *uint16, bufferLength uint32, returnLength *uint32) (err error) {
2562 r1, _, e1 := syscall.Syscall6(procGetVolumePathNamesForVolumeNameW.Addr(), 4, uintptr(unsafe.Pointer(volumeName)), uintptr(unsafe.Pointer(volumePathNames)), uintptr(bufferLength), uintptr(unsafe.Pointer(returnLength)), 0, 0)
2563 if r1 == 0 {
2564 if e1 != 0 {
2565 err = errnoErr(e1)
2566 } else {
2567 err = syscall.EINVAL
2568 }
2569 }
2570 return
2571}
2572
2573func QueryDosDevice(deviceName *uint16, targetPath *uint16, max uint32) (n uint32, err error) {
2574 r0, _, e1 := syscall.Syscall(procQueryDosDeviceW.Addr(), 3, uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)), uintptr(max))
2575 n = uint32(r0)
2576 if n == 0 {
2577 if e1 != 0 {
2578 err = errnoErr(e1)
2579 } else {
2580 err = syscall.EINVAL
2581 }
2582 }
2583 return
2584}
2585
2586func SetVolumeLabel(rootPathName *uint16, volumeName *uint16) (err error) {
2587 r1, _, e1 := syscall.Syscall(procSetVolumeLabelW.Addr(), 2, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeName)), 0)
2588 if r1 == 0 {
2589 if e1 != 0 {
2590 err = errnoErr(e1)
2591 } else {
2592 err = syscall.EINVAL
2593 }
2594 }
2595 return
2596}
2597
2598func SetVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16) (err error) {
2599 r1, _, e1 := syscall.Syscall(procSetVolumeMountPointW.Addr(), 2, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), 0)
2600 if r1 == 0 {
2601 if e1 != 0 {
2602 err = errnoErr(e1)
2603 } else {
2604 err = syscall.EINVAL
2605 }
2606 }
2607 return
2608}
2609
Jason A. Donenfeldea4c4252019-05-25 15:27:23 +02002610func MessageBox(hwnd Handle, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) {
2611 r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0)
2612 ret = int32(r0)
2613 if ret == 0 {
2614 if e1 != 0 {
2615 err = errnoErr(e1)
2616 } else {
2617 err = syscall.EINVAL
2618 }
2619 }
2620 return
2621}
2622
Jason A. Donenfeld8a691402019-09-15 11:50:40 -06002623func ExitWindowsEx(flags uint32, reason uint32) (err error) {
2624 r1, _, e1 := syscall.Syscall(procExitWindowsEx.Addr(), 2, uintptr(flags), uintptr(reason), 0)
2625 if r1 == 0 {
2626 if e1 != 0 {
2627 err = errnoErr(e1)
2628 } else {
2629 err = syscall.EINVAL
2630 }
2631 }
2632 return
2633}
2634
2635func InitiateSystemShutdownEx(machineName *uint16, message *uint16, timeout uint32, forceAppsClosed bool, rebootAfterShutdown bool, reason uint32) (err error) {
2636 var _p0 uint32
2637 if forceAppsClosed {
2638 _p0 = 1
2639 } else {
2640 _p0 = 0
2641 }
2642 var _p1 uint32
2643 if rebootAfterShutdown {
2644 _p1 = 1
2645 } else {
2646 _p1 = 0
2647 }
2648 r1, _, e1 := syscall.Syscall6(procInitiateSystemShutdownExW.Addr(), 6, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(message)), uintptr(timeout), uintptr(_p0), uintptr(_p1), uintptr(reason))
2649 if r1 == 0 {
2650 if e1 != 0 {
2651 err = errnoErr(e1)
2652 } else {
2653 err = syscall.EINVAL
2654 }
2655 }
2656 return
2657}
2658
2659func SetProcessShutdownParameters(level uint32, flags uint32) (err error) {
2660 r1, _, e1 := syscall.Syscall(procSetProcessShutdownParameters.Addr(), 2, uintptr(level), uintptr(flags), 0)
2661 if r1 == 0 {
2662 if e1 != 0 {
2663 err = errnoErr(e1)
2664 } else {
2665 err = syscall.EINVAL
2666 }
2667 }
2668 return
2669}
2670
2671func GetProcessShutdownParameters(level *uint32, flags *uint32) (err error) {
2672 r1, _, e1 := syscall.Syscall(procGetProcessShutdownParameters.Addr(), 2, uintptr(unsafe.Pointer(level)), uintptr(unsafe.Pointer(flags)), 0)
2673 if r1 == 0 {
2674 if e1 != 0 {
2675 err = errnoErr(e1)
2676 } else {
2677 err = syscall.EINVAL
2678 }
2679 }
2680 return
2681}
2682
Jason A. Donenfeld6df407b2019-06-08 22:13:16 +02002683func clsidFromString(lpsz *uint16, pclsid *GUID) (ret error) {
2684 r0, _, _ := syscall.Syscall(procCLSIDFromString.Addr(), 2, uintptr(unsafe.Pointer(lpsz)), uintptr(unsafe.Pointer(pclsid)), 0)
2685 if r0 != 0 {
2686 ret = syscall.Errno(r0)
Jason A. Donenfeld7fc4e5e2019-06-06 19:29:06 +02002687 }
2688 return
2689}
2690
Jason A. Donenfeld6df407b2019-06-08 22:13:16 +02002691func stringFromGUID2(rguid *GUID, lpsz *uint16, cchMax int32) (chars int32) {
Jason A. Donenfeld7fc4e5e2019-06-06 19:29:06 +02002692 r0, _, _ := syscall.Syscall(procStringFromGUID2.Addr(), 3, uintptr(unsafe.Pointer(rguid)), uintptr(unsafe.Pointer(lpsz)), uintptr(cchMax))
Jason A. Donenfeld6df407b2019-06-08 22:13:16 +02002693 chars = int32(r0)
Jason A. Donenfeld7fc4e5e2019-06-06 19:29:06 +02002694 return
2695}
2696
2697func coCreateGuid(pguid *GUID) (ret error) {
2698 r0, _, _ := syscall.Syscall(procCoCreateGuid.Addr(), 1, uintptr(unsafe.Pointer(pguid)), 0, 0)
2699 if r0 != 0 {
2700 ret = syscall.Errno(r0)
2701 }
2702 return
2703}
2704
Jason A. Donenfelde40ef342019-06-13 14:48:46 +02002705func CoTaskMemFree(address unsafe.Pointer) {
Jason A. Donenfeld5ed27942019-06-11 14:57:48 +02002706 syscall.Syscall(procCoTaskMemFree.Addr(), 1, uintptr(address), 0, 0)
2707 return
2708}
2709
Jason A. Donenfeld516e3c22019-06-18 12:54:32 +02002710func rtlGetVersion(info *OsVersionInfoEx) (ret error) {
2711 r0, _, _ := syscall.Syscall(procRtlGetVersion.Addr(), 1, uintptr(unsafe.Pointer(info)), 0, 0)
2712 if r0 != 0 {
2713 ret = syscall.Errno(r0)
2714 }
2715 return
2716}
2717
Jason A. Donenfeldfb817012019-07-30 23:46:11 +02002718func rtlGetNtVersionNumbers(majorVersion *uint32, minorVersion *uint32, buildNumber *uint32) {
2719 syscall.Syscall(procRtlGetNtVersionNumbers.Addr(), 3, uintptr(unsafe.Pointer(majorVersion)), uintptr(unsafe.Pointer(minorVersion)), uintptr(unsafe.Pointer(buildNumber)))
2720 return
2721}
2722
Rob Pike20acc5c2014-08-11 14:48:46 -07002723func WSAStartup(verreq uint32, data *WSAData) (sockerr error) {
Rob Pike71181952014-08-13 14:08:39 -07002724 r0, _, _ := syscall.Syscall(procWSAStartup.Addr(), 2, uintptr(verreq), uintptr(unsafe.Pointer(data)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07002725 if r0 != 0 {
Rob Pike4faa3362014-08-14 10:28:19 -07002726 sockerr = syscall.Errno(r0)
Rob Pike20acc5c2014-08-11 14:48:46 -07002727 }
2728 return
2729}
2730
2731func WSACleanup() (err error) {
Rob Pike71181952014-08-13 14:08:39 -07002732 r1, _, e1 := syscall.Syscall(procWSACleanup.Addr(), 0, 0, 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07002733 if r1 == socket_error {
2734 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002735 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07002736 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10002737 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002738 }
2739 }
2740 return
2741}
2742
2743func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07002744 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))
Rob Pike20acc5c2014-08-11 14:48:46 -07002745 if r1 == socket_error {
2746 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002747 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07002748 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10002749 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002750 }
2751 }
2752 return
2753}
2754
2755func socket(af int32, typ int32, protocol int32) (handle Handle, err error) {
Rob Pike71181952014-08-13 14:08:39 -07002756 r0, _, e1 := syscall.Syscall(procsocket.Addr(), 3, uintptr(af), uintptr(typ), uintptr(protocol))
Rob Pike20acc5c2014-08-11 14:48:46 -07002757 handle = Handle(r0)
2758 if handle == InvalidHandle {
2759 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002760 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07002761 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10002762 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002763 }
2764 }
2765 return
2766}
2767
2768func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07002769 r1, _, e1 := syscall.Syscall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(optlen), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07002770 if r1 == socket_error {
2771 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002772 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07002773 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10002774 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002775 }
2776 }
2777 return
2778}
2779
2780func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07002781 r1, _, e1 := syscall.Syscall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(unsafe.Pointer(optlen)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07002782 if r1 == socket_error {
2783 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002784 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07002785 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10002786 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002787 }
2788 }
2789 return
2790}
2791
2792func bind(s Handle, name unsafe.Pointer, namelen int32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07002793 r1, _, e1 := syscall.Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
Rob Pike20acc5c2014-08-11 14:48:46 -07002794 if r1 == socket_error {
2795 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002796 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07002797 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10002798 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002799 }
2800 }
2801 return
2802}
2803
2804func connect(s Handle, name unsafe.Pointer, namelen int32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07002805 r1, _, e1 := syscall.Syscall(procconnect.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
Rob Pike20acc5c2014-08-11 14:48:46 -07002806 if r1 == socket_error {
2807 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002808 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07002809 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10002810 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002811 }
2812 }
2813 return
2814}
2815
2816func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07002817 r1, _, e1 := syscall.Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
Rob Pike20acc5c2014-08-11 14:48:46 -07002818 if r1 == socket_error {
2819 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002820 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07002821 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10002822 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002823 }
2824 }
2825 return
2826}
2827
2828func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07002829 r1, _, e1 := syscall.Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
Rob Pike20acc5c2014-08-11 14:48:46 -07002830 if r1 == socket_error {
2831 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002832 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07002833 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10002834 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002835 }
2836 }
2837 return
2838}
2839
2840func listen(s Handle, backlog int32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07002841 r1, _, e1 := syscall.Syscall(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07002842 if r1 == socket_error {
2843 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002844 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07002845 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10002846 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002847 }
2848 }
2849 return
2850}
2851
2852func shutdown(s Handle, how int32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07002853 r1, _, e1 := syscall.Syscall(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07002854 if r1 == socket_error {
2855 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002856 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07002857 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10002858 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002859 }
2860 }
2861 return
2862}
2863
2864func Closesocket(s Handle) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07002865 r1, _, e1 := syscall.Syscall(procclosesocket.Addr(), 1, uintptr(s), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07002866 if r1 == socket_error {
2867 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002868 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07002869 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10002870 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002871 }
2872 }
2873 return
2874}
2875
2876func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07002877 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)
Rob Pike20acc5c2014-08-11 14:48:46 -07002878 if r1 == 0 {
2879 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002880 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07002881 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10002882 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002883 }
2884 }
2885 return
2886}
2887
2888func GetAcceptExSockaddrs(buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, lrsa **RawSockaddrAny, lrsalen *int32, rrsa **RawSockaddrAny, rrsalen *int32) {
Rob Pike71181952014-08-13 14:08:39 -07002889 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)
Rob Pike20acc5c2014-08-11 14:48:46 -07002890 return
2891}
2892
2893func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07002894 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)
Rob Pike20acc5c2014-08-11 14:48:46 -07002895 if r1 == socket_error {
2896 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002897 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07002898 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10002899 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002900 }
2901 }
2902 return
2903}
2904
2905func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07002906 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)
Rob Pike20acc5c2014-08-11 14:48:46 -07002907 if r1 == socket_error {
2908 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002909 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07002910 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10002911 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002912 }
2913 }
2914 return
2915}
2916
2917func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07002918 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)))
Rob Pike20acc5c2014-08-11 14:48:46 -07002919 if r1 == socket_error {
2920 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002921 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07002922 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10002923 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002924 }
2925 }
2926 return
2927}
2928
2929func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07002930 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)))
Rob Pike20acc5c2014-08-11 14:48:46 -07002931 if r1 == socket_error {
2932 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002933 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07002934 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10002935 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002936 }
2937 }
2938 return
2939}
2940
2941func GetHostByName(name string) (h *Hostent, err error) {
2942 var _p0 *byte
Alex Brainman7d091bf2014-08-19 15:20:17 +10002943 _p0, err = syscall.BytePtrFromString(name)
Rob Pike20acc5c2014-08-11 14:48:46 -07002944 if err != nil {
2945 return
2946 }
Alex Brainmanc17938b2014-10-06 10:48:58 +11002947 return _GetHostByName(_p0)
2948}
2949
2950func _GetHostByName(name *byte) (h *Hostent, err error) {
2951 r0, _, e1 := syscall.Syscall(procgethostbyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07002952 h = (*Hostent)(unsafe.Pointer(r0))
2953 if h == nil {
2954 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002955 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07002956 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10002957 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002958 }
2959 }
2960 return
2961}
2962
2963func GetServByName(name string, proto string) (s *Servent, err error) {
2964 var _p0 *byte
Alex Brainman7d091bf2014-08-19 15:20:17 +10002965 _p0, err = syscall.BytePtrFromString(name)
Rob Pike20acc5c2014-08-11 14:48:46 -07002966 if err != nil {
2967 return
2968 }
2969 var _p1 *byte
Alex Brainman7d091bf2014-08-19 15:20:17 +10002970 _p1, err = syscall.BytePtrFromString(proto)
Rob Pike20acc5c2014-08-11 14:48:46 -07002971 if err != nil {
2972 return
2973 }
Alex Brainmanc17938b2014-10-06 10:48:58 +11002974 return _GetServByName(_p0, _p1)
2975}
2976
2977func _GetServByName(name *byte, proto *byte) (s *Servent, err error) {
2978 r0, _, e1 := syscall.Syscall(procgetservbyname.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(proto)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07002979 s = (*Servent)(unsafe.Pointer(r0))
2980 if s == nil {
2981 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11002982 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07002983 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10002984 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07002985 }
2986 }
2987 return
2988}
2989
2990func Ntohs(netshort uint16) (u uint16) {
Rob Pike71181952014-08-13 14:08:39 -07002991 r0, _, _ := syscall.Syscall(procntohs.Addr(), 1, uintptr(netshort), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07002992 u = uint16(r0)
2993 return
2994}
2995
2996func GetProtoByName(name string) (p *Protoent, err error) {
2997 var _p0 *byte
Alex Brainman7d091bf2014-08-19 15:20:17 +10002998 _p0, err = syscall.BytePtrFromString(name)
Rob Pike20acc5c2014-08-11 14:48:46 -07002999 if err != nil {
3000 return
3001 }
Alex Brainmanc17938b2014-10-06 10:48:58 +11003002 return _GetProtoByName(_p0)
3003}
3004
3005func _GetProtoByName(name *byte) (p *Protoent, err error) {
3006 r0, _, e1 := syscall.Syscall(procgetprotobyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07003007 p = (*Protoent)(unsafe.Pointer(r0))
3008 if p == nil {
3009 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11003010 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07003011 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10003012 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07003013 }
3014 }
3015 return
3016}
3017
3018func DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) {
3019 var _p0 *uint16
Alex Brainman7d091bf2014-08-19 15:20:17 +10003020 _p0, status = syscall.UTF16PtrFromString(name)
Rob Pike20acc5c2014-08-11 14:48:46 -07003021 if status != nil {
3022 return
3023 }
Alex Brainmanc17938b2014-10-06 10:48:58 +11003024 return _DnsQuery(_p0, qtype, options, extra, qrs, pr)
3025}
3026
3027func _DnsQuery(name *uint16, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) {
3028 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)))
Rob Pike20acc5c2014-08-11 14:48:46 -07003029 if r0 != 0 {
Rob Pike4faa3362014-08-14 10:28:19 -07003030 status = syscall.Errno(r0)
Rob Pike20acc5c2014-08-11 14:48:46 -07003031 }
3032 return
3033}
3034
3035func DnsRecordListFree(rl *DNSRecord, freetype uint32) {
Rob Pike71181952014-08-13 14:08:39 -07003036 syscall.Syscall(procDnsRecordListFree.Addr(), 2, uintptr(unsafe.Pointer(rl)), uintptr(freetype), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07003037 return
3038}
3039
Alex Brainmand1ee94c2014-08-20 12:25:19 +10003040func DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) {
3041 r0, _, _ := syscall.Syscall(procDnsNameCompare_W.Addr(), 2, uintptr(unsafe.Pointer(name1)), uintptr(unsafe.Pointer(name2)), 0)
3042 same = r0 != 0
3043 return
3044}
3045
Rob Pike20acc5c2014-08-11 14:48:46 -07003046func GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) {
Rob Pike71181952014-08-13 14:08:39 -07003047 r0, _, _ := syscall.Syscall6(procGetAddrInfoW.Addr(), 4, uintptr(unsafe.Pointer(nodename)), uintptr(unsafe.Pointer(servicename)), uintptr(unsafe.Pointer(hints)), uintptr(unsafe.Pointer(result)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07003048 if r0 != 0 {
Rob Pike4faa3362014-08-14 10:28:19 -07003049 sockerr = syscall.Errno(r0)
Rob Pike20acc5c2014-08-11 14:48:46 -07003050 }
3051 return
3052}
3053
3054func FreeAddrInfoW(addrinfo *AddrinfoW) {
Rob Pike71181952014-08-13 14:08:39 -07003055 syscall.Syscall(procFreeAddrInfoW.Addr(), 1, uintptr(unsafe.Pointer(addrinfo)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07003056 return
3057}
3058
3059func GetIfEntry(pIfRow *MibIfRow) (errcode error) {
Rob Pike71181952014-08-13 14:08:39 -07003060 r0, _, _ := syscall.Syscall(procGetIfEntry.Addr(), 1, uintptr(unsafe.Pointer(pIfRow)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07003061 if r0 != 0 {
Rob Pike4faa3362014-08-14 10:28:19 -07003062 errcode = syscall.Errno(r0)
Rob Pike20acc5c2014-08-11 14:48:46 -07003063 }
3064 return
3065}
3066
3067func GetAdaptersInfo(ai *IpAdapterInfo, ol *uint32) (errcode error) {
Rob Pike71181952014-08-13 14:08:39 -07003068 r0, _, _ := syscall.Syscall(procGetAdaptersInfo.Addr(), 2, uintptr(unsafe.Pointer(ai)), uintptr(unsafe.Pointer(ol)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07003069 if r0 != 0 {
Rob Pike4faa3362014-08-14 10:28:19 -07003070 errcode = syscall.Errno(r0)
Rob Pike20acc5c2014-08-11 14:48:46 -07003071 }
3072 return
3073}
3074
3075func SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07003076 r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(handle), uintptr(flags), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07003077 if r1 == 0 {
3078 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11003079 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07003080 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10003081 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07003082 }
3083 }
3084 return
3085}
3086
3087func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferLength *uint32) (n int32, err error) {
Rob Pike71181952014-08-13 14:08:39 -07003088 r0, _, e1 := syscall.Syscall(procWSAEnumProtocolsW.Addr(), 3, uintptr(unsafe.Pointer(protocols)), uintptr(unsafe.Pointer(protocolBuffer)), uintptr(unsafe.Pointer(bufferLength)))
Rob Pike20acc5c2014-08-11 14:48:46 -07003089 n = int32(r0)
3090 if n == -1 {
3091 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11003092 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07003093 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10003094 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07003095 }
3096 }
3097 return
3098}
3099
Alex Brainman442cd602016-01-13 11:01:27 +11003100func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) {
3101 r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0)
3102 if r0 != 0 {
3103 errcode = syscall.Errno(r0)
3104 }
3105 return
3106}
3107
3108func GetACP() (acp uint32) {
3109 r0, _, _ := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0)
3110 acp = uint32(r0)
3111 return
3112}
3113
3114func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) {
3115 r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar))
3116 nwrite = int32(r0)
3117 if nwrite == 0 {
3118 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11003119 err = errnoErr(e1)
Alex Brainman442cd602016-01-13 11:01:27 +11003120 } else {
3121 err = syscall.EINVAL
3122 }
3123 }
3124 return
3125}
3126
Rob Pike20acc5c2014-08-11 14:48:46 -07003127func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint32, translatedName *uint16, nSize *uint32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07003128 r1, _, e1 := syscall.Syscall6(procTranslateNameW.Addr(), 5, uintptr(unsafe.Pointer(accName)), uintptr(accNameFormat), uintptr(desiredNameFormat), uintptr(unsafe.Pointer(translatedName)), uintptr(unsafe.Pointer(nSize)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07003129 if r1&0xff == 0 {
3130 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11003131 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07003132 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10003133 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07003134 }
3135 }
3136 return
3137}
3138
3139func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07003140 r1, _, e1 := syscall.Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize)))
Rob Pike20acc5c2014-08-11 14:48:46 -07003141 if r1&0xff == 0 {
3142 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11003143 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07003144 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10003145 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07003146 }
3147 }
3148 return
3149}
3150
3151func NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **byte) (neterr error) {
Rob Pike71181952014-08-13 14:08:39 -07003152 r0, _, _ := syscall.Syscall6(procNetUserGetInfo.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(userName)), uintptr(level), uintptr(unsafe.Pointer(buf)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07003153 if r0 != 0 {
Rob Pike4faa3362014-08-14 10:28:19 -07003154 neterr = syscall.Errno(r0)
Rob Pike20acc5c2014-08-11 14:48:46 -07003155 }
3156 return
3157}
3158
3159func NetGetJoinInformation(server *uint16, name **uint16, bufType *uint32) (neterr error) {
Rob Pike71181952014-08-13 14:08:39 -07003160 r0, _, _ := syscall.Syscall(procNetGetJoinInformation.Addr(), 3, uintptr(unsafe.Pointer(server)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(bufType)))
Rob Pike20acc5c2014-08-11 14:48:46 -07003161 if r0 != 0 {
Rob Pike4faa3362014-08-14 10:28:19 -07003162 neterr = syscall.Errno(r0)
Rob Pike20acc5c2014-08-11 14:48:46 -07003163 }
3164 return
3165}
3166
3167func NetApiBufferFree(buf *byte) (neterr error) {
Rob Pike71181952014-08-13 14:08:39 -07003168 r0, _, _ := syscall.Syscall(procNetApiBufferFree.Addr(), 1, uintptr(unsafe.Pointer(buf)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07003169 if r0 != 0 {
Rob Pike4faa3362014-08-14 10:28:19 -07003170 neterr = syscall.Errno(r0)
Rob Pike20acc5c2014-08-11 14:48:46 -07003171 }
3172 return
3173}
3174
3175func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07003176 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)
Rob Pike20acc5c2014-08-11 14:48:46 -07003177 if r1 == 0 {
3178 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11003179 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07003180 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10003181 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07003182 }
3183 }
3184 return
3185}
3186
3187func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07003188 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)
Rob Pike20acc5c2014-08-11 14:48:46 -07003189 if r1 == 0 {
3190 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11003191 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07003192 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10003193 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07003194 }
3195 }
3196 return
3197}
3198
3199func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07003200 r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(stringSid)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07003201 if r1 == 0 {
3202 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11003203 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07003204 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10003205 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07003206 }
3207 }
3208 return
3209}
3210
3211func ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07003212 r1, _, e1 := syscall.Syscall(procConvertStringSidToSidW.Addr(), 2, uintptr(unsafe.Pointer(stringSid)), uintptr(unsafe.Pointer(sid)), 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07003213 if r1 == 0 {
3214 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11003215 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07003216 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10003217 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07003218 }
3219 }
3220 return
3221}
3222
3223func GetLengthSid(sid *SID) (len uint32) {
Rob Pike71181952014-08-13 14:08:39 -07003224 r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
Rob Pike20acc5c2014-08-11 14:48:46 -07003225 len = uint32(r0)
3226 return
3227}
3228
3229func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07003230 r1, _, e1 := syscall.Syscall(procCopySid.Addr(), 3, uintptr(destSidLen), uintptr(unsafe.Pointer(destSid)), uintptr(unsafe.Pointer(srcSid)))
Rob Pike20acc5c2014-08-11 14:48:46 -07003231 if r1 == 0 {
3232 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11003233 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07003234 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10003235 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07003236 }
3237 }
3238 return
3239}
3240
Alex Brainman65705ef2015-04-17 16:35:40 +10003241func 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) {
3242 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)
3243 if r1 == 0 {
3244 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11003245 err = errnoErr(e1)
Alex Brainman65705ef2015-04-17 16:35:40 +10003246 } else {
3247 err = syscall.EINVAL
3248 }
3249 }
3250 return
3251}
3252
Jason A. Donenfelda2f829d2019-03-13 03:55:42 -06003253func createWellKnownSid(sidType WELL_KNOWN_SID_TYPE, domainSid *SID, sid *SID, sizeSid *uint32) (err error) {
3254 r1, _, e1 := syscall.Syscall6(procCreateWellKnownSid.Addr(), 4, uintptr(sidType), uintptr(unsafe.Pointer(domainSid)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sizeSid)), 0, 0)
3255 if r1 == 0 {
3256 if e1 != 0 {
3257 err = errnoErr(e1)
3258 } else {
3259 err = syscall.EINVAL
3260 }
3261 }
3262 return
3263}
3264
Jason A. Donenfeld2219a012019-05-21 17:33:12 +02003265func isWellKnownSid(sid *SID, sidType WELL_KNOWN_SID_TYPE) (isWellKnown bool) {
3266 r0, _, _ := syscall.Syscall(procIsWellKnownSid.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(sidType), 0)
3267 isWellKnown = r0 != 0
3268 return
3269}
3270
Alex Brainman65705ef2015-04-17 16:35:40 +10003271func FreeSid(sid *SID) (err error) {
3272 r1, _, e1 := syscall.Syscall(procFreeSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
3273 if r1 != 0 {
3274 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11003275 err = errnoErr(e1)
Alex Brainman65705ef2015-04-17 16:35:40 +10003276 } else {
3277 err = syscall.EINVAL
3278 }
3279 }
3280 return
3281}
3282
3283func EqualSid(sid1 *SID, sid2 *SID) (isEqual bool) {
3284 r0, _, _ := syscall.Syscall(procEqualSid.Addr(), 2, uintptr(unsafe.Pointer(sid1)), uintptr(unsafe.Pointer(sid2)), 0)
3285 isEqual = r0 != 0
3286 return
3287}
3288
Jason A. Donenfeld2219a012019-05-21 17:33:12 +02003289func getSidIdentifierAuthority(sid *SID) (authority *SidIdentifierAuthority) {
3290 r0, _, _ := syscall.Syscall(procGetSidIdentifierAuthority.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
3291 authority = (*SidIdentifierAuthority)(unsafe.Pointer(r0))
3292 return
3293}
3294
3295func getSidSubAuthorityCount(sid *SID) (count *uint8) {
3296 r0, _, _ := syscall.Syscall(procGetSidSubAuthorityCount.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
3297 count = (*uint8)(unsafe.Pointer(r0))
3298 return
3299}
3300
3301func getSidSubAuthority(sid *SID, index uint32) (subAuthority *uint32) {
3302 r0, _, _ := syscall.Syscall(procGetSidSubAuthority.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(index), 0)
3303 subAuthority = (*uint32)(unsafe.Pointer(r0))
3304 return
3305}
3306
3307func isValidSid(sid *SID) (isValid bool) {
3308 r0, _, _ := syscall.Syscall(procIsValidSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
3309 isValid = r0 != 0
3310 return
3311}
3312
Scott Crunkleton1006bb32017-11-27 18:10:40 -08003313func checkTokenMembership(tokenHandle Token, sidToCheck *SID, isMember *int32) (err error) {
3314 r1, _, e1 := syscall.Syscall(procCheckTokenMembership.Addr(), 3, uintptr(tokenHandle), uintptr(unsafe.Pointer(sidToCheck)), uintptr(unsafe.Pointer(isMember)))
3315 if r1 == 0 {
3316 if e1 != 0 {
3317 err = errnoErr(e1)
3318 } else {
3319 err = syscall.EINVAL
3320 }
3321 }
3322 return
3323}
3324
Jason A. Donenfeld3a4b5fb2019-05-13 11:46:50 +02003325func OpenProcessToken(process Handle, access uint32, token *Token) (err error) {
3326 r1, _, e1 := syscall.Syscall(procOpenProcessToken.Addr(), 3, uintptr(process), uintptr(access), uintptr(unsafe.Pointer(token)))
Rob Pike20acc5c2014-08-11 14:48:46 -07003327 if r1 == 0 {
3328 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11003329 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07003330 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10003331 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07003332 }
3333 }
3334 return
3335}
3336
Jason A. Donenfeld3a4b5fb2019-05-13 11:46:50 +02003337func OpenThreadToken(thread Handle, access uint32, openAsSelf bool, token *Token) (err error) {
3338 var _p0 uint32
3339 if openAsSelf {
3340 _p0 = 1
3341 } else {
3342 _p0 = 0
3343 }
3344 r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(thread), uintptr(access), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0)
3345 if r1 == 0 {
3346 if e1 != 0 {
3347 err = errnoErr(e1)
3348 } else {
3349 err = syscall.EINVAL
3350 }
3351 }
3352 return
3353}
3354
Jason A. Donenfeld3a4b5fb2019-05-13 11:46:50 +02003355func ImpersonateSelf(impersonationlevel uint32) (err error) {
3356 r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(impersonationlevel), 0, 0)
3357 if r1 == 0 {
3358 if e1 != 0 {
3359 err = errnoErr(e1)
3360 } else {
3361 err = syscall.EINVAL
3362 }
3363 }
3364 return
3365}
3366
3367func RevertToSelf() (err error) {
3368 r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0)
3369 if r1 == 0 {
3370 if e1 != 0 {
3371 err = errnoErr(e1)
3372 } else {
3373 err = syscall.EINVAL
3374 }
3375 }
3376 return
3377}
3378
3379func SetThreadToken(thread *Handle, token Token) (err error) {
3380 r1, _, e1 := syscall.Syscall(procSetThreadToken.Addr(), 2, uintptr(unsafe.Pointer(thread)), uintptr(token), 0)
3381 if r1 == 0 {
3382 if e1 != 0 {
3383 err = errnoErr(e1)
3384 } else {
3385 err = syscall.EINVAL
3386 }
3387 }
3388 return
3389}
3390
3391func LookupPrivilegeValue(systemname *uint16, name *uint16, luid *LUID) (err error) {
3392 r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemname)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid)))
3393 if r1 == 0 {
3394 if e1 != 0 {
3395 err = errnoErr(e1)
3396 } else {
3397 err = syscall.EINVAL
3398 }
3399 }
3400 return
3401}
3402
3403func AdjustTokenPrivileges(token Token, disableAllPrivileges bool, newstate *Tokenprivileges, buflen uint32, prevstate *Tokenprivileges, returnlen *uint32) (err error) {
3404 var _p0 uint32
3405 if disableAllPrivileges {
3406 _p0 = 1
3407 } else {
3408 _p0 = 0
3409 }
3410 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)))
3411 if r1 == 0 {
3412 if e1 != 0 {
3413 err = errnoErr(e1)
3414 } else {
3415 err = syscall.EINVAL
3416 }
3417 }
3418 return
3419}
3420
Jason A. Donenfeldcedb8e12019-05-15 13:59:33 +02003421func AdjustTokenGroups(token Token, resetToDefault bool, newstate *Tokengroups, buflen uint32, prevstate *Tokengroups, returnlen *uint32) (err error) {
3422 var _p0 uint32
3423 if resetToDefault {
3424 _p0 = 1
3425 } else {
3426 _p0 = 0
3427 }
3428 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)))
3429 if r1 == 0 {
3430 if e1 != 0 {
3431 err = errnoErr(e1)
3432 } else {
3433 err = syscall.EINVAL
3434 }
3435 }
3436 return
3437}
3438
Jason A. Donenfeld3a4b5fb2019-05-13 11:46:50 +02003439func GetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint32, returnedLen *uint32) (err error) {
3440 r1, _, e1 := syscall.Syscall6(procGetTokenInformation.Addr(), 5, uintptr(token), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), uintptr(unsafe.Pointer(returnedLen)), 0)
3441 if r1 == 0 {
3442 if e1 != 0 {
3443 err = errnoErr(e1)
3444 } else {
3445 err = syscall.EINVAL
3446 }
3447 }
3448 return
3449}
3450
3451func SetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint32) (err error) {
3452 r1, _, e1 := syscall.Syscall6(procSetTokenInformation.Addr(), 4, uintptr(token), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), 0, 0)
3453 if r1 == 0 {
3454 if e1 != 0 {
3455 err = errnoErr(e1)
3456 } else {
3457 err = syscall.EINVAL
3458 }
3459 }
3460 return
3461}
3462
3463func DuplicateTokenEx(existingToken Token, desiredAccess uint32, tokenAttributes *SecurityAttributes, impersonationLevel uint32, tokenType uint32, newToken *Token) (err error) {
3464 r1, _, e1 := syscall.Syscall6(procDuplicateTokenEx.Addr(), 6, uintptr(existingToken), uintptr(desiredAccess), uintptr(unsafe.Pointer(tokenAttributes)), uintptr(impersonationLevel), uintptr(tokenType), uintptr(unsafe.Pointer(newToken)))
Rob Pike20acc5c2014-08-11 14:48:46 -07003465 if r1 == 0 {
3466 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11003467 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07003468 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10003469 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07003470 }
3471 }
3472 return
3473}
3474
3475func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) {
Rob Pike71181952014-08-13 14:08:39 -07003476 r1, _, e1 := syscall.Syscall(procGetUserProfileDirectoryW.Addr(), 3, uintptr(t), uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen)))
Rob Pike20acc5c2014-08-11 14:48:46 -07003477 if r1 == 0 {
3478 if e1 != 0 {
Alex Brainmanca83bd22016-12-02 16:54:46 +11003479 err = errnoErr(e1)
Rob Pike20acc5c2014-08-11 14:48:46 -07003480 } else {
Alex Brainman70c4b522014-08-15 13:37:15 +10003481 err = syscall.EINVAL
Rob Pike20acc5c2014-08-11 14:48:46 -07003482 }
3483 }
3484 return
3485}
Jason A. Donenfeld10058d72019-03-06 18:49:41 +01003486
3487func getSystemDirectory(dir *uint16, dirLen uint32) (len uint32, err error) {
3488 r0, _, e1 := syscall.Syscall(procGetSystemDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0)
3489 len = uint32(r0)
3490 if len == 0 {
3491 if e1 != 0 {
3492 err = errnoErr(e1)
3493 } else {
3494 err = syscall.EINVAL
3495 }
3496 }
3497 return
3498}
Jason A. Donenfeldf91f9b32019-05-13 10:42:08 +02003499
Jason A. Donenfeldc7b8b682019-08-25 20:57:52 -06003500func getWindowsDirectory(dir *uint16, dirLen uint32) (len uint32, err error) {
3501 r0, _, e1 := syscall.Syscall(procGetWindowsDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0)
3502 len = uint32(r0)
3503 if len == 0 {
3504 if e1 != 0 {
3505 err = errnoErr(e1)
3506 } else {
3507 err = syscall.EINVAL
3508 }
3509 }
3510 return
3511}
3512
3513func getSystemWindowsDirectory(dir *uint16, dirLen uint32) (len uint32, err error) {
3514 r0, _, e1 := syscall.Syscall(procGetSystemWindowsDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0)
3515 len = uint32(r0)
3516 if len == 0 {
3517 if e1 != 0 {
3518 err = errnoErr(e1)
3519 } else {
3520 err = syscall.EINVAL
3521 }
3522 }
3523 return
3524}
3525
Jason A. Donenfeldf91f9b32019-05-13 10:42:08 +02003526func WTSQueryUserToken(session uint32, token *Token) (err error) {
3527 r1, _, e1 := syscall.Syscall(procWTSQueryUserToken.Addr(), 2, uintptr(session), uintptr(unsafe.Pointer(token)), 0)
3528 if r1 == 0 {
3529 if e1 != 0 {
3530 err = errnoErr(e1)
3531 } else {
3532 err = syscall.EINVAL
3533 }
3534 }
3535 return
3536}
3537
3538func WTSEnumerateSessions(handle Handle, reserved uint32, version uint32, sessions **WTS_SESSION_INFO, count *uint32) (err error) {
3539 r1, _, e1 := syscall.Syscall6(procWTSEnumerateSessionsW.Addr(), 5, uintptr(handle), uintptr(reserved), uintptr(version), uintptr(unsafe.Pointer(sessions)), uintptr(unsafe.Pointer(count)), 0)
3540 if r1 == 0 {
3541 if e1 != 0 {
3542 err = errnoErr(e1)
3543 } else {
3544 err = syscall.EINVAL
3545 }
3546 }
3547 return
3548}
3549
3550func WTSFreeMemory(ptr uintptr) {
3551 syscall.Syscall(procWTSFreeMemory.Addr(), 1, uintptr(ptr), 0, 0)
3552 return
3553}
Jason A. Donenfeld14da1ac2019-09-15 15:06:23 -06003554
3555func getSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) {
3556 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)
3557 if r0 != 0 {
3558 ret = syscall.Errno(r0)
3559 }
3560 return
3561}
3562
3563func SetSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) {
3564 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)
3565 return
3566}
3567
3568func getNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) {
3569 var _p0 *uint16
3570 _p0, ret = syscall.UTF16PtrFromString(objectName)
3571 if ret != nil {
3572 return
3573 }
3574 return _getNamedSecurityInfo(_p0, objectType, securityInformation, owner, group, dacl, sacl, sd)
3575}
3576
3577func _getNamedSecurityInfo(objectName *uint16, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) {
3578 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)
3579 if r0 != 0 {
3580 ret = syscall.Errno(r0)
3581 }
3582 return
3583}
3584
3585func SetNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) (ret error) {
3586 var _p0 *uint16
3587 _p0, ret = syscall.UTF16PtrFromString(objectName)
3588 if ret != nil {
3589 return
3590 }
3591 return _SetNamedSecurityInfo(_p0, objectType, securityInformation, owner, group, dacl, sacl)
3592}
3593
3594func _SetNamedSecurityInfo(objectName *uint16, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) (ret error) {
3595 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)
3596 if r0 != 0 {
3597 ret = syscall.Errno(r0)
3598 }
3599 return
3600}
3601
3602func 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) {
3603 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)))
3604 if r0 != 0 {
3605 ret = syscall.Errno(r0)
3606 }
3607 return
3608}
3609
3610func initializeSecurityDescriptor(absoluteSD *SECURITY_DESCRIPTOR, revision uint32) (err error) {
3611 r1, _, e1 := syscall.Syscall(procInitializeSecurityDescriptor.Addr(), 2, uintptr(unsafe.Pointer(absoluteSD)), uintptr(revision), 0)
3612 if r1 == 0 {
3613 if e1 != 0 {
3614 err = errnoErr(e1)
3615 } else {
3616 err = syscall.EINVAL
3617 }
3618 }
3619 return
3620}
3621
3622func getSecurityDescriptorControl(sd *SECURITY_DESCRIPTOR, control *SECURITY_DESCRIPTOR_CONTROL, revision *uint32) (err error) {
3623 r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorControl.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(control)), uintptr(unsafe.Pointer(revision)))
3624 if r1 == 0 {
3625 if e1 != 0 {
3626 err = errnoErr(e1)
3627 } else {
3628 err = syscall.EINVAL
3629 }
3630 }
3631 return
3632}
3633
3634func getSecurityDescriptorDacl(sd *SECURITY_DESCRIPTOR, daclPresent *bool, dacl **ACL, daclDefaulted *bool) (err error) {
3635 var _p0 uint32
3636 if *daclPresent {
3637 _p0 = 1
3638 } else {
3639 _p0 = 0
3640 }
3641 var _p1 uint32
3642 if *daclDefaulted {
3643 _p1 = 1
3644 } else {
3645 _p1 = 0
3646 }
3647 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)
3648 *daclPresent = _p0 != 0
3649 *daclDefaulted = _p1 != 0
3650 if r1 == 0 {
3651 if e1 != 0 {
3652 err = errnoErr(e1)
3653 } else {
3654 err = syscall.EINVAL
3655 }
3656 }
3657 return
3658}
3659
3660func getSecurityDescriptorSacl(sd *SECURITY_DESCRIPTOR, saclPresent *bool, sacl **ACL, saclDefaulted *bool) (err error) {
3661 var _p0 uint32
3662 if *saclPresent {
3663 _p0 = 1
3664 } else {
3665 _p0 = 0
3666 }
3667 var _p1 uint32
3668 if *saclDefaulted {
3669 _p1 = 1
3670 } else {
3671 _p1 = 0
3672 }
3673 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)
3674 *saclPresent = _p0 != 0
3675 *saclDefaulted = _p1 != 0
3676 if r1 == 0 {
3677 if e1 != 0 {
3678 err = errnoErr(e1)
3679 } else {
3680 err = syscall.EINVAL
3681 }
3682 }
3683 return
3684}
3685
3686func getSecurityDescriptorOwner(sd *SECURITY_DESCRIPTOR, owner **SID, ownerDefaulted *bool) (err error) {
3687 var _p0 uint32
3688 if *ownerDefaulted {
3689 _p0 = 1
3690 } else {
3691 _p0 = 0
3692 }
3693 r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorOwner.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(&_p0)))
3694 *ownerDefaulted = _p0 != 0
3695 if r1 == 0 {
3696 if e1 != 0 {
3697 err = errnoErr(e1)
3698 } else {
3699 err = syscall.EINVAL
3700 }
3701 }
3702 return
3703}
3704
3705func getSecurityDescriptorGroup(sd *SECURITY_DESCRIPTOR, group **SID, groupDefaulted *bool) (err error) {
3706 var _p0 uint32
3707 if *groupDefaulted {
3708 _p0 = 1
3709 } else {
3710 _p0 = 0
3711 }
3712 r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorGroup.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(&_p0)))
3713 *groupDefaulted = _p0 != 0
3714 if r1 == 0 {
3715 if e1 != 0 {
3716 err = errnoErr(e1)
3717 } else {
3718 err = syscall.EINVAL
3719 }
3720 }
3721 return
3722}
3723
3724func getSecurityDescriptorLength(sd *SECURITY_DESCRIPTOR) (len uint32) {
3725 r0, _, _ := syscall.Syscall(procGetSecurityDescriptorLength.Addr(), 1, uintptr(unsafe.Pointer(sd)), 0, 0)
3726 len = uint32(r0)
3727 return
3728}
3729
3730func getSecurityDescriptorRMControl(sd *SECURITY_DESCRIPTOR, rmControl *uint8) (ret error) {
3731 r0, _, _ := syscall.Syscall(procGetSecurityDescriptorRMControl.Addr(), 2, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(rmControl)), 0)
3732 if r0 != 0 {
3733 ret = syscall.Errno(r0)
3734 }
3735 return
3736}
3737
3738func isValidSecurityDescriptor(sd *SECURITY_DESCRIPTOR) (isValid bool) {
3739 r0, _, _ := syscall.Syscall(procIsValidSecurityDescriptor.Addr(), 1, uintptr(unsafe.Pointer(sd)), 0, 0)
3740 isValid = r0 != 0
3741 return
3742}
3743
3744func setSecurityDescriptorControl(sd *SECURITY_DESCRIPTOR, controlBitsOfInterest SECURITY_DESCRIPTOR_CONTROL, controlBitsToSet SECURITY_DESCRIPTOR_CONTROL) (err error) {
3745 r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorControl.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(controlBitsOfInterest), uintptr(controlBitsToSet))
3746 if r1 == 0 {
3747 if e1 != 0 {
3748 err = errnoErr(e1)
3749 } else {
3750 err = syscall.EINVAL
3751 }
3752 }
3753 return
3754}
3755
3756func setSecurityDescriptorDacl(sd *SECURITY_DESCRIPTOR, daclPresent bool, dacl *ACL, daclDefaulted bool) (err error) {
3757 var _p0 uint32
3758 if daclPresent {
3759 _p0 = 1
3760 } else {
3761 _p0 = 0
3762 }
3763 var _p1 uint32
3764 if daclDefaulted {
3765 _p1 = 1
3766 } else {
3767 _p1 = 0
3768 }
3769 r1, _, e1 := syscall.Syscall6(procSetSecurityDescriptorDacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(_p0), uintptr(unsafe.Pointer(dacl)), uintptr(_p1), 0, 0)
3770 if r1 == 0 {
3771 if e1 != 0 {
3772 err = errnoErr(e1)
3773 } else {
3774 err = syscall.EINVAL
3775 }
3776 }
3777 return
3778}
3779
3780func setSecurityDescriptorSacl(sd *SECURITY_DESCRIPTOR, saclPresent bool, sacl *ACL, saclDefaulted bool) (err error) {
3781 var _p0 uint32
3782 if saclPresent {
3783 _p0 = 1
3784 } else {
3785 _p0 = 0
3786 }
3787 var _p1 uint32
3788 if saclDefaulted {
3789 _p1 = 1
3790 } else {
3791 _p1 = 0
3792 }
3793 r1, _, e1 := syscall.Syscall6(procSetSecurityDescriptorSacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(_p0), uintptr(unsafe.Pointer(sacl)), uintptr(_p1), 0, 0)
3794 if r1 == 0 {
3795 if e1 != 0 {
3796 err = errnoErr(e1)
3797 } else {
3798 err = syscall.EINVAL
3799 }
3800 }
3801 return
3802}
3803
3804func setSecurityDescriptorOwner(sd *SECURITY_DESCRIPTOR, owner *SID, ownerDefaulted bool) (err error) {
3805 var _p0 uint32
3806 if ownerDefaulted {
3807 _p0 = 1
3808 } else {
3809 _p0 = 0
3810 }
3811 r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorOwner.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(owner)), uintptr(_p0))
3812 if r1 == 0 {
3813 if e1 != 0 {
3814 err = errnoErr(e1)
3815 } else {
3816 err = syscall.EINVAL
3817 }
3818 }
3819 return
3820}
3821
3822func setSecurityDescriptorGroup(sd *SECURITY_DESCRIPTOR, group *SID, groupDefaulted bool) (err error) {
3823 var _p0 uint32
3824 if groupDefaulted {
3825 _p0 = 1
3826 } else {
3827 _p0 = 0
3828 }
3829 r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorGroup.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(group)), uintptr(_p0))
3830 if r1 == 0 {
3831 if e1 != 0 {
3832 err = errnoErr(e1)
3833 } else {
3834 err = syscall.EINVAL
3835 }
3836 }
3837 return
3838}
3839
3840func setSecurityDescriptorRMControl(sd *SECURITY_DESCRIPTOR, rmControl *uint8) {
3841 syscall.Syscall(procSetSecurityDescriptorRMControl.Addr(), 2, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(rmControl)), 0)
3842 return
3843}
3844
3845func convertStringSecurityDescriptorToSecurityDescriptor(str string, revision uint32, sd **SECURITY_DESCRIPTOR, size *uint32) (err error) {
3846 var _p0 *uint16
3847 _p0, err = syscall.UTF16PtrFromString(str)
3848 if err != nil {
3849 return
3850 }
3851 return _convertStringSecurityDescriptorToSecurityDescriptor(_p0, revision, sd, size)
3852}
3853
3854func _convertStringSecurityDescriptorToSecurityDescriptor(str *uint16, revision uint32, sd **SECURITY_DESCRIPTOR, size *uint32) (err error) {
3855 r1, _, e1 := syscall.Syscall6(procConvertStringSecurityDescriptorToSecurityDescriptorW.Addr(), 4, uintptr(unsafe.Pointer(str)), uintptr(revision), uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(size)), 0, 0)
3856 if r1 == 0 {
3857 if e1 != 0 {
3858 err = errnoErr(e1)
3859 } else {
3860 err = syscall.EINVAL
3861 }
3862 }
3863 return
3864}
3865
3866func convertSecurityDescriptorToStringSecurityDescriptor(sd *SECURITY_DESCRIPTOR, revision uint32, securityInformation SECURITY_INFORMATION, str **uint16, strLen *uint32) (err error) {
3867 r1, _, e1 := syscall.Syscall6(procConvertSecurityDescriptorToStringSecurityDescriptorW.Addr(), 5, uintptr(unsafe.Pointer(sd)), uintptr(revision), uintptr(securityInformation), uintptr(unsafe.Pointer(str)), uintptr(unsafe.Pointer(strLen)), 0)
3868 if r1 == 0 {
3869 if e1 != 0 {
3870 err = errnoErr(e1)
3871 } else {
3872 err = syscall.EINVAL
3873 }
3874 }
3875 return
3876}
3877
3878func 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) {
3879 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)
3880 if r1 == 0 {
3881 if e1 != 0 {
3882 err = errnoErr(e1)
3883 } else {
3884 err = syscall.EINVAL
3885 }
3886 }
3887 return
3888}
3889
3890func makeSelfRelativeSD(absoluteSD *SECURITY_DESCRIPTOR, selfRelativeSD *SECURITY_DESCRIPTOR, selfRelativeSDSize *uint32) (err error) {
3891 r1, _, e1 := syscall.Syscall(procMakeSelfRelativeSD.Addr(), 3, uintptr(unsafe.Pointer(absoluteSD)), uintptr(unsafe.Pointer(selfRelativeSD)), uintptr(unsafe.Pointer(selfRelativeSDSize)))
3892 if r1 == 0 {
3893 if e1 != 0 {
3894 err = errnoErr(e1)
3895 } else {
3896 err = syscall.EINVAL
3897 }
3898 }
3899 return
3900}
3901
3902func setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) {
3903 r0, _, _ := syscall.Syscall6(procSetEntriesInAclW.Addr(), 4, uintptr(countExplicitEntries), uintptr(unsafe.Pointer(explicitEntries)), uintptr(unsafe.Pointer(oldACL)), uintptr(unsafe.Pointer(newACL)), 0, 0)
3904 if r0 != 0 {
3905 ret = syscall.Errno(r0)
3906 }
3907 return
3908}