unattended

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package unattended gives the Windows service (`remohop service install --unattended`) the interactive console session: its screen, including the sign-in screen, the lock screen and UAC prompts on the secure desktop, and its keyboard and mouse.

A Windows service runs as LocalSystem in session 0, which has no display. The service therefore stays the network endpoint and does the encoding, and for anything that needs the desktop it starts a helper process: the same remohop binary (`remohop service session-helper`), with a copy of the service's own token moved into the console session, started on winsta0\Winlogon. The helper's capture and input threads attach to whichever desktop currently receives input (Default, Winlogon, the screen saver) before every operation, so they follow the user from the desktop to the lock screen to a UAC prompt and back. As LocalSystem on the input desktop its SendInput is not filtered by UIPI, and GDI capture works on the secure desktop where the Desktop Duplication API and ffmpeg's grabbers do not reach.

Service and helper talk over a named pipe the helper creates for its launch only: a random name, an access list that admits LocalSystem alone, remote clients rejected. Each end checks the process ID of the other (the helper accepts only the service that started it; the service only the helper it started) and both prove knowledge of a per-launch secret, which the service hands the helper through an inherited anonymous pipe (its standard input), never on the command line. The helper refuses to run unless it is LocalSystem, so nobody else can start one usefully.

The service follows the console session: when the user logs off, another user takes over through fast user switching, or a remote desktop connection moves the session away from the console, the helper of the old session is ended and the next request starts one in the new console session. Helpers are started on demand and end when idle.

Ctrl+Alt+Del is raised by the service itself with SendSAS, which Windows allows only when the SoftwareSASGeneration policy permits services.

Index

Constants

View Source
const SASPolicyHint = `Windows lets services send Ctrl+Alt+Del only if the policy "Disable or enable software Secure Attention Sequence" ` +
	`is Enabled for Services: HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System, SoftwareSASGeneration=1`

SASPolicyHint says how to allow the service to send Ctrl+Alt+Del (kept short: viewers show at most 300 characters of a reason).

View Source
const SessionEnv = "REMOHOP_UNATTENDED_SESSION"

SessionEnv selects which session the service shows: "console" (the default) is the physical console, whatever is on it (a user's desktop or the sign-in screen); "active" prefers a session with a user logged in, the console's if it has one, else a remote desktop session.

Variables

View Source
var ErrNotActive = errWindowsOnly

ErrNotActive is returned when the process is not a service with unattended access.

View Source
var ErrStreamClosed = errors.New("unattended: the stream was closed")

ErrStreamClosed is what Stream.Copy returns once the service closed the stream itself.

Functions

func Active

func Active() bool

Active reports whether this process is the Windows service with unattended access enabled; never on this system.

func ConsoleSession

func ConsoleSession() (uint32, bool)

ConsoleSession: there is no console session to start programs in here.

func DesktopKind

func DesktopKind(name string) string

DesktopKind describes a desktop name for people.

func Enable

func Enable(io.Writer) (func(), error)

Enable is only available on Windows.

func RestoreSAS

func RestoreSAS(SASChange) error

RestoreSAS is only available on Windows.

func RunHelper

func RunHelper(context.Context, io.Reader, io.Writer) error

RunHelper is only available on Windows.

func RunInConsole

func RunInConsole(context.Context, string, []string) ([]byte, error)

RunInConsole is only available on Windows.

func SASAvailable

func SASAvailable() (bool, string)

SASAvailable reports that Ctrl+Alt+Del cannot be raised here.

func SASPolicyAllows

func SASPolicyAllows() bool

SASPolicyAllows reports that no policy lets anything raise Ctrl+Alt+Del here.

Types

type CaptureStats

type CaptureStats struct {
	Window float64 `json:"window_s"`
	// Loops is capture attempts; Frames changed frames sent, Same
	// unchanged ones, Fails failed captures.
	Loops  int `json:"loops"`
	Frames int `json:"frames"`
	Same   int `json:"same"`
	Fails  int `json:"fails"`
	// GrabMS is the average capture (BitBlt and copy), GrabMaxMS the
	// longest; CmpMS the average comparison with the previous frame;
	// WriteMS the average write of a changed frame to the pipe (long when
	// the service is behind).
	GrabMS    float64 `json:"grab_ms"`
	GrabMaxMS float64 `json:"grab_max_ms"`
	CmpMS     float64 `json:"cmp_ms"`
	WriteMS   float64 `json:"write_ms"`
	// Dropped is set by the service: frames and repeats it did not write
	// to ffmpeg because a newer one came first (ffmpeg was behind).
	Dropped int `json:"dropped,omitempty"`
	// Service side: reading a changed frame from the pipe (IPCMS) and
	// writing a frame into ffmpeg (FeedMS), on average.
	IPCMS  float64 `json:"ipc_ms,omitempty"`
	FeedMS float64 `json:"feed_ms,omitempty"`
}

CaptureStats are the console-session helper's capture timings over a stretch of a stream (Window seconds), with the service's side of the pipe: where the time of a frame goes before ffmpeg has it. The service logs them; a GDI capture that cannot keep up shows as GrabMS near the frame period.

func (CaptureStats) FPS

func (c CaptureStats) FPS() float64

FPS is the rate of capture attempts.

type ConsoleProcess

type ConsoleProcess struct {
	Stdin          io.WriteCloser
	Stdout, Stderr io.ReadCloser
}

ConsoleProcess is a program started in the console session; never here.

func StartInConsole

func StartInConsole(string, []string, string, string) (*ConsoleProcess, error)

StartInConsole is only available on Windows.

type SASChange

type SASChange struct {
	// Prev is the value before, HadPrev whether there was one.
	Prev    uint32 `json:"prev"`
	HadPrev bool   `json:"had_prev"`
	// Set is the value AllowSAS wrote.
	Set uint32 `json:"set"`
}

SASChange is what AllowSAS changed in the SoftwareSASGeneration policy, kept by the desktop app's administrator step so that turning unattended access off can put it back (RestoreSAS).

func AllowSAS

func AllowSAS() (SASChange, bool, error)

AllowSAS is only available on Windows.

Jump to

Keyboard shortcuts

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