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