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