blob: a7663b5fc280280342f5bc5c46830f2868f17a4a [file] [log] [blame]
Zack Williamse940c7a2019-08-21 14:25:39 -07001// Code generated by 'go generate'; DO NOT EDIT.
2
3package windows
4
5import (
6 "syscall"
7 "unsafe"
8)
9
10var _ unsafe.Pointer
11
12// Do the interface allocations only once for common
13// Errno values.
14const (
15 errnoERROR_IO_PENDING = 997
16)
17
18var (
19 errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
20)
21
22// errnoErr returns common boxed Errno values, to prevent
23// allocations at runtime.
24func errnoErr(e syscall.Errno) error {
25 switch e {
26 case 0:
27 return nil
28 case errnoERROR_IO_PENDING:
29 return errERROR_IO_PENDING
30 }
31 // TODO: add more here, after collecting data on the common
32 // error values see on Windows. (perhaps when running
33 // all.bat?)
34 return e
35}
36
37var (
38 modadvapi32 = NewLazySystemDLL("advapi32.dll")
39 modkernel32 = NewLazySystemDLL("kernel32.dll")
40 modshell32 = NewLazySystemDLL("shell32.dll")
41 moduserenv = NewLazySystemDLL("userenv.dll")
42 modmswsock = NewLazySystemDLL("mswsock.dll")
43 modcrypt32 = NewLazySystemDLL("crypt32.dll")
44 moduser32 = NewLazySystemDLL("user32.dll")
45 modws2_32 = NewLazySystemDLL("ws2_32.dll")
46 moddnsapi = NewLazySystemDLL("dnsapi.dll")
47 modiphlpapi = NewLazySystemDLL("iphlpapi.dll")
48 modsecur32 = NewLazySystemDLL("secur32.dll")
49 modnetapi32 = NewLazySystemDLL("netapi32.dll")
50 modwtsapi32 = NewLazySystemDLL("wtsapi32.dll")
51
52 procRegisterEventSourceW = modadvapi32.NewProc("RegisterEventSourceW")
53 procDeregisterEventSource = modadvapi32.NewProc("DeregisterEventSource")
54 procReportEventW = modadvapi32.NewProc("ReportEventW")
55 procOpenSCManagerW = modadvapi32.NewProc("OpenSCManagerW")
56 procCloseServiceHandle = modadvapi32.NewProc("CloseServiceHandle")
57 procCreateServiceW = modadvapi32.NewProc("CreateServiceW")
58 procOpenServiceW = modadvapi32.NewProc("OpenServiceW")
59 procDeleteService = modadvapi32.NewProc("DeleteService")
60 procStartServiceW = modadvapi32.NewProc("StartServiceW")
61 procQueryServiceStatus = modadvapi32.NewProc("QueryServiceStatus")
62 procControlService = modadvapi32.NewProc("ControlService")
63 procStartServiceCtrlDispatcherW = modadvapi32.NewProc("StartServiceCtrlDispatcherW")
64 procSetServiceStatus = modadvapi32.NewProc("SetServiceStatus")
65 procChangeServiceConfigW = modadvapi32.NewProc("ChangeServiceConfigW")
66 procQueryServiceConfigW = modadvapi32.NewProc("QueryServiceConfigW")
67 procChangeServiceConfig2W = modadvapi32.NewProc("ChangeServiceConfig2W")
68 procQueryServiceConfig2W = modadvapi32.NewProc("QueryServiceConfig2W")
69 procEnumServicesStatusExW = modadvapi32.NewProc("EnumServicesStatusExW")
70 procQueryServiceStatusEx = modadvapi32.NewProc("QueryServiceStatusEx")
71 procNotifyServiceStatusChangeW = modadvapi32.NewProc("NotifyServiceStatusChangeW")
72 procGetLastError = modkernel32.NewProc("GetLastError")
73 procLoadLibraryW = modkernel32.NewProc("LoadLibraryW")
74 procLoadLibraryExW = modkernel32.NewProc("LoadLibraryExW")
75 procFreeLibrary = modkernel32.NewProc("FreeLibrary")
76 procGetProcAddress = modkernel32.NewProc("GetProcAddress")
77 procGetVersion = modkernel32.NewProc("GetVersion")
78 procFormatMessageW = modkernel32.NewProc("FormatMessageW")
79 procExitProcess = modkernel32.NewProc("ExitProcess")
80 procIsWow64Process = modkernel32.NewProc("IsWow64Process")
81 procCreateFileW = modkernel32.NewProc("CreateFileW")
82 procReadFile = modkernel32.NewProc("ReadFile")
83 procWriteFile = modkernel32.NewProc("WriteFile")
84 procGetOverlappedResult = modkernel32.NewProc("GetOverlappedResult")
85 procSetFilePointer = modkernel32.NewProc("SetFilePointer")
86 procCloseHandle = modkernel32.NewProc("CloseHandle")
87 procGetStdHandle = modkernel32.NewProc("GetStdHandle")
88 procSetStdHandle = modkernel32.NewProc("SetStdHandle")
89 procFindFirstFileW = modkernel32.NewProc("FindFirstFileW")
90 procFindNextFileW = modkernel32.NewProc("FindNextFileW")
91 procFindClose = modkernel32.NewProc("FindClose")
92 procGetFileInformationByHandle = modkernel32.NewProc("GetFileInformationByHandle")
93 procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx")
94 procGetCurrentDirectoryW = modkernel32.NewProc("GetCurrentDirectoryW")
95 procSetCurrentDirectoryW = modkernel32.NewProc("SetCurrentDirectoryW")
96 procCreateDirectoryW = modkernel32.NewProc("CreateDirectoryW")
97 procRemoveDirectoryW = modkernel32.NewProc("RemoveDirectoryW")
98 procDeleteFileW = modkernel32.NewProc("DeleteFileW")
99 procMoveFileW = modkernel32.NewProc("MoveFileW")
100 procMoveFileExW = modkernel32.NewProc("MoveFileExW")
101 procGetComputerNameW = modkernel32.NewProc("GetComputerNameW")
102 procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
103 procSetEndOfFile = modkernel32.NewProc("SetEndOfFile")
104 procGetSystemTimeAsFileTime = modkernel32.NewProc("GetSystemTimeAsFileTime")
105 procGetSystemTimePreciseAsFileTime = modkernel32.NewProc("GetSystemTimePreciseAsFileTime")
106 procGetTimeZoneInformation = modkernel32.NewProc("GetTimeZoneInformation")
107 procCreateIoCompletionPort = modkernel32.NewProc("CreateIoCompletionPort")
108 procGetQueuedCompletionStatus = modkernel32.NewProc("GetQueuedCompletionStatus")
109 procPostQueuedCompletionStatus = modkernel32.NewProc("PostQueuedCompletionStatus")
110 procCancelIo = modkernel32.NewProc("CancelIo")
111 procCancelIoEx = modkernel32.NewProc("CancelIoEx")
112 procCreateProcessW = modkernel32.NewProc("CreateProcessW")
113 procOpenProcess = modkernel32.NewProc("OpenProcess")
114 procShellExecuteW = modshell32.NewProc("ShellExecuteW")
115 procTerminateProcess = modkernel32.NewProc("TerminateProcess")
116 procGetExitCodeProcess = modkernel32.NewProc("GetExitCodeProcess")
117 procGetStartupInfoW = modkernel32.NewProc("GetStartupInfoW")
118 procGetCurrentProcess = modkernel32.NewProc("GetCurrentProcess")
119 procGetCurrentThread = modkernel32.NewProc("GetCurrentThread")
120 procGetProcessTimes = modkernel32.NewProc("GetProcessTimes")
121 procDuplicateHandle = modkernel32.NewProc("DuplicateHandle")
122 procWaitForSingleObject = modkernel32.NewProc("WaitForSingleObject")
123 procWaitForMultipleObjects = modkernel32.NewProc("WaitForMultipleObjects")
124 procGetTempPathW = modkernel32.NewProc("GetTempPathW")
125 procCreatePipe = modkernel32.NewProc("CreatePipe")
126 procGetFileType = modkernel32.NewProc("GetFileType")
127 procCryptAcquireContextW = modadvapi32.NewProc("CryptAcquireContextW")
128 procCryptReleaseContext = modadvapi32.NewProc("CryptReleaseContext")
129 procCryptGenRandom = modadvapi32.NewProc("CryptGenRandom")
130 procGetEnvironmentStringsW = modkernel32.NewProc("GetEnvironmentStringsW")
131 procFreeEnvironmentStringsW = modkernel32.NewProc("FreeEnvironmentStringsW")
132 procGetEnvironmentVariableW = modkernel32.NewProc("GetEnvironmentVariableW")
133 procSetEnvironmentVariableW = modkernel32.NewProc("SetEnvironmentVariableW")
134 procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock")
135 procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock")
David Bainbridge86971522019-09-26 22:09:39 +0000136 procGetTickCount64 = modkernel32.NewProc("GetTickCount64")
Zack Williamse940c7a2019-08-21 14:25:39 -0700137 procSetFileTime = modkernel32.NewProc("SetFileTime")
138 procGetFileAttributesW = modkernel32.NewProc("GetFileAttributesW")
139 procSetFileAttributesW = modkernel32.NewProc("SetFileAttributesW")
140 procGetFileAttributesExW = modkernel32.NewProc("GetFileAttributesExW")
141 procGetCommandLineW = modkernel32.NewProc("GetCommandLineW")
142 procCommandLineToArgvW = modshell32.NewProc("CommandLineToArgvW")
143 procLocalFree = modkernel32.NewProc("LocalFree")
144 procSetHandleInformation = modkernel32.NewProc("SetHandleInformation")
145 procFlushFileBuffers = modkernel32.NewProc("FlushFileBuffers")
146 procGetFullPathNameW = modkernel32.NewProc("GetFullPathNameW")
147 procGetLongPathNameW = modkernel32.NewProc("GetLongPathNameW")
148 procGetShortPathNameW = modkernel32.NewProc("GetShortPathNameW")
149 procCreateFileMappingW = modkernel32.NewProc("CreateFileMappingW")
150 procMapViewOfFile = modkernel32.NewProc("MapViewOfFile")
151 procUnmapViewOfFile = modkernel32.NewProc("UnmapViewOfFile")
152 procFlushViewOfFile = modkernel32.NewProc("FlushViewOfFile")
153 procVirtualLock = modkernel32.NewProc("VirtualLock")
154 procVirtualUnlock = modkernel32.NewProc("VirtualUnlock")
155 procVirtualAlloc = modkernel32.NewProc("VirtualAlloc")
156 procVirtualFree = modkernel32.NewProc("VirtualFree")
157 procVirtualProtect = modkernel32.NewProc("VirtualProtect")
158 procTransmitFile = modmswsock.NewProc("TransmitFile")
159 procReadDirectoryChangesW = modkernel32.NewProc("ReadDirectoryChangesW")
160 procCertOpenSystemStoreW = modcrypt32.NewProc("CertOpenSystemStoreW")
161 procCertOpenStore = modcrypt32.NewProc("CertOpenStore")
162 procCertEnumCertificatesInStore = modcrypt32.NewProc("CertEnumCertificatesInStore")
163 procCertAddCertificateContextToStore = modcrypt32.NewProc("CertAddCertificateContextToStore")
164 procCertCloseStore = modcrypt32.NewProc("CertCloseStore")
165 procCertGetCertificateChain = modcrypt32.NewProc("CertGetCertificateChain")
166 procCertFreeCertificateChain = modcrypt32.NewProc("CertFreeCertificateChain")
167 procCertCreateCertificateContext = modcrypt32.NewProc("CertCreateCertificateContext")
168 procCertFreeCertificateContext = modcrypt32.NewProc("CertFreeCertificateContext")
169 procCertVerifyCertificateChainPolicy = modcrypt32.NewProc("CertVerifyCertificateChainPolicy")
170 procRegOpenKeyExW = modadvapi32.NewProc("RegOpenKeyExW")
171 procRegCloseKey = modadvapi32.NewProc("RegCloseKey")
172 procRegQueryInfoKeyW = modadvapi32.NewProc("RegQueryInfoKeyW")
173 procRegEnumKeyExW = modadvapi32.NewProc("RegEnumKeyExW")
174 procRegQueryValueExW = modadvapi32.NewProc("RegQueryValueExW")
175 procGetCurrentProcessId = modkernel32.NewProc("GetCurrentProcessId")
176 procGetConsoleMode = modkernel32.NewProc("GetConsoleMode")
177 procSetConsoleMode = modkernel32.NewProc("SetConsoleMode")
178 procGetConsoleScreenBufferInfo = modkernel32.NewProc("GetConsoleScreenBufferInfo")
179 procWriteConsoleW = modkernel32.NewProc("WriteConsoleW")
180 procReadConsoleW = modkernel32.NewProc("ReadConsoleW")
181 procCreateToolhelp32Snapshot = modkernel32.NewProc("CreateToolhelp32Snapshot")
182 procProcess32FirstW = modkernel32.NewProc("Process32FirstW")
183 procProcess32NextW = modkernel32.NewProc("Process32NextW")
184 procDeviceIoControl = modkernel32.NewProc("DeviceIoControl")
185 procCreateSymbolicLinkW = modkernel32.NewProc("CreateSymbolicLinkW")
186 procCreateHardLinkW = modkernel32.NewProc("CreateHardLinkW")
187 procGetCurrentThreadId = modkernel32.NewProc("GetCurrentThreadId")
188 procCreateEventW = modkernel32.NewProc("CreateEventW")
189 procCreateEventExW = modkernel32.NewProc("CreateEventExW")
190 procOpenEventW = modkernel32.NewProc("OpenEventW")
191 procSetEvent = modkernel32.NewProc("SetEvent")
192 procResetEvent = modkernel32.NewProc("ResetEvent")
193 procPulseEvent = modkernel32.NewProc("PulseEvent")
194 procSleepEx = modkernel32.NewProc("SleepEx")
195 procCreateJobObjectW = modkernel32.NewProc("CreateJobObjectW")
196 procAssignProcessToJobObject = modkernel32.NewProc("AssignProcessToJobObject")
197 procTerminateJobObject = modkernel32.NewProc("TerminateJobObject")
198 procSetErrorMode = modkernel32.NewProc("SetErrorMode")
199 procResumeThread = modkernel32.NewProc("ResumeThread")
200 procSetPriorityClass = modkernel32.NewProc("SetPriorityClass")
201 procGetPriorityClass = modkernel32.NewProc("GetPriorityClass")
202 procSetInformationJobObject = modkernel32.NewProc("SetInformationJobObject")
David Bainbridge86971522019-09-26 22:09:39 +0000203 procGenerateConsoleCtrlEvent = modkernel32.NewProc("GenerateConsoleCtrlEvent")
Zack Williamse940c7a2019-08-21 14:25:39 -0700204 procDefineDosDeviceW = modkernel32.NewProc("DefineDosDeviceW")
205 procDeleteVolumeMountPointW = modkernel32.NewProc("DeleteVolumeMountPointW")
206 procFindFirstVolumeW = modkernel32.NewProc("FindFirstVolumeW")
207 procFindFirstVolumeMountPointW = modkernel32.NewProc("FindFirstVolumeMountPointW")
208 procFindNextVolumeW = modkernel32.NewProc("FindNextVolumeW")
209 procFindNextVolumeMountPointW = modkernel32.NewProc("FindNextVolumeMountPointW")
210 procFindVolumeClose = modkernel32.NewProc("FindVolumeClose")
211 procFindVolumeMountPointClose = modkernel32.NewProc("FindVolumeMountPointClose")
212 procGetDriveTypeW = modkernel32.NewProc("GetDriveTypeW")
213 procGetLogicalDrives = modkernel32.NewProc("GetLogicalDrives")
214 procGetLogicalDriveStringsW = modkernel32.NewProc("GetLogicalDriveStringsW")
215 procGetVolumeInformationW = modkernel32.NewProc("GetVolumeInformationW")
216 procGetVolumeInformationByHandleW = modkernel32.NewProc("GetVolumeInformationByHandleW")
217 procGetVolumeNameForVolumeMountPointW = modkernel32.NewProc("GetVolumeNameForVolumeMountPointW")
218 procGetVolumePathNameW = modkernel32.NewProc("GetVolumePathNameW")
219 procGetVolumePathNamesForVolumeNameW = modkernel32.NewProc("GetVolumePathNamesForVolumeNameW")
220 procQueryDosDeviceW = modkernel32.NewProc("QueryDosDeviceW")
221 procSetVolumeLabelW = modkernel32.NewProc("SetVolumeLabelW")
222 procSetVolumeMountPointW = modkernel32.NewProc("SetVolumeMountPointW")
223 procMessageBoxW = moduser32.NewProc("MessageBoxW")
224 procWSAStartup = modws2_32.NewProc("WSAStartup")
225 procWSACleanup = modws2_32.NewProc("WSACleanup")
226 procWSAIoctl = modws2_32.NewProc("WSAIoctl")
227 procsocket = modws2_32.NewProc("socket")
228 procsetsockopt = modws2_32.NewProc("setsockopt")
229 procgetsockopt = modws2_32.NewProc("getsockopt")
230 procbind = modws2_32.NewProc("bind")
231 procconnect = modws2_32.NewProc("connect")
232 procgetsockname = modws2_32.NewProc("getsockname")
233 procgetpeername = modws2_32.NewProc("getpeername")
234 proclisten = modws2_32.NewProc("listen")
235 procshutdown = modws2_32.NewProc("shutdown")
236 procclosesocket = modws2_32.NewProc("closesocket")
237 procAcceptEx = modmswsock.NewProc("AcceptEx")
238 procGetAcceptExSockaddrs = modmswsock.NewProc("GetAcceptExSockaddrs")
239 procWSARecv = modws2_32.NewProc("WSARecv")
240 procWSASend = modws2_32.NewProc("WSASend")
241 procWSARecvFrom = modws2_32.NewProc("WSARecvFrom")
242 procWSASendTo = modws2_32.NewProc("WSASendTo")
243 procgethostbyname = modws2_32.NewProc("gethostbyname")
244 procgetservbyname = modws2_32.NewProc("getservbyname")
245 procntohs = modws2_32.NewProc("ntohs")
246 procgetprotobyname = modws2_32.NewProc("getprotobyname")
247 procDnsQuery_W = moddnsapi.NewProc("DnsQuery_W")
248 procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree")
249 procDnsNameCompare_W = moddnsapi.NewProc("DnsNameCompare_W")
250 procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW")
251 procFreeAddrInfoW = modws2_32.NewProc("FreeAddrInfoW")
252 procGetIfEntry = modiphlpapi.NewProc("GetIfEntry")
253 procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo")
254 procSetFileCompletionNotificationModes = modkernel32.NewProc("SetFileCompletionNotificationModes")
255 procWSAEnumProtocolsW = modws2_32.NewProc("WSAEnumProtocolsW")
256 procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses")
257 procGetACP = modkernel32.NewProc("GetACP")
258 procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar")
259 procTranslateNameW = modsecur32.NewProc("TranslateNameW")
260 procGetUserNameExW = modsecur32.NewProc("GetUserNameExW")
261 procNetUserGetInfo = modnetapi32.NewProc("NetUserGetInfo")
262 procNetGetJoinInformation = modnetapi32.NewProc("NetGetJoinInformation")
263 procNetApiBufferFree = modnetapi32.NewProc("NetApiBufferFree")
264 procLookupAccountSidW = modadvapi32.NewProc("LookupAccountSidW")
265 procLookupAccountNameW = modadvapi32.NewProc("LookupAccountNameW")
266 procConvertSidToStringSidW = modadvapi32.NewProc("ConvertSidToStringSidW")
267 procConvertStringSidToSidW = modadvapi32.NewProc("ConvertStringSidToSidW")
268 procGetLengthSid = modadvapi32.NewProc("GetLengthSid")
269 procCopySid = modadvapi32.NewProc("CopySid")
270 procAllocateAndInitializeSid = modadvapi32.NewProc("AllocateAndInitializeSid")
271 procCreateWellKnownSid = modadvapi32.NewProc("CreateWellKnownSid")
272 procIsWellKnownSid = modadvapi32.NewProc("IsWellKnownSid")
273 procFreeSid = modadvapi32.NewProc("FreeSid")
274 procEqualSid = modadvapi32.NewProc("EqualSid")
275 procGetSidIdentifierAuthority = modadvapi32.NewProc("GetSidIdentifierAuthority")
276 procGetSidSubAuthorityCount = modadvapi32.NewProc("GetSidSubAuthorityCount")
277 procGetSidSubAuthority = modadvapi32.NewProc("GetSidSubAuthority")
278 procIsValidSid = modadvapi32.NewProc("IsValidSid")
279 procCheckTokenMembership = modadvapi32.NewProc("CheckTokenMembership")
280 procOpenProcessToken = modadvapi32.NewProc("OpenProcessToken")
281 procOpenThreadToken = modadvapi32.NewProc("OpenThreadToken")
282 procImpersonateSelf = modadvapi32.NewProc("ImpersonateSelf")
283 procRevertToSelf = modadvapi32.NewProc("RevertToSelf")
284 procSetThreadToken = modadvapi32.NewProc("SetThreadToken")
285 procLookupPrivilegeValueW = modadvapi32.NewProc("LookupPrivilegeValueW")
286 procAdjustTokenPrivileges = modadvapi32.NewProc("AdjustTokenPrivileges")
287 procAdjustTokenGroups = modadvapi32.NewProc("AdjustTokenGroups")
288 procGetTokenInformation = modadvapi32.NewProc("GetTokenInformation")
289 procSetTokenInformation = modadvapi32.NewProc("SetTokenInformation")
290 procDuplicateTokenEx = modadvapi32.NewProc("DuplicateTokenEx")
291 procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW")
292 procGetSystemDirectoryW = modkernel32.NewProc("GetSystemDirectoryW")
293 procWTSQueryUserToken = modwtsapi32.NewProc("WTSQueryUserToken")
294 procWTSEnumerateSessionsW = modwtsapi32.NewProc("WTSEnumerateSessionsW")
295 procWTSFreeMemory = modwtsapi32.NewProc("WTSFreeMemory")
296)
297
298func RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) {
299 r0, _, e1 := syscall.Syscall(procRegisterEventSourceW.Addr(), 2, uintptr(unsafe.Pointer(uncServerName)), uintptr(unsafe.Pointer(sourceName)), 0)
300 handle = Handle(r0)
301 if handle == 0 {
302 if e1 != 0 {
303 err = errnoErr(e1)
304 } else {
305 err = syscall.EINVAL
306 }
307 }
308 return
309}
310
311func DeregisterEventSource(handle Handle) (err error) {
312 r1, _, e1 := syscall.Syscall(procDeregisterEventSource.Addr(), 1, uintptr(handle), 0, 0)
313 if r1 == 0 {
314 if e1 != 0 {
315 err = errnoErr(e1)
316 } else {
317 err = syscall.EINVAL
318 }
319 }
320 return
321}
322
323func ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) {
324 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)))
325 if r1 == 0 {
326 if e1 != 0 {
327 err = errnoErr(e1)
328 } else {
329 err = syscall.EINVAL
330 }
331 }
332 return
333}
334
335func OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle Handle, err error) {
336 r0, _, e1 := syscall.Syscall(procOpenSCManagerW.Addr(), 3, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(databaseName)), uintptr(access))
337 handle = Handle(r0)
338 if handle == 0 {
339 if e1 != 0 {
340 err = errnoErr(e1)
341 } else {
342 err = syscall.EINVAL
343 }
344 }
345 return
346}
347
348func CloseServiceHandle(handle Handle) (err error) {
349 r1, _, e1 := syscall.Syscall(procCloseServiceHandle.Addr(), 1, uintptr(handle), 0, 0)
350 if r1 == 0 {
351 if e1 != 0 {
352 err = errnoErr(e1)
353 } else {
354 err = syscall.EINVAL
355 }
356 }
357 return
358}
359
360func 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) {
361 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)
362 handle = Handle(r0)
363 if handle == 0 {
364 if e1 != 0 {
365 err = errnoErr(e1)
366 } else {
367 err = syscall.EINVAL
368 }
369 }
370 return
371}
372
373func OpenService(mgr Handle, serviceName *uint16, access uint32) (handle Handle, err error) {
374 r0, _, e1 := syscall.Syscall(procOpenServiceW.Addr(), 3, uintptr(mgr), uintptr(unsafe.Pointer(serviceName)), uintptr(access))
375 handle = Handle(r0)
376 if handle == 0 {
377 if e1 != 0 {
378 err = errnoErr(e1)
379 } else {
380 err = syscall.EINVAL
381 }
382 }
383 return
384}
385
386func DeleteService(service Handle) (err error) {
387 r1, _, e1 := syscall.Syscall(procDeleteService.Addr(), 1, uintptr(service), 0, 0)
388 if r1 == 0 {
389 if e1 != 0 {
390 err = errnoErr(e1)
391 } else {
392 err = syscall.EINVAL
393 }
394 }
395 return
396}
397
398func StartService(service Handle, numArgs uint32, argVectors **uint16) (err error) {
399 r1, _, e1 := syscall.Syscall(procStartServiceW.Addr(), 3, uintptr(service), uintptr(numArgs), uintptr(unsafe.Pointer(argVectors)))
400 if r1 == 0 {
401 if e1 != 0 {
402 err = errnoErr(e1)
403 } else {
404 err = syscall.EINVAL
405 }
406 }
407 return
408}
409
410func QueryServiceStatus(service Handle, status *SERVICE_STATUS) (err error) {
411 r1, _, e1 := syscall.Syscall(procQueryServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(status)), 0)
412 if r1 == 0 {
413 if e1 != 0 {
414 err = errnoErr(e1)
415 } else {
416 err = syscall.EINVAL
417 }
418 }
419 return
420}
421
422func ControlService(service Handle, control uint32, status *SERVICE_STATUS) (err error) {
423 r1, _, e1 := syscall.Syscall(procControlService.Addr(), 3, uintptr(service), uintptr(control), uintptr(unsafe.Pointer(status)))
424 if r1 == 0 {
425 if e1 != 0 {
426 err = errnoErr(e1)
427 } else {
428 err = syscall.EINVAL
429 }
430 }
431 return
432}
433
434func StartServiceCtrlDispatcher(serviceTable *SERVICE_TABLE_ENTRY) (err error) {
435 r1, _, e1 := syscall.Syscall(procStartServiceCtrlDispatcherW.Addr(), 1, uintptr(unsafe.Pointer(serviceTable)), 0, 0)
436 if r1 == 0 {
437 if e1 != 0 {
438 err = errnoErr(e1)
439 } else {
440 err = syscall.EINVAL
441 }
442 }
443 return
444}
445
446func SetServiceStatus(service Handle, serviceStatus *SERVICE_STATUS) (err error) {
447 r1, _, e1 := syscall.Syscall(procSetServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(serviceStatus)), 0)
448 if r1 == 0 {
449 if e1 != 0 {
450 err = errnoErr(e1)
451 } else {
452 err = syscall.EINVAL
453 }
454 }
455 return
456}
457
458func 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) {
459 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)
460 if r1 == 0 {
461 if e1 != 0 {
462 err = errnoErr(e1)
463 } else {
464 err = syscall.EINVAL
465 }
466 }
467 return
468}
469
470func QueryServiceConfig(service Handle, serviceConfig *QUERY_SERVICE_CONFIG, bufSize uint32, bytesNeeded *uint32) (err error) {
471 r1, _, e1 := syscall.Syscall6(procQueryServiceConfigW.Addr(), 4, uintptr(service), uintptr(unsafe.Pointer(serviceConfig)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0)
472 if r1 == 0 {
473 if e1 != 0 {
474 err = errnoErr(e1)
475 } else {
476 err = syscall.EINVAL
477 }
478 }
479 return
480}
481
482func ChangeServiceConfig2(service Handle, infoLevel uint32, info *byte) (err error) {
483 r1, _, e1 := syscall.Syscall(procChangeServiceConfig2W.Addr(), 3, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(info)))
484 if r1 == 0 {
485 if e1 != 0 {
486 err = errnoErr(e1)
487 } else {
488 err = syscall.EINVAL
489 }
490 }
491 return
492}
493
494func QueryServiceConfig2(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) {
495 r1, _, e1 := syscall.Syscall6(procQueryServiceConfig2W.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0)
496 if r1 == 0 {
497 if e1 != 0 {
498 err = errnoErr(e1)
499 } else {
500 err = syscall.EINVAL
501 }
502 }
503 return
504}
505
506func EnumServicesStatusEx(mgr Handle, infoLevel uint32, serviceType uint32, serviceState uint32, services *byte, bufSize uint32, bytesNeeded *uint32, servicesReturned *uint32, resumeHandle *uint32, groupName *uint16) (err error) {
507 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)
508 if r1 == 0 {
509 if e1 != 0 {
510 err = errnoErr(e1)
511 } else {
512 err = syscall.EINVAL
513 }
514 }
515 return
516}
517
518func QueryServiceStatusEx(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) {
519 r1, _, e1 := syscall.Syscall6(procQueryServiceStatusEx.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0)
520 if r1 == 0 {
521 if e1 != 0 {
522 err = errnoErr(e1)
523 } else {
524 err = syscall.EINVAL
525 }
526 }
527 return
528}
529
530func NotifyServiceStatusChange(service Handle, notifyMask uint32, notifier *SERVICE_NOTIFY) (ret error) {
531 r0, _, _ := syscall.Syscall(procNotifyServiceStatusChangeW.Addr(), 3, uintptr(service), uintptr(notifyMask), uintptr(unsafe.Pointer(notifier)))
532 if r0 != 0 {
533 ret = syscall.Errno(r0)
534 }
535 return
536}
537
538func GetLastError() (lasterr error) {
539 r0, _, _ := syscall.Syscall(procGetLastError.Addr(), 0, 0, 0, 0)
540 if r0 != 0 {
541 lasterr = syscall.Errno(r0)
542 }
543 return
544}
545
546func LoadLibrary(libname string) (handle Handle, err error) {
547 var _p0 *uint16
548 _p0, err = syscall.UTF16PtrFromString(libname)
549 if err != nil {
550 return
551 }
552 return _LoadLibrary(_p0)
553}
554
555func _LoadLibrary(libname *uint16) (handle Handle, err error) {
556 r0, _, e1 := syscall.Syscall(procLoadLibraryW.Addr(), 1, uintptr(unsafe.Pointer(libname)), 0, 0)
557 handle = Handle(r0)
558 if handle == 0 {
559 if e1 != 0 {
560 err = errnoErr(e1)
561 } else {
562 err = syscall.EINVAL
563 }
564 }
565 return
566}
567
568func LoadLibraryEx(libname string, zero Handle, flags uintptr) (handle Handle, err error) {
569 var _p0 *uint16
570 _p0, err = syscall.UTF16PtrFromString(libname)
571 if err != nil {
572 return
573 }
574 return _LoadLibraryEx(_p0, zero, flags)
575}
576
577func _LoadLibraryEx(libname *uint16, zero Handle, flags uintptr) (handle Handle, err error) {
578 r0, _, e1 := syscall.Syscall(procLoadLibraryExW.Addr(), 3, uintptr(unsafe.Pointer(libname)), uintptr(zero), uintptr(flags))
579 handle = Handle(r0)
580 if handle == 0 {
581 if e1 != 0 {
582 err = errnoErr(e1)
583 } else {
584 err = syscall.EINVAL
585 }
586 }
587 return
588}
589
590func FreeLibrary(handle Handle) (err error) {
591 r1, _, e1 := syscall.Syscall(procFreeLibrary.Addr(), 1, uintptr(handle), 0, 0)
592 if r1 == 0 {
593 if e1 != 0 {
594 err = errnoErr(e1)
595 } else {
596 err = syscall.EINVAL
597 }
598 }
599 return
600}
601
602func GetProcAddress(module Handle, procname string) (proc uintptr, err error) {
603 var _p0 *byte
604 _p0, err = syscall.BytePtrFromString(procname)
605 if err != nil {
606 return
607 }
608 return _GetProcAddress(module, _p0)
609}
610
611func _GetProcAddress(module Handle, procname *byte) (proc uintptr, err error) {
612 r0, _, e1 := syscall.Syscall(procGetProcAddress.Addr(), 2, uintptr(module), uintptr(unsafe.Pointer(procname)), 0)
613 proc = uintptr(r0)
614 if proc == 0 {
615 if e1 != 0 {
616 err = errnoErr(e1)
617 } else {
618 err = syscall.EINVAL
619 }
620 }
621 return
622}
623
624func GetVersion() (ver uint32, err error) {
625 r0, _, e1 := syscall.Syscall(procGetVersion.Addr(), 0, 0, 0, 0)
626 ver = uint32(r0)
627 if ver == 0 {
628 if e1 != 0 {
629 err = errnoErr(e1)
630 } else {
631 err = syscall.EINVAL
632 }
633 }
634 return
635}
636
637func FormatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, buf []uint16, args *byte) (n uint32, err error) {
638 var _p0 *uint16
639 if len(buf) > 0 {
640 _p0 = &buf[0]
641 }
642 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)
643 n = uint32(r0)
644 if n == 0 {
645 if e1 != 0 {
646 err = errnoErr(e1)
647 } else {
648 err = syscall.EINVAL
649 }
650 }
651 return
652}
653
654func ExitProcess(exitcode uint32) {
655 syscall.Syscall(procExitProcess.Addr(), 1, uintptr(exitcode), 0, 0)
656 return
657}
658
659func IsWow64Process(handle Handle, isWow64 *bool) (err error) {
660 r1, _, e1 := syscall.Syscall(procIsWow64Process.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(isWow64)), 0)
661 if r1 == 0 {
662 if e1 != 0 {
663 err = errnoErr(e1)
664 } else {
665 err = syscall.EINVAL
666 }
667 }
668 return
669}
670
671func CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile Handle) (handle Handle, err error) {
672 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)
673 handle = Handle(r0)
674 if handle == InvalidHandle {
675 if e1 != 0 {
676 err = errnoErr(e1)
677 } else {
678 err = syscall.EINVAL
679 }
680 }
681 return
682}
683
684func ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) {
685 var _p0 *byte
686 if len(buf) > 0 {
687 _p0 = &buf[0]
688 }
689 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)
690 if r1 == 0 {
691 if e1 != 0 {
692 err = errnoErr(e1)
693 } else {
694 err = syscall.EINVAL
695 }
696 }
697 return
698}
699
700func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) {
701 var _p0 *byte
702 if len(buf) > 0 {
703 _p0 = &buf[0]
704 }
705 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)
706 if r1 == 0 {
707 if e1 != 0 {
708 err = errnoErr(e1)
709 } else {
710 err = syscall.EINVAL
711 }
712 }
713 return
714}
715
716func GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error) {
717 var _p0 uint32
718 if wait {
719 _p0 = 1
720 } else {
721 _p0 = 0
722 }
723 r1, _, e1 := syscall.Syscall6(procGetOverlappedResult.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(done)), uintptr(_p0), 0, 0)
724 if r1 == 0 {
725 if e1 != 0 {
726 err = errnoErr(e1)
727 } else {
728 err = syscall.EINVAL
729 }
730 }
731 return
732}
733
734func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) {
735 r0, _, e1 := syscall.Syscall6(procSetFilePointer.Addr(), 4, uintptr(handle), uintptr(lowoffset), uintptr(unsafe.Pointer(highoffsetptr)), uintptr(whence), 0, 0)
736 newlowoffset = uint32(r0)
737 if newlowoffset == 0xffffffff {
738 if e1 != 0 {
739 err = errnoErr(e1)
740 } else {
741 err = syscall.EINVAL
742 }
743 }
744 return
745}
746
747func CloseHandle(handle Handle) (err error) {
748 r1, _, e1 := syscall.Syscall(procCloseHandle.Addr(), 1, uintptr(handle), 0, 0)
749 if r1 == 0 {
750 if e1 != 0 {
751 err = errnoErr(e1)
752 } else {
753 err = syscall.EINVAL
754 }
755 }
756 return
757}
758
759func GetStdHandle(stdhandle uint32) (handle Handle, err error) {
760 r0, _, e1 := syscall.Syscall(procGetStdHandle.Addr(), 1, uintptr(stdhandle), 0, 0)
761 handle = Handle(r0)
762 if handle == InvalidHandle {
763 if e1 != 0 {
764 err = errnoErr(e1)
765 } else {
766 err = syscall.EINVAL
767 }
768 }
769 return
770}
771
772func SetStdHandle(stdhandle uint32, handle Handle) (err error) {
773 r1, _, e1 := syscall.Syscall(procSetStdHandle.Addr(), 2, uintptr(stdhandle), uintptr(handle), 0)
774 if r1 == 0 {
775 if e1 != 0 {
776 err = errnoErr(e1)
777 } else {
778 err = syscall.EINVAL
779 }
780 }
781 return
782}
783
784func findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err error) {
785 r0, _, e1 := syscall.Syscall(procFindFirstFileW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(data)), 0)
786 handle = Handle(r0)
787 if handle == InvalidHandle {
788 if e1 != 0 {
789 err = errnoErr(e1)
790 } else {
791 err = syscall.EINVAL
792 }
793 }
794 return
795}
796
797func findNextFile1(handle Handle, data *win32finddata1) (err error) {
798 r1, _, e1 := syscall.Syscall(procFindNextFileW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
799 if r1 == 0 {
800 if e1 != 0 {
801 err = errnoErr(e1)
802 } else {
803 err = syscall.EINVAL
804 }
805 }
806 return
807}
808
809func FindClose(handle Handle) (err error) {
810 r1, _, e1 := syscall.Syscall(procFindClose.Addr(), 1, uintptr(handle), 0, 0)
811 if r1 == 0 {
812 if e1 != 0 {
813 err = errnoErr(e1)
814 } else {
815 err = syscall.EINVAL
816 }
817 }
818 return
819}
820
821func GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (err error) {
822 r1, _, e1 := syscall.Syscall(procGetFileInformationByHandle.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
823 if r1 == 0 {
824 if e1 != 0 {
825 err = errnoErr(e1)
826 } else {
827 err = syscall.EINVAL
828 }
829 }
830 return
831}
832
833func GetFileInformationByHandleEx(handle Handle, class uint32, outBuffer *byte, outBufferLen uint32) (err error) {
834 r1, _, e1 := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 4, uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(outBuffer)), uintptr(outBufferLen), 0, 0)
835 if r1 == 0 {
836 if e1 != 0 {
837 err = errnoErr(e1)
838 } else {
839 err = syscall.EINVAL
840 }
841 }
842 return
843}
844
845func GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) {
846 r0, _, e1 := syscall.Syscall(procGetCurrentDirectoryW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
847 n = uint32(r0)
848 if n == 0 {
849 if e1 != 0 {
850 err = errnoErr(e1)
851 } else {
852 err = syscall.EINVAL
853 }
854 }
855 return
856}
857
858func SetCurrentDirectory(path *uint16) (err error) {
859 r1, _, e1 := syscall.Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
860 if r1 == 0 {
861 if e1 != 0 {
862 err = errnoErr(e1)
863 } else {
864 err = syscall.EINVAL
865 }
866 }
867 return
868}
869
870func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) {
871 r1, _, e1 := syscall.Syscall(procCreateDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(sa)), 0)
872 if r1 == 0 {
873 if e1 != 0 {
874 err = errnoErr(e1)
875 } else {
876 err = syscall.EINVAL
877 }
878 }
879 return
880}
881
882func RemoveDirectory(path *uint16) (err error) {
883 r1, _, e1 := syscall.Syscall(procRemoveDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
884 if r1 == 0 {
885 if e1 != 0 {
886 err = errnoErr(e1)
887 } else {
888 err = syscall.EINVAL
889 }
890 }
891 return
892}
893
894func DeleteFile(path *uint16) (err error) {
895 r1, _, e1 := syscall.Syscall(procDeleteFileW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
896 if r1 == 0 {
897 if e1 != 0 {
898 err = errnoErr(e1)
899 } else {
900 err = syscall.EINVAL
901 }
902 }
903 return
904}
905
906func MoveFile(from *uint16, to *uint16) (err error) {
907 r1, _, e1 := syscall.Syscall(procMoveFileW.Addr(), 2, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), 0)
908 if r1 == 0 {
909 if e1 != 0 {
910 err = errnoErr(e1)
911 } else {
912 err = syscall.EINVAL
913 }
914 }
915 return
916}
917
918func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) {
919 r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags))
920 if r1 == 0 {
921 if e1 != 0 {
922 err = errnoErr(e1)
923 } else {
924 err = syscall.EINVAL
925 }
926 }
927 return
928}
929
930func GetComputerName(buf *uint16, n *uint32) (err error) {
931 r1, _, e1 := syscall.Syscall(procGetComputerNameW.Addr(), 2, uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)), 0)
932 if r1 == 0 {
933 if e1 != 0 {
934 err = errnoErr(e1)
935 } else {
936 err = syscall.EINVAL
937 }
938 }
939 return
940}
941
942func GetComputerNameEx(nametype uint32, buf *uint16, n *uint32) (err error) {
943 r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nametype), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)))
944 if r1 == 0 {
945 if e1 != 0 {
946 err = errnoErr(e1)
947 } else {
948 err = syscall.EINVAL
949 }
950 }
951 return
952}
953
954func SetEndOfFile(handle Handle) (err error) {
955 r1, _, e1 := syscall.Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0)
956 if r1 == 0 {
957 if e1 != 0 {
958 err = errnoErr(e1)
959 } else {
960 err = syscall.EINVAL
961 }
962 }
963 return
964}
965
966func GetSystemTimeAsFileTime(time *Filetime) {
967 syscall.Syscall(procGetSystemTimeAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0)
968 return
969}
970
971func GetSystemTimePreciseAsFileTime(time *Filetime) {
972 syscall.Syscall(procGetSystemTimePreciseAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0)
973 return
974}
975
976func GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) {
977 r0, _, e1 := syscall.Syscall(procGetTimeZoneInformation.Addr(), 1, uintptr(unsafe.Pointer(tzi)), 0, 0)
978 rc = uint32(r0)
979 if rc == 0xffffffff {
980 if e1 != 0 {
981 err = errnoErr(e1)
982 } else {
983 err = syscall.EINVAL
984 }
985 }
986 return
987}
988
989func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (handle Handle, err error) {
990 r0, _, e1 := syscall.Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(filehandle), uintptr(cphandle), uintptr(key), uintptr(threadcnt), 0, 0)
991 handle = Handle(r0)
992 if handle == 0 {
993 if e1 != 0 {
994 err = errnoErr(e1)
995 } else {
996 err = syscall.EINVAL
997 }
998 }
999 return
1000}
1001
1002func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error) {
1003 r1, _, e1 := syscall.Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(cphandle), uintptr(unsafe.Pointer(qty)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(overlapped)), uintptr(timeout), 0)
1004 if r1 == 0 {
1005 if e1 != 0 {
1006 err = errnoErr(e1)
1007 } else {
1008 err = syscall.EINVAL
1009 }
1010 }
1011 return
1012}
1013
1014func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error) {
1015 r1, _, e1 := syscall.Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0)
1016 if r1 == 0 {
1017 if e1 != 0 {
1018 err = errnoErr(e1)
1019 } else {
1020 err = syscall.EINVAL
1021 }
1022 }
1023 return
1024}
1025
1026func CancelIo(s Handle) (err error) {
1027 r1, _, e1 := syscall.Syscall(procCancelIo.Addr(), 1, uintptr(s), 0, 0)
1028 if r1 == 0 {
1029 if e1 != 0 {
1030 err = errnoErr(e1)
1031 } else {
1032 err = syscall.EINVAL
1033 }
1034 }
1035 return
1036}
1037
1038func CancelIoEx(s Handle, o *Overlapped) (err error) {
1039 r1, _, e1 := syscall.Syscall(procCancelIoEx.Addr(), 2, uintptr(s), uintptr(unsafe.Pointer(o)), 0)
1040 if r1 == 0 {
1041 if e1 != 0 {
1042 err = errnoErr(e1)
1043 } else {
1044 err = syscall.EINVAL
1045 }
1046 }
1047 return
1048}
1049
1050func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) {
1051 var _p0 uint32
1052 if inheritHandles {
1053 _p0 = 1
1054 } else {
1055 _p0 = 0
1056 }
1057 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)
1058 if r1 == 0 {
1059 if e1 != 0 {
1060 err = errnoErr(e1)
1061 } else {
1062 err = syscall.EINVAL
1063 }
1064 }
1065 return
1066}
1067
1068func OpenProcess(da uint32, inheritHandle bool, pid uint32) (handle Handle, err error) {
1069 var _p0 uint32
1070 if inheritHandle {
1071 _p0 = 1
1072 } else {
1073 _p0 = 0
1074 }
1075 r0, _, e1 := syscall.Syscall(procOpenProcess.Addr(), 3, uintptr(da), uintptr(_p0), uintptr(pid))
1076 handle = Handle(r0)
1077 if handle == 0 {
1078 if e1 != 0 {
1079 err = errnoErr(e1)
1080 } else {
1081 err = syscall.EINVAL
1082 }
1083 }
1084 return
1085}
1086
1087func ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) {
1088 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))
1089 if r1 == 0 {
1090 if e1 != 0 {
1091 err = errnoErr(e1)
1092 } else {
1093 err = syscall.EINVAL
1094 }
1095 }
1096 return
1097}
1098
1099func TerminateProcess(handle Handle, exitcode uint32) (err error) {
1100 r1, _, e1 := syscall.Syscall(procTerminateProcess.Addr(), 2, uintptr(handle), uintptr(exitcode), 0)
1101 if r1 == 0 {
1102 if e1 != 0 {
1103 err = errnoErr(e1)
1104 } else {
1105 err = syscall.EINVAL
1106 }
1107 }
1108 return
1109}
1110
1111func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) {
1112 r1, _, e1 := syscall.Syscall(procGetExitCodeProcess.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(exitcode)), 0)
1113 if r1 == 0 {
1114 if e1 != 0 {
1115 err = errnoErr(e1)
1116 } else {
1117 err = syscall.EINVAL
1118 }
1119 }
1120 return
1121}
1122
1123func GetStartupInfo(startupInfo *StartupInfo) (err error) {
1124 r1, _, e1 := syscall.Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0)
1125 if r1 == 0 {
1126 if e1 != 0 {
1127 err = errnoErr(e1)
1128 } else {
1129 err = syscall.EINVAL
1130 }
1131 }
1132 return
1133}
1134
1135func GetCurrentProcess() (pseudoHandle Handle, err error) {
1136 r0, _, e1 := syscall.Syscall(procGetCurrentProcess.Addr(), 0, 0, 0, 0)
1137 pseudoHandle = Handle(r0)
1138 if pseudoHandle == 0 {
1139 if e1 != 0 {
1140 err = errnoErr(e1)
1141 } else {
1142 err = syscall.EINVAL
1143 }
1144 }
1145 return
1146}
1147
1148func GetCurrentThread() (pseudoHandle Handle, err error) {
1149 r0, _, e1 := syscall.Syscall(procGetCurrentThread.Addr(), 0, 0, 0, 0)
1150 pseudoHandle = Handle(r0)
1151 if pseudoHandle == 0 {
1152 if e1 != 0 {
1153 err = errnoErr(e1)
1154 } else {
1155 err = syscall.EINVAL
1156 }
1157 }
1158 return
1159}
1160
1161func GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, kernelTime *Filetime, userTime *Filetime) (err error) {
1162 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)
1163 if r1 == 0 {
1164 if e1 != 0 {
1165 err = errnoErr(e1)
1166 } else {
1167 err = syscall.EINVAL
1168 }
1169 }
1170 return
1171}
1172
1173func DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetProcessHandle Handle, lpTargetHandle *Handle, dwDesiredAccess uint32, bInheritHandle bool, dwOptions uint32) (err error) {
1174 var _p0 uint32
1175 if bInheritHandle {
1176 _p0 = 1
1177 } else {
1178 _p0 = 0
1179 }
1180 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)
1181 if r1 == 0 {
1182 if e1 != 0 {
1183 err = errnoErr(e1)
1184 } else {
1185 err = syscall.EINVAL
1186 }
1187 }
1188 return
1189}
1190
1191func WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32, err error) {
1192 r0, _, e1 := syscall.Syscall(procWaitForSingleObject.Addr(), 2, uintptr(handle), uintptr(waitMilliseconds), 0)
1193 event = uint32(r0)
1194 if event == 0xffffffff {
1195 if e1 != 0 {
1196 err = errnoErr(e1)
1197 } else {
1198 err = syscall.EINVAL
1199 }
1200 }
1201 return
1202}
1203
1204func waitForMultipleObjects(count uint32, handles uintptr, waitAll bool, waitMilliseconds uint32) (event uint32, err error) {
1205 var _p0 uint32
1206 if waitAll {
1207 _p0 = 1
1208 } else {
1209 _p0 = 0
1210 }
1211 r0, _, e1 := syscall.Syscall6(procWaitForMultipleObjects.Addr(), 4, uintptr(count), uintptr(handles), uintptr(_p0), uintptr(waitMilliseconds), 0, 0)
1212 event = uint32(r0)
1213 if event == 0xffffffff {
1214 if e1 != 0 {
1215 err = errnoErr(e1)
1216 } else {
1217 err = syscall.EINVAL
1218 }
1219 }
1220 return
1221}
1222
1223func GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) {
1224 r0, _, e1 := syscall.Syscall(procGetTempPathW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
1225 n = uint32(r0)
1226 if n == 0 {
1227 if e1 != 0 {
1228 err = errnoErr(e1)
1229 } else {
1230 err = syscall.EINVAL
1231 }
1232 }
1233 return
1234}
1235
1236func CreatePipe(readhandle *Handle, writehandle *Handle, sa *SecurityAttributes, size uint32) (err error) {
1237 r1, _, e1 := syscall.Syscall6(procCreatePipe.Addr(), 4, uintptr(unsafe.Pointer(readhandle)), uintptr(unsafe.Pointer(writehandle)), uintptr(unsafe.Pointer(sa)), uintptr(size), 0, 0)
1238 if r1 == 0 {
1239 if e1 != 0 {
1240 err = errnoErr(e1)
1241 } else {
1242 err = syscall.EINVAL
1243 }
1244 }
1245 return
1246}
1247
1248func GetFileType(filehandle Handle) (n uint32, err error) {
1249 r0, _, e1 := syscall.Syscall(procGetFileType.Addr(), 1, uintptr(filehandle), 0, 0)
1250 n = uint32(r0)
1251 if n == 0 {
1252 if e1 != 0 {
1253 err = errnoErr(e1)
1254 } else {
1255 err = syscall.EINVAL
1256 }
1257 }
1258 return
1259}
1260
1261func CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16, provtype uint32, flags uint32) (err error) {
1262 r1, _, e1 := syscall.Syscall6(procCryptAcquireContextW.Addr(), 5, uintptr(unsafe.Pointer(provhandle)), uintptr(unsafe.Pointer(container)), uintptr(unsafe.Pointer(provider)), uintptr(provtype), uintptr(flags), 0)
1263 if r1 == 0 {
1264 if e1 != 0 {
1265 err = errnoErr(e1)
1266 } else {
1267 err = syscall.EINVAL
1268 }
1269 }
1270 return
1271}
1272
1273func CryptReleaseContext(provhandle Handle, flags uint32) (err error) {
1274 r1, _, e1 := syscall.Syscall(procCryptReleaseContext.Addr(), 2, uintptr(provhandle), uintptr(flags), 0)
1275 if r1 == 0 {
1276 if e1 != 0 {
1277 err = errnoErr(e1)
1278 } else {
1279 err = syscall.EINVAL
1280 }
1281 }
1282 return
1283}
1284
1285func CryptGenRandom(provhandle Handle, buflen uint32, buf *byte) (err error) {
1286 r1, _, e1 := syscall.Syscall(procCryptGenRandom.Addr(), 3, uintptr(provhandle), uintptr(buflen), uintptr(unsafe.Pointer(buf)))
1287 if r1 == 0 {
1288 if e1 != 0 {
1289 err = errnoErr(e1)
1290 } else {
1291 err = syscall.EINVAL
1292 }
1293 }
1294 return
1295}
1296
1297func GetEnvironmentStrings() (envs *uint16, err error) {
1298 r0, _, e1 := syscall.Syscall(procGetEnvironmentStringsW.Addr(), 0, 0, 0, 0)
1299 envs = (*uint16)(unsafe.Pointer(r0))
1300 if envs == nil {
1301 if e1 != 0 {
1302 err = errnoErr(e1)
1303 } else {
1304 err = syscall.EINVAL
1305 }
1306 }
1307 return
1308}
1309
1310func FreeEnvironmentStrings(envs *uint16) (err error) {
1311 r1, _, e1 := syscall.Syscall(procFreeEnvironmentStringsW.Addr(), 1, uintptr(unsafe.Pointer(envs)), 0, 0)
1312 if r1 == 0 {
1313 if e1 != 0 {
1314 err = errnoErr(e1)
1315 } else {
1316 err = syscall.EINVAL
1317 }
1318 }
1319 return
1320}
1321
1322func GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32, err error) {
1323 r0, _, e1 := syscall.Syscall(procGetEnvironmentVariableW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buffer)), uintptr(size))
1324 n = uint32(r0)
1325 if n == 0 {
1326 if e1 != 0 {
1327 err = errnoErr(e1)
1328 } else {
1329 err = syscall.EINVAL
1330 }
1331 }
1332 return
1333}
1334
1335func SetEnvironmentVariable(name *uint16, value *uint16) (err error) {
1336 r1, _, e1 := syscall.Syscall(procSetEnvironmentVariableW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), 0)
1337 if r1 == 0 {
1338 if e1 != 0 {
1339 err = errnoErr(e1)
1340 } else {
1341 err = syscall.EINVAL
1342 }
1343 }
1344 return
1345}
1346
1347func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) {
1348 var _p0 uint32
1349 if inheritExisting {
1350 _p0 = 1
1351 } else {
1352 _p0 = 0
1353 }
1354 r1, _, e1 := syscall.Syscall(procCreateEnvironmentBlock.Addr(), 3, uintptr(unsafe.Pointer(block)), uintptr(token), uintptr(_p0))
1355 if r1 == 0 {
1356 if e1 != 0 {
1357 err = errnoErr(e1)
1358 } else {
1359 err = syscall.EINVAL
1360 }
1361 }
1362 return
1363}
1364
1365func DestroyEnvironmentBlock(block *uint16) (err error) {
1366 r1, _, e1 := syscall.Syscall(procDestroyEnvironmentBlock.Addr(), 1, uintptr(unsafe.Pointer(block)), 0, 0)
1367 if r1 == 0 {
1368 if e1 != 0 {
1369 err = errnoErr(e1)
1370 } else {
1371 err = syscall.EINVAL
1372 }
1373 }
1374 return
1375}
1376
David Bainbridge86971522019-09-26 22:09:39 +00001377func getTickCount64() (ms uint64) {
1378 r0, _, _ := syscall.Syscall(procGetTickCount64.Addr(), 0, 0, 0, 0)
1379 ms = uint64(r0)
1380 return
1381}
1382
Zack Williamse940c7a2019-08-21 14:25:39 -07001383func SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error) {
1384 r1, _, e1 := syscall.Syscall6(procSetFileTime.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(ctime)), uintptr(unsafe.Pointer(atime)), uintptr(unsafe.Pointer(wtime)), 0, 0)
1385 if r1 == 0 {
1386 if e1 != 0 {
1387 err = errnoErr(e1)
1388 } else {
1389 err = syscall.EINVAL
1390 }
1391 }
1392 return
1393}
1394
1395func GetFileAttributes(name *uint16) (attrs uint32, err error) {
1396 r0, _, e1 := syscall.Syscall(procGetFileAttributesW.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
1397 attrs = uint32(r0)
1398 if attrs == INVALID_FILE_ATTRIBUTES {
1399 if e1 != 0 {
1400 err = errnoErr(e1)
1401 } else {
1402 err = syscall.EINVAL
1403 }
1404 }
1405 return
1406}
1407
1408func SetFileAttributes(name *uint16, attrs uint32) (err error) {
1409 r1, _, e1 := syscall.Syscall(procSetFileAttributesW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(attrs), 0)
1410 if r1 == 0 {
1411 if e1 != 0 {
1412 err = errnoErr(e1)
1413 } else {
1414 err = syscall.EINVAL
1415 }
1416 }
1417 return
1418}
1419
1420func GetFileAttributesEx(name *uint16, level uint32, info *byte) (err error) {
1421 r1, _, e1 := syscall.Syscall(procGetFileAttributesExW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(level), uintptr(unsafe.Pointer(info)))
1422 if r1 == 0 {
1423 if e1 != 0 {
1424 err = errnoErr(e1)
1425 } else {
1426 err = syscall.EINVAL
1427 }
1428 }
1429 return
1430}
1431
1432func GetCommandLine() (cmd *uint16) {
1433 r0, _, _ := syscall.Syscall(procGetCommandLineW.Addr(), 0, 0, 0, 0)
1434 cmd = (*uint16)(unsafe.Pointer(r0))
1435 return
1436}
1437
1438func CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err error) {
1439 r0, _, e1 := syscall.Syscall(procCommandLineToArgvW.Addr(), 2, uintptr(unsafe.Pointer(cmd)), uintptr(unsafe.Pointer(argc)), 0)
1440 argv = (*[8192]*[8192]uint16)(unsafe.Pointer(r0))
1441 if argv == nil {
1442 if e1 != 0 {
1443 err = errnoErr(e1)
1444 } else {
1445 err = syscall.EINVAL
1446 }
1447 }
1448 return
1449}
1450
1451func LocalFree(hmem Handle) (handle Handle, err error) {
1452 r0, _, e1 := syscall.Syscall(procLocalFree.Addr(), 1, uintptr(hmem), 0, 0)
1453 handle = Handle(r0)
1454 if handle != 0 {
1455 if e1 != 0 {
1456 err = errnoErr(e1)
1457 } else {
1458 err = syscall.EINVAL
1459 }
1460 }
1461 return
1462}
1463
1464func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error) {
1465 r1, _, e1 := syscall.Syscall(procSetHandleInformation.Addr(), 3, uintptr(handle), uintptr(mask), uintptr(flags))
1466 if r1 == 0 {
1467 if e1 != 0 {
1468 err = errnoErr(e1)
1469 } else {
1470 err = syscall.EINVAL
1471 }
1472 }
1473 return
1474}
1475
1476func FlushFileBuffers(handle Handle) (err error) {
1477 r1, _, e1 := syscall.Syscall(procFlushFileBuffers.Addr(), 1, uintptr(handle), 0, 0)
1478 if r1 == 0 {
1479 if e1 != 0 {
1480 err = errnoErr(e1)
1481 } else {
1482 err = syscall.EINVAL
1483 }
1484 }
1485 return
1486}
1487
1488func GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) (n uint32, err error) {
1489 r0, _, e1 := syscall.Syscall6(procGetFullPathNameW.Addr(), 4, uintptr(unsafe.Pointer(path)), uintptr(buflen), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(fname)), 0, 0)
1490 n = uint32(r0)
1491 if n == 0 {
1492 if e1 != 0 {
1493 err = errnoErr(e1)
1494 } else {
1495 err = syscall.EINVAL
1496 }
1497 }
1498 return
1499}
1500
1501func GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err error) {
1502 r0, _, e1 := syscall.Syscall(procGetLongPathNameW.Addr(), 3, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(buf)), uintptr(buflen))
1503 n = uint32(r0)
1504 if n == 0 {
1505 if e1 != 0 {
1506 err = errnoErr(e1)
1507 } else {
1508 err = syscall.EINVAL
1509 }
1510 }
1511 return
1512}
1513
1514func GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uint32, err error) {
1515 r0, _, e1 := syscall.Syscall(procGetShortPathNameW.Addr(), 3, uintptr(unsafe.Pointer(longpath)), uintptr(unsafe.Pointer(shortpath)), uintptr(buflen))
1516 n = uint32(r0)
1517 if n == 0 {
1518 if e1 != 0 {
1519 err = errnoErr(e1)
1520 } else {
1521 err = syscall.EINVAL
1522 }
1523 }
1524 return
1525}
1526
1527func CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error) {
1528 r0, _, e1 := syscall.Syscall6(procCreateFileMappingW.Addr(), 6, uintptr(fhandle), uintptr(unsafe.Pointer(sa)), uintptr(prot), uintptr(maxSizeHigh), uintptr(maxSizeLow), uintptr(unsafe.Pointer(name)))
1529 handle = Handle(r0)
1530 if handle == 0 {
1531 if e1 != 0 {
1532 err = errnoErr(e1)
1533 } else {
1534 err = syscall.EINVAL
1535 }
1536 }
1537 return
1538}
1539
1540func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow uint32, length uintptr) (addr uintptr, err error) {
1541 r0, _, e1 := syscall.Syscall6(procMapViewOfFile.Addr(), 5, uintptr(handle), uintptr(access), uintptr(offsetHigh), uintptr(offsetLow), uintptr(length), 0)
1542 addr = uintptr(r0)
1543 if addr == 0 {
1544 if e1 != 0 {
1545 err = errnoErr(e1)
1546 } else {
1547 err = syscall.EINVAL
1548 }
1549 }
1550 return
1551}
1552
1553func UnmapViewOfFile(addr uintptr) (err error) {
1554 r1, _, e1 := syscall.Syscall(procUnmapViewOfFile.Addr(), 1, uintptr(addr), 0, 0)
1555 if r1 == 0 {
1556 if e1 != 0 {
1557 err = errnoErr(e1)
1558 } else {
1559 err = syscall.EINVAL
1560 }
1561 }
1562 return
1563}
1564
1565func FlushViewOfFile(addr uintptr, length uintptr) (err error) {
1566 r1, _, e1 := syscall.Syscall(procFlushViewOfFile.Addr(), 2, uintptr(addr), uintptr(length), 0)
1567 if r1 == 0 {
1568 if e1 != 0 {
1569 err = errnoErr(e1)
1570 } else {
1571 err = syscall.EINVAL
1572 }
1573 }
1574 return
1575}
1576
1577func VirtualLock(addr uintptr, length uintptr) (err error) {
1578 r1, _, e1 := syscall.Syscall(procVirtualLock.Addr(), 2, uintptr(addr), uintptr(length), 0)
1579 if r1 == 0 {
1580 if e1 != 0 {
1581 err = errnoErr(e1)
1582 } else {
1583 err = syscall.EINVAL
1584 }
1585 }
1586 return
1587}
1588
1589func VirtualUnlock(addr uintptr, length uintptr) (err error) {
1590 r1, _, e1 := syscall.Syscall(procVirtualUnlock.Addr(), 2, uintptr(addr), uintptr(length), 0)
1591 if r1 == 0 {
1592 if e1 != 0 {
1593 err = errnoErr(e1)
1594 } else {
1595 err = syscall.EINVAL
1596 }
1597 }
1598 return
1599}
1600
1601func VirtualAlloc(address uintptr, size uintptr, alloctype uint32, protect uint32) (value uintptr, err error) {
1602 r0, _, e1 := syscall.Syscall6(procVirtualAlloc.Addr(), 4, uintptr(address), uintptr(size), uintptr(alloctype), uintptr(protect), 0, 0)
1603 value = uintptr(r0)
1604 if value == 0 {
1605 if e1 != 0 {
1606 err = errnoErr(e1)
1607 } else {
1608 err = syscall.EINVAL
1609 }
1610 }
1611 return
1612}
1613
1614func VirtualFree(address uintptr, size uintptr, freetype uint32) (err error) {
1615 r1, _, e1 := syscall.Syscall(procVirtualFree.Addr(), 3, uintptr(address), uintptr(size), uintptr(freetype))
1616 if r1 == 0 {
1617 if e1 != 0 {
1618 err = errnoErr(e1)
1619 } else {
1620 err = syscall.EINVAL
1621 }
1622 }
1623 return
1624}
1625
1626func VirtualProtect(address uintptr, size uintptr, newprotect uint32, oldprotect *uint32) (err error) {
1627 r1, _, e1 := syscall.Syscall6(procVirtualProtect.Addr(), 4, uintptr(address), uintptr(size), uintptr(newprotect), uintptr(unsafe.Pointer(oldprotect)), 0, 0)
1628 if r1 == 0 {
1629 if e1 != 0 {
1630 err = errnoErr(e1)
1631 } else {
1632 err = syscall.EINVAL
1633 }
1634 }
1635 return
1636}
1637
1638func TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) {
1639 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)
1640 if r1 == 0 {
1641 if e1 != 0 {
1642 err = errnoErr(e1)
1643 } else {
1644 err = syscall.EINVAL
1645 }
1646 }
1647 return
1648}
1649
1650func ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
1651 var _p0 uint32
1652 if watchSubTree {
1653 _p0 = 1
1654 } else {
1655 _p0 = 0
1656 }
1657 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)
1658 if r1 == 0 {
1659 if e1 != 0 {
1660 err = errnoErr(e1)
1661 } else {
1662 err = syscall.EINVAL
1663 }
1664 }
1665 return
1666}
1667
1668func CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) {
1669 r0, _, e1 := syscall.Syscall(procCertOpenSystemStoreW.Addr(), 2, uintptr(hprov), uintptr(unsafe.Pointer(name)), 0)
1670 store = Handle(r0)
1671 if store == 0 {
1672 if e1 != 0 {
1673 err = errnoErr(e1)
1674 } else {
1675 err = syscall.EINVAL
1676 }
1677 }
1678 return
1679}
1680
1681func CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) {
1682 r0, _, e1 := syscall.Syscall6(procCertOpenStore.Addr(), 5, uintptr(storeProvider), uintptr(msgAndCertEncodingType), uintptr(cryptProv), uintptr(flags), uintptr(para), 0)
1683 handle = Handle(r0)
1684 if handle == InvalidHandle {
1685 if e1 != 0 {
1686 err = errnoErr(e1)
1687 } else {
1688 err = syscall.EINVAL
1689 }
1690 }
1691 return
1692}
1693
1694func CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) {
1695 r0, _, e1 := syscall.Syscall(procCertEnumCertificatesInStore.Addr(), 2, uintptr(store), uintptr(unsafe.Pointer(prevContext)), 0)
1696 context = (*CertContext)(unsafe.Pointer(r0))
1697 if context == nil {
1698 if e1 != 0 {
1699 err = errnoErr(e1)
1700 } else {
1701 err = syscall.EINVAL
1702 }
1703 }
1704 return
1705}
1706
1707func CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) {
1708 r1, _, e1 := syscall.Syscall6(procCertAddCertificateContextToStore.Addr(), 4, uintptr(store), uintptr(unsafe.Pointer(certContext)), uintptr(addDisposition), uintptr(unsafe.Pointer(storeContext)), 0, 0)
1709 if r1 == 0 {
1710 if e1 != 0 {
1711 err = errnoErr(e1)
1712 } else {
1713 err = syscall.EINVAL
1714 }
1715 }
1716 return
1717}
1718
1719func CertCloseStore(store Handle, flags uint32) (err error) {
1720 r1, _, e1 := syscall.Syscall(procCertCloseStore.Addr(), 2, uintptr(store), uintptr(flags), 0)
1721 if r1 == 0 {
1722 if e1 != 0 {
1723 err = errnoErr(e1)
1724 } else {
1725 err = syscall.EINVAL
1726 }
1727 }
1728 return
1729}
1730
1731func CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) {
1732 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)
1733 if r1 == 0 {
1734 if e1 != 0 {
1735 err = errnoErr(e1)
1736 } else {
1737 err = syscall.EINVAL
1738 }
1739 }
1740 return
1741}
1742
1743func CertFreeCertificateChain(ctx *CertChainContext) {
1744 syscall.Syscall(procCertFreeCertificateChain.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
1745 return
1746}
1747
1748func CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, encodedLen uint32) (context *CertContext, err error) {
1749 r0, _, e1 := syscall.Syscall(procCertCreateCertificateContext.Addr(), 3, uintptr(certEncodingType), uintptr(unsafe.Pointer(certEncoded)), uintptr(encodedLen))
1750 context = (*CertContext)(unsafe.Pointer(r0))
1751 if context == nil {
1752 if e1 != 0 {
1753 err = errnoErr(e1)
1754 } else {
1755 err = syscall.EINVAL
1756 }
1757 }
1758 return
1759}
1760
1761func CertFreeCertificateContext(ctx *CertContext) (err error) {
1762 r1, _, e1 := syscall.Syscall(procCertFreeCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
1763 if r1 == 0 {
1764 if e1 != 0 {
1765 err = errnoErr(e1)
1766 } else {
1767 err = syscall.EINVAL
1768 }
1769 }
1770 return
1771}
1772
1773func CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) {
1774 r1, _, e1 := syscall.Syscall6(procCertVerifyCertificateChainPolicy.Addr(), 4, uintptr(policyOID), uintptr(unsafe.Pointer(chain)), uintptr(unsafe.Pointer(para)), uintptr(unsafe.Pointer(status)), 0, 0)
1775 if r1 == 0 {
1776 if e1 != 0 {
1777 err = errnoErr(e1)
1778 } else {
1779 err = syscall.EINVAL
1780 }
1781 }
1782 return
1783}
1784
1785func RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno error) {
1786 r0, _, _ := syscall.Syscall6(procRegOpenKeyExW.Addr(), 5, uintptr(key), uintptr(unsafe.Pointer(subkey)), uintptr(options), uintptr(desiredAccess), uintptr(unsafe.Pointer(result)), 0)
1787 if r0 != 0 {
1788 regerrno = syscall.Errno(r0)
1789 }
1790 return
1791}
1792
1793func RegCloseKey(key Handle) (regerrno error) {
1794 r0, _, _ := syscall.Syscall(procRegCloseKey.Addr(), 1, uintptr(key), 0, 0)
1795 if r0 != 0 {
1796 regerrno = syscall.Errno(r0)
1797 }
1798 return
1799}
1800
1801func 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) {
1802 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)))
1803 if r0 != 0 {
1804 regerrno = syscall.Errno(r0)
1805 }
1806 return
1807}
1808
1809func RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) {
1810 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)
1811 if r0 != 0 {
1812 regerrno = syscall.Errno(r0)
1813 }
1814 return
1815}
1816
1817func RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) {
1818 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)))
1819 if r0 != 0 {
1820 regerrno = syscall.Errno(r0)
1821 }
1822 return
1823}
1824
1825func getCurrentProcessId() (pid uint32) {
1826 r0, _, _ := syscall.Syscall(procGetCurrentProcessId.Addr(), 0, 0, 0, 0)
1827 pid = uint32(r0)
1828 return
1829}
1830
1831func GetConsoleMode(console Handle, mode *uint32) (err error) {
1832 r1, _, e1 := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0)
1833 if r1 == 0 {
1834 if e1 != 0 {
1835 err = errnoErr(e1)
1836 } else {
1837 err = syscall.EINVAL
1838 }
1839 }
1840 return
1841}
1842
1843func SetConsoleMode(console Handle, mode uint32) (err error) {
1844 r1, _, e1 := syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(console), uintptr(mode), 0)
1845 if r1 == 0 {
1846 if e1 != 0 {
1847 err = errnoErr(e1)
1848 } else {
1849 err = syscall.EINVAL
1850 }
1851 }
1852 return
1853}
1854
1855func GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) {
1856 r1, _, e1 := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(info)), 0)
1857 if r1 == 0 {
1858 if e1 != 0 {
1859 err = errnoErr(e1)
1860 } else {
1861 err = syscall.EINVAL
1862 }
1863 }
1864 return
1865}
1866
1867func WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) {
1868 r1, _, e1 := syscall.Syscall6(procWriteConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(towrite), uintptr(unsafe.Pointer(written)), uintptr(unsafe.Pointer(reserved)), 0)
1869 if r1 == 0 {
1870 if e1 != 0 {
1871 err = errnoErr(e1)
1872 } else {
1873 err = syscall.EINVAL
1874 }
1875 }
1876 return
1877}
1878
1879func ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) {
1880 r1, _, e1 := syscall.Syscall6(procReadConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(toread), uintptr(unsafe.Pointer(read)), uintptr(unsafe.Pointer(inputControl)), 0)
1881 if r1 == 0 {
1882 if e1 != 0 {
1883 err = errnoErr(e1)
1884 } else {
1885 err = syscall.EINVAL
1886 }
1887 }
1888 return
1889}
1890
1891func CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) {
1892 r0, _, e1 := syscall.Syscall(procCreateToolhelp32Snapshot.Addr(), 2, uintptr(flags), uintptr(processId), 0)
1893 handle = Handle(r0)
1894 if handle == InvalidHandle {
1895 if e1 != 0 {
1896 err = errnoErr(e1)
1897 } else {
1898 err = syscall.EINVAL
1899 }
1900 }
1901 return
1902}
1903
1904func Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) {
1905 r1, _, e1 := syscall.Syscall(procProcess32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
1906 if r1 == 0 {
1907 if e1 != 0 {
1908 err = errnoErr(e1)
1909 } else {
1910 err = syscall.EINVAL
1911 }
1912 }
1913 return
1914}
1915
1916func Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) {
1917 r1, _, e1 := syscall.Syscall(procProcess32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
1918 if r1 == 0 {
1919 if e1 != 0 {
1920 err = errnoErr(e1)
1921 } else {
1922 err = syscall.EINVAL
1923 }
1924 }
1925 return
1926}
1927
1928func DeviceIoControl(handle Handle, ioControlCode uint32, inBuffer *byte, inBufferSize uint32, outBuffer *byte, outBufferSize uint32, bytesReturned *uint32, overlapped *Overlapped) (err error) {
1929 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)
1930 if r1 == 0 {
1931 if e1 != 0 {
1932 err = errnoErr(e1)
1933 } else {
1934 err = syscall.EINVAL
1935 }
1936 }
1937 return
1938}
1939
1940func CreateSymbolicLink(symlinkfilename *uint16, targetfilename *uint16, flags uint32) (err error) {
1941 r1, _, e1 := syscall.Syscall(procCreateSymbolicLinkW.Addr(), 3, uintptr(unsafe.Pointer(symlinkfilename)), uintptr(unsafe.Pointer(targetfilename)), uintptr(flags))
1942 if r1&0xff == 0 {
1943 if e1 != 0 {
1944 err = errnoErr(e1)
1945 } else {
1946 err = syscall.EINVAL
1947 }
1948 }
1949 return
1950}
1951
1952func CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr) (err error) {
1953 r1, _, e1 := syscall.Syscall(procCreateHardLinkW.Addr(), 3, uintptr(unsafe.Pointer(filename)), uintptr(unsafe.Pointer(existingfilename)), uintptr(reserved))
1954 if r1&0xff == 0 {
1955 if e1 != 0 {
1956 err = errnoErr(e1)
1957 } else {
1958 err = syscall.EINVAL
1959 }
1960 }
1961 return
1962}
1963
1964func GetCurrentThreadId() (id uint32) {
1965 r0, _, _ := syscall.Syscall(procGetCurrentThreadId.Addr(), 0, 0, 0, 0)
1966 id = uint32(r0)
1967 return
1968}
1969
1970func CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) {
1971 r0, _, e1 := syscall.Syscall6(procCreateEventW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(manualReset), uintptr(initialState), uintptr(unsafe.Pointer(name)), 0, 0)
1972 handle = Handle(r0)
1973 if handle == 0 {
1974 if e1 != 0 {
1975 err = errnoErr(e1)
1976 } else {
1977 err = syscall.EINVAL
1978 }
1979 }
1980 return
1981}
1982
1983func CreateEventEx(eventAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) {
1984 r0, _, e1 := syscall.Syscall6(procCreateEventExW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(desiredAccess), 0, 0)
1985 handle = Handle(r0)
1986 if handle == 0 {
1987 if e1 != 0 {
1988 err = errnoErr(e1)
1989 } else {
1990 err = syscall.EINVAL
1991 }
1992 }
1993 return
1994}
1995
1996func OpenEvent(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) {
1997 var _p0 uint32
1998 if inheritHandle {
1999 _p0 = 1
2000 } else {
2001 _p0 = 0
2002 }
2003 r0, _, e1 := syscall.Syscall(procOpenEventW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name)))
2004 handle = Handle(r0)
2005 if handle == 0 {
2006 if e1 != 0 {
2007 err = errnoErr(e1)
2008 } else {
2009 err = syscall.EINVAL
2010 }
2011 }
2012 return
2013}
2014
2015func SetEvent(event Handle) (err error) {
2016 r1, _, e1 := syscall.Syscall(procSetEvent.Addr(), 1, uintptr(event), 0, 0)
2017 if r1 == 0 {
2018 if e1 != 0 {
2019 err = errnoErr(e1)
2020 } else {
2021 err = syscall.EINVAL
2022 }
2023 }
2024 return
2025}
2026
2027func ResetEvent(event Handle) (err error) {
2028 r1, _, e1 := syscall.Syscall(procResetEvent.Addr(), 1, uintptr(event), 0, 0)
2029 if r1 == 0 {
2030 if e1 != 0 {
2031 err = errnoErr(e1)
2032 } else {
2033 err = syscall.EINVAL
2034 }
2035 }
2036 return
2037}
2038
2039func PulseEvent(event Handle) (err error) {
2040 r1, _, e1 := syscall.Syscall(procPulseEvent.Addr(), 1, uintptr(event), 0, 0)
2041 if r1 == 0 {
2042 if e1 != 0 {
2043 err = errnoErr(e1)
2044 } else {
2045 err = syscall.EINVAL
2046 }
2047 }
2048 return
2049}
2050
2051func SleepEx(milliseconds uint32, alertable bool) (ret uint32) {
2052 var _p0 uint32
2053 if alertable {
2054 _p0 = 1
2055 } else {
2056 _p0 = 0
2057 }
2058 r0, _, _ := syscall.Syscall(procSleepEx.Addr(), 2, uintptr(milliseconds), uintptr(_p0), 0)
2059 ret = uint32(r0)
2060 return
2061}
2062
2063func CreateJobObject(jobAttr *SecurityAttributes, name *uint16) (handle Handle, err error) {
2064 r0, _, e1 := syscall.Syscall(procCreateJobObjectW.Addr(), 2, uintptr(unsafe.Pointer(jobAttr)), uintptr(unsafe.Pointer(name)), 0)
2065 handle = Handle(r0)
2066 if handle == 0 {
2067 if e1 != 0 {
2068 err = errnoErr(e1)
2069 } else {
2070 err = syscall.EINVAL
2071 }
2072 }
2073 return
2074}
2075
2076func AssignProcessToJobObject(job Handle, process Handle) (err error) {
2077 r1, _, e1 := syscall.Syscall(procAssignProcessToJobObject.Addr(), 2, uintptr(job), uintptr(process), 0)
2078 if r1 == 0 {
2079 if e1 != 0 {
2080 err = errnoErr(e1)
2081 } else {
2082 err = syscall.EINVAL
2083 }
2084 }
2085 return
2086}
2087
2088func TerminateJobObject(job Handle, exitCode uint32) (err error) {
2089 r1, _, e1 := syscall.Syscall(procTerminateJobObject.Addr(), 2, uintptr(job), uintptr(exitCode), 0)
2090 if r1 == 0 {
2091 if e1 != 0 {
2092 err = errnoErr(e1)
2093 } else {
2094 err = syscall.EINVAL
2095 }
2096 }
2097 return
2098}
2099
2100func SetErrorMode(mode uint32) (ret uint32) {
2101 r0, _, _ := syscall.Syscall(procSetErrorMode.Addr(), 1, uintptr(mode), 0, 0)
2102 ret = uint32(r0)
2103 return
2104}
2105
2106func ResumeThread(thread Handle) (ret uint32, err error) {
2107 r0, _, e1 := syscall.Syscall(procResumeThread.Addr(), 1, uintptr(thread), 0, 0)
2108 ret = uint32(r0)
2109 if ret == 0xffffffff {
2110 if e1 != 0 {
2111 err = errnoErr(e1)
2112 } else {
2113 err = syscall.EINVAL
2114 }
2115 }
2116 return
2117}
2118
2119func SetPriorityClass(process Handle, priorityClass uint32) (err error) {
2120 r1, _, e1 := syscall.Syscall(procSetPriorityClass.Addr(), 2, uintptr(process), uintptr(priorityClass), 0)
2121 if r1 == 0 {
2122 if e1 != 0 {
2123 err = errnoErr(e1)
2124 } else {
2125 err = syscall.EINVAL
2126 }
2127 }
2128 return
2129}
2130
2131func GetPriorityClass(process Handle) (ret uint32, err error) {
2132 r0, _, e1 := syscall.Syscall(procGetPriorityClass.Addr(), 1, uintptr(process), 0, 0)
2133 ret = uint32(r0)
2134 if ret == 0 {
2135 if e1 != 0 {
2136 err = errnoErr(e1)
2137 } else {
2138 err = syscall.EINVAL
2139 }
2140 }
2141 return
2142}
2143
2144func SetInformationJobObject(job Handle, JobObjectInformationClass uint32, JobObjectInformation uintptr, JobObjectInformationLength uint32) (ret int, err error) {
2145 r0, _, e1 := syscall.Syscall6(procSetInformationJobObject.Addr(), 4, uintptr(job), uintptr(JobObjectInformationClass), uintptr(JobObjectInformation), uintptr(JobObjectInformationLength), 0, 0)
2146 ret = int(r0)
2147 if ret == 0 {
2148 if e1 != 0 {
2149 err = errnoErr(e1)
2150 } else {
2151 err = syscall.EINVAL
2152 }
2153 }
2154 return
2155}
2156
David Bainbridge86971522019-09-26 22:09:39 +00002157func GenerateConsoleCtrlEvent(ctrlEvent uint32, processGroupID uint32) (err error) {
2158 r1, _, e1 := syscall.Syscall(procGenerateConsoleCtrlEvent.Addr(), 2, uintptr(ctrlEvent), uintptr(processGroupID), 0)
2159 if r1 == 0 {
2160 if e1 != 0 {
2161 err = errnoErr(e1)
2162 } else {
2163 err = syscall.EINVAL
2164 }
2165 }
2166 return
2167}
2168
Zack Williamse940c7a2019-08-21 14:25:39 -07002169func DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) {
2170 r1, _, e1 := syscall.Syscall(procDefineDosDeviceW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)))
2171 if r1 == 0 {
2172 if e1 != 0 {
2173 err = errnoErr(e1)
2174 } else {
2175 err = syscall.EINVAL
2176 }
2177 }
2178 return
2179}
2180
2181func DeleteVolumeMountPoint(volumeMountPoint *uint16) (err error) {
2182 r1, _, e1 := syscall.Syscall(procDeleteVolumeMountPointW.Addr(), 1, uintptr(unsafe.Pointer(volumeMountPoint)), 0, 0)
2183 if r1 == 0 {
2184 if e1 != 0 {
2185 err = errnoErr(e1)
2186 } else {
2187 err = syscall.EINVAL
2188 }
2189 }
2190 return
2191}
2192
2193func FindFirstVolume(volumeName *uint16, bufferLength uint32) (handle Handle, err error) {
2194 r0, _, e1 := syscall.Syscall(procFindFirstVolumeW.Addr(), 2, uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength), 0)
2195 handle = Handle(r0)
2196 if handle == InvalidHandle {
2197 if e1 != 0 {
2198 err = errnoErr(e1)
2199 } else {
2200 err = syscall.EINVAL
2201 }
2202 }
2203 return
2204}
2205
2206func FindFirstVolumeMountPoint(rootPathName *uint16, volumeMountPoint *uint16, bufferLength uint32) (handle Handle, err error) {
2207 r0, _, e1 := syscall.Syscall(procFindFirstVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength))
2208 handle = Handle(r0)
2209 if handle == InvalidHandle {
2210 if e1 != 0 {
2211 err = errnoErr(e1)
2212 } else {
2213 err = syscall.EINVAL
2214 }
2215 }
2216 return
2217}
2218
2219func FindNextVolume(findVolume Handle, volumeName *uint16, bufferLength uint32) (err error) {
2220 r1, _, e1 := syscall.Syscall(procFindNextVolumeW.Addr(), 3, uintptr(findVolume), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength))
2221 if r1 == 0 {
2222 if e1 != 0 {
2223 err = errnoErr(e1)
2224 } else {
2225 err = syscall.EINVAL
2226 }
2227 }
2228 return
2229}
2230
2231func FindNextVolumeMountPoint(findVolumeMountPoint Handle, volumeMountPoint *uint16, bufferLength uint32) (err error) {
2232 r1, _, e1 := syscall.Syscall(procFindNextVolumeMountPointW.Addr(), 3, uintptr(findVolumeMountPoint), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength))
2233 if r1 == 0 {
2234 if e1 != 0 {
2235 err = errnoErr(e1)
2236 } else {
2237 err = syscall.EINVAL
2238 }
2239 }
2240 return
2241}
2242
2243func FindVolumeClose(findVolume Handle) (err error) {
2244 r1, _, e1 := syscall.Syscall(procFindVolumeClose.Addr(), 1, uintptr(findVolume), 0, 0)
2245 if r1 == 0 {
2246 if e1 != 0 {
2247 err = errnoErr(e1)
2248 } else {
2249 err = syscall.EINVAL
2250 }
2251 }
2252 return
2253}
2254
2255func FindVolumeMountPointClose(findVolumeMountPoint Handle) (err error) {
2256 r1, _, e1 := syscall.Syscall(procFindVolumeMountPointClose.Addr(), 1, uintptr(findVolumeMountPoint), 0, 0)
2257 if r1 == 0 {
2258 if e1 != 0 {
2259 err = errnoErr(e1)
2260 } else {
2261 err = syscall.EINVAL
2262 }
2263 }
2264 return
2265}
2266
2267func GetDriveType(rootPathName *uint16) (driveType uint32) {
2268 r0, _, _ := syscall.Syscall(procGetDriveTypeW.Addr(), 1, uintptr(unsafe.Pointer(rootPathName)), 0, 0)
2269 driveType = uint32(r0)
2270 return
2271}
2272
2273func GetLogicalDrives() (drivesBitMask uint32, err error) {
2274 r0, _, e1 := syscall.Syscall(procGetLogicalDrives.Addr(), 0, 0, 0, 0)
2275 drivesBitMask = uint32(r0)
2276 if drivesBitMask == 0 {
2277 if e1 != 0 {
2278 err = errnoErr(e1)
2279 } else {
2280 err = syscall.EINVAL
2281 }
2282 }
2283 return
2284}
2285
2286func GetLogicalDriveStrings(bufferLength uint32, buffer *uint16) (n uint32, err error) {
2287 r0, _, e1 := syscall.Syscall(procGetLogicalDriveStringsW.Addr(), 2, uintptr(bufferLength), uintptr(unsafe.Pointer(buffer)), 0)
2288 n = uint32(r0)
2289 if n == 0 {
2290 if e1 != 0 {
2291 err = errnoErr(e1)
2292 } else {
2293 err = syscall.EINVAL
2294 }
2295 }
2296 return
2297}
2298
2299func GetVolumeInformation(rootPathName *uint16, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) {
2300 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)
2301 if r1 == 0 {
2302 if e1 != 0 {
2303 err = errnoErr(e1)
2304 } else {
2305 err = syscall.EINVAL
2306 }
2307 }
2308 return
2309}
2310
2311func GetVolumeInformationByHandle(file Handle, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) {
2312 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)
2313 if r1 == 0 {
2314 if e1 != 0 {
2315 err = errnoErr(e1)
2316 } else {
2317 err = syscall.EINVAL
2318 }
2319 }
2320 return
2321}
2322
2323func GetVolumeNameForVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16, bufferlength uint32) (err error) {
2324 r1, _, e1 := syscall.Syscall(procGetVolumeNameForVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferlength))
2325 if r1 == 0 {
2326 if e1 != 0 {
2327 err = errnoErr(e1)
2328 } else {
2329 err = syscall.EINVAL
2330 }
2331 }
2332 return
2333}
2334
2335func GetVolumePathName(fileName *uint16, volumePathName *uint16, bufferLength uint32) (err error) {
2336 r1, _, e1 := syscall.Syscall(procGetVolumePathNameW.Addr(), 3, uintptr(unsafe.Pointer(fileName)), uintptr(unsafe.Pointer(volumePathName)), uintptr(bufferLength))
2337 if r1 == 0 {
2338 if e1 != 0 {
2339 err = errnoErr(e1)
2340 } else {
2341 err = syscall.EINVAL
2342 }
2343 }
2344 return
2345}
2346
2347func GetVolumePathNamesForVolumeName(volumeName *uint16, volumePathNames *uint16, bufferLength uint32, returnLength *uint32) (err error) {
2348 r1, _, e1 := syscall.Syscall6(procGetVolumePathNamesForVolumeNameW.Addr(), 4, uintptr(unsafe.Pointer(volumeName)), uintptr(unsafe.Pointer(volumePathNames)), uintptr(bufferLength), uintptr(unsafe.Pointer(returnLength)), 0, 0)
2349 if r1 == 0 {
2350 if e1 != 0 {
2351 err = errnoErr(e1)
2352 } else {
2353 err = syscall.EINVAL
2354 }
2355 }
2356 return
2357}
2358
2359func QueryDosDevice(deviceName *uint16, targetPath *uint16, max uint32) (n uint32, err error) {
2360 r0, _, e1 := syscall.Syscall(procQueryDosDeviceW.Addr(), 3, uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)), uintptr(max))
2361 n = uint32(r0)
2362 if n == 0 {
2363 if e1 != 0 {
2364 err = errnoErr(e1)
2365 } else {
2366 err = syscall.EINVAL
2367 }
2368 }
2369 return
2370}
2371
2372func SetVolumeLabel(rootPathName *uint16, volumeName *uint16) (err error) {
2373 r1, _, e1 := syscall.Syscall(procSetVolumeLabelW.Addr(), 2, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeName)), 0)
2374 if r1 == 0 {
2375 if e1 != 0 {
2376 err = errnoErr(e1)
2377 } else {
2378 err = syscall.EINVAL
2379 }
2380 }
2381 return
2382}
2383
2384func SetVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16) (err error) {
2385 r1, _, e1 := syscall.Syscall(procSetVolumeMountPointW.Addr(), 2, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), 0)
2386 if r1 == 0 {
2387 if e1 != 0 {
2388 err = errnoErr(e1)
2389 } else {
2390 err = syscall.EINVAL
2391 }
2392 }
2393 return
2394}
2395
2396func MessageBox(hwnd Handle, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) {
2397 r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0)
2398 ret = int32(r0)
2399 if ret == 0 {
2400 if e1 != 0 {
2401 err = errnoErr(e1)
2402 } else {
2403 err = syscall.EINVAL
2404 }
2405 }
2406 return
2407}
2408
2409func WSAStartup(verreq uint32, data *WSAData) (sockerr error) {
2410 r0, _, _ := syscall.Syscall(procWSAStartup.Addr(), 2, uintptr(verreq), uintptr(unsafe.Pointer(data)), 0)
2411 if r0 != 0 {
2412 sockerr = syscall.Errno(r0)
2413 }
2414 return
2415}
2416
2417func WSACleanup() (err error) {
2418 r1, _, e1 := syscall.Syscall(procWSACleanup.Addr(), 0, 0, 0, 0)
2419 if r1 == socket_error {
2420 if e1 != 0 {
2421 err = errnoErr(e1)
2422 } else {
2423 err = syscall.EINVAL
2424 }
2425 }
2426 return
2427}
2428
2429func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
2430 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))
2431 if r1 == socket_error {
2432 if e1 != 0 {
2433 err = errnoErr(e1)
2434 } else {
2435 err = syscall.EINVAL
2436 }
2437 }
2438 return
2439}
2440
2441func socket(af int32, typ int32, protocol int32) (handle Handle, err error) {
2442 r0, _, e1 := syscall.Syscall(procsocket.Addr(), 3, uintptr(af), uintptr(typ), uintptr(protocol))
2443 handle = Handle(r0)
2444 if handle == InvalidHandle {
2445 if e1 != 0 {
2446 err = errnoErr(e1)
2447 } else {
2448 err = syscall.EINVAL
2449 }
2450 }
2451 return
2452}
2453
2454func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) {
2455 r1, _, e1 := syscall.Syscall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(optlen), 0)
2456 if r1 == socket_error {
2457 if e1 != 0 {
2458 err = errnoErr(e1)
2459 } else {
2460 err = syscall.EINVAL
2461 }
2462 }
2463 return
2464}
2465
2466func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) {
2467 r1, _, e1 := syscall.Syscall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(unsafe.Pointer(optlen)), 0)
2468 if r1 == socket_error {
2469 if e1 != 0 {
2470 err = errnoErr(e1)
2471 } else {
2472 err = syscall.EINVAL
2473 }
2474 }
2475 return
2476}
2477
2478func bind(s Handle, name unsafe.Pointer, namelen int32) (err error) {
2479 r1, _, e1 := syscall.Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
2480 if r1 == socket_error {
2481 if e1 != 0 {
2482 err = errnoErr(e1)
2483 } else {
2484 err = syscall.EINVAL
2485 }
2486 }
2487 return
2488}
2489
2490func connect(s Handle, name unsafe.Pointer, namelen int32) (err error) {
2491 r1, _, e1 := syscall.Syscall(procconnect.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
2492 if r1 == socket_error {
2493 if e1 != 0 {
2494 err = errnoErr(e1)
2495 } else {
2496 err = syscall.EINVAL
2497 }
2498 }
2499 return
2500}
2501
2502func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
2503 r1, _, e1 := syscall.Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
2504 if r1 == socket_error {
2505 if e1 != 0 {
2506 err = errnoErr(e1)
2507 } else {
2508 err = syscall.EINVAL
2509 }
2510 }
2511 return
2512}
2513
2514func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
2515 r1, _, e1 := syscall.Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
2516 if r1 == socket_error {
2517 if e1 != 0 {
2518 err = errnoErr(e1)
2519 } else {
2520 err = syscall.EINVAL
2521 }
2522 }
2523 return
2524}
2525
2526func listen(s Handle, backlog int32) (err error) {
2527 r1, _, e1 := syscall.Syscall(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0)
2528 if r1 == socket_error {
2529 if e1 != 0 {
2530 err = errnoErr(e1)
2531 } else {
2532 err = syscall.EINVAL
2533 }
2534 }
2535 return
2536}
2537
2538func shutdown(s Handle, how int32) (err error) {
2539 r1, _, e1 := syscall.Syscall(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0)
2540 if r1 == socket_error {
2541 if e1 != 0 {
2542 err = errnoErr(e1)
2543 } else {
2544 err = syscall.EINVAL
2545 }
2546 }
2547 return
2548}
2549
2550func Closesocket(s Handle) (err error) {
2551 r1, _, e1 := syscall.Syscall(procclosesocket.Addr(), 1, uintptr(s), 0, 0)
2552 if r1 == socket_error {
2553 if e1 != 0 {
2554 err = errnoErr(e1)
2555 } else {
2556 err = syscall.EINVAL
2557 }
2558 }
2559 return
2560}
2561
2562func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) {
2563 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)
2564 if r1 == 0 {
2565 if e1 != 0 {
2566 err = errnoErr(e1)
2567 } else {
2568 err = syscall.EINVAL
2569 }
2570 }
2571 return
2572}
2573
2574func GetAcceptExSockaddrs(buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, lrsa **RawSockaddrAny, lrsalen *int32, rrsa **RawSockaddrAny, rrsalen *int32) {
2575 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)
2576 return
2577}
2578
2579func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) {
2580 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)
2581 if r1 == socket_error {
2582 if e1 != 0 {
2583 err = errnoErr(e1)
2584 } else {
2585 err = syscall.EINVAL
2586 }
2587 }
2588 return
2589}
2590
2591func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) {
2592 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)
2593 if r1 == socket_error {
2594 if e1 != 0 {
2595 err = errnoErr(e1)
2596 } else {
2597 err = syscall.EINVAL
2598 }
2599 }
2600 return
2601}
2602
2603func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) {
2604 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)))
2605 if r1 == socket_error {
2606 if e1 != 0 {
2607 err = errnoErr(e1)
2608 } else {
2609 err = syscall.EINVAL
2610 }
2611 }
2612 return
2613}
2614
2615func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) {
2616 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)))
2617 if r1 == socket_error {
2618 if e1 != 0 {
2619 err = errnoErr(e1)
2620 } else {
2621 err = syscall.EINVAL
2622 }
2623 }
2624 return
2625}
2626
2627func GetHostByName(name string) (h *Hostent, err error) {
2628 var _p0 *byte
2629 _p0, err = syscall.BytePtrFromString(name)
2630 if err != nil {
2631 return
2632 }
2633 return _GetHostByName(_p0)
2634}
2635
2636func _GetHostByName(name *byte) (h *Hostent, err error) {
2637 r0, _, e1 := syscall.Syscall(procgethostbyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
2638 h = (*Hostent)(unsafe.Pointer(r0))
2639 if h == nil {
2640 if e1 != 0 {
2641 err = errnoErr(e1)
2642 } else {
2643 err = syscall.EINVAL
2644 }
2645 }
2646 return
2647}
2648
2649func GetServByName(name string, proto string) (s *Servent, err error) {
2650 var _p0 *byte
2651 _p0, err = syscall.BytePtrFromString(name)
2652 if err != nil {
2653 return
2654 }
2655 var _p1 *byte
2656 _p1, err = syscall.BytePtrFromString(proto)
2657 if err != nil {
2658 return
2659 }
2660 return _GetServByName(_p0, _p1)
2661}
2662
2663func _GetServByName(name *byte, proto *byte) (s *Servent, err error) {
2664 r0, _, e1 := syscall.Syscall(procgetservbyname.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(proto)), 0)
2665 s = (*Servent)(unsafe.Pointer(r0))
2666 if s == nil {
2667 if e1 != 0 {
2668 err = errnoErr(e1)
2669 } else {
2670 err = syscall.EINVAL
2671 }
2672 }
2673 return
2674}
2675
2676func Ntohs(netshort uint16) (u uint16) {
2677 r0, _, _ := syscall.Syscall(procntohs.Addr(), 1, uintptr(netshort), 0, 0)
2678 u = uint16(r0)
2679 return
2680}
2681
2682func GetProtoByName(name string) (p *Protoent, err error) {
2683 var _p0 *byte
2684 _p0, err = syscall.BytePtrFromString(name)
2685 if err != nil {
2686 return
2687 }
2688 return _GetProtoByName(_p0)
2689}
2690
2691func _GetProtoByName(name *byte) (p *Protoent, err error) {
2692 r0, _, e1 := syscall.Syscall(procgetprotobyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
2693 p = (*Protoent)(unsafe.Pointer(r0))
2694 if p == nil {
2695 if e1 != 0 {
2696 err = errnoErr(e1)
2697 } else {
2698 err = syscall.EINVAL
2699 }
2700 }
2701 return
2702}
2703
2704func DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) {
2705 var _p0 *uint16
2706 _p0, status = syscall.UTF16PtrFromString(name)
2707 if status != nil {
2708 return
2709 }
2710 return _DnsQuery(_p0, qtype, options, extra, qrs, pr)
2711}
2712
2713func _DnsQuery(name *uint16, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) {
2714 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)))
2715 if r0 != 0 {
2716 status = syscall.Errno(r0)
2717 }
2718 return
2719}
2720
2721func DnsRecordListFree(rl *DNSRecord, freetype uint32) {
2722 syscall.Syscall(procDnsRecordListFree.Addr(), 2, uintptr(unsafe.Pointer(rl)), uintptr(freetype), 0)
2723 return
2724}
2725
2726func DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) {
2727 r0, _, _ := syscall.Syscall(procDnsNameCompare_W.Addr(), 2, uintptr(unsafe.Pointer(name1)), uintptr(unsafe.Pointer(name2)), 0)
2728 same = r0 != 0
2729 return
2730}
2731
2732func GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) {
2733 r0, _, _ := syscall.Syscall6(procGetAddrInfoW.Addr(), 4, uintptr(unsafe.Pointer(nodename)), uintptr(unsafe.Pointer(servicename)), uintptr(unsafe.Pointer(hints)), uintptr(unsafe.Pointer(result)), 0, 0)
2734 if r0 != 0 {
2735 sockerr = syscall.Errno(r0)
2736 }
2737 return
2738}
2739
2740func FreeAddrInfoW(addrinfo *AddrinfoW) {
2741 syscall.Syscall(procFreeAddrInfoW.Addr(), 1, uintptr(unsafe.Pointer(addrinfo)), 0, 0)
2742 return
2743}
2744
2745func GetIfEntry(pIfRow *MibIfRow) (errcode error) {
2746 r0, _, _ := syscall.Syscall(procGetIfEntry.Addr(), 1, uintptr(unsafe.Pointer(pIfRow)), 0, 0)
2747 if r0 != 0 {
2748 errcode = syscall.Errno(r0)
2749 }
2750 return
2751}
2752
2753func GetAdaptersInfo(ai *IpAdapterInfo, ol *uint32) (errcode error) {
2754 r0, _, _ := syscall.Syscall(procGetAdaptersInfo.Addr(), 2, uintptr(unsafe.Pointer(ai)), uintptr(unsafe.Pointer(ol)), 0)
2755 if r0 != 0 {
2756 errcode = syscall.Errno(r0)
2757 }
2758 return
2759}
2760
2761func SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) {
2762 r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(handle), uintptr(flags), 0)
2763 if r1 == 0 {
2764 if e1 != 0 {
2765 err = errnoErr(e1)
2766 } else {
2767 err = syscall.EINVAL
2768 }
2769 }
2770 return
2771}
2772
2773func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferLength *uint32) (n int32, err error) {
2774 r0, _, e1 := syscall.Syscall(procWSAEnumProtocolsW.Addr(), 3, uintptr(unsafe.Pointer(protocols)), uintptr(unsafe.Pointer(protocolBuffer)), uintptr(unsafe.Pointer(bufferLength)))
2775 n = int32(r0)
2776 if n == -1 {
2777 if e1 != 0 {
2778 err = errnoErr(e1)
2779 } else {
2780 err = syscall.EINVAL
2781 }
2782 }
2783 return
2784}
2785
2786func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) {
2787 r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0)
2788 if r0 != 0 {
2789 errcode = syscall.Errno(r0)
2790 }
2791 return
2792}
2793
2794func GetACP() (acp uint32) {
2795 r0, _, _ := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0)
2796 acp = uint32(r0)
2797 return
2798}
2799
2800func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) {
2801 r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar))
2802 nwrite = int32(r0)
2803 if nwrite == 0 {
2804 if e1 != 0 {
2805 err = errnoErr(e1)
2806 } else {
2807 err = syscall.EINVAL
2808 }
2809 }
2810 return
2811}
2812
2813func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint32, translatedName *uint16, nSize *uint32) (err error) {
2814 r1, _, e1 := syscall.Syscall6(procTranslateNameW.Addr(), 5, uintptr(unsafe.Pointer(accName)), uintptr(accNameFormat), uintptr(desiredNameFormat), uintptr(unsafe.Pointer(translatedName)), uintptr(unsafe.Pointer(nSize)), 0)
2815 if r1&0xff == 0 {
2816 if e1 != 0 {
2817 err = errnoErr(e1)
2818 } else {
2819 err = syscall.EINVAL
2820 }
2821 }
2822 return
2823}
2824
2825func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err error) {
2826 r1, _, e1 := syscall.Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize)))
2827 if r1&0xff == 0 {
2828 if e1 != 0 {
2829 err = errnoErr(e1)
2830 } else {
2831 err = syscall.EINVAL
2832 }
2833 }
2834 return
2835}
2836
2837func NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **byte) (neterr error) {
2838 r0, _, _ := syscall.Syscall6(procNetUserGetInfo.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(userName)), uintptr(level), uintptr(unsafe.Pointer(buf)), 0, 0)
2839 if r0 != 0 {
2840 neterr = syscall.Errno(r0)
2841 }
2842 return
2843}
2844
2845func NetGetJoinInformation(server *uint16, name **uint16, bufType *uint32) (neterr error) {
2846 r0, _, _ := syscall.Syscall(procNetGetJoinInformation.Addr(), 3, uintptr(unsafe.Pointer(server)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(bufType)))
2847 if r0 != 0 {
2848 neterr = syscall.Errno(r0)
2849 }
2850 return
2851}
2852
2853func NetApiBufferFree(buf *byte) (neterr error) {
2854 r0, _, _ := syscall.Syscall(procNetApiBufferFree.Addr(), 1, uintptr(unsafe.Pointer(buf)), 0, 0)
2855 if r0 != 0 {
2856 neterr = syscall.Errno(r0)
2857 }
2858 return
2859}
2860
2861func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
2862 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)
2863 if r1 == 0 {
2864 if e1 != 0 {
2865 err = errnoErr(e1)
2866 } else {
2867 err = syscall.EINVAL
2868 }
2869 }
2870 return
2871}
2872
2873func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
2874 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)
2875 if r1 == 0 {
2876 if e1 != 0 {
2877 err = errnoErr(e1)
2878 } else {
2879 err = syscall.EINVAL
2880 }
2881 }
2882 return
2883}
2884
2885func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) {
2886 r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(stringSid)), 0)
2887 if r1 == 0 {
2888 if e1 != 0 {
2889 err = errnoErr(e1)
2890 } else {
2891 err = syscall.EINVAL
2892 }
2893 }
2894 return
2895}
2896
2897func ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) {
2898 r1, _, e1 := syscall.Syscall(procConvertStringSidToSidW.Addr(), 2, uintptr(unsafe.Pointer(stringSid)), uintptr(unsafe.Pointer(sid)), 0)
2899 if r1 == 0 {
2900 if e1 != 0 {
2901 err = errnoErr(e1)
2902 } else {
2903 err = syscall.EINVAL
2904 }
2905 }
2906 return
2907}
2908
2909func GetLengthSid(sid *SID) (len uint32) {
2910 r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
2911 len = uint32(r0)
2912 return
2913}
2914
2915func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) {
2916 r1, _, e1 := syscall.Syscall(procCopySid.Addr(), 3, uintptr(destSidLen), uintptr(unsafe.Pointer(destSid)), uintptr(unsafe.Pointer(srcSid)))
2917 if r1 == 0 {
2918 if e1 != 0 {
2919 err = errnoErr(e1)
2920 } else {
2921 err = syscall.EINVAL
2922 }
2923 }
2924 return
2925}
2926
2927func 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) {
2928 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)
2929 if r1 == 0 {
2930 if e1 != 0 {
2931 err = errnoErr(e1)
2932 } else {
2933 err = syscall.EINVAL
2934 }
2935 }
2936 return
2937}
2938
2939func createWellKnownSid(sidType WELL_KNOWN_SID_TYPE, domainSid *SID, sid *SID, sizeSid *uint32) (err error) {
2940 r1, _, e1 := syscall.Syscall6(procCreateWellKnownSid.Addr(), 4, uintptr(sidType), uintptr(unsafe.Pointer(domainSid)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sizeSid)), 0, 0)
2941 if r1 == 0 {
2942 if e1 != 0 {
2943 err = errnoErr(e1)
2944 } else {
2945 err = syscall.EINVAL
2946 }
2947 }
2948 return
2949}
2950
2951func isWellKnownSid(sid *SID, sidType WELL_KNOWN_SID_TYPE) (isWellKnown bool) {
2952 r0, _, _ := syscall.Syscall(procIsWellKnownSid.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(sidType), 0)
2953 isWellKnown = r0 != 0
2954 return
2955}
2956
2957func FreeSid(sid *SID) (err error) {
2958 r1, _, e1 := syscall.Syscall(procFreeSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
2959 if r1 != 0 {
2960 if e1 != 0 {
2961 err = errnoErr(e1)
2962 } else {
2963 err = syscall.EINVAL
2964 }
2965 }
2966 return
2967}
2968
2969func EqualSid(sid1 *SID, sid2 *SID) (isEqual bool) {
2970 r0, _, _ := syscall.Syscall(procEqualSid.Addr(), 2, uintptr(unsafe.Pointer(sid1)), uintptr(unsafe.Pointer(sid2)), 0)
2971 isEqual = r0 != 0
2972 return
2973}
2974
2975func getSidIdentifierAuthority(sid *SID) (authority *SidIdentifierAuthority) {
2976 r0, _, _ := syscall.Syscall(procGetSidIdentifierAuthority.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
2977 authority = (*SidIdentifierAuthority)(unsafe.Pointer(r0))
2978 return
2979}
2980
2981func getSidSubAuthorityCount(sid *SID) (count *uint8) {
2982 r0, _, _ := syscall.Syscall(procGetSidSubAuthorityCount.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
2983 count = (*uint8)(unsafe.Pointer(r0))
2984 return
2985}
2986
2987func getSidSubAuthority(sid *SID, index uint32) (subAuthority *uint32) {
2988 r0, _, _ := syscall.Syscall(procGetSidSubAuthority.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(index), 0)
2989 subAuthority = (*uint32)(unsafe.Pointer(r0))
2990 return
2991}
2992
2993func isValidSid(sid *SID) (isValid bool) {
2994 r0, _, _ := syscall.Syscall(procIsValidSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
2995 isValid = r0 != 0
2996 return
2997}
2998
2999func checkTokenMembership(tokenHandle Token, sidToCheck *SID, isMember *int32) (err error) {
3000 r1, _, e1 := syscall.Syscall(procCheckTokenMembership.Addr(), 3, uintptr(tokenHandle), uintptr(unsafe.Pointer(sidToCheck)), uintptr(unsafe.Pointer(isMember)))
3001 if r1 == 0 {
3002 if e1 != 0 {
3003 err = errnoErr(e1)
3004 } else {
3005 err = syscall.EINVAL
3006 }
3007 }
3008 return
3009}
3010
3011func OpenProcessToken(process Handle, access uint32, token *Token) (err error) {
3012 r1, _, e1 := syscall.Syscall(procOpenProcessToken.Addr(), 3, uintptr(process), uintptr(access), uintptr(unsafe.Pointer(token)))
3013 if r1 == 0 {
3014 if e1 != 0 {
3015 err = errnoErr(e1)
3016 } else {
3017 err = syscall.EINVAL
3018 }
3019 }
3020 return
3021}
3022
3023func OpenThreadToken(thread Handle, access uint32, openAsSelf bool, token *Token) (err error) {
3024 var _p0 uint32
3025 if openAsSelf {
3026 _p0 = 1
3027 } else {
3028 _p0 = 0
3029 }
3030 r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(thread), uintptr(access), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0)
3031 if r1 == 0 {
3032 if e1 != 0 {
3033 err = errnoErr(e1)
3034 } else {
3035 err = syscall.EINVAL
3036 }
3037 }
3038 return
3039}
3040
3041func ImpersonateSelf(impersonationlevel uint32) (err error) {
3042 r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(impersonationlevel), 0, 0)
3043 if r1 == 0 {
3044 if e1 != 0 {
3045 err = errnoErr(e1)
3046 } else {
3047 err = syscall.EINVAL
3048 }
3049 }
3050 return
3051}
3052
3053func RevertToSelf() (err error) {
3054 r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0)
3055 if r1 == 0 {
3056 if e1 != 0 {
3057 err = errnoErr(e1)
3058 } else {
3059 err = syscall.EINVAL
3060 }
3061 }
3062 return
3063}
3064
3065func SetThreadToken(thread *Handle, token Token) (err error) {
3066 r1, _, e1 := syscall.Syscall(procSetThreadToken.Addr(), 2, uintptr(unsafe.Pointer(thread)), uintptr(token), 0)
3067 if r1 == 0 {
3068 if e1 != 0 {
3069 err = errnoErr(e1)
3070 } else {
3071 err = syscall.EINVAL
3072 }
3073 }
3074 return
3075}
3076
3077func LookupPrivilegeValue(systemname *uint16, name *uint16, luid *LUID) (err error) {
3078 r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemname)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid)))
3079 if r1 == 0 {
3080 if e1 != 0 {
3081 err = errnoErr(e1)
3082 } else {
3083 err = syscall.EINVAL
3084 }
3085 }
3086 return
3087}
3088
3089func AdjustTokenPrivileges(token Token, disableAllPrivileges bool, newstate *Tokenprivileges, buflen uint32, prevstate *Tokenprivileges, returnlen *uint32) (err error) {
3090 var _p0 uint32
3091 if disableAllPrivileges {
3092 _p0 = 1
3093 } else {
3094 _p0 = 0
3095 }
3096 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)))
3097 if r1 == 0 {
3098 if e1 != 0 {
3099 err = errnoErr(e1)
3100 } else {
3101 err = syscall.EINVAL
3102 }
3103 }
3104 return
3105}
3106
3107func AdjustTokenGroups(token Token, resetToDefault bool, newstate *Tokengroups, buflen uint32, prevstate *Tokengroups, returnlen *uint32) (err error) {
3108 var _p0 uint32
3109 if resetToDefault {
3110 _p0 = 1
3111 } else {
3112 _p0 = 0
3113 }
3114 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)))
3115 if r1 == 0 {
3116 if e1 != 0 {
3117 err = errnoErr(e1)
3118 } else {
3119 err = syscall.EINVAL
3120 }
3121 }
3122 return
3123}
3124
3125func GetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint32, returnedLen *uint32) (err error) {
3126 r1, _, e1 := syscall.Syscall6(procGetTokenInformation.Addr(), 5, uintptr(token), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), uintptr(unsafe.Pointer(returnedLen)), 0)
3127 if r1 == 0 {
3128 if e1 != 0 {
3129 err = errnoErr(e1)
3130 } else {
3131 err = syscall.EINVAL
3132 }
3133 }
3134 return
3135}
3136
3137func SetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint32) (err error) {
3138 r1, _, e1 := syscall.Syscall6(procSetTokenInformation.Addr(), 4, uintptr(token), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), 0, 0)
3139 if r1 == 0 {
3140 if e1 != 0 {
3141 err = errnoErr(e1)
3142 } else {
3143 err = syscall.EINVAL
3144 }
3145 }
3146 return
3147}
3148
3149func DuplicateTokenEx(existingToken Token, desiredAccess uint32, tokenAttributes *SecurityAttributes, impersonationLevel uint32, tokenType uint32, newToken *Token) (err error) {
3150 r1, _, e1 := syscall.Syscall6(procDuplicateTokenEx.Addr(), 6, uintptr(existingToken), uintptr(desiredAccess), uintptr(unsafe.Pointer(tokenAttributes)), uintptr(impersonationLevel), uintptr(tokenType), uintptr(unsafe.Pointer(newToken)))
3151 if r1 == 0 {
3152 if e1 != 0 {
3153 err = errnoErr(e1)
3154 } else {
3155 err = syscall.EINVAL
3156 }
3157 }
3158 return
3159}
3160
3161func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) {
3162 r1, _, e1 := syscall.Syscall(procGetUserProfileDirectoryW.Addr(), 3, uintptr(t), uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen)))
3163 if r1 == 0 {
3164 if e1 != 0 {
3165 err = errnoErr(e1)
3166 } else {
3167 err = syscall.EINVAL
3168 }
3169 }
3170 return
3171}
3172
3173func getSystemDirectory(dir *uint16, dirLen uint32) (len uint32, err error) {
3174 r0, _, e1 := syscall.Syscall(procGetSystemDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0)
3175 len = uint32(r0)
3176 if len == 0 {
3177 if e1 != 0 {
3178 err = errnoErr(e1)
3179 } else {
3180 err = syscall.EINVAL
3181 }
3182 }
3183 return
3184}
3185
3186func WTSQueryUserToken(session uint32, token *Token) (err error) {
3187 r1, _, e1 := syscall.Syscall(procWTSQueryUserToken.Addr(), 2, uintptr(session), uintptr(unsafe.Pointer(token)), 0)
3188 if r1 == 0 {
3189 if e1 != 0 {
3190 err = errnoErr(e1)
3191 } else {
3192 err = syscall.EINVAL
3193 }
3194 }
3195 return
3196}
3197
3198func WTSEnumerateSessions(handle Handle, reserved uint32, version uint32, sessions **WTS_SESSION_INFO, count *uint32) (err error) {
3199 r1, _, e1 := syscall.Syscall6(procWTSEnumerateSessionsW.Addr(), 5, uintptr(handle), uintptr(reserved), uintptr(version), uintptr(unsafe.Pointer(sessions)), uintptr(unsafe.Pointer(count)), 0)
3200 if r1 == 0 {
3201 if e1 != 0 {
3202 err = errnoErr(e1)
3203 } else {
3204 err = syscall.EINVAL
3205 }
3206 }
3207 return
3208}
3209
3210func WTSFreeMemory(ptr uintptr) {
3211 syscall.Syscall(procWTSFreeMemory.Addr(), 1, uintptr(ptr), 0, 0)
3212 return
3213}