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