devtools

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoWindows = xerr.New("only supported on Windows devices")

ErrNoWindows is an error that is returned when a non-Windows device attempts a Windows specific function.

Functions

func AdjustPrivileges

func AdjustPrivileges(_ ...string) error

AdjustPrivileges will attempt to enable the supplied Windows privilege values on the current process's Token. Errors during encoding, lookup or assignment will be returned and not all privileges will be assigned, if they occur. Always returns 'ErrNoWindows' on non-Windows devices.

func AdjustTokenPrivileges

func AdjustTokenPrivileges(_ uintptr, _ ...string) error

AdjustTokenPrivileges will attempt to enable the supplied Windows privilege values on the supplied process Token. Errors during encoding, lookup or assignment will be returned and not all privileges will be assigned, if they occur. Always returns 'ErrNoWindows' on non-Windows devices.

Types

type RegistryFile

type RegistryFile struct {
	// contains filtered or unexported fields
}

RegistryFile is a struct that is returned from a Registry function call on Windows devices. This interface is a combinaton of the io.Reader and os.FileInfo interfaces.

func Registry

func Registry(_, _ string) (*RegistryFile, error)

Registry attempts to open a registry value or key, value pair on Windows devices. Returns err if the system is not a Windows device or an error occurred during the open. Always returns 'ErrNoWindows' on non-windows devices.

func (RegistryFile) Close

func (RegistryFile) Close() error

Close fulfills the io.Closer interface. For this struct, this function does nothing and always returns nil.

func (RegistryFile) IsDir

func (r RegistryFile) IsDir() bool

IsDir returns true if the specified registry path represents a key.

func (RegistryFile) ModTime

func (r RegistryFile) ModTime() time.Time

ModTime returns the RegistryFile's last modified time, if avaliable.

func (RegistryFile) Mode

func (r RegistryFile) Mode() os.FileMode

Mode returns the file mode of this RegistryFile. This will return a ModeDir is this represents a key.

func (RegistryFile) Name

func (r RegistryFile) Name() string

Name returns the full path of this RegistryFile.

func (*RegistryFile) Read

func (r *RegistryFile) Read(b []byte) (int, error)

Read will attempt to read the data from this RegistryFile into the supplied buffer. This will return io.EOF if this struct represents a key.

func (RegistryFile) Size

func (r RegistryFile) Size() int64

Size returns the size of the data enclosed in this RegistryFile. This function returns 0 if the path is to a registry key or there is not data to read.

func (RegistryFile) String

func (r RegistryFile) String() string

Similar to the Name function, this returns the full path of this RegistryFile.

func (RegistryFile) Sys

func (r RegistryFile) Sys() interface{}

Sys will return a pointer to the underlying buffer if the RegistryFile represents a value.

type Service

type Service struct {
	Start, End, Exec func()
	Name             string
	Interval         time.Duration
}

Service is a struct that assists in running a Windows service. This struct can be created and given functions to run (Exec - the function to run for each Timeout when greater than zero, Start - function to run on service start, End - function to run on service shutdown.) Trigger the service to start by using the 'Service.Run' function. The 'Run' function always returns 'ErrNoWindows' on non-Windows devices.

func (*Service) Run

func (s *Service) Run() error

Run will trigger the service to start and will block until the service completes. Will always returns 'ErrNoWindows' on non-Windows devices.

func (*Service) RunContext

func (s *Service) RunContext(_ context.Context) error

RunContext will trigger the service to start and will block until the service completes. Will always returns 'ErrNoWindows' on non-Windows devices. This function allows to pass a Context to cancel the running service.

Jump to

Keyboard shortcuts

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