wtsapi

package
v0.0.0-...-51074a1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Rendered for windows/amd64

Overview

Package wtsapi provides low-level access to the Remote Desktop Services API.

Index

Constants

View Source
const Local = 0 // WTS_CURRENT_SERVER_HANDLE

Local can be passed as a system handle to many WTS API calls to indicate local machine.

Variables

This section is empty.

Functions

func CloseServer

func CloseServer(server syscall.Handle) (err error)

CloseServer closes a connection to windows terminal server. It calls the WTSCloseServer windows API function.

https://docs.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtscloseserver

func OpenServer

func OpenServer(name string) (server syscall.Handle, err error)

OpenServer opens a connection to the windows terminal server with the given server name. It calls the WTSOpenServerExW windows API function.

If name is empty it connects to the local terminal server instance.

It is the caller's responsibility to close the returned handle when finished with it by calling CloseServer().

https://docs.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsopenserverexw

func QuerySessionData

func QuerySessionData(server syscall.Handle, sessionID, infoClass uint32, buffer []byte) (data []byte, err error)

QuerySessionData returns raw session data for the requested server, session and information class. It calls the WTSQuerySessionInformationW windows API function.

This is a low-level function that returns data as a slice of bytes. If a non-nil buffer of sufficient size is provided, the returned data will be sliced from the buffer.

To efficiently query the local terminal server, specify Local when calling this function.

https://docs.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsquerysessioninformationw

func QueryUserDomain

func QueryUserDomain(server syscall.Handle, sessionID uint32) (userName string, err error)

QueryUserDomain returns the domain of the user for the given server and session ID.

func QueryUserName

func QueryUserName(server syscall.Handle, sessionID uint32) (userName string, err error)

QueryUserName returns the name of the user for the given server and session ID.

func QueryUserToken

func QueryUserToken(sessionID uint32) (token syscall.Token, err error)

QueryUserToken returns the primary access token of the user currently logged on to the given local session ID. It calls the WTSQueryUserToken windows API function.

This function is highly restricted and will only succeed for applications running as LocalSystem.

It is the caller's responsibility to close the token handle when finished with it by calling syscall.CloseHandle().

https://docs.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsqueryusertoken

Types

type ClientInfo

type ClientInfo struct {
	ComputerName            string
	ComputerDomain          string
	UserName                string
	WorkDirectory           string
	InitialProgram          string
	EncryptionLevel         encryptionlevel.Value
	ClientAddressFamily     uint32
	ClientAddress           string
	HRes                    uint16 // Horizontal resolution (pixels)
	VRes                    uint16 // Vertical resolution (pixels)
	ColorDepth              colordepth.Value
	ClientDirectory         string
	ClientBuildNumber       uint32
	OutputBufferCountHost   uint16
	OutputBufferCountClient uint16
	OutputBufferLength      uint16
	DeviceID                string
}

ClientInfo holds information about a remote client with a session in windows terminal server. It contains data extracted from the WTSCLIENTW windows API structure.

https://docs.microsoft.com/en-us/windows/win32/api/wtsapi32/ns-wtsapi32-wtsclientw

func QueryClientInfo

func QueryClientInfo(server syscall.Handle, sessionID uint32) (ClientInfo, error)

QueryClientInfo returns information about the client connected to the requested session.

type SessionEntry

type SessionEntry struct {
	SessionID     uint32
	WindowStation string
	State         connstate.Value
}

SessionEntry holds data information about a session in windows terminal server. It contains data extracted from the WTS_SESSION_INFOW windows API structure.

https://docs.microsoft.com/en-us/windows/win32/api/wtsapi32/ns-wtsapi32-wts_session_infow

func EnumerateSessions

func EnumerateSessions(server syscall.Handle) (sessions []SessionEntry, err error)

EnumerateSessions returns a slice of session information for the requested server. It calls the WTSEnumerateSessionsW windows API function.

To efficiently query the local terminal server, specify Local when calling this function.

https://docs.microsoft.com/en-us/windows/win32/api/wtsapi32/nf-wtsapi32-wtsenumeratesessionsw

type SessionInfo

type SessionInfo struct {
	SessionID               uint32
	ConnState               connstate.Value
	LockState               lockstate.Value
	WindowStation           string
	UserName                string
	UserDomain              string
	LogonTime               time.Time
	ConnectTime             time.Time
	DisconnectTime          time.Time
	LastInputTime           time.Time
	CurrentTime             time.Time
	IncomingBytes           uint32
	OutgoingBytes           uint32
	IncomingFrames          uint32
	OutgoingFrames          uint32
	IncomingCompressedBytes uint32
	OutgoingCompressedBytes uint32
}

SessionInfo holds detailed information about a session in windows terminal server. It contains data extracted from the WTSINFOEXW windows API structure.

https://docs.microsoft.com/en-us/windows/win32/api/wtsapi32/ns-wtsapi32-wtsinfoexw

func QuerySessionInfo

func QuerySessionInfo(server syscall.Handle, sessionID uint32) (SessionInfo, error)

QuerySessionInfo returns detailed information for the requested session.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL