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