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