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