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