regedit

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package regedit is a helper package that allows easy access to the Windows registry on Windows systems and allows non-Windows systems to read data generated from registry entries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(_, _ string) error

Delete will attempt to delete the specified key or value name specified.

The value will be probed for a type and if it is a key, it will delete the key ONLY if it is empty. (Use 'DeleteEx' for recursive deletion).

The key path can either be a "reg" style path (ex: HKLM\System or HKCU\Software) or PowerShell style (ex: HKLM:\System or HKCU:\Software).

Any errors deleting the key or value will be returned.

Returns device.ErrNoWindows on non-Windows devices.

func DeleteEx

func DeleteEx(_, _ string, _ bool) error

DeleteEx will attempt to delete the specified key or value name specified.

The value will be probed for a type and if it is a key, it will delete the key ONLY if it is empty or force is true (which will recursively delete the key)

The key path can either be a "reg" style path (ex: HKLM\System or HKCU\Software) or PowerShell style (ex: HKLM:\System or HKCU:\Software).

Any errors deleting the key or value will be returned.

Returns device.ErrNoWindows on non-Windows devices.

func DeleteKey

func DeleteKey(_ string, _ bool) error

DeleteKey will attempt to delete the specified subkey name specified.

If force is specified, this will recursively delete a subkey and will delete non-empty subkeys. Otherwise, if force is false, non-empty subkeys will NOT be deleted.

The key path can either be a "reg" style path (ex: HKLM\System or HKCU\Software) or PowerShell style (ex: HKLM:\System or HKCU:\Software).

Any errors creating the key will be returned.

Returns device.ErrNoWindows on non-Windows devices.

func MakeKey

func MakeKey(_ string) error

MakeKey will attempt to create an empty key for the supplied path.

The key path can either be a "reg" style path (ex: HKLM\System or HKCU\Software) or PowerShell style (ex: HKLM:\System or HKCU:\Software).

Any errors creating the key will be returned.

Returns device.ErrNoWindows on non-Windows devices.

func Set

func Set(_, _ string, _ uint32, _ []byte) error

Set will attempt to set the data of the value in the supplied key path to the supplied value type indicated with the type flag and will use the provided raw bytes for the value data.

This function is a "lower-level" function but allows more control of HOW the data is used.

This will create the key/value if it does not exist.

The key path can either be a "reg" style path (ex: HKLM\System or HKCU\Software) or PowerShell style (ex: HKLM:\System or HKCU:\Software).

Any errors writing the data will be returned.

Returns device.ErrNoWindows on non-Windows devices.

func SetBytes

func SetBytes(_, _ string, _ []byte) error

SetBytes will attempt to set the data of the value in the supplied key path to the supplied byte array as a REG_BINARY value type.

This will create the key/value if it does not exist.

The key path can either be a "reg" style path (ex: HKLM\System or HKCU\Software) or PowerShell style (ex: HKLM:\System or HKCU:\Software).

Any errors writing the data will be returned.

Returns device.ErrNoWindows on non-Windows devices.

func SetDword

func SetDword(_, _ string, _ uint32) error

SetDword will attempt to set the data of the value in the supplied key path to the supplied uint32 integer as a REG_DWORD value type.

This will create the key/value if it does not exist.

The key path can either be a "reg" style path (ex: HKLM\System or HKCU\Software) or PowerShell style (ex: HKLM:\System or HKCU:\Software).

Any errors writing the data will be returned.

Returns device.ErrNoWindows on non-Windows devices.

func SetExpandString

func SetExpandString(_, _, _ string) error

SetExpandString will attempt to set the data of the value in the supplied key path to the supplied string as a REG_EXPAND_SZ value type.

This will create the key/value if it does not exist.

The key path can either be a "reg" style path (ex: HKLM\System or HKCU\Software) or PowerShell style (ex: HKLM:\System or HKCU:\Software).

Any errors writing the data will be returned.

Returns device.ErrNoWindows on non-Windows devices.

func SetFromString

func SetFromString(_, _ string, _ uint32, _ string) error

SetFromString will attempt to set the data of the value in the supplied key path to the supplied value type indicated with the type flag and will interpret the supplied string using the type value to properly set the value data.

- Dword or Qword values will attempt to parse the string as a base10 integer that may be negative. - String and ExpandString values will be interrupted as is. - Binary will attempt to decode the value using the StdEncoding base64 decoder. - StringLists will be split using the NEWLINE ("\n") character into an array to be used.

This will create the key/value if it does not exist.

The key path can either be a "reg" style path (ex: HKLM\System or HKCU\Software) or PowerShell style (ex: HKLM:\System or HKCU:\Software).

Any errors writing the data will be returned.

Returns device.ErrNoWindows on non-Windows devices.

func SetQword

func SetQword(_, _ string, _ uint64) error

SetQword will attempt to set the data of the value in the supplied key path to the supplied uint64 integer as a REG_QWORD value type.

This will create the key/value if it does not exist.

The key path can either be a "reg" style path (ex: HKLM\System or HKCU\Software) or PowerShell style (ex: HKLM:\System or HKCU:\Software).

Any errors writing the data will be returned.

Returns device.ErrNoWindows on non-Windows devices.

func SetString

func SetString(_, _, _ string) error

SetString will attempt to set the data of the value in the supplied key path to the supplied string as a REG_SZ value type.

This will create the key/value if it does not exist.

The key path can either be a "reg" style path (ex: HKLM\System or HKCU\Software) or PowerShell style (ex: HKLM:\System or HKCU:\Software).

Any errors writing the data will be returned.

Returns device.ErrNoWindows on non-Windows devices.

func SetStrings

func SetStrings(_, _ string, _ []string) error

SetStrings will attempt to set the data of the value in the supplied key path to the supplied string list as a REG_MULTI_SZ value type.

This will create the key/value if it does not exist.

The key path can either be a "reg" style path (ex: HKLM\System or HKCU\Software) or PowerShell style (ex: HKLM:\System or HKCU:\Software).

Any errors writing the data will be returned.

Returns device.ErrNoWindows on non-Windows devices.

Types

type Entry

type Entry struct {
	Name string
	Data []byte
	Type uint32
}

Entry represents a Windows registry entry.

This may represent a Key or a Value. Values will also include their data in the 'Data' byte array and can be translated using any of the 'To*' functions to get the data represented in its proper type cast.

func Dir

func Dir(_ string) ([]Entry, error)

Dir returns a list of registry entries for the supplied key or an error if the path does not exist.

The key path can either be a "reg" style path (ex: HKLM\System or HKCU\Software) or PowerShell style (ex: HKLM:\System or HKCU:\Software).

Returns device.ErrNoWindows on non-Windows devices.

func Get

func Get(_, _ string) (Entry, error)

Get returns a single registry entry for the supplied value name under the key path specified or an error if any of the paths do not exist.

The key path can either be a "reg" style path (ex: HKLM\System or HKCU\Software) or PowerShell style (ex: HKLM:\System or HKCU:\Software).

Returns device.ErrNoWindows on non-Windows devices.

func (Entry) IsKey

func (e Entry) IsKey() bool

IsKey returns true if this entry represents a SubKey.

func (Entry) IsZero

func (e Entry) IsZero() bool

IsZero returns true if this entry is an invalid Entry.

func (Entry) MarshalStream

func (e Entry) MarshalStream(w data.Writer) error

MarshalStream writes the data for this Entry to the supplied Writer.

func (Entry) String

func (e Entry) String() string

String returns the string representation of the data held in the Data buffer. Invalid values of keys return an empty string.

func (Entry) ToBinary

func (e Entry) ToBinary() ([]byte, error)

ToBinary will attempt to return the data in the Data buffer as a binary array.

This function returns an error if conversion fails or the specified type is not a BINARY type.

func (Entry) ToInteger

func (e Entry) ToInteger() (uint64, error)

ToInteger will attempt to return the data in the Data buffer as an unsigned integer.

This function returns an error if conversion fails or the specified type is not a DWORD or QWORD type.

func (Entry) ToString

func (e Entry) ToString() (string, error)

ToString will attempt to return the data in the Data buffer as a string.

This function returns an error if conversion fails or the specified type is not a STRING or EXPAND_STRING type.

func (Entry) ToStringList

func (e Entry) ToStringList() ([]string, error)

ToStringList will attempt to return the data in the Data buffer as a string array.

This function returns an error if conversion fails or the specified type is not a MULTI_STRING type.

func (Entry) TypeName

func (e Entry) TypeName() string

TypeName returns a string representation of the Type value, which represents the value data type.

func (*Entry) UnmarshalStream

func (e *Entry) UnmarshalStream(r data.Reader) error

UnmarshalStream reads the data for this Entry from the supplied Reader.

Jump to

Keyboard shortcuts

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