Debian Codegraph @

src/internal/runtime/syscall/windows/syscall_windows.go

raw
1 // Copyright 2025 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // Package windows provides the syscall primitives required for the runtime.
6
7 package windows
8
9 import (
10 "internal/abi"
11 )
12
13 // MaxArgs should be divisible by 2, as Windows stack
14 // must be kept 16-byte aligned on syscall entry.
15 //
16 // Although it only permits maximum 42 parameters, it
17 // is arguably large enough.
18 const MaxArgs = 42
19
20 // StdCallInfo is a structure used to pass parameters to the system call.
21 type StdCallInfo struct {
22 Fn uintptr
23 N uintptr // number of parameters
24 Args uintptr // parameters
25 R1 uintptr // return values
26 R2 uintptr
27 Err uintptr // error number
28 }
29
30 // StdCall calls a function using Windows' stdcall convention.
31 //
32 //go:noescape
33 func StdCall(fn *StdCallInfo)
34
35 // asmstdcall is the function pointer for [AsmStdCallAddr].
36 func asmstdcall(fn *StdCallInfo)
37
38 // AsmStdCallAddr is the address of a function that accepts a pointer
39 // to [StdCallInfo] stored on the stack following the C calling convention,
40 // and calls the function using Windows' stdcall calling convention.
41 // Shouldn't be called directly from Go.
42 func AsmStdCallAddr() uintptr {
43 return abi.FuncPCABI0(asmstdcall)
44 }