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