Debian Codegraph @

internal/syscall/windows/zsyscall_windows.go

raw symbols SCIP
1 // Code generated by 'go generate'; DO NOT EDIT.
2
3 package windows
4
5 import (
6 "syscall"
7 "unsafe"
8
9 "github.com/rogpeppe/go-internal/internal/syscall/windows/sysdll"
10 )
11
12 var _ unsafe.Pointer
13
14 // Do the interface allocations only once for common
15 // Errno values.
16 const (
17 errnoERROR_IO_PENDING = 997
18 )
19
20 var (
21 errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
22 )
23
24 // errnoErr returns common boxed Errno values, to prevent
25 // allocations at runtime.
26 func errnoErr(e syscall.Errno) error {
27 switch e {
28 case 0:
29 return nil
30 case errnoERROR_IO_PENDING:
31 return errERROR_IO_PENDING
32 }
33 // TODO: add more here, after collecting data on the common
34 // error values see on Windows. (perhaps when running
35 // all.bat?)
36 return e
37 }
38
39 var (
40 modiphlpapi = syscall.NewLazyDLL(sysdll.Add("iphlpapi.dll"))
41 modkernel32 = syscall.NewLazyDLL(sysdll.Add("kernel32.dll"))
42 modws2_32 = syscall.NewLazyDLL(sysdll.Add("ws2_32.dll"))
43 modnetapi32 = syscall.NewLazyDLL(sysdll.Add("netapi32.dll"))
44 modadvapi32 = syscall.NewLazyDLL(sysdll.Add("advapi32.dll"))
45 moduserenv = syscall.NewLazyDLL(sysdll.Add("userenv.dll"))
46 modpsapi = syscall.NewLazyDLL(sysdll.Add("psapi.dll"))
47
48 procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses")
49 procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
50 procMoveFileExW = modkernel32.NewProc("MoveFileExW")
51 procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW")
52 procWSASocketW = modws2_32.NewProc("WSASocketW")
53 procLockFileEx = modkernel32.NewProc("LockFileEx")
54 procUnlockFileEx = modkernel32.NewProc("UnlockFileEx")
55 procGetACP = modkernel32.NewProc("GetACP")
56 procGetConsoleCP = modkernel32.NewProc("GetConsoleCP")
57 procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar")
58 procGetCurrentThread = modkernel32.NewProc("GetCurrentThread")
59 procNetShareAdd = modnetapi32.NewProc("NetShareAdd")
60 procNetShareDel = modnetapi32.NewProc("NetShareDel")
61 procGetFinalPathNameByHandleW = modkernel32.NewProc("GetFinalPathNameByHandleW")
62 procImpersonateSelf = modadvapi32.NewProc("ImpersonateSelf")
63 procRevertToSelf = modadvapi32.NewProc("RevertToSelf")
64 procOpenThreadToken = modadvapi32.NewProc("OpenThreadToken")
65 procLookupPrivilegeValueW = modadvapi32.NewProc("LookupPrivilegeValueW")
66 procAdjustTokenPrivileges = modadvapi32.NewProc("AdjustTokenPrivileges")
67 procDuplicateTokenEx = modadvapi32.NewProc("DuplicateTokenEx")
68 procSetTokenInformation = modadvapi32.NewProc("SetTokenInformation")
69 procGetProfilesDirectoryW = moduserenv.NewProc("GetProfilesDirectoryW")
70 procNetUserGetLocalGroups = modnetapi32.NewProc("NetUserGetLocalGroups")
71 procGetProcessMemoryInfo = modpsapi.NewProc("GetProcessMemoryInfo")
72 procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx")
73 )
74
75 func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) {
76 r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0)
77 if r0 != 0 {
78 errcode = syscall.Errno(r0)
79 }
80 return
81 }
82
83 func GetComputerNameEx(nameformat uint32, buf *uint16, n *uint32) (err error) {
84 r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nameformat), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)))
85 if r1 == 0 {
86 if e1 != 0 {
87 err = errnoErr(e1)
88 } else {
89 err = syscall.EINVAL
90 }
91 }
92 return
93 }
94
95 func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) {
96 r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags))
97 if r1 == 0 {
98 if e1 != 0 {
99 err = errnoErr(e1)
100 } else {
101 err = syscall.EINVAL
102 }
103 }
104 return
105 }
106
107 func GetModuleFileName(module syscall.Handle, fn *uint16, len uint32) (n uint32, err error) {
108 r0, _, e1 := syscall.Syscall(procGetModuleFileNameW.Addr(), 3, uintptr(module), uintptr(unsafe.Pointer(fn)), uintptr(len))
109 n = uint32(r0)
110 if n == 0 {
111 if e1 != 0 {
112 err = errnoErr(e1)
113 } else {
114 err = syscall.EINVAL
115 }
116 }
117 return
118 }
119
120 func WSASocket(af int32, typ int32, protocol int32, protinfo *syscall.WSAProtocolInfo, group uint32, flags uint32) (handle syscall.Handle, err error) {
121 r0, _, e1 := syscall.Syscall6(procWSASocketW.Addr(), 6, uintptr(af), uintptr(typ), uintptr(protocol), uintptr(unsafe.Pointer(protinfo)), uintptr(group), uintptr(flags))
122 handle = syscall.Handle(r0)
123 if handle == syscall.InvalidHandle {
124 if e1 != 0 {
125 err = errnoErr(e1)
126 } else {
127 err = syscall.EINVAL
128 }
129 }
130 return
131 }
132
133 func LockFileEx(file syscall.Handle, flags uint32, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *syscall.Overlapped) (err error) {
134 r1, _, e1 := syscall.Syscall6(procLockFileEx.Addr(), 6, uintptr(file), uintptr(flags), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)))
135 if r1 == 0 {
136 if e1 != 0 {
137 err = errnoErr(e1)
138 } else {
139 err = syscall.EINVAL
140 }
141 }
142 return
143 }
144
145 func UnlockFileEx(file syscall.Handle, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *syscall.Overlapped) (err error) {
146 r1, _, e1 := syscall.Syscall6(procUnlockFileEx.Addr(), 5, uintptr(file), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)), 0)
147 if r1 == 0 {
148 if e1 != 0 {
149 err = errnoErr(e1)
150 } else {
151 err = syscall.EINVAL
152 }
153 }
154 return
155 }
156
157 func GetACP() (acp uint32) {
158 r0, _, _ := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0)
159 acp = uint32(r0)
160 return
161 }
162
163 func GetConsoleCP() (ccp uint32) {
164 r0, _, _ := syscall.Syscall(procGetConsoleCP.Addr(), 0, 0, 0, 0)
165 ccp = uint32(r0)
166 return
167 }
168
169 func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) {
170 r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar))
171 nwrite = int32(r0)
172 if nwrite == 0 {
173 if e1 != 0 {
174 err = errnoErr(e1)
175 } else {
176 err = syscall.EINVAL
177 }
178 }
179 return
180 }
181
182 func GetCurrentThread() (pseudoHandle syscall.Handle, err error) {
183 r0, _, e1 := syscall.Syscall(procGetCurrentThread.Addr(), 0, 0, 0, 0)
184 pseudoHandle = syscall.Handle(r0)
185 if pseudoHandle == 0 {
186 if e1 != 0 {
187 err = errnoErr(e1)
188 } else {
189 err = syscall.EINVAL
190 }
191 }
192 return
193 }
194
195 func NetShareAdd(serverName *uint16, level uint32, buf *byte, parmErr *uint16) (neterr error) {
196 r0, _, _ := syscall.Syscall6(procNetShareAdd.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(level), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(parmErr)), 0, 0)
197 if r0 != 0 {
198 neterr = syscall.Errno(r0)
199 }
200 return
201 }
202
203 func NetShareDel(serverName *uint16, netName *uint16, reserved uint32) (neterr error) {
204 r0, _, _ := syscall.Syscall(procNetShareDel.Addr(), 3, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(netName)), uintptr(reserved))
205 if r0 != 0 {
206 neterr = syscall.Errno(r0)
207 }
208 return
209 }
210
211 func GetFinalPathNameByHandle(file syscall.Handle, filePath *uint16, filePathSize uint32, flags uint32) (n uint32, err error) {
212 r0, _, e1 := syscall.Syscall6(procGetFinalPathNameByHandleW.Addr(), 4, uintptr(file), uintptr(unsafe.Pointer(filePath)), uintptr(filePathSize), uintptr(flags), 0, 0)
213 n = uint32(r0)
214 if n == 0 {
215 if e1 != 0 {
216 err = errnoErr(e1)
217 } else {
218 err = syscall.EINVAL
219 }
220 }
221 return
222 }
223
224 func ImpersonateSelf(impersonationlevel uint32) (err error) {
225 r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(impersonationlevel), 0, 0)
226 if r1 == 0 {
227 if e1 != 0 {
228 err = errnoErr(e1)
229 } else {
230 err = syscall.EINVAL
231 }
232 }
233 return
234 }
235
236 func RevertToSelf() (err error) {
237 r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 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 OpenThreadToken(h syscall.Handle, access uint32, openasself bool, token *syscall.Token) (err error) {
249 var _p0 uint32
250 if openasself {
251 _p0 = 1
252 } else {
253 _p0 = 0
254 }
255 r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(h), uintptr(access), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0)
256 if r1 == 0 {
257 if e1 != 0 {
258 err = errnoErr(e1)
259 } else {
260 err = syscall.EINVAL
261 }
262 }
263 return
264 }
265
266 func LookupPrivilegeValue(systemname *uint16, name *uint16, luid *LUID) (err error) {
267 r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemname)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid)))
268 if r1 == 0 {
269 if e1 != 0 {
270 err = errnoErr(e1)
271 } else {
272 err = syscall.EINVAL
273 }
274 }
275 return
276 }
277
278 func adjustTokenPrivileges(token syscall.Token, disableAllPrivileges bool, newstate *TOKEN_PRIVILEGES, buflen uint32, prevstate *TOKEN_PRIVILEGES, returnlen *uint32) (ret uint32, err error) {
279 var _p0 uint32
280 if disableAllPrivileges {
281 _p0 = 1
282 } else {
283 _p0 = 0
284 }
285 r0, _, e1 := syscall.Syscall6(procAdjustTokenPrivileges.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(newstate)), uintptr(buflen), uintptr(unsafe.Pointer(prevstate)), uintptr(unsafe.Pointer(returnlen)))
286 ret = uint32(r0)
287 if true {
288 if e1 != 0 {
289 err = errnoErr(e1)
290 } else {
291 err = syscall.EINVAL
292 }
293 }
294 return
295 }
296
297 func DuplicateTokenEx(hExistingToken syscall.Token, dwDesiredAccess uint32, lpTokenAttributes *syscall.SecurityAttributes, impersonationLevel uint32, tokenType TokenType, phNewToken *syscall.Token) (err error) {
298 r1, _, e1 := syscall.Syscall6(procDuplicateTokenEx.Addr(), 6, uintptr(hExistingToken), uintptr(dwDesiredAccess), uintptr(unsafe.Pointer(lpTokenAttributes)), uintptr(impersonationLevel), uintptr(tokenType), uintptr(unsafe.Pointer(phNewToken)))
299 if r1 == 0 {
300 if e1 != 0 {
301 err = errnoErr(e1)
302 } else {
303 err = syscall.EINVAL
304 }
305 }
306 return
307 }
308
309 func SetTokenInformation(tokenHandle syscall.Token, tokenInformationClass uint32, tokenInformation uintptr, tokenInformationLength uint32) (err error) {
310 r1, _, e1 := syscall.Syscall6(procSetTokenInformation.Addr(), 4, uintptr(tokenHandle), uintptr(tokenInformationClass), uintptr(tokenInformation), uintptr(tokenInformationLength), 0, 0)
311 if r1 == 0 {
312 if e1 != 0 {
313 err = errnoErr(e1)
314 } else {
315 err = syscall.EINVAL
316 }
317 }
318 return
319 }
320
321 func GetProfilesDirectory(dir *uint16, dirLen *uint32) (err error) {
322 r1, _, e1 := syscall.Syscall(procGetProfilesDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen)), 0)
323 if r1 == 0 {
324 if e1 != 0 {
325 err = errnoErr(e1)
326 } else {
327 err = syscall.EINVAL
328 }
329 }
330 return
331 }
332
333 func NetUserGetLocalGroups(serverName *uint16, userName *uint16, level uint32, flags uint32, buf **byte, prefMaxLen uint32, entriesRead *uint32, totalEntries *uint32) (neterr error) {
334 r0, _, _ := syscall.Syscall9(procNetUserGetLocalGroups.Addr(), 8, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(userName)), uintptr(level), uintptr(flags), uintptr(unsafe.Pointer(buf)), uintptr(prefMaxLen), uintptr(unsafe.Pointer(entriesRead)), uintptr(unsafe.Pointer(totalEntries)), 0)
335 if r0 != 0 {
336 neterr = syscall.Errno(r0)
337 }
338 return
339 }
340
341 func GetProcessMemoryInfo(handle syscall.Handle, memCounters *PROCESS_MEMORY_COUNTERS, cb uint32) (err error) {
342 r1, _, e1 := syscall.Syscall(procGetProcessMemoryInfo.Addr(), 3, uintptr(handle), uintptr(unsafe.Pointer(memCounters)), uintptr(cb))
343 if r1 == 0 {
344 if e1 != 0 {
345 err = errnoErr(e1)
346 } else {
347 err = syscall.EINVAL
348 }
349 }
350 return
351 }
352
353 func GetFileInformationByHandleEx(handle syscall.Handle, class uint32, info *byte, bufsize uint32) (err error) {
354 r1, _, e1 := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 4, uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(info)), uintptr(bufsize), 0, 0)
355 if r1 == 0 {
356 if e1 != 0 {
357 err = errnoErr(e1)
358 } else {
359 err = syscall.EINVAL
360 }
361 }
362 return
363 }