code
stringlengths 11
335k
| docstring
stringlengths 20
11.8k
| func_name
stringlengths 1
100
| language
stringclasses 1
value | repo
stringclasses 245
values | path
stringlengths 4
144
| url
stringlengths 43
214
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
func LookupSID(system, account string) (sid *SID, domain string, accType uint32, err error) {
if len(account) == 0 {
return nil, "", 0, syscall.EINVAL
}
acc, e := UTF16PtrFromString(account)
if e != nil {
return nil, "", 0, e
}
var sys *uint16
if len(system) > 0 {
sys, e = UTF16PtrFromString(system)
if e != nil {
return nil, "", 0, e
}
}
n := uint32(50)
dn := uint32(50)
for {
b := make([]byte, n)
db := make([]uint16, dn)
sid = (*SID)(unsafe.Pointer(&b[0]))
e = LookupAccountName(sys, acc, sid, &n, &db[0], &dn, &accType)
if e == nil {
return sid, UTF16ToString(db), accType, nil
}
if e != ERROR_INSUFFICIENT_BUFFER {
return nil, "", 0, e
}
if n <= uint32(len(b)) {
return nil, "", 0, e
}
}
} | LookupSID retrieves a security identifier SID for the account
and the name of the domain on which the account was found.
System specify target computer to search. | LookupSID | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func (sid *SID) String() (string, error) {
var s *uint16
e := ConvertSidToStringSid(sid, &s)
if e != nil {
return "", e
}
defer LocalFree((Handle)(unsafe.Pointer(s)))
return UTF16ToString((*[256]uint16)(unsafe.Pointer(s))[:]), nil
} | String converts SID to a string format
suitable for display, storage, or transmission. | String | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func (sid *SID) Len() int {
return int(GetLengthSid(sid))
} | Len returns the length, in bytes, of a valid security identifier SID. | Len | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func (sid *SID) Copy() (*SID, error) {
b := make([]byte, sid.Len())
sid2 := (*SID)(unsafe.Pointer(&b[0]))
e := CopySid(uint32(len(b)), sid2, sid)
if e != nil {
return nil, e
}
return sid2, nil
} | Copy creates a duplicate of security identifier SID. | Copy | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func (sid *SID) IdentifierAuthority() SidIdentifierAuthority {
return *getSidIdentifierAuthority(sid)
} | IdentifierAuthority returns the identifier authority of the SID. | IdentifierAuthority | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func (sid *SID) SubAuthorityCount() uint8 {
return *getSidSubAuthorityCount(sid)
} | SubAuthorityCount returns the number of sub-authorities in the SID. | SubAuthorityCount | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func (sid *SID) SubAuthority(idx uint32) uint32 {
if idx >= uint32(sid.SubAuthorityCount()) {
panic("sub-authority index out of range")
}
return *getSidSubAuthority(sid, idx)
} | SubAuthority returns the sub-authority of the SID as specified by
the index, which must be less than sid.SubAuthorityCount(). | SubAuthority | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func (sid *SID) IsValid() bool {
return isValidSid(sid)
} | IsValid returns whether the SID has a valid revision and length. | IsValid | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func (sid *SID) Equals(sid2 *SID) bool {
return EqualSid(sid, sid2)
} | Equals compares two SIDs for equality. | Equals | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func (sid *SID) IsWellKnown(sidType WELL_KNOWN_SID_TYPE) bool {
return isWellKnownSid(sid, sidType)
} | IsWellKnown determines whether the SID matches the well-known sidType. | IsWellKnown | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func (sid *SID) LookupAccount(system string) (account, domain string, accType uint32, err error) {
var sys *uint16
if len(system) > 0 {
sys, err = UTF16PtrFromString(system)
if err != nil {
return "", "", 0, err
}
}
n := uint32(50)
dn := uint32(50)
for {
b := make([]uint16, n)
db := make([]uint16, dn)
e := LookupAccountSid(sys, sid, &b[0], &n, &db[0], &dn, &accType)
if e == nil {
return UTF16ToString(b), UTF16ToString(db), accType, nil
}
if e != ERROR_INSUFFICIENT_BUFFER {
return "", "", 0, e
}
if n <= uint32(len(b)) {
return "", "", 0, e
}
}
} | LookupAccount retrieves the name of the account for this SID
and the name of the first domain on which this SID is found.
System specify target computer to search for. | LookupAccount | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func CreateWellKnownSid(sidType WELL_KNOWN_SID_TYPE) (*SID, error) {
return CreateWellKnownDomainSid(sidType, nil)
} | Creates a SID for a well-known predefined alias, generally using the constants of the form
Win*Sid, for the local machine. | CreateWellKnownSid | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func CreateWellKnownDomainSid(sidType WELL_KNOWN_SID_TYPE, domainSid *SID) (*SID, error) {
n := uint32(50)
for {
b := make([]byte, n)
sid := (*SID)(unsafe.Pointer(&b[0]))
err := createWellKnownSid(sidType, domainSid, sid, &n)
if err == nil {
return sid, nil
}
if err != ERROR_INSUFFICIENT_BUFFER {
return nil, err
}
if n <= uint32(len(b)) {
return nil, err
}
}
} | Creates a SID for a well-known predefined alias, generally using the constants of the form
Win*Sid, for the domain specified by the domainSid parameter. | CreateWellKnownDomainSid | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func (g *Tokengroups) AllGroups() []SIDAndAttributes {
return (*[(1 << 28) - 1]SIDAndAttributes)(unsafe.Pointer(&g.Groups[0]))[:g.GroupCount:g.GroupCount]
} | AllGroups returns a slice that can be used to iterate over the groups in g. | AllGroups | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func (p *Tokenprivileges) AllPrivileges() []LUIDAndAttributes {
return (*[(1 << 27) - 1]LUIDAndAttributes)(unsafe.Pointer(&p.Privileges[0]))[:p.PrivilegeCount:p.PrivilegeCount]
} | AllPrivileges returns a slice that can be used to iterate over the privileges in p. | AllPrivileges | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func OpenCurrentProcessToken() (Token, error) {
p, e := GetCurrentProcess()
if e != nil {
return 0, e
}
var t Token
e = OpenProcessToken(p, TOKEN_QUERY, &t)
if e != nil {
return 0, e
}
return t, nil
} | OpenCurrentProcessToken opens the access token
associated with current process. It is a real
token that needs to be closed, unlike
GetCurrentProcessToken. | OpenCurrentProcessToken | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func GetCurrentProcessToken() Token {
return Token(^uintptr(4 - 1))
} | GetCurrentProcessToken returns the access token associated with
the current process. It is a pseudo token that does not need
to be closed. | GetCurrentProcessToken | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func GetCurrentThreadToken() Token {
return Token(^uintptr(5 - 1))
} | GetCurrentThreadToken return the access token associated with
the current thread. It is a pseudo token that does not need
to be closed. | GetCurrentThreadToken | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func GetCurrentThreadEffectiveToken() Token {
return Token(^uintptr(6 - 1))
} | GetCurrentThreadEffectiveToken returns the effective access token
associated with the current thread. It is a pseudo token that does
not need to be closed. | GetCurrentThreadEffectiveToken | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func (t Token) Close() error {
return CloseHandle(Handle(t))
} | Close releases access to access token. | Close | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func (t Token) getInfo(class uint32, initSize int) (unsafe.Pointer, error) {
n := uint32(initSize)
for {
b := make([]byte, n)
e := GetTokenInformation(t, class, &b[0], uint32(len(b)), &n)
if e == nil {
return unsafe.Pointer(&b[0]), nil
}
if e != ERROR_INSUFFICIENT_BUFFER {
return nil, e
}
if n <= uint32(len(b)) {
return nil, e
}
}
} | getInfo retrieves a specified type of information about an access token. | getInfo | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func (t Token) GetTokenUser() (*Tokenuser, error) {
i, e := t.getInfo(TokenUser, 50)
if e != nil {
return nil, e
}
return (*Tokenuser)(i), nil
} | GetTokenUser retrieves access token t user account information. | GetTokenUser | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func (t Token) GetTokenGroups() (*Tokengroups, error) {
i, e := t.getInfo(TokenGroups, 50)
if e != nil {
return nil, e
}
return (*Tokengroups)(i), nil
} | GetTokenGroups retrieves group accounts associated with access token t. | GetTokenGroups | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func (t Token) GetTokenPrimaryGroup() (*Tokenprimarygroup, error) {
i, e := t.getInfo(TokenPrimaryGroup, 50)
if e != nil {
return nil, e
}
return (*Tokenprimarygroup)(i), nil
} | GetTokenPrimaryGroup retrieves access token t primary group information.
A pointer to a SID structure representing a group that will become
the primary group of any objects created by a process using this access token. | GetTokenPrimaryGroup | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func (t Token) GetUserProfileDirectory() (string, error) {
n := uint32(100)
for {
b := make([]uint16, n)
e := GetUserProfileDirectory(t, &b[0], &n)
if e == nil {
return UTF16ToString(b), nil
}
if e != ERROR_INSUFFICIENT_BUFFER {
return "", e
}
if n <= uint32(len(b)) {
return "", e
}
}
} | GetUserProfileDirectory retrieves path to the
root directory of the access token t user's profile. | GetUserProfileDirectory | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func (token Token) IsElevated() bool {
var isElevated uint32
var outLen uint32
err := GetTokenInformation(token, TokenElevation, (*byte)(unsafe.Pointer(&isElevated)), uint32(unsafe.Sizeof(isElevated)), &outLen)
if err != nil {
return false
}
return outLen == uint32(unsafe.Sizeof(isElevated)) && isElevated != 0
} | IsElevated returns whether the current token is elevated from a UAC perspective. | IsElevated | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func (token Token) GetLinkedToken() (Token, error) {
var linkedToken Token
var outLen uint32
err := GetTokenInformation(token, TokenLinkedToken, (*byte)(unsafe.Pointer(&linkedToken)), uint32(unsafe.Sizeof(linkedToken)), &outLen)
if err != nil {
return Token(0), err
}
return linkedToken, nil
} | GetLinkedToken returns the linked token, which may be an elevated UAC token. | GetLinkedToken | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func GetSystemDirectory() (string, error) {
n := uint32(MAX_PATH)
for {
b := make([]uint16, n)
l, e := getSystemDirectory(&b[0], n)
if e != nil {
return "", e
}
if l <= n {
return UTF16ToString(b[:l]), nil
}
n = l
}
} | GetSystemDirectory retrieves path to current location of the system
directory, which is typically, though not always, C:\Windows\System32. | GetSystemDirectory | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func (t Token) IsMember(sid *SID) (bool, error) {
var b int32
if e := checkTokenMembership(t, sid, &b); e != nil {
return false, e
}
return b != 0, nil
} | IsMember reports whether the access token t is a member of the provided SID. | IsMember | go | flynn/flynn | vendor/golang.org/x/sys/windows/security_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/security_windows.go | BSD-3-Clause |
func StringToUTF16(s string) []uint16 {
a, err := UTF16FromString(s)
if err != nil {
panic("windows: string with NUL passed to StringToUTF16")
}
return a
} | StringToUTF16 is deprecated. Use UTF16FromString instead.
If s contains a NUL byte this function panics instead of
returning an error. | StringToUTF16 | go | flynn/flynn | vendor/golang.org/x/sys/windows/syscall_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/syscall_windows.go | BSD-3-Clause |
func UTF16FromString(s string) ([]uint16, error) {
for i := 0; i < len(s); i++ {
if s[i] == 0 {
return nil, syscall.EINVAL
}
}
return utf16.Encode([]rune(s + "\x00")), nil
} | UTF16FromString returns the UTF-16 encoding of the UTF-8 string
s, with a terminating NUL added. If s contains a NUL byte at any
location, it returns (nil, syscall.EINVAL). | UTF16FromString | go | flynn/flynn | vendor/golang.org/x/sys/windows/syscall_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/syscall_windows.go | BSD-3-Clause |
func UTF16ToString(s []uint16) string {
for i, v := range s {
if v == 0 {
s = s[0:i]
break
}
}
return string(utf16.Decode(s))
} | UTF16ToString returns the UTF-8 encoding of the UTF-16 sequence s,
with a terminating NUL removed. | UTF16ToString | go | flynn/flynn | vendor/golang.org/x/sys/windows/syscall_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/syscall_windows.go | BSD-3-Clause |
func StringToUTF16Ptr(s string) *uint16 { return &StringToUTF16(s)[0] } | StringToUTF16Ptr is deprecated. Use UTF16PtrFromString instead.
If s contains a NUL byte this function panics instead of
returning an error. | StringToUTF16Ptr | go | flynn/flynn | vendor/golang.org/x/sys/windows/syscall_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/syscall_windows.go | BSD-3-Clause |
func UTF16PtrFromString(s string) (*uint16, error) {
a, err := UTF16FromString(s)
if err != nil {
return nil, err
}
return &a[0], nil
} | UTF16PtrFromString returns pointer to the UTF-16 encoding of
the UTF-8 string s, with a terminating NUL added. If s
contains a NUL byte at any location, it returns (nil, syscall.EINVAL). | UTF16PtrFromString | go | flynn/flynn | vendor/golang.org/x/sys/windows/syscall_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/syscall_windows.go | BSD-3-Clause |
func NewCallback(fn interface{}) uintptr {
return syscall.NewCallback(fn)
} | NewCallback converts a Go function to a function pointer conforming to the stdcall calling convention.
This is useful when interoperating with Windows code requiring callbacks.
The argument is expected to be a function with with one uintptr-sized result. The function must not have arguments with size larger than the size of uintptr. | NewCallback | go | flynn/flynn | vendor/golang.org/x/sys/windows/syscall_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/syscall_windows.go | BSD-3-Clause |
func NewCallbackCDecl(fn interface{}) uintptr {
return syscall.NewCallbackCDecl(fn)
} | NewCallbackCDecl converts a Go function to a function pointer conforming to the cdecl calling convention.
This is useful when interoperating with Windows code requiring callbacks.
The argument is expected to be a function with with one uintptr-sized result. The function must not have arguments with size larger than the size of uintptr. | NewCallbackCDecl | go | flynn/flynn | vendor/golang.org/x/sys/windows/syscall_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/syscall_windows.go | BSD-3-Clause |
func GetProcAddressByOrdinal(module Handle, ordinal uintptr) (proc uintptr, err error) {
r0, _, e1 := syscall.Syscall(procGetProcAddress.Addr(), 2, uintptr(module), ordinal, 0)
proc = uintptr(r0)
if proc == 0 {
if e1 != 0 {
err = errnoErr(e1)
} else {
err = syscall.EINVAL
}
}
return
} | GetProcAddressByOrdinal retrieves the address of the exported
function from module by ordinal. | GetProcAddressByOrdinal | go | flynn/flynn | vendor/golang.org/x/sys/windows/syscall_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/syscall_windows.go | BSD-3-Clause |
func Readlink(path string, buf []byte) (n int, err error) {
fd, err := CreateFile(StringToUTF16Ptr(path), GENERIC_READ, 0, nil, OPEN_EXISTING,
FILE_FLAG_OPEN_REPARSE_POINT|FILE_FLAG_BACKUP_SEMANTICS, 0)
if err != nil {
return -1, err
}
defer CloseHandle(fd)
rdbbuf := make([]byte, MAXIMUM_REPARSE_DATA_BUFFER_SIZE)
var bytesReturned uint32
err = DeviceIoControl(fd, FSCTL_GET_REPARSE_POINT, nil, 0, &rdbbuf[0], uint32(len(rdbbuf)), &bytesReturned, nil)
if err != nil {
return -1, err
}
rdb := (*reparseDataBuffer)(unsafe.Pointer(&rdbbuf[0]))
var s string
switch rdb.ReparseTag {
case IO_REPARSE_TAG_SYMLINK:
data := (*symbolicLinkReparseBuffer)(unsafe.Pointer(&rdb.reparseBuffer))
p := (*[0xffff]uint16)(unsafe.Pointer(&data.PathBuffer[0]))
s = UTF16ToString(p[data.PrintNameOffset/2 : (data.PrintNameLength-data.PrintNameOffset)/2])
case IO_REPARSE_TAG_MOUNT_POINT:
data := (*mountPointReparseBuffer)(unsafe.Pointer(&rdb.reparseBuffer))
p := (*[0xffff]uint16)(unsafe.Pointer(&data.PathBuffer[0]))
s = UTF16ToString(p[data.PrintNameOffset/2 : (data.PrintNameLength-data.PrintNameOffset)/2])
default:
// the path is not a symlink or junction but another type of reparse
// point
return -1, syscall.ENOENT
}
n = copy(buf, []byte(s))
return n, nil
} | Readlink returns the destination of the named symbolic link. | Readlink | go | flynn/flynn | vendor/golang.org/x/sys/windows/syscall_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/syscall_windows.go | BSD-3-Clause |
func GUIDFromString(str string) (GUID, error) {
guid := GUID{}
str16, err := syscall.UTF16PtrFromString(str)
if err != nil {
return guid, err
}
err = clsidFromString(str16, &guid)
if err != nil {
return guid, err
}
return guid, nil
} | GUIDFromString parses a string in the form of
"{XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}" into a GUID. | GUIDFromString | go | flynn/flynn | vendor/golang.org/x/sys/windows/syscall_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/syscall_windows.go | BSD-3-Clause |
func GenerateGUID() (GUID, error) {
guid := GUID{}
err := coCreateGuid(&guid)
if err != nil {
return guid, err
}
return guid, nil
} | GenerateGUID creates a new random GUID. | GenerateGUID | go | flynn/flynn | vendor/golang.org/x/sys/windows/syscall_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/syscall_windows.go | BSD-3-Clause |
func (guid GUID) String() string {
var str [100]uint16
chars := stringFromGUID2(&guid, &str[0], int32(len(str)))
if chars <= 1 {
return ""
}
return string(utf16.Decode(str[:chars-1]))
} | String returns the canonical string form of the GUID,
in the form of "{XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}". | String | go | flynn/flynn | vendor/golang.org/x/sys/windows/syscall_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/syscall_windows.go | BSD-3-Clause |
func KnownFolderPath(folderID *KNOWNFOLDERID, flags uint32) (string, error) {
return Token(0).KnownFolderPath(folderID, flags)
} | KnownFolderPath returns a well-known folder path for the current user, specified by one of
the FOLDERID_ constants, and chosen and optionally created based on a KF_ flag. | KnownFolderPath | go | flynn/flynn | vendor/golang.org/x/sys/windows/syscall_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/syscall_windows.go | BSD-3-Clause |
func (t Token) KnownFolderPath(folderID *KNOWNFOLDERID, flags uint32) (string, error) {
var p *uint16
err := shGetKnownFolderPath(folderID, flags, t, &p)
if err != nil {
return "", err
}
defer CoTaskMemFree(unsafe.Pointer(p))
return UTF16ToString((*[(1 << 30) - 1]uint16)(unsafe.Pointer(p))[:]), nil
} | KnownFolderPath returns a well-known folder path for the user token, specified by one of
the FOLDERID_ constants, and chosen and optionally created based on a KF_ flag. | KnownFolderPath | go | flynn/flynn | vendor/golang.org/x/sys/windows/syscall_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/syscall_windows.go | BSD-3-Clause |
func RtlGetVersion() *OsVersionInfoEx {
info := &OsVersionInfoEx{}
info.osVersionInfoSize = uint32(unsafe.Sizeof(*info))
// According to documentation, this function always succeeds.
// The function doesn't even check the validity of the
// osVersionInfoSize member. Disassembling ntdll.dll indicates
// that the documentation is indeed correct about that.
_ = rtlGetVersion(info)
return info
} | RtlGetVersion returns the true version of the underlying operating system, ignoring
any manifesting or compatibility layers on top of the win32 layer. | RtlGetVersion | go | flynn/flynn | vendor/golang.org/x/sys/windows/syscall_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/syscall_windows.go | BSD-3-Clause |
func EscapeArg(s string) string {
if len(s) == 0 {
return "\"\""
}
n := len(s)
hasSpace := false
for i := 0; i < len(s); i++ {
switch s[i] {
case '"', '\\':
n++
case ' ', '\t':
hasSpace = true
}
}
if hasSpace {
n += 2
}
if n == len(s) {
return s
}
qs := make([]byte, n)
j := 0
if hasSpace {
qs[j] = '"'
j++
}
slashes := 0
for i := 0; i < len(s); i++ {
switch s[i] {
default:
slashes = 0
qs[j] = s[i]
case '\\':
slashes++
qs[j] = s[i]
case '"':
for ; slashes > 0; slashes-- {
qs[j] = '\\'
j++
}
qs[j] = '\\'
j++
qs[j] = s[i]
}
j++
}
if hasSpace {
for ; slashes > 0; slashes-- {
qs[j] = '\\'
j++
}
qs[j] = '"'
j++
}
return string(qs[:j])
} | EscapeArg rewrites command line argument s as prescribed
in http://msdn.microsoft.com/en-us/library/ms880421.
This function returns "" (2 double quotes) if s is empty.
Alternatively, these transformations are done:
- every back slash (\) is doubled, but only if immediately
followed by double quote (");
- every double quote (") is escaped by back slash (\);
- finally, s is wrapped with double quotes (arg -> "arg"),
but only if there is space or tab inside s. | EscapeArg | go | flynn/flynn | vendor/golang.org/x/sys/windows/exec_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/exec_windows.go | BSD-3-Clause |
func FullPath(name string) (path string, err error) {
p, err := UTF16PtrFromString(name)
if err != nil {
return "", err
}
n := uint32(100)
for {
buf := make([]uint16, n)
n, err = GetFullPathName(p, uint32(len(buf)), &buf[0], nil)
if err != nil {
return "", err
}
if n <= uint32(len(buf)) {
return UTF16ToString(buf[:n]), nil
}
}
} | FullPath retrieves the full path of the specified file. | FullPath | go | flynn/flynn | vendor/golang.org/x/sys/windows/exec_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/exec_windows.go | BSD-3-Clause |
func loadlibrary(filename *uint16) (handle uintptr, err syscall.Errno)
func getprocaddress(handle uintptr, procname *uint8) (proc uintptr, err syscall.Errno)
// A DLL implements access to a single DLL.
type DLL struct {
Name string
Handle Handle
} | Implemented in runtime/syscall_windows.goc; we provide jumps to them in our assembly file. | loadlibrary | go | flynn/flynn | vendor/golang.org/x/sys/windows/dll_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/dll_windows.go | BSD-3-Clause |
func LoadDLL(name string) (dll *DLL, err error) {
namep, err := UTF16PtrFromString(name)
if err != nil {
return nil, err
}
h, e := loadlibrary(namep)
if e != 0 {
return nil, &DLLError{
Err: e,
ObjName: name,
Msg: "Failed to load " + name + ": " + e.Error(),
}
}
d := &DLL{
Name: name,
Handle: Handle(h),
}
return d, nil
} | LoadDLL loads DLL file into memory.
Warning: using LoadDLL without an absolute path name is subject to
DLL preloading attacks. To safely load a system DLL, use LazyDLL
with System set to true, or use LoadLibraryEx directly. | LoadDLL | go | flynn/flynn | vendor/golang.org/x/sys/windows/dll_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/dll_windows.go | BSD-3-Clause |
func MustLoadDLL(name string) *DLL {
d, e := LoadDLL(name)
if e != nil {
panic(e)
}
return d
} | MustLoadDLL is like LoadDLL but panics if load operation failes. | MustLoadDLL | go | flynn/flynn | vendor/golang.org/x/sys/windows/dll_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/dll_windows.go | BSD-3-Clause |
func (d *DLL) FindProc(name string) (proc *Proc, err error) {
namep, err := BytePtrFromString(name)
if err != nil {
return nil, err
}
a, e := getprocaddress(uintptr(d.Handle), namep)
if e != 0 {
return nil, &DLLError{
Err: e,
ObjName: name,
Msg: "Failed to find " + name + " procedure in " + d.Name + ": " + e.Error(),
}
}
p := &Proc{
Dll: d,
Name: name,
addr: a,
}
return p, nil
} | FindProc searches DLL d for procedure named name and returns *Proc
if found. It returns an error if search fails. | FindProc | go | flynn/flynn | vendor/golang.org/x/sys/windows/dll_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/dll_windows.go | BSD-3-Clause |
func (d *DLL) MustFindProc(name string) *Proc {
p, e := d.FindProc(name)
if e != nil {
panic(e)
}
return p
} | MustFindProc is like FindProc but panics if search fails. | MustFindProc | go | flynn/flynn | vendor/golang.org/x/sys/windows/dll_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/dll_windows.go | BSD-3-Clause |
func (d *DLL) Release() (err error) {
return FreeLibrary(d.Handle)
} | Release unloads DLL d from memory. | Release | go | flynn/flynn | vendor/golang.org/x/sys/windows/dll_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/dll_windows.go | BSD-3-Clause |
func (p *Proc) Addr() uintptr {
return p.addr
} | Addr returns the address of the procedure represented by p.
The return value can be passed to Syscall to run the procedure. | Addr | go | flynn/flynn | vendor/golang.org/x/sys/windows/dll_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/dll_windows.go | BSD-3-Clause |
func (p *Proc) Call(a ...uintptr) (r1, r2 uintptr, lastErr error) {
switch len(a) {
case 0:
return syscall.Syscall(p.Addr(), uintptr(len(a)), 0, 0, 0)
case 1:
return syscall.Syscall(p.Addr(), uintptr(len(a)), a[0], 0, 0)
case 2:
return syscall.Syscall(p.Addr(), uintptr(len(a)), a[0], a[1], 0)
case 3:
return syscall.Syscall(p.Addr(), uintptr(len(a)), a[0], a[1], a[2])
case 4:
return syscall.Syscall6(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], 0, 0)
case 5:
return syscall.Syscall6(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], 0)
case 6:
return syscall.Syscall6(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5])
case 7:
return syscall.Syscall9(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], 0, 0)
case 8:
return syscall.Syscall9(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], 0)
case 9:
return syscall.Syscall9(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8])
case 10:
return syscall.Syscall12(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], 0, 0)
case 11:
return syscall.Syscall12(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], 0)
case 12:
return syscall.Syscall12(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11])
case 13:
return syscall.Syscall15(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], 0, 0)
case 14:
return syscall.Syscall15(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], 0)
case 15:
return syscall.Syscall15(p.Addr(), uintptr(len(a)), a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14])
default:
panic("Call " + p.Name + " with too many arguments " + itoa(len(a)) + ".")
}
} | Call executes procedure p with arguments a. It will panic, if more than 15 arguments
are supplied.
The returned error is always non-nil, constructed from the result of GetLastError.
Callers must inspect the primary return value to decide whether an error occurred
(according to the semantics of the specific function being called) before consulting
the error. The error will be guaranteed to contain windows.Errno. | Call | go | flynn/flynn | vendor/golang.org/x/sys/windows/dll_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/dll_windows.go | BSD-3-Clause |
func (d *LazyDLL) Load() error {
// Non-racy version of:
// if d.dll != nil {
if atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&d.dll))) != nil {
return nil
}
d.mu.Lock()
defer d.mu.Unlock()
if d.dll != nil {
return nil
}
// kernel32.dll is special, since it's where LoadLibraryEx comes from.
// The kernel already special-cases its name, so it's always
// loaded from system32.
var dll *DLL
var err error
if d.Name == "kernel32.dll" {
dll, err = LoadDLL(d.Name)
} else {
dll, err = loadLibraryEx(d.Name, d.System)
}
if err != nil {
return err
}
// Non-racy version of:
// d.dll = dll
atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(&d.dll)), unsafe.Pointer(dll))
return nil
} | Load loads DLL file d.Name into memory. It returns an error if fails.
Load will not try to load DLL, if it is already loaded into memory. | Load | go | flynn/flynn | vendor/golang.org/x/sys/windows/dll_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/dll_windows.go | BSD-3-Clause |
func (d *LazyDLL) mustLoad() {
e := d.Load()
if e != nil {
panic(e)
}
} | mustLoad is like Load but panics if search fails. | mustLoad | go | flynn/flynn | vendor/golang.org/x/sys/windows/dll_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/dll_windows.go | BSD-3-Clause |
func (d *LazyDLL) Handle() uintptr {
d.mustLoad()
return uintptr(d.dll.Handle)
} | Handle returns d's module handle. | Handle | go | flynn/flynn | vendor/golang.org/x/sys/windows/dll_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/dll_windows.go | BSD-3-Clause |
func (d *LazyDLL) NewProc(name string) *LazyProc {
return &LazyProc{l: d, Name: name}
} | NewProc returns a LazyProc for accessing the named procedure in the DLL d. | NewProc | go | flynn/flynn | vendor/golang.org/x/sys/windows/dll_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/dll_windows.go | BSD-3-Clause |
func NewLazyDLL(name string) *LazyDLL {
return &LazyDLL{Name: name}
} | NewLazyDLL creates new LazyDLL associated with DLL file. | NewLazyDLL | go | flynn/flynn | vendor/golang.org/x/sys/windows/dll_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/dll_windows.go | BSD-3-Clause |
func NewLazySystemDLL(name string) *LazyDLL {
return &LazyDLL{Name: name, System: true}
} | NewLazySystemDLL is like NewLazyDLL, but will only
search Windows System directory for the DLL if name is
a base name (like "advapi32.dll"). | NewLazySystemDLL | go | flynn/flynn | vendor/golang.org/x/sys/windows/dll_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/dll_windows.go | BSD-3-Clause |
func (p *LazyProc) Find() error {
// Non-racy version of:
// if p.proc == nil {
if atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(&p.proc))) == nil {
p.mu.Lock()
defer p.mu.Unlock()
if p.proc == nil {
e := p.l.Load()
if e != nil {
return e
}
proc, e := p.l.dll.FindProc(p.Name)
if e != nil {
return e
}
// Non-racy version of:
// p.proc = proc
atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(&p.proc)), unsafe.Pointer(proc))
}
}
return nil
} | Find searches DLL for procedure named p.Name. It returns
an error if search fails. Find will not search procedure,
if it is already found and loaded into memory. | Find | go | flynn/flynn | vendor/golang.org/x/sys/windows/dll_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/dll_windows.go | BSD-3-Clause |
func (p *LazyProc) mustFind() {
e := p.Find()
if e != nil {
panic(e)
}
} | mustFind is like Find but panics if search fails. | mustFind | go | flynn/flynn | vendor/golang.org/x/sys/windows/dll_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/dll_windows.go | BSD-3-Clause |
func (p *LazyProc) Addr() uintptr {
p.mustFind()
return p.proc.Addr()
} | Addr returns the address of the procedure represented by p.
The return value can be passed to Syscall to run the procedure.
It will panic if the procedure cannot be found. | Addr | go | flynn/flynn | vendor/golang.org/x/sys/windows/dll_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/dll_windows.go | BSD-3-Clause |
func (p *LazyProc) Call(a ...uintptr) (r1, r2 uintptr, lastErr error) {
p.mustFind()
return p.proc.Call(a...)
} | Call executes procedure p with arguments a. It will panic, if more than 15 arguments
are supplied. It will also panic if the procedure cannot be found.
The returned error is always non-nil, constructed from the result of GetLastError.
Callers must inspect the primary return value to decide whether an error occurred
(according to the semantics of the specific function being called) before consulting
the error. The error will be guaranteed to contain windows.Errno. | Call | go | flynn/flynn | vendor/golang.org/x/sys/windows/dll_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/dll_windows.go | BSD-3-Clause |
func loadLibraryEx(name string, system bool) (*DLL, error) {
loadDLL := name
var flags uintptr
if system {
if canDoSearchSystem32() {
const LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800
flags = LOAD_LIBRARY_SEARCH_SYSTEM32
} else if isBaseName(name) {
// WindowsXP or unpatched Windows machine
// trying to load "foo.dll" out of the system
// folder, but LoadLibraryEx doesn't support
// that yet on their system, so emulate it.
systemdir, err := GetSystemDirectory()
if err != nil {
return nil, err
}
loadDLL = systemdir + "\\" + name
}
}
h, err := LoadLibraryEx(loadDLL, 0, flags)
if err != nil {
return nil, err
}
return &DLL{Name: name, Handle: h}, nil
} | loadLibraryEx wraps the Windows LoadLibraryEx function.
See https://msdn.microsoft.com/en-us/library/windows/desktop/ms684179(v=vs.85).aspx
If name is not an absolute path, LoadLibraryEx searches for the DLL
in a variety of automatic locations unless constrained by flags.
See: https://msdn.microsoft.com/en-us/library/ff919712%28VS.85%29.aspx | loadLibraryEx | go | flynn/flynn | vendor/golang.org/x/sys/windows/dll_windows.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/windows/dll_windows.go | BSD-3-Clause |
func bitIsSet(bits []uint64, index uint) bool {
return bits[index/64]&((1<<63)>>(index%64)) != 0
} | bitIsSet reports whether the bit at index is set. The bit index
is in big endian order, so bit index 0 is the leftmost bit. | bitIsSet | go | flynn/flynn | vendor/golang.org/x/sys/cpu/cpu_linux_s390x.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/cpu/cpu_linux_s390x.go | BSD-3-Clause |
func (q *queryResult) Has(fns ...function) bool {
if len(fns) == 0 {
panic("no function codes provided")
}
for _, f := range fns {
if !bitIsSet(q.bits[:], uint(f)) {
return false
}
}
return true
} | Has reports whether the given functions are present. | Has | go | flynn/flynn | vendor/golang.org/x/sys/cpu/cpu_linux_s390x.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/cpu/cpu_linux_s390x.go | BSD-3-Clause |
func (s *facilityList) Has(fs ...facility) bool {
if len(fs) == 0 {
panic("no facility bits provided")
}
for _, f := range fs {
if !bitIsSet(s.bits[:], uint(f)) {
return false
}
}
return true
} | Has reports whether the given facilities are present. | Has | go | flynn/flynn | vendor/golang.org/x/sys/cpu/cpu_linux_s390x.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/cpu/cpu_linux_s390x.go | BSD-3-Clause |
func hostByteOrder() binary.ByteOrder {
switch runtime.GOARCH {
case "386", "amd64", "amd64p32",
"arm", "arm64",
"mipsle", "mips64le", "mips64p32le",
"ppc64le",
"riscv", "riscv64":
return binary.LittleEndian
case "armbe", "arm64be",
"mips", "mips64", "mips64p32",
"ppc", "ppc64",
"s390", "s390x",
"sparc", "sparc64":
return binary.BigEndian
}
panic("unknown architecture")
} | hostByteOrder returns binary.LittleEndian on little-endian machines and
binary.BigEndian on big-endian machines. | hostByteOrder | go | flynn/flynn | vendor/golang.org/x/sys/cpu/byteorder.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/cpu/byteorder.go | BSD-3-Clause |
func haveAsmFunctions() bool { return false } | haveAsmFunctions reports whether the other functions in this file can
be safely called. | haveAsmFunctions | go | flynn/flynn | vendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go | BSD-3-Clause |
func stfle() facilityList { panic("not implemented for gccgo") } | TODO(mundaym): the following feature detection functions are currently
stubs. See https://golang.org/cl/162887 for how to fix this.
They are likely to be expensive to call so the results should be cached. | stfle | go | flynn/flynn | vendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go | BSD-3-Clause |
func rawSyscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err errno)
func syscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err errno)
func callgetsystemcfg(label int) (r1 uintptr, e1 errno) {
r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_getsystemcfg)), 1, uintptr(label), 0, 0, 0, 0, 0)
return
} | Implemented in runtime/syscall_aix.go. | rawSyscall6 | go | flynn/flynn | vendor/golang.org/x/sys/cpu/syscall_aix_ppc64_gc.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/cpu/syscall_aix_ppc64_gc.go | BSD-3-Clause |
func gccgoGetCpuidCount(eaxArg, ecxArg uint32, eax, ebx, ecx, edx *uint32)
func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32) {
var a, b, c, d uint32
gccgoGetCpuidCount(eaxArg, ecxArg, &a, &b, &c, &d)
return a, b, c, d
} | extern gccgoGetCpuidCount | gccgoGetCpuidCount | go | flynn/flynn | vendor/golang.org/x/sys/cpu/cpu_gccgo.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/cpu/cpu_gccgo.go | BSD-3-Clause |
func haveAsmFunctions() bool { return true } | haveAsmFunctions reports whether the other functions in this file can
be safely called. | haveAsmFunctions | go | flynn/flynn | vendor/golang.org/x/sys/cpu/cpu_gc_s390x.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/cpu/cpu_gc_s390x.go | BSD-3-Clause |
func Major(dev uint64) uint32 {
return uint32((dev >> 8) & 0xff)
} | Major returns the major component of a DragonFlyBSD device number. | Major | go | flynn/flynn | vendor/golang.org/x/sys/unix/dev_dragonfly.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dev_dragonfly.go | BSD-3-Clause |
func Minor(dev uint64) uint32 {
return uint32(dev & 0xffff00ff)
} | Minor returns the minor component of a DragonFlyBSD device number. | Minor | go | flynn/flynn | vendor/golang.org/x/sys/unix/dev_dragonfly.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dev_dragonfly.go | BSD-3-Clause |
func Mkdev(major, minor uint32) uint64 {
return (uint64(major) << 8) | uint64(minor)
} | Mkdev returns a DragonFlyBSD device number generated from the given major and
minor components. | Mkdev | go | flynn/flynn | vendor/golang.org/x/sys/unix/dev_dragonfly.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dev_dragonfly.go | BSD-3-Clause |
func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr)
//extern gccgoRealSyscall
func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr)
func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) {
syscall.Entersyscall()
r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
syscall.Exitsyscall()
return r, 0
} | extern gccgoRealSyscallNoError | realSyscallNoError | go | flynn/flynn | vendor/golang.org/x/sys/unix/gccgo.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/gccgo.go | BSD-3-Clause |
func nametomib(name string) (mib []_C_int, err error) {
const siz = unsafe.Sizeof(mib[0])
// NOTE(rsc): It seems strange to set the buffer to have
// size CTL_MAXNAME+2 but use only CTL_MAXNAME
// as the size. I don't know why the +2 is here, but the
// kernel uses +2 for its own implementation of this function.
// I am scared that if we don't include the +2 here, the kernel
// will silently write 2 words farther than we specify
// and we'll get memory corruption.
var buf [CTL_MAXNAME + 2]_C_int
n := uintptr(CTL_MAXNAME) * siz
p := (*byte)(unsafe.Pointer(&buf[0]))
bytes, err := ByteSliceFromString(name)
if err != nil {
return nil, err
}
// Magic sysctl: "setting" 0.3 to a string name
// lets you read back the array of integers form.
if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil {
return nil, err
}
return buf[0 : n/siz], nil
} | Translate "kern.hostname" to []_C_int{0,1,2,3}. | nametomib | go | flynn/flynn | vendor/golang.org/x/sys/unix/syscall_dragonfly.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_dragonfly.go | BSD-3-Clause |
func Pread(fd int, p []byte, offset int64) (n int, err error) {
return extpread(fd, p, 0, offset)
} | sys extpread(fd int, p []byte, flags int, offset int64) (n int, err error) | Pread | go | flynn/flynn | vendor/golang.org/x/sys/unix/syscall_dragonfly.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_dragonfly.go | BSD-3-Clause |
func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
return extpwrite(fd, p, 0, offset)
} | sys extpwrite(fd int, p []byte, flags int, offset int64) (n int, err error) | Pwrite | go | flynn/flynn | vendor/golang.org/x/sys/unix/syscall_dragonfly.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_dragonfly.go | BSD-3-Clause |
func IoctlSetInt(fd int, req uint, value int) error {
return ioctl(fd, req, uintptr(value))
} | IoctlSetInt performs an ioctl operation which sets an integer value
on fd, using the specified request number. | IoctlSetInt | go | flynn/flynn | vendor/golang.org/x/sys/unix/syscall_dragonfly.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_dragonfly.go | BSD-3-Clause |
func IoctlGetInt(fd int, req uint) (int, error) {
var value int
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return value, err
} | IoctlGetInt performs an ioctl operation which gets an integer value
from fd, using the specified request number. | IoctlGetInt | go | flynn/flynn | vendor/golang.org/x/sys/unix/syscall_dragonfly.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_dragonfly.go | BSD-3-Clause |
func PtraceGetRegsMips(pid int, regsout *PtraceRegsMips) error {
return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout)))
} | PtraceGetRegsMips fetches the registers used by mips binaries. | PtraceGetRegsMips | go | flynn/flynn | vendor/golang.org/x/sys/unix/zptracemips_linux.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/zptracemips_linux.go | BSD-3-Clause |
func PtraceSetRegsMips(pid int, regs *PtraceRegsMips) error {
return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs)))
} | PtraceSetRegsMips sets the registers used by mips binaries. | PtraceSetRegsMips | go | flynn/flynn | vendor/golang.org/x/sys/unix/zptracemips_linux.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/zptracemips_linux.go | BSD-3-Clause |
func PtraceGetRegsMips64(pid int, regsout *PtraceRegsMips64) error {
return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout)))
} | PtraceGetRegsMips64 fetches the registers used by mips64 binaries. | PtraceGetRegsMips64 | go | flynn/flynn | vendor/golang.org/x/sys/unix/zptracemips_linux.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/zptracemips_linux.go | BSD-3-Clause |
func PtraceSetRegsMips64(pid int, regs *PtraceRegsMips64) error {
return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs)))
} | PtraceSetRegsMips64 sets the registers used by mips64 binaries. | PtraceSetRegsMips64 | go | flynn/flynn | vendor/golang.org/x/sys/unix/zptracemips_linux.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/zptracemips_linux.go | BSD-3-Clause |
func syscall_syscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
func syscall_syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
func syscall_syscall6X(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
func syscall_syscall9(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) // 32-bit only
func syscall_rawSyscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
func syscall_rawSyscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
//go:linkname syscall_syscall syscall.syscall
//go:linkname syscall_syscall6 syscall.syscall6
//go:linkname syscall_syscall6X syscall.syscall6X
//go:linkname syscall_syscall9 syscall.syscall9
//go:linkname syscall_rawSyscall syscall.rawSyscall
//go:linkname syscall_rawSyscall6 syscall.rawSyscall6
// Find the entry point for f. See comments in runtime/proc.go for the
// function of the same name.
//go:nosplit
func funcPC(f func()) uintptr {
return **(**uintptr)(unsafe.Pointer(&f))
} | Implemented in the runtime package (runtime/sys_darwin.go) | syscall_syscall | go | flynn/flynn | vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go | BSD-3-Clause |
func readInt(b []byte, off, size uintptr) (u uint64, ok bool) {
if len(b) < int(off+size) {
return 0, false
}
if isBigEndian {
return readIntBE(b[off:], size), true
}
return readIntLE(b[off:], size), true
} | readInt returns the size-bytes unsigned integer in native byte order at offset off. | readInt | go | flynn/flynn | vendor/golang.org/x/sys/unix/dirent.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dirent.go | BSD-3-Clause |
func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
origlen := len(buf)
count = 0
for max != 0 && len(buf) > 0 {
reclen, ok := direntReclen(buf)
if !ok || reclen > uint64(len(buf)) {
return origlen, count, names
}
rec := buf[:reclen]
buf = buf[reclen:]
ino, ok := direntIno(rec)
if !ok {
break
}
if ino == 0 { // File absent in directory.
continue
}
const namoff = uint64(unsafe.Offsetof(Dirent{}.Name))
namlen, ok := direntNamlen(rec)
if !ok || namoff+namlen > uint64(len(rec)) {
break
}
name := rec[namoff : namoff+namlen]
for i, c := range name {
if c == 0 {
name = name[:i]
break
}
}
// Check for useless names before allocating a string.
if string(name) == "." || string(name) == ".." {
continue
}
max--
count++
names = append(names, string(name))
}
return origlen - len(buf), count, names
} | ParseDirent parses up to max directory entries in buf,
appending the names to names. It returns the number of
bytes consumed from buf, the number of entries added
to names, and the new names slice. | ParseDirent | go | flynn/flynn | vendor/golang.org/x/sys/unix/dirent.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dirent.go | BSD-3-Clause |
func ByteSliceFromString(s string) ([]byte, error) {
if strings.IndexByte(s, 0) != -1 {
return nil, EINVAL
}
a := make([]byte, len(s)+1)
copy(a, s)
return a, nil
} | ByteSliceFromString returns a NUL-terminated slice of bytes
containing the text of s. If s contains a NUL byte at any
location, it returns (nil, EINVAL). | ByteSliceFromString | go | flynn/flynn | vendor/golang.org/x/sys/unix/syscall.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall.go | BSD-3-Clause |
func BytePtrFromString(s string) (*byte, error) {
a, err := ByteSliceFromString(s)
if err != nil {
return nil, err
}
return &a[0], nil
} | BytePtrFromString returns a pointer to a NUL-terminated array of
bytes containing the text of s. If s contains a NUL byte at any
location, it returns (nil, EINVAL). | BytePtrFromString | go | flynn/flynn | vendor/golang.org/x/sys/unix/syscall.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall.go | BSD-3-Clause |
func errnoErr(e syscall.Errno) error {
switch e {
case 0:
return nil
case EAGAIN:
return errEAGAIN
case EINVAL:
return errEINVAL
case ENOENT:
return errENOENT
}
return e
} | errnoErr returns common boxed Errno values, to prevent
allocations at runtime. | errnoErr | go | flynn/flynn | vendor/golang.org/x/sys/unix/syscall_unix.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_unix.go | BSD-3-Clause |
func ErrnoName(e syscall.Errno) string {
i := sort.Search(len(errorList), func(i int) bool {
return errorList[i].num >= e
})
if i < len(errorList) && errorList[i].num == e {
return errorList[i].name
}
return ""
} | ErrnoName returns the error name for error number e. | ErrnoName | go | flynn/flynn | vendor/golang.org/x/sys/unix/syscall_unix.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_unix.go | BSD-3-Clause |
func SignalName(s syscall.Signal) string {
i := sort.Search(len(signalList), func(i int) bool {
return signalList[i].num >= s
})
if i < len(signalList) && signalList[i].num == s {
return signalList[i].name
}
return ""
} | SignalName returns the signal name for signal number s. | SignalName | go | flynn/flynn | vendor/golang.org/x/sys/unix/syscall_unix.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_unix.go | BSD-3-Clause |
func SignalNum(s string) syscall.Signal {
signalNameMapOnce.Do(func() {
signalNameMap = make(map[string]syscall.Signal)
for _, signal := range signalList {
signalNameMap[signal.name] = signal.num
}
})
return signalNameMap[s]
} | SignalNum returns the syscall.Signal for signal named s,
or 0 if a signal with such name is not found.
The signal name should start with "SIG". | SignalNum | go | flynn/flynn | vendor/golang.org/x/sys/unix/syscall_unix.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_unix.go | BSD-3-Clause |
func clen(n []byte) int {
i := bytes.IndexByte(n, 0)
if i == -1 {
i = len(n)
}
return i
} | clen returns the index of the first NULL byte in n or len(n) if n contains no NULL byte. | clen | go | flynn/flynn | vendor/golang.org/x/sys/unix/syscall_unix.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_unix.go | BSD-3-Clause |
func Exec(argv0 string, argv []string, envv []string) error {
return syscall.Exec(argv0, argv, envv)
} | Exec calls execve(2), which replaces the calling executable in the process
tree. argv0 should be the full path to an executable ("/bin/ls") and the
executable name should also be the first argument in argv (["ls", "-l"]).
envv are the environment variables that should be passed to the new
process (["USER=go", "PWD=/tmp"]). | Exec | go | flynn/flynn | vendor/golang.org/x/sys/unix/syscall_unix.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_unix.go | BSD-3-Clause |
func Lutimes(path string, tv []Timeval) error {
if tv == nil {
return UtimesNanoAt(AT_FDCWD, path, nil, AT_SYMLINK_NOFOLLOW)
}
if len(tv) != 2 {
return EINVAL
}
ts := []Timespec{
NsecToTimespec(TimevalToNsec(tv[0])),
NsecToTimespec(TimevalToNsec(tv[1])),
}
return UtimesNanoAt(AT_FDCWD, path, ts, AT_SYMLINK_NOFOLLOW)
} | Lutimes sets the access and modification times tv on path. If path refers to
a symlink, it is not dereferenced and the timestamps are set on the symlink.
If tv is nil, the access and modification times are set to the current time.
Otherwise tv must contain exactly 2 elements, with access time as the first
element and modification time as the second element. | Lutimes | go | flynn/flynn | vendor/golang.org/x/sys/unix/syscall_unix.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/syscall_unix.go | BSD-3-Clause |
func Major(dev uint64) uint32 {
return uint32((dev >> 16) & 0xffff)
} | Major returns the major component of a Linux device number. | Major | go | flynn/flynn | vendor/golang.org/x/sys/unix/dev_aix_ppc.go | https://github.com/flynn/flynn/blob/master/vendor/golang.org/x/sys/unix/dev_aix_ppc.go | BSD-3-Clause |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.