windows
packagestandard libraryThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Index¶
- Constants
- Variables
- func AdjustTokenPrivileges(token syscall.Token, disableAllPrivileges bool, newstate *TOKEN_PRIVILEGES, ...) error
- func CreateEnvironmentBlock(block **uint16, token syscall.Token, inheritExisting bool) (err error)
- func CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, ...) (handle syscall.Handle, err error)
- func CreateIoCompletionPort(filehandle syscall.Handle, cphandle syscall.Handle, key uintptr, ...) (handle syscall.Handle, err error)
- func CreateNamedPipe(name *uint16, flags uint32, pipeMode uint32, maxInstances uint32, ...) (handle syscall.Handle, err error)
- func Deleteat(dirfd syscall.Handle, name string, options uint32) error
- func DestroyEnvironmentBlock(block *uint16) (err error)
- func DuplicateTokenEx(hExistingToken syscall.Token, dwDesiredAccess uint32, ...) (err error)
- func ErrorLoadingGetTempPath2() error
- func FinalPath(h syscall.Handle, flags uint32) (string, error)
- func GetACP() (acp uint32)
- func GetAdaptersAddresses(family uint32, flags uint32, reserved unsafe.Pointer, ...) (errcode error)
- func GetComputerNameEx(nameformat uint32, buf *uint16, n *uint32) (err error)
- func GetConsoleCP() (ccp uint32)
- func GetCurrentThread() (pseudoHandle syscall.Handle, err error)
- func GetFileInformationByHandleEx(handle syscall.Handle, class uint32, info *byte, bufsize uint32) (err error)
- func GetFinalPathNameByHandle(file syscall.Handle, filePath *uint16, filePathSize uint32, flags uint32) (n uint32, err error)
- func GetModuleFileName(module syscall.Handle, fn *uint16, len uint32) (n uint32, err error)
- func GetModuleHandle(modulename *uint16) (handle syscall.Handle, err error)
- func GetOverlappedResult(handle syscall.Handle, overlapped *syscall.Overlapped, done *uint32, wait bool) (err error)
- func GetProcessMemoryInfo(handle syscall.Handle, memCounters *PROCESS_MEMORY_COUNTERS, cb uint32) (err error)
- func GetProfilesDirectory(dir *uint16, dirLen *uint32) (err error)
- func GetSidSubAuthority(sid *syscall.SID, subAuthorityIdx uint32) uint32
- func GetSidSubAuthorityCount(sid *syscall.SID) uint8
- func GetSystemDirectory() string
- func GetTempPath2(buflen uint32, buf *uint16) (n uint32, err error)
- func GetUserName(format uint32) (string, error)
- func GetVolumeInformationByHandle(file syscall.Handle, volumeNameBuffer *uint16, volumeNameSize uint32, ...) (err error)
- func GetVolumeNameForVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16, bufferlength uint32) (err error)
- func ImpersonateLoggedOnUser(token syscall.Token) (err error)
- func ImpersonateSelf(impersonationlevel uint32) (err error)
- func IsNonblock(fd syscall.Handle) (nonblocking bool, err error)
- func IsValidSid(sid *syscall.SID) (valid bool)
- func Linkat(olddirfd syscall.Handle, oldpath string, newdirfd syscall.Handle, ...) error
- func LockFileEx(file syscall.Handle, flags uint32, reserved uint32, bytesLow uint32, ...) (err error)
- func LogonUser(username *uint16, domain *uint16, password *uint16, logonType uint32, ...) (err error)
- func LookupPrivilegeValue(systemname *uint16, name *uint16, luid *LUID) (err error)
- func Mkdirat(dirfd syscall.Handle, name string, mode uint32) error
- func Module32First(snapshot syscall.Handle, moduleEntry *ModuleEntry32) (err error)
- func Module32Next(snapshot syscall.Handle, moduleEntry *ModuleEntry32) (err error)
- func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error)
- func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, ...) (nwrite int32, err error)
- func NetShareAdd(serverName *uint16, level uint32, buf *byte, parmErr *uint16) (neterr error)
- func NetShareDel(serverName *uint16, netName *uint16, reserved uint32) (neterr error)
- func NetUserAdd(serverName *uint16, level uint32, buf *byte, parmErr *uint32) (neterr error)
- func NetUserDel(serverName *uint16, userName *uint16) (neterr error)
- func NetUserGetLocalGroups(serverName *uint16, userName *uint16, level uint32, flags uint32, buf **byte, ...) (neterr error)
- func NtCreateFile(handle *syscall.Handle, access uint32, oa *OBJECT_ATTRIBUTES, ...) (ntstatus error)
- func NtOpenFile(handle *syscall.Handle, access uint32, oa *OBJECT_ATTRIBUTES, ...) (ntstatus error)
- func NtQueryInformationFile(handle syscall.Handle, iosb *IO_STATUS_BLOCK, inBuffer unsafe.Pointer, ...) (ntstatus error)
- func NtSetInformationFile(handle syscall.Handle, iosb *IO_STATUS_BLOCK, inBuffer unsafe.Pointer, ...) (ntstatus error)
- func OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle syscall.Handle, err error)
- func OpenService(mgr syscall.Handle, serviceName *uint16, access uint32) (handle syscall.Handle, err error)
- func OpenThreadToken(h syscall.Handle, access uint32, openasself bool, token *syscall.Token) (err error)
- func Openat(dirfd syscall.Handle, name string, flag uint64, perm uint32) (_ syscall.Handle, e1 error)
- func ProcessPrng(buf []byte) (err error)
- func QueryPerformanceCounter() int64
- func QueryPerformanceFrequency() int64
- func QueryServiceStatus(hService syscall.Handle, lpServiceStatus *SERVICE_STATUS) (err error)
- func Rename(oldpath, newpath string) error
- func Renameat(olddirfd syscall.Handle, oldpath string, newdirfd syscall.Handle, ...) error
- func RevertToSelf() (err error)
- func RtlIsDosDeviceName_U(name *uint16) (ret uint32)
- func RtlVirtualUnwind(handlerType uint32, baseAddress uintptr, pc uintptr, entry *RUNTIME_FUNCTION, ...) (ret uintptr)
- func SetFileInformationByHandle(handle syscall.Handle, fileInformationClass uint32, buf unsafe.Pointer, ...) (err error)
- func SetTokenInformation(tokenHandle syscall.Token, tokenInformationClass uint32, ...) (err error)
- func SupportTCPKeepAliveCount() bool
- func SupportTCPKeepAliveIdle() bool
- func SupportTCPKeepAliveInterval() bool
- func Symlinkat(oldname string, newdirfd syscall.Handle, newname string, flags SymlinkatFlags) error
- func UTF16PtrToString(p *uint16) string
- func UnlockFileEx(file syscall.Handle, reserved uint32, bytesLow uint32, bytesHigh uint32, ...) (err error)
- func Version() (major, minor, build uint32)
- func VirtualQuery(address uintptr, buffer *MemoryBasicInformation, length uintptr) (err error)
- func WSADuplicateSocket(s syscall.Handle, processID uint32, info *syscall.WSAProtocolInfo) (err error)
- func WSAGetOverlappedResult(h syscall.Handle, o *syscall.Overlapped, bytes *uint32, wait bool, ...) (err error)
- func WSARecvMsg(fd syscall.Handle, msg *WSAMsg, bytesReceived *uint32, ...) error
- func WSASendMsg(fd syscall.Handle, msg *WSAMsg, flags uint32, bytesSent *uint32, ...) error
- func WSASendtoInet4(s syscall.Handle, bufs *syscall.WSABuf, bufcnt uint32, sent *uint32, ...) (err error)
- func WSASendtoInet6(s syscall.Handle, bufs *syscall.WSABuf, bufcnt uint32, sent *uint32, ...) (err error)
- func WSASocket(af int32, typ int32, protocol int32, protinfo *syscall.WSAProtocolInfo, ...) (handle syscall.Handle, err error)
- type ACCESS_MASK
- type ACL
- type FILE_ATTRIBUTE_TAG_INFO
- type FILE_BASIC_INFO
- type FILE_COMPLETION_INFORMATION
- type FILE_DISPOSITION_INFORMATION
- type FILE_DISPOSITION_INFORMATION_EX
- type FILE_FULL_DIR_INFO
- type FILE_ID_BOTH_DIR_INFO
- type FILE_LINK_INFORMATION
- type FILE_MODE_INFORMATION
- type FILE_RENAME_INFORMATION
- type FILE_RENAME_INFORMATION_EX
- type IO_STATUS_BLOCK
- type IpAdapterAddresses
- type IpAdapterAnycastAddress
- type IpAdapterDnsServerAdapter
- type IpAdapterGatewayAddress
- type IpAdapterMulticastAddress
- type IpAdapterPrefix
- type IpAdapterUnicastAddress
- type IpAdapterWinsServerAddress
- type LUID
- type LUID_AND_ATTRIBUTES
- type LocalGroupUserInfo0
- type MemoryBasicInformation
- type ModuleEntry32
- type MountPointReparseBuffer
- type NTStatus
- type NTUnicodeString
- type OBJECT_ATTRIBUTES
- type PROCESS_MEMORY_COUNTERS
- type REPARSE_DATA_BUFFER
- type REPARSE_DATA_BUFFER_HEADER
- type RUNTIME_FUNCTION
- type SECURITY_DESCRIPTOR
- type SECURITY_DESCRIPTOR_CONTROL
- type SECURITY_QUALITY_OF_SERVICE
- type SERVICE_STATUS
- type SHARE_INFO_2
- type SID_AND_ATTRIBUTES
- type SID_IDENTIFIER_AUTHORITY
- type SecurityAttributes
- type SocketAddress
- type SymbolicLinkReparseBuffer
- type SymlinkatFlags
- type TCP_INITIAL_RTO_PARAMETERS
- type TOKEN_GROUPS
- type TOKEN_MANDATORY_LABEL
- type TOKEN_PRIVILEGES
- type TokenType
- type UserInfo1
- type UserInfo4
- type WSAMsg
Constants¶
const (O_DIRECTORY = 0x100000// target must be a directoryO_NOFOLLOW_ANY = 0x20000000// disallow symlinks anywhere in the pathO_OPEN_REPARSE = 0x40000000// FILE_OPEN_REPARSE_POINT, used by LstatO_WRITE_ATTRS = 0x80000000// FILE_WRITE_ATTRIBUTES, used by Chmod)
Openat flags not supported by syscall.Open.
These are invented values.
When adding a new flag here, add an unexported version tothe set of invented O_ values in syscall/types_windows.goto avoid overlap.
const (SYMLINKAT_DIRECTORY =SymlinkatFlags(1 <<iota)SYMLINKAT_RELATIVE)
const (SO_TYPE = 0x1008SIO_TCP_INITIAL_RTO =syscall.IOC_IN |syscall.IOC_VENDOR | 17TCP_INITIAL_RTO_UNSPECIFIED_RTT = ^uint16(0)TCP_INITIAL_RTO_NO_SYN_RETRANSMISSIONS = ^uint8(1))
const (FSCTL_SET_REPARSE_POINT = 0x000900A4IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003IO_REPARSE_TAG_DEDUP = 0x80000013IO_REPARSE_TAG_AF_UNIX = 0x80000023SYMLINK_FLAG_RELATIVE = 1)
Reparse tag values are taken fromhttps://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/c8e77b37-3909-4fe6-a4ea-2b9d423b1ee4
const (SecurityAnonymous = 0SecurityIdentification = 1SecurityImpersonation = 2SecurityDelegation = 3)
const (TOKEN_ADJUST_PRIVILEGES = 0x0020SE_PRIVILEGE_ENABLED = 0x00000002)
const (LG_INCLUDE_INDIRECT = 0x1MAX_PREFERRED_LENGTH = 0xFFFFFFFF)
const (NERR_UserNotFoundsyscall.Errno = 2221NERR_UserExistssyscall.Errno = 2224)
const (SID_REVISION = 1//https://learn.microsoft.com/en-us/windows/win32/services/localsystem-accountSECURITY_LOCAL_SYSTEM_RID = 18//https://learn.microsoft.com/en-us/windows/win32/services/localservice-accountSECURITY_LOCAL_SERVICE_RID = 19//https://learn.microsoft.com/en-us/windows/win32/services/networkservice-accountSECURITY_NETWORK_SERVICE_RID = 20)
const (ERROR_INVALID_PARAMETERsyscall.Errno = 87FILE_SUPPORTS_OBJECT_IDS = 0x00010000FILE_SUPPORTS_OPEN_BY_FILE_ID = 0x01000000// symlink support for CreateSymbolicLink() starting with Windows 10 (1703, v10.0.14972)SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE = 0x2// FileInformationClass valuesFileBasicInfo = 0// FILE_BASIC_INFOFileStandardInfo = 1// FILE_STANDARD_INFOFileNameInfo = 2// FILE_NAME_INFOFileStreamInfo = 7// FILE_STREAM_INFOFileCompressionInfo = 8// FILE_COMPRESSION_INFOFileAttributeTagInfo = 9// FILE_ATTRIBUTE_TAG_INFOFileIdBothDirectoryInfo = 0xa// FILE_ID_BOTH_DIR_INFOFileIdBothDirectoryRestartInfo = 0xb// FILE_ID_BOTH_DIR_INFOFileRemoteProtocolInfo = 0xd// FILE_REMOTE_PROTOCOL_INFOFileFullDirectoryInfo = 0xe// FILE_FULL_DIR_INFOFileFullDirectoryRestartInfo = 0xf// FILE_FULL_DIR_INFOFileStorageInfo = 0x10// FILE_STORAGE_INFOFileAlignmentInfo = 0x11// FILE_ALIGNMENT_INFOFileIdInfo = 0x12// FILE_ID_INFOFileIdExtdDirectoryInfo = 0x13// FILE_ID_EXTD_DIR_INFOFileIdExtdDirectoryRestartInfo = 0x14// FILE_ID_EXTD_DIR_INFO)
const (ERROR_INVALID_HANDLEsyscall.Errno = 6ERROR_BAD_LENGTHsyscall.Errno = 24ERROR_SHARING_VIOLATIONsyscall.Errno = 32ERROR_LOCK_VIOLATIONsyscall.Errno = 33ERROR_NOT_SUPPORTEDsyscall.Errno = 50ERROR_CALL_NOT_IMPLEMENTEDsyscall.Errno = 120ERROR_INVALID_NAMEsyscall.Errno = 123ERROR_LOCK_FAILEDsyscall.Errno = 167ERROR_IO_INCOMPLETEsyscall.Errno = 996ERROR_NO_TOKENsyscall.Errno = 1008ERROR_NO_UNICODE_TRANSLATIONsyscall.Errno = 1113ERROR_CANT_ACCESS_FILEsyscall.Errno = 1920)
const (GAA_FLAG_INCLUDE_PREFIX = 0x00000010GAA_FLAG_INCLUDE_GATEWAYS = 0x0080)
const (IF_TYPE_OTHER = 1IF_TYPE_ETHERNET_CSMACD = 6IF_TYPE_ISO88025_TOKENRING = 9IF_TYPE_PPP = 23IF_TYPE_SOFTWARE_LOOPBACK = 24IF_TYPE_ATM = 37IF_TYPE_IEEE80211 = 71IF_TYPE_TUNNEL = 131IF_TYPE_IEEE1394 = 144)
const (IfOperStatusUp = 1IfOperStatusDown = 2IfOperStatusTesting = 3IfOperStatusUnknown = 4IfOperStatusDormant = 5IfOperStatusNotPresent = 6IfOperStatusLowerLayerDown = 7)
const (// flags for CreateToolhelp32SnapshotTH32CS_SNAPMODULE = 0x08TH32CS_SNAPMODULE32 = 0x10)
const (WSA_FLAG_OVERLAPPED = 0x01WSA_FLAG_NO_HANDLE_INHERIT = 0x80WSAEINVALsyscall.Errno = 10022WSAEMSGSIZEsyscall.Errno = 10040WSAEAFNOSUPPORTsyscall.Errno = 10047MSG_PEEK = 0x2MSG_TRUNC = 0x0100MSG_CTRUNC = 0x0200)
const (ComputerNameNetBIOS = 0ComputerNameDnsHostname = 1ComputerNameDnsDomain = 2ComputerNameDnsFullyQualified = 3ComputerNamePhysicalNetBIOS = 4ComputerNamePhysicalDnsHostname = 5ComputerNamePhysicalDnsDomain = 6ComputerNamePhysicalDnsFullyQualified = 7ComputerNameMax = 8MOVEFILE_REPLACE_EXISTING = 0x1MOVEFILE_COPY_ALLOWED = 0x2MOVEFILE_DELAY_UNTIL_REBOOT = 0x4MOVEFILE_WRITE_THROUGH = 0x8MOVEFILE_CREATE_HARDLINK = 0x10MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20)
const (LOCKFILE_FAIL_IMMEDIATELY = 0x00000001LOCKFILE_EXCLUSIVE_LOCK = 0x00000002)
const (STYPE_DISKTREE = 0x00STYPE_TEMPORARY = 0x40000000)
Constants from lmshare.h
const (FILE_NAME_NORMALIZED = 0x0FILE_NAME_OPENED = 0x8VOLUME_NAME_DOS = 0x0VOLUME_NAME_GUID = 0x1VOLUME_NAME_NONE = 0x4VOLUME_NAME_NT = 0x2)
const (SERVICE_RUNNING = 4SERVICE_QUERY_STATUS = 4)
const (PIPE_ACCESS_INBOUND = 0x00000001PIPE_ACCESS_OUTBOUND = 0x00000002PIPE_ACCESS_DUPLEX = 0x00000003PIPE_TYPE_BYTE = 0x00000000PIPE_TYPE_MESSAGE = 0x00000004PIPE_READMODE_BYTE = 0x00000000PIPE_READMODE_MESSAGE = 0x00000002)
const (TCP_KEEPIDLE = 0x03TCP_KEEPCNT = 0x10TCP_KEEPINTVL = 0x11SIO_UDP_NETRESET =syscall.IOC_IN |syscall.IOC_VENDOR | 15)
Socket related.
const (FILE_READ_DATA = 0x00000001FILE_READ_ATTRIBUTES = 0x00000080FILE_READ_EA = 0x00000008FILE_WRITE_DATA = 0x00000002FILE_WRITE_ATTRIBUTES = 0x00000100FILE_WRITE_EA = 0x00000010FILE_APPEND_DATA = 0x00000004FILE_EXECUTE = 0x00000020FILE_GENERIC_READ =STANDARD_RIGHTS_READ |FILE_READ_DATA |FILE_READ_ATTRIBUTES |FILE_READ_EA |SYNCHRONIZEFILE_GENERIC_WRITE =STANDARD_RIGHTS_WRITE |FILE_WRITE_DATA |FILE_WRITE_ATTRIBUTES |FILE_WRITE_EA |FILE_APPEND_DATA |SYNCHRONIZEFILE_GENERIC_EXECUTE =STANDARD_RIGHTS_EXECUTE |FILE_READ_ATTRIBUTES |FILE_EXECUTE |SYNCHRONIZEFILE_LIST_DIRECTORY = 0x00000001FILE_TRAVERSE = 0x00000020FILE_SHARE_READ = 0x00000001FILE_SHARE_WRITE = 0x00000002FILE_SHARE_DELETE = 0x00000004FILE_ATTRIBUTE_READONLY = 0x00000001FILE_ATTRIBUTE_HIDDEN = 0x00000002FILE_ATTRIBUTE_SYSTEM = 0x00000004FILE_ATTRIBUTE_DIRECTORY = 0x00000010FILE_ATTRIBUTE_ARCHIVE = 0x00000020FILE_ATTRIBUTE_DEVICE = 0x00000040FILE_ATTRIBUTE_NORMAL = 0x00000080FILE_ATTRIBUTE_TEMPORARY = 0x00000100FILE_ATTRIBUTE_SPARSE_FILE = 0x00000200FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400FILE_ATTRIBUTE_COMPRESSED = 0x00000800FILE_ATTRIBUTE_OFFLINE = 0x00001000FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x00002000FILE_ATTRIBUTE_ENCRYPTED = 0x00004000FILE_ATTRIBUTE_INTEGRITY_STREAM = 0x00008000FILE_ATTRIBUTE_VIRTUAL = 0x00010000FILE_ATTRIBUTE_NO_SCRUB_DATA = 0x00020000FILE_ATTRIBUTE_RECALL_ON_OPEN = 0x00040000FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = 0x00400000INVALID_FILE_ATTRIBUTES = 0xffffffff)
const (DELETE = 0x00010000READ_CONTROL = 0x00020000WRITE_DAC = 0x00040000WRITE_OWNER = 0x00080000SYNCHRONIZE = 0x00100000STANDARD_RIGHTS_REQUIRED = 0x000F0000STANDARD_RIGHTS_READ =READ_CONTROLSTANDARD_RIGHTS_WRITE =READ_CONTROLSTANDARD_RIGHTS_EXECUTE =READ_CONTROLSTANDARD_RIGHTS_ALL = 0x001F0000SPECIFIC_RIGHTS_ALL = 0x0000FFFFACCESS_SYSTEM_SECURITY = 0x01000000MAXIMUM_ALLOWED = 0x02000000GENERIC_READ = 0x80000000GENERIC_WRITE = 0x40000000GENERIC_EXECUTE = 0x20000000GENERIC_ALL = 0x10000000)
Constants for type ACCESS_MASK
const (OBJ_INHERIT = 0x00000002OBJ_PERMANENT = 0x00000010OBJ_EXCLUSIVE = 0x00000020OBJ_CASE_INSENSITIVE = 0x00000040OBJ_OPENIF = 0x00000080OBJ_OPENLINK = 0x00000100OBJ_KERNEL_HANDLE = 0x00000200OBJ_FORCE_ACCESS_CHECK = 0x00000400OBJ_IGNORE_IMPERSONATED_DEVICEMAP = 0x00000800OBJ_DONT_REPARSE = 0x00001000OBJ_VALID_ATTRIBUTES = 0x00001FF2)
Values for the Attributes member of OBJECT_ATTRIBUTES.
const (// CreateDisposition flags for NtCreateFile and NtCreateNamedPipeFile.FILE_SUPERSEDE = 0x00000000FILE_OPEN = 0x00000001FILE_CREATE = 0x00000002FILE_OPEN_IF = 0x00000003FILE_OVERWRITE = 0x00000004FILE_OVERWRITE_IF = 0x00000005FILE_MAXIMUM_DISPOSITION = 0x00000005// CreateOptions flags for NtCreateFile and NtCreateNamedPipeFile.FILE_DIRECTORY_FILE = 0x00000001FILE_WRITE_THROUGH = 0x00000002FILE_SEQUENTIAL_ONLY = 0x00000004FILE_NO_INTERMEDIATE_BUFFERING = 0x00000008FILE_SYNCHRONOUS_IO_ALERT = 0x00000010FILE_SYNCHRONOUS_IO_NONALERT = 0x00000020FILE_NON_DIRECTORY_FILE = 0x00000040FILE_CREATE_TREE_CONNECTION = 0x00000080FILE_COMPLETE_IF_OPLOCKED = 0x00000100FILE_NO_EA_KNOWLEDGE = 0x00000200FILE_OPEN_REMOTE_INSTANCE = 0x00000400FILE_RANDOM_ACCESS = 0x00000800FILE_DELETE_ON_CLOSE = 0x00001000FILE_OPEN_BY_FILE_ID = 0x00002000FILE_OPEN_FOR_BACKUP_INTENT = 0x00004000FILE_NO_COMPRESSION = 0x00008000FILE_OPEN_REQUIRING_OPLOCK = 0x00010000FILE_DISALLOW_EXCLUSIVE = 0x00020000FILE_RESERVE_OPFILTER = 0x00100000FILE_OPEN_REPARSE_POINT = 0x00200000FILE_OPEN_NO_RECALL = 0x00400000FILE_OPEN_FOR_FREE_SPACE_QUERY = 0x00800000)
const (FILE_DISPOSITION_DO_NOT_DELETE = 0x00000000FILE_DISPOSITION_DELETE = 0x00000001FILE_DISPOSITION_POSIX_SEMANTICS = 0x00000002FILE_DISPOSITION_FORCE_IMAGE_SECTION_CHECK = 0x00000004FILE_DISPOSITION_ON_CLOSE = 0x00000008FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE = 0x00000010)
const (FILE_RENAME_REPLACE_IF_EXISTS = 0x00000001FILE_RENAME_POSIX_SEMANTICS = 0x00000002)
Flags for FILE_RENAME_INFORMATION_EX.
const (FileModeInformation = 16)
const FileReplaceCompletionInformation = 61
const MAX_MODULE_NAME32 = 255
const MB_ERR_INVALID_CHARS = 8
const SE_GROUP_INTEGRITY = 0x00000020
const SizeofModuleEntry32 =unsafe.Sizeof(ModuleEntry32{})
const (USER_PRIV_USER = 1)
const VER_NT_WORKSTATION = 0x0000001
https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-osversioninfoexahttps://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/ns-wdm-_osversioninfoexw
Variables¶
var CanUseLongPathsbool
CanUseLongPaths is true when the OS supports opting intoproper long path handling without the need for fixups.
var SECURITY_NT_AUTHORITY =SID_IDENTIFIER_AUTHORITY{Value: [6]byte{0, 0, 0, 0, 0, 5},}
var SupportTCPInitialRTONoSYNRetransmissions =sync.OnceValue(func()bool {major, _, build :=Version()return major >= 10 && build >= 16299})
SupportTCPInitialRTONoSYNRetransmissions indicates whether the currentWindows version supports the TCP_INITIAL_RTO_NO_SYN_RETRANSMISSIONS.The minimal requirement is Windows 10.0.16299.
var SupportUnixSocket =sync.OnceValue(func()bool {var sizeuint32_, _ =syscall.WSAEnumProtocols(nil,nil, &size)n :=int32(size) /int32(unsafe.Sizeof(syscall.WSAProtocolInfo{}))buf :=make([]syscall.WSAProtocolInfo, n)n, err :=syscall.WSAEnumProtocols(nil, &buf[0], &size)if err !=nil {returnfalse}for i :=int32(0); i < n; i++ {if buf[i].AddressFamily ==syscall.AF_UNIX {returntrue}}returnfalse})
SupportUnixSocket indicates whether the current Windows version supportsUnix Domain Sockets.The minimal requirement is Windows 10.0.17063.
var SupportUnlimitedTransmitFile =sync.OnceValue(func()bool {info := getVersionInfo()return info.productType !=VER_NT_WORKSTATION})
SupportUnlimitedTransmitFile indicates whether the currentWindows version's TransmitFile function imposes anyconcurrent operation limits.Workstation and client versions of Windows limit the numberof concurrent TransmitFile operations allowed on the systemto a maximum of two. Please see:https://learn.microsoft.com/en-us/windows/win32/api/mswsock/nf-mswsock-transmitfilehttps://golang.org/issue/73746
var WSAID_WSARECVMSG =syscall.GUID{Data1: 0xf689d7c8,Data2: 0x6f1f,Data3: 0x436b,Data4: [8]byte{0x8a, 0x53, 0xe5, 0x4f, 0xe3, 0x51, 0xc3, 0x22},}
var WSAID_WSASENDMSG =syscall.GUID{Data1: 0xa441e712,Data2: 0x754f,Data3: 0x43ca,Data4: [8]byte{0x84, 0xa7, 0x0d, 0xee, 0x44, 0xcf, 0x60, 0x6d},}
Functions¶
funcAdjustTokenPrivileges¶added ingo1.8
func AdjustTokenPrivileges(tokensyscall.Token, disableAllPrivilegesbool, newstate *TOKEN_PRIVILEGES, buflenuint32, prevstate *TOKEN_PRIVILEGES, returnlen *uint32)error
funcCreateEnvironmentBlock¶added ingo1.12.6
funcCreateEvent¶added ingo1.21.0
funcCreateIoCompletionPort¶added ingo1.25.0
funcCreateNamedPipe¶added ingo1.25.0
funcDestroyEnvironmentBlock¶added ingo1.12.6
funcDuplicateTokenEx¶added ingo1.10
funcErrorLoadingGetTempPath2¶added ingo1.21.0
func ErrorLoadingGetTempPath2()error
funcGetConsoleCP¶added ingo1.8
func GetConsoleCP() (ccpuint32)
funcGetCurrentThread¶added ingo1.8
funcGetFileInformationByHandleEx¶added ingo1.12
funcGetFinalPathNameByHandle¶added ingo1.10
funcGetModuleFileName¶added ingo1.8
funcGetModuleHandle¶added ingo1.24.0
funcGetOverlappedResult¶added ingo1.25.0
funcGetProcessMemoryInfo¶added ingo1.10
func GetProcessMemoryInfo(handlesyscall.Handle, memCounters *PROCESS_MEMORY_COUNTERS, cbuint32) (errerror)
funcGetProfilesDirectory¶added ingo1.11
funcGetSidSubAuthority¶added ingo1.24.0
funcGetSidSubAuthorityCount¶added ingo1.24.0
funcGetSystemDirectory¶added ingo1.22.0
func GetSystemDirectory()string
GetSystemDirectory retrieves the path to current location of the systemdirectory, which is typically, though not always, `C:\Windows\System32`.
funcGetUserName¶added ingo1.24.0
GetUserName retrieves the user name of the current threadin the specified format.
funcGetVolumeInformationByHandle¶added ingo1.21.0
funcGetVolumeNameForVolumeMountPoint¶added ingo1.22.0
funcImpersonateLoggedOnUser¶added ingo1.24.0
funcImpersonateSelf¶added ingo1.8
funcIsNonblock¶added ingo1.25.0
IsNonblock returns whether the file descriptor fd is openedin non-blocking mode, that is, thesyscall.FILE_FLAG_OVERLAPPED flagwas set when the file was opened.
funcIsValidSid¶added ingo1.24.0
funcLockFileEx¶added ingo1.12
funcLookupPrivilegeValue¶added ingo1.8
funcModule32First¶added ingo1.20
func Module32First(snapshotsyscall.Handle, moduleEntry *ModuleEntry32) (errerror)
funcModule32Next¶added ingo1.20
func Module32Next(snapshotsyscall.Handle, moduleEntry *ModuleEntry32) (errerror)
funcMultiByteToWideChar¶added ingo1.6
funcNetShareAdd¶added ingo1.8
funcNetShareDel¶added ingo1.8
funcNetUserAdd¶added ingo1.24.0
funcNetUserDel¶added ingo1.24.0
funcNetUserGetLocalGroups¶added ingo1.11
funcNtCreateFile¶added ingo1.24.0
funcNtOpenFile¶added ingo1.24.0
func NtOpenFile(handle *syscall.Handle, accessuint32, oa *OBJECT_ATTRIBUTES, iosb *IO_STATUS_BLOCK, shareuint32, optionsuint32) (ntstatuserror)
funcNtQueryInformationFile¶added ingo1.25.0
funcNtSetInformationFile¶added ingo1.24.0
funcOpenSCManager¶added ingo1.22.0
funcOpenService¶added ingo1.22.0
funcOpenThreadToken¶added ingo1.8
funcProcessPrng¶added ingo1.21.5
funcQueryPerformanceCounter¶added ingo1.23.0
func QueryPerformanceCounter()int64
QueryPerformanceCounter retrieves the current value of performance counter.
funcQueryPerformanceFrequency¶added ingo1.23.0
func QueryPerformanceFrequency()int64
QueryPerformanceFrequency retrieves the frequency of the performance counter.The returned value is represented as counts per second.
funcQueryServiceStatus¶added ingo1.22.0
func QueryServiceStatus(hServicesyscall.Handle, lpServiceStatus *SERVICE_STATUS) (errerror)
funcRevertToSelf¶added ingo1.8
func RevertToSelf() (errerror)
funcRtlIsDosDeviceName_U¶added ingo1.25.0
funcRtlVirtualUnwind¶added ingo1.21.0
funcSetFileInformationByHandle¶added ingo1.16
funcSetTokenInformation¶added ingo1.10
funcSupportTCPKeepAliveCount¶added ingo1.23.0
func SupportTCPKeepAliveCount()bool
SupportTCPKeepAliveCount indicates whether TCP_KEEPCNT is supported.supports TCP_KEEPCNT.The minimal requirement is Windows 10.0.15063.
funcSupportTCPKeepAliveIdle¶added ingo1.23.0
func SupportTCPKeepAliveIdle()bool
SupportTCPKeepAliveIdle indicates whether TCP_KEEPIDLE is supported.The minimal requirement is Windows 10.0.16299.
funcSupportTCPKeepAliveInterval¶added ingo1.23.0
func SupportTCPKeepAliveInterval()bool
SupportTCPKeepAliveInterval indicates whether TCP_KEEPINTVL is supported.The minimal requirement is Windows 10.0.16299.
funcUTF16PtrToString¶added ingo1.14
UTF16PtrToString is like UTF16ToString, but takes *uint16as a parameter instead of []uint16.
funcUnlockFileEx¶added ingo1.12
funcVersion¶added ingo1.24.0
func Version() (major, minor, builduint32)
Version retrieves the major, minor, and build version numbersof the current Windows OS from the RtlGetVersion API.
funcVirtualQuery¶added ingo1.19
func VirtualQuery(addressuintptr, buffer *MemoryBasicInformation, lengthuintptr) (errerror)
funcWSADuplicateSocket¶added ingo1.25.0
funcWSAGetOverlappedResult¶added ingo1.23.0
funcWSARecvMsg¶added ingo1.10
funcWSASendMsg¶added ingo1.10
funcWSASendtoInet4¶added ingo1.18
funcWSASendtoInet6¶added ingo1.18
Types¶
typeACCESS_MASK¶added ingo1.24.0
type ACCESS_MASKuint32
https://learn.microsoft.com/en-us/windows/win32/secauthz/access-mask
typeACL¶added ingo1.24.0
https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/ns-wdm-_acl
typeFILE_ATTRIBUTE_TAG_INFO¶added ingo1.12
typeFILE_BASIC_INFO¶added ingo1.16
typeFILE_COMPLETION_INFORMATION¶added ingo1.25.0
typeFILE_DISPOSITION_INFORMATION¶added ingo1.24.0
type FILE_DISPOSITION_INFORMATION struct {DeleteFilebool}
typeFILE_DISPOSITION_INFORMATION_EX¶added ingo1.24.0
type FILE_DISPOSITION_INFORMATION_EX struct {Flagsuint32}
typeFILE_FULL_DIR_INFO¶added ingo1.22.0
typeFILE_ID_BOTH_DIR_INFO¶added ingo1.21.0
type FILE_ID_BOTH_DIR_INFO struct {NextEntryOffsetuint32FileIndexuint32CreationTimesyscall.FiletimeLastAccessTimesyscall.FiletimeLastWriteTimesyscall.FiletimeChangeTimesyscall.FiletimeEndOfFileuint64AllocationSizeuint64FileAttributesuint32FileNameLengthuint32EaSizeuint32ShortNameLengthuint32ShortName [12]uint16FileIDuint64FileName [1]uint16}
typeFILE_LINK_INFORMATION¶added ingo1.25.0
type FILE_LINK_INFORMATION struct {ReplaceIfExistsboolRootDirectorysyscall.HandleFileNameLengthuint32FileName [syscall.MAX_PATH]uint16}
https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/ns-ntifs-_file_link_information
typeFILE_MODE_INFORMATION¶added ingo1.25.0
type FILE_MODE_INFORMATION struct {Modeuint32}
https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/ns-ntifs-_file_mode_information
typeFILE_RENAME_INFORMATION¶added ingo1.25.0
typeFILE_RENAME_INFORMATION_EX¶added ingo1.25.0
typeIO_STATUS_BLOCK¶added ingo1.24.0
https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/ns-wdm-_io_status_block
typeIpAdapterAddresses¶
type IpAdapterAddresses struct {Lengthuint32IfIndexuint32Next *IpAdapterAddressesAdapterName *byteFirstUnicastAddress *IpAdapterUnicastAddressFirstAnycastAddress *IpAdapterAnycastAddressFirstMulticastAddress *IpAdapterMulticastAddressFirstDnsServerAddress *IpAdapterDnsServerAdapterDnsSuffix *uint16Description *uint16FriendlyName *uint16PhysicalAddress [syscall.MAX_ADAPTER_ADDRESS_LENGTH]bytePhysicalAddressLengthuint32Flagsuint32Mtuuint32IfTypeuint32OperStatusuint32Ipv6IfIndexuint32ZoneIndices [16]uint32FirstPrefix *IpAdapterPrefixTransmitLinkSpeeduint64ReceiveLinkSpeeduint64FirstWinsServerAddress *IpAdapterWinsServerAddressFirstGatewayAddress *IpAdapterGatewayAddress}
typeIpAdapterAnycastAddress¶
type IpAdapterAnycastAddress struct {Lengthuint32Flagsuint32Next *IpAdapterAnycastAddressAddressSocketAddress}
typeIpAdapterDnsServerAdapter¶
type IpAdapterDnsServerAdapter struct {Lengthuint32Reserveduint32Next *IpAdapterDnsServerAdapterAddressSocketAddress}
typeIpAdapterGatewayAddress¶added ingo1.23.0
type IpAdapterGatewayAddress struct {Lengthuint32Reserveduint32Next *IpAdapterGatewayAddressAddressSocketAddress}
typeIpAdapterMulticastAddress¶
type IpAdapterMulticastAddress struct {Lengthuint32Flagsuint32Next *IpAdapterMulticastAddressAddressSocketAddress}
typeIpAdapterPrefix¶
type IpAdapterPrefix struct {Lengthuint32Flagsuint32Next *IpAdapterPrefixAddressSocketAddressPrefixLengthuint32}
typeIpAdapterWinsServerAddress¶added ingo1.23.0
type IpAdapterWinsServerAddress struct {Lengthuint32Reserveduint32Next *IpAdapterWinsServerAddressAddressSocketAddress}
typeLUID_AND_ATTRIBUTES¶added ingo1.8
typeLocalGroupUserInfo0¶added ingo1.11
type LocalGroupUserInfo0 struct {Name *uint16}
typeMemoryBasicInformation¶added ingo1.19
type MemoryBasicInformation struct {// A pointer to the base address of the region of pages.BaseAddressuintptr// A pointer to the base address of a range of pages allocated by the VirtualAlloc function.// The page pointed to by the BaseAddress member is contained within this allocation range.AllocationBaseuintptr// The memory protection option when the region was initially allocatedAllocationProtectuint32PartitionIduint16// The size of the region beginning at the base address in which all pages have identical attributes, in bytes.RegionSizeuintptr// The state of the pages in the region.Stateuint32// The access protection of the pages in the region.Protectuint32// The type of pages in the region.Typeuint32}
typeModuleEntry32¶added ingo1.20
typeMountPointReparseBuffer¶added ingo1.8
type MountPointReparseBuffer struct {// The integer that contains the offset, in bytes,// of the substitute name string in the PathBuffer array,// computed as an offset from byte 0 of PathBuffer. Note that// this offset must be divided by 2 to get the array index.SubstituteNameOffsetuint16// The integer that contains the length, in bytes, of the// substitute name string. If this string is null-terminated,// SubstituteNameLength does not include the Unicode null character.SubstituteNameLengthuint16// PrintNameOffset is similar to SubstituteNameOffset.PrintNameOffsetuint16// PrintNameLength is similar to SubstituteNameLength.PrintNameLengthuint16PathBuffer [1]uint16}
func (*MountPointReparseBuffer)Path¶added ingo1.13
func (rb *MountPointReparseBuffer) Path()string
Path returns path stored in rb.
typeNTStatus¶added ingo1.24.0
type NTStatusuint32
NTStatus corresponds with NTSTATUS, error values returned by ntdll.dll andother native functions.
const (STATUS_OBJECT_NAME_COLLISIONNTStatus = 0xC0000035STATUS_FILE_IS_A_DIRECTORYNTStatus = 0xC00000BASTATUS_DIRECTORY_NOT_EMPTYNTStatus = 0xC0000101STATUS_NOT_A_DIRECTORYNTStatus = 0xC0000103STATUS_CANNOT_DELETENTStatus = 0xC0000121STATUS_REPARSE_POINT_ENCOUNTEREDNTStatus = 0xC000050B)
x/sys/windows/mkerrors.bash can generate a complete list of NTStatus codes.
At the moment, we only need a couple, so just put them here manually.If this list starts getting long, we should consider generating the full set.
typeNTUnicodeString¶added ingo1.24.0
NTUnicodeString is a UTF-16 string for NT native APIs, corresponding to UNICODE_STRING.
funcNewNTUnicodeString¶added ingo1.24.0
func NewNTUnicodeString(sstring) (*NTUnicodeString,error)
NewNTUnicodeString returns a new NTUnicodeString structure for use with nativeNT APIs that work over the NTUnicodeString type. Note that most Windows APIsdo not use NTUnicodeString, and instead UTF16PtrFromString should be used forthe more common *uint16 string type.
typeOBJECT_ATTRIBUTES¶added ingo1.24.0
type OBJECT_ATTRIBUTES struct {Lengthuint32RootDirectorysyscall.HandleObjectName *NTUnicodeStringAttributesuint32SecurityDescriptor *SECURITY_DESCRIPTORSecurityQoS *SECURITY_QUALITY_OF_SERVICE}
https://learn.microsoft.com/en-us/windows/win32/api/ntdef/ns-ntdef-_object_attributes
typePROCESS_MEMORY_COUNTERS¶added ingo1.10
typeREPARSE_DATA_BUFFER¶added ingo1.13
typeREPARSE_DATA_BUFFER_HEADER¶added ingo1.8
type REPARSE_DATA_BUFFER_HEADER struct {ReparseTaguint32// The size, in bytes, of the reparse data that follows// the common portion of the REPARSE_DATA_BUFFER element.// This value is the length of the data starting at the// SubstituteNameOffset field.ReparseDataLengthuint16Reserveduint16}
REPARSE_DATA_BUFFER_HEADER is a common part of REPARSE_DATA_BUFFER structure.
typeRUNTIME_FUNCTION¶added ingo1.25.0
funcRtlLookupFunctionEntry¶added ingo1.21.0
func RtlLookupFunctionEntry(pcuintptr, baseAddress *uintptr, tableunsafe.Pointer) (ret *RUNTIME_FUNCTION)
typeSECURITY_DESCRIPTOR¶added ingo1.24.0
type SECURITY_DESCRIPTOR struct {// contains filtered or unexported fields}
https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/ns-ntifs-_security_descriptor
typeSECURITY_DESCRIPTOR_CONTROL¶added ingo1.24.0
type SECURITY_DESCRIPTOR_CONTROLuint16
https://learn.microsoft.com/en-us/windows-hardware/drivers/ifs/security-descriptor-control
typeSECURITY_QUALITY_OF_SERVICE¶added ingo1.24.0
type SECURITY_QUALITY_OF_SERVICE struct {Lengthuint32ImpersonationLeveluint32// type SECURITY_IMPERSONATION_LEVELContextTrackingModebyte// type SECURITY_CONTEXT_TRACKING_MODEEffectiveOnlybyte}
https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-security_quality_of_service
typeSERVICE_STATUS¶added ingo1.22.0
typeSHARE_INFO_2¶added ingo1.8
typeSID_AND_ATTRIBUTES¶added ingo1.10
typeSID_IDENTIFIER_AUTHORITY¶added ingo1.24.0
type SID_IDENTIFIER_AUTHORITY struct {Value [6]byte}
https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-sid_identifier_authority
funcGetSidIdentifierAuthority¶added ingo1.24.0
func GetSidIdentifierAuthority(sid *syscall.SID)SID_IDENTIFIER_AUTHORITY
typeSecurityAttributes¶added ingo1.21.0
typeSocketAddress¶
type SocketAddress struct {Sockaddr *syscall.RawSockaddrAnySockaddrLengthint32}
typeSymbolicLinkReparseBuffer¶added ingo1.8
type SymbolicLinkReparseBuffer struct {// The integer that contains the offset, in bytes,// of the substitute name string in the PathBuffer array,// computed as an offset from byte 0 of PathBuffer. Note that// this offset must be divided by 2 to get the array index.SubstituteNameOffsetuint16// The integer that contains the length, in bytes, of the// substitute name string. If this string is null-terminated,// SubstituteNameLength does not include the Unicode null character.SubstituteNameLengthuint16// PrintNameOffset is similar to SubstituteNameOffset.PrintNameOffsetuint16// PrintNameLength is similar to SubstituteNameLength.PrintNameLengthuint16// Flags specifies whether the substitute name is a full path name or// a path name relative to the directory containing the symbolic link.Flagsuint32PathBuffer [1]uint16}
func (*SymbolicLinkReparseBuffer)Path¶added ingo1.13
func (rb *SymbolicLinkReparseBuffer) Path()string
Path returns path stored in rb.
typeSymlinkatFlags¶added ingo1.25.0
type SymlinkatFlagsuint
SymlinkatFlags configure Symlinkat.
Symbolic links have two properties: They may be directory or file links,and they may be absolute or relative.
The Windows API defines flags describing these properties(SYMBOLIC_LINK_FLAG_DIRECTORY and SYMLINK_FLAG_RELATIVE),but the flags are passed to different system calls anddo not have distinct values, so we define our own enumerationthat permits expressing both.
typeTCP_INITIAL_RTO_PARAMETERS¶added ingo1.21.0
typeTOKEN_GROUPS¶added ingo1.24.0
type TOKEN_GROUPS struct {GroupCountuint32Groups [1]SID_AND_ATTRIBUTES}
funcGetTokenGroups¶added ingo1.24.0
func GetTokenGroups(tsyscall.Token) (*TOKEN_GROUPS,error)
func (*TOKEN_GROUPS)AllGroups¶added ingo1.24.0
func (g *TOKEN_GROUPS) AllGroups() []SID_AND_ATTRIBUTES
typeTOKEN_MANDATORY_LABEL¶added ingo1.10
type TOKEN_MANDATORY_LABEL struct {LabelSID_AND_ATTRIBUTES}
func (*TOKEN_MANDATORY_LABEL)Size¶added ingo1.10
func (tml *TOKEN_MANDATORY_LABEL) Size()uint32
typeTOKEN_PRIVILEGES¶added ingo1.8
type TOKEN_PRIVILEGES struct {PrivilegeCountuint32Privileges [1]LUID_AND_ATTRIBUTES}
typeUserInfo4¶added ingo1.11
type UserInfo4 struct {Name *uint16Password *uint16PasswordAgeuint32Privuint32HomeDir *uint16Comment *uint16Flagsuint32ScriptPath *uint16AuthFlagsuint32FullName *uint16UsrComment *uint16Parms *uint16Workstations *uint16LastLogonuint32LastLogoffuint32AcctExpiresuint32MaxStorageuint32UnitsPerWeekuint32LogonHours *byteBadPwCountuint32NumLogonsuint32LogonServer *uint16CountryCodeuint32CodePageuint32UserSid *syscall.SIDPrimaryGroupIDuint32Profile *uint16HomeDirDrive *uint16PasswordExpireduint32}
Source Files¶
Directories¶
Path | Synopsis |
---|---|
Package registry provides access to the Windows registry. | Package registry provides access to the Windows registry. |
Package sysdll is an internal leaf package that records and reports which Windows DLL names are used by Go itself. | Package sysdll is an internal leaf package that records and reports which Windows DLL names are used by Go itself. |