lnkfile

package module
v0.0.0-...-1b650e6 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2025 License: MIT Imports: 13 Imported by: 0

README

lnkfile

A Go library for parsing Windows .lnk (shortcut) files.

Documentation

Index

Constants

View Source
const (
	TrackerDataBlockV1       = 0x00000000
	TrackerDataBlockV1Length = 0x00000058
)
View Source
const (
	LinkInfoHeaderSize         = 0x1c
	LinkInfoHeaderExtendedSize = 0x24
)
View Source
const (
	MaxSectionSize = 0x7ffff
)

Variables

View Source
var (
	ErrNoExtraDataBlock = errors.New("no extra data block found")
	ErrTooBig           = errors.New("data block is too big")
)
View Source
var (
	LinkCLSID = PlatformGUID{
		Data1: 0x00021401,
		Data2: 0x0000,
		Data3: 0x0000,
		Data4: [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46},
	}
)

Functions

func ReadFile

func ReadFile(filename string, out *LnkFile) error

ReadFile reads a lnk file into an LnkFile struct.

Types

type ConsoleDataBlock

type ConsoleDataBlock struct {
	Header ExtraDataBlockHead

	FillAttributes      uint16
	PopupFillAttributes uint16
	ScreenBufferSizeX   uint16
	ScreenBufferSizeY   uint16
	WindowSizeX         uint16
	WindowSizeY         uint16
	WindowOriginX       uint16
	WindowOriginY       uint16

	Unused1 uint32
	Unused2 uint32

	FontSize   uint32
	FontFamily TextFontFamily
	FontWeight uint32
	FaceName   PlatformString

	CursorSize             uint32
	FullScreen             uint32
	QuickEdit              uint32
	InsertMode             uint32
	AutoPosition           uint32
	HistoryBufferSize      uint32
	NumberOfHistoryBuffers uint32
	HistoryNoDup           uint32

	ColorTable [16]uint32
}

ConsoleDataBlock represents a console data block in the LNK file.

func (*ConsoleDataBlock) ReadFrom

func (blk *ConsoleDataBlock) ReadFrom(rd io.Reader) (n int64, err error)

type ConsoleFEDataBlock

type ConsoleFEDataBlock struct {
	Header ExtraDataBlockHead

	CodePage uint32
}

ConsoleFEDataBlock represents a console fe data block in the LNK file.

func (*ConsoleFEDataBlock) ReadFrom

func (blk *ConsoleFEDataBlock) ReadFrom(rd io.Reader) (n int64, err error)

type Decoder

type Decoder interface {
	// Decode converts the given encoded bytes to UTF-8.
	// Returns the converted bytes or nil and err if any error occurred.
	Decode(b []byte) (string, error)
}

type DriveType

type DriveType uint32

DriveType specifies the type of drive the link target is stored on.

const (
	DriveTypeUnknown DriveType = iota
	DriveTypeNoRootDir
	DriveTypeRemovable
	DriveTypeFixed
	DriveTypeRemote
	DriveTypeCDROM
	DriveTypeRAMDisk
)

func (DriveType) String

func (i DriveType) String() string

type Encoder

type Encoder interface {
	// Encode converts the given UTF-8 string to bytes.
	// Returns the converted bytes or nil and err if any error occurred.
	Encode(s string) ([]byte, error)
}

type Encoding

type Encoding interface {
	// NewDecoder returns a Decoder.
	NewDecoder() Decoder

	// NewEncoder returns an Encoder.
	NewEncoder() Encoder
}

type EnvironmentVariableDataBlock

type EnvironmentVariableDataBlock struct {
	Encoding Encoding

	Header ExtraDataBlockHead

	Target PlatformString
}

func (*EnvironmentVariableDataBlock) ReadFrom

func (blk *EnvironmentVariableDataBlock) ReadFrom(rd io.Reader) (n int64, err error)

ReadFrom implements the io.ReaderFrom interface.

type ExtraDataBlock

type ExtraDataBlock interface {
	// contains filtered or unexported methods
}

ExtraDataBlock represents an extra data block in the LNK file.

type ExtraDataBlockHead

type ExtraDataBlockHead struct {
	// Size of the extra data block in bytes.
	Size uint32

	// Signature of the extra data block.
	Signature ExtraDataSignature
}

ExtraDataBlockHead represents the header of an extra data block in the LNK file.

func (*ExtraDataBlockHead) ReadFrom

func (e *ExtraDataBlockHead) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom implements the io.ReaderFrom interface.

type ExtraDataSection

type ExtraDataSection struct {
	Encoding Encoding

	// Blocks hold the extra data blocks.
	Blocks []ExtraDataBlock
}

func (*ExtraDataSection) ReadFrom

func (s *ExtraDataSection) ReadFrom(rd io.Reader) (n int64, err error)

ReadFrom implements the io.ReaderFrom interface.

type ExtraDataSignature

type ExtraDataSignature uint32
const (
	Console       ExtraDataSignature = 0xA0000002
	ConsoleFE     ExtraDataSignature = 0xA0000004
	Darwin        ExtraDataSignature = 0xA0000006
	EnvVar        ExtraDataSignature = 0xA0000001
	IconEnv       ExtraDataSignature = 0xA0000007
	KnownFolder   ExtraDataSignature = 0xA000000B
	PropertyStore ExtraDataSignature = 0xA0000009
	ShimSignature ExtraDataSignature = 0xA0000008
	SpecialFolder ExtraDataSignature = 0xA0000005
	Tracker       ExtraDataSignature = 0xA0000003
	VistaIDList   ExtraDataSignature = 0xA000000C
)

func (ExtraDataSignature) String

func (i ExtraDataSignature) String() string

type FileAttrs

type FileAttrs uint32

FileAttrs represents the file attributes in the lnk header.

const (
	FileAttrReadOnly          FileAttrs = 0x00000001
	FileAttrHidden            FileAttrs = 0x00000002
	FileAttrSystem            FileAttrs = 0x00000004
	FileAttrDirectory         FileAttrs = 0x00000010
	FileAttrArchive           FileAttrs = 0x00000020
	FileAttrNormal            FileAttrs = 0x00000080
	FileAttrTemporary         FileAttrs = 0x00000100
	FileAttrSparseFile        FileAttrs = 0x00000200
	FileAttrReparsePoint      FileAttrs = 0x00000400
	FileAttrCompressed        FileAttrs = 0x00000800
	FileAttrOffline           FileAttrs = 0x00001000
	FileAttrNotContentIndexed FileAttrs = 0x00002000
	FileAttrEncrypted         FileAttrs = 0x00004000
)

func (FileAttrs) ActiveFlags

func (i FileAttrs) ActiveFlags() []string

func (FileAttrs) String

func (i FileAttrs) String() string

type FileHeader

type FileHeader struct {
	// HeaderSize is the size of the header in bytes.
	HeaderSize uint32

	// CLSID is the CLSID identifying the file as a shell link, must be 00021401-0000-0000-C000-000000000046.
	CLSID PlatformGUID

	// Flags is the flags in the lnk header.
	Flags LinkFlags

	// FileAttributes is the file attributes of the link target.
	FileAttributes FileAttrs

	// CreationTime is the time the link target was created.
	CreationTime PlatformTime

	// AccessTime is the time the link target was last accessed.
	AccessTime PlatformTime

	// WriteTime is the time the link target was last written to.
	WriteTime PlatformTime

	// FileSize is the size of the link target file. If larger than capacity, it will have the LSB 32-bits of size.
	FileSize uint32

	// IconIndex is the index of the icon in the icon location.
	IconIndex int32

	// ShowCommand is the expected window state of the target after execution.
	ShowCommand ShowCommand

	// HotKey is the hotkey to open the target.
	HotKey uint16
}

FileHeader represents the lnk header.

func (*FileHeader) ReadFrom

func (s *FileHeader) ReadFrom(rrd io.Reader) (n int64, err error)

type IDList

type IDList struct {
	// ItemIDList contains the IDLists.
	ItemIDList []ItemID
}

IDList represents a persisted item ID list.

func (*IDList) ReadFrom

func (il *IDList) ReadFrom(rdd io.Reader) (n int64, err error)

ReadFrom reads the IDList from the given io.Reader.

type IconEnvironmentDataBlock

type IconEnvironmentDataBlock struct {
	Encoding Encoding

	Header ExtraDataBlockHead

	// Target the link target using environment variable substitution.
	Target PlatformString
}

func (*IconEnvironmentDataBlock) ReadFrom

func (blk *IconEnvironmentDataBlock) ReadFrom(rd io.Reader) (n int64, err error)

ReadFrom implements the io.ReaderFrom interface.

type ItemID

type ItemID struct {
	// Size describes the length of the ItemID structure in bytes including the size field.
	Size uint16

	// Data is the source-defined data that specifies an item.
	Data []byte
}

ItemID is an element in IDList.

func (*ItemID) ReadFrom

func (id *ItemID) ReadFrom(rd io.Reader) (n int64, err error)

ReadFrom reads the ItemID from the given io.Reader.

type LinkFlags

type LinkFlags uint32

LinkFlags represents the flags in the lnk header.

const (
	LinkFlagHasLinkTargetIDList         LinkFlags = 0x00000001
	LinkFlagHasLinkInfo                 LinkFlags = 0x00000002
	LinkFlagHasName                     LinkFlags = 0x00000004
	LinkFlagHasRelativePath             LinkFlags = 0x00000008
	LinkFlagHasWorkingDir               LinkFlags = 0x00000010
	LinkFlagHasArguments                LinkFlags = 0x00000020
	LinkFlagHasIconLocation             LinkFlags = 0x00000040
	LinkFlagIsUnicode                   LinkFlags = 0x00000080
	LinkFlagForceNoLinkInfo             LinkFlags = 0x00000100
	LinkFlagHasExpString                LinkFlags = 0x00000200
	LinkFlagRunInSeparateProcess        LinkFlags = 0x00000400
	LinkFlagHasDarwinID                 LinkFlags = 0x00001000
	LinkFlagRunAsUser                   LinkFlags = 0x00002000
	LinkFlagHasExpIconLocation          LinkFlags = 0x00004000
	LinkFlagNoPIDLAlias                 LinkFlags = 0x00008000
	LinkFlagRunWithShimLayer            LinkFlags = 0x00020000
	LinkFlagForceNoLinkTrack            LinkFlags = 0x00040000
	LinkFlagEnableTargetMetadata        LinkFlags = 0x00080000
	LinkFlagDisableLinkPathTracking     LinkFlags = 0x00100000
	LinkFlagDisableKnownFolderTracking  LinkFlags = 0x00200000
	LinkFlagDisableKnownFolderAlias     LinkFlags = 0x00400000
	LinkFlagAllowLinkToLink             LinkFlags = 0x00800000
	LinkFlagUnaliasOnSave               LinkFlags = 0x01000000
	LinkFlagPreferEnvironmentPath       LinkFlags = 0x02000000
	LinkFlagKeepLocalIDListForUNCTarget LinkFlags = 0x04000000
)

func (LinkFlags) ActiveFlags

func (i LinkFlags) ActiveFlags() []string
func (i LinkFlags) AllowLinkToLink() bool
func (i LinkFlags) ClearAllowLinkToLink() LinkFlags

func (LinkFlags) ClearDisableKnownFolderAlias

func (i LinkFlags) ClearDisableKnownFolderAlias() LinkFlags

func (LinkFlags) ClearDisableKnownFolderTracking

func (i LinkFlags) ClearDisableKnownFolderTracking() LinkFlags

func (LinkFlags) ClearDisableLinkPathTracking

func (i LinkFlags) ClearDisableLinkPathTracking() LinkFlags

func (LinkFlags) ClearEnableTargetMetadata

func (i LinkFlags) ClearEnableTargetMetadata() LinkFlags

func (LinkFlags) ClearForceNoLinkInfo

func (i LinkFlags) ClearForceNoLinkInfo() LinkFlags

func (LinkFlags) ClearForceNoLinkTrack

func (i LinkFlags) ClearForceNoLinkTrack() LinkFlags

func (LinkFlags) ClearHasArguments

func (i LinkFlags) ClearHasArguments() LinkFlags

func (LinkFlags) ClearHasDarwinID

func (i LinkFlags) ClearHasDarwinID() LinkFlags

func (LinkFlags) ClearHasExpIconLocation

func (i LinkFlags) ClearHasExpIconLocation() LinkFlags

func (LinkFlags) ClearHasExpString

func (i LinkFlags) ClearHasExpString() LinkFlags

func (LinkFlags) ClearHasIconLocation

func (i LinkFlags) ClearHasIconLocation() LinkFlags

func (LinkFlags) ClearHasLinkInfo

func (i LinkFlags) ClearHasLinkInfo() LinkFlags

func (LinkFlags) ClearHasLinkTargetIDList

func (i LinkFlags) ClearHasLinkTargetIDList() LinkFlags

func (LinkFlags) ClearHasName

func (i LinkFlags) ClearHasName() LinkFlags

func (LinkFlags) ClearHasRelativePath

func (i LinkFlags) ClearHasRelativePath() LinkFlags

func (LinkFlags) ClearHasWorkingDir

func (i LinkFlags) ClearHasWorkingDir() LinkFlags

func (LinkFlags) ClearIsUnicode

func (i LinkFlags) ClearIsUnicode() LinkFlags

func (LinkFlags) ClearKeepLocalIDListForUNCTarget

func (i LinkFlags) ClearKeepLocalIDListForUNCTarget() LinkFlags

func (LinkFlags) ClearNoPIDLAlias

func (i LinkFlags) ClearNoPIDLAlias() LinkFlags

func (LinkFlags) ClearPreferEnvironmentPath

func (i LinkFlags) ClearPreferEnvironmentPath() LinkFlags

func (LinkFlags) ClearRunAsUser

func (i LinkFlags) ClearRunAsUser() LinkFlags

func (LinkFlags) ClearRunInSeparateProcess

func (i LinkFlags) ClearRunInSeparateProcess() LinkFlags

func (LinkFlags) ClearRunWithShimLayer

func (i LinkFlags) ClearRunWithShimLayer() LinkFlags

func (LinkFlags) ClearUnaliasOnSave

func (i LinkFlags) ClearUnaliasOnSave() LinkFlags

func (LinkFlags) DisableKnownFolderAlias

func (i LinkFlags) DisableKnownFolderAlias() bool

func (LinkFlags) DisableKnownFolderTracking

func (i LinkFlags) DisableKnownFolderTracking() bool

func (LinkFlags) DisableLinkPathTracking

func (i LinkFlags) DisableLinkPathTracking() bool

func (LinkFlags) EnableTargetMetadata

func (i LinkFlags) EnableTargetMetadata() bool

func (LinkFlags) ForceNoLinkInfo

func (i LinkFlags) ForceNoLinkInfo() bool

func (LinkFlags) ForceNoLinkTrack

func (i LinkFlags) ForceNoLinkTrack() bool

func (LinkFlags) HasArguments

func (i LinkFlags) HasArguments() bool

func (LinkFlags) HasDarwinID

func (i LinkFlags) HasDarwinID() bool

func (LinkFlags) HasExpIconLocation

func (i LinkFlags) HasExpIconLocation() bool

func (LinkFlags) HasExpString

func (i LinkFlags) HasExpString() bool

func (LinkFlags) HasIconLocation

func (i LinkFlags) HasIconLocation() bool

func (LinkFlags) HasLinkInfo

func (i LinkFlags) HasLinkInfo() bool

func (LinkFlags) HasLinkTargetIDList

func (i LinkFlags) HasLinkTargetIDList() bool

func (LinkFlags) HasName

func (i LinkFlags) HasName() bool

func (LinkFlags) HasRelativePath

func (i LinkFlags) HasRelativePath() bool

func (LinkFlags) HasWorkingDir

func (i LinkFlags) HasWorkingDir() bool

func (LinkFlags) IsUnicode

func (i LinkFlags) IsUnicode() bool

func (LinkFlags) KeepLocalIDListForUNCTarget

func (i LinkFlags) KeepLocalIDListForUNCTarget() bool

func (LinkFlags) NoPIDLAlias

func (i LinkFlags) NoPIDLAlias() bool

func (LinkFlags) PreferEnvironmentPath

func (i LinkFlags) PreferEnvironmentPath() bool

func (LinkFlags) RunAsUser

func (i LinkFlags) RunAsUser() bool

func (LinkFlags) RunInSeparateProcess

func (i LinkFlags) RunInSeparateProcess() bool

func (LinkFlags) RunWithShimLayer

func (i LinkFlags) RunWithShimLayer() bool
func (i LinkFlags) SetAllowLinkToLink() LinkFlags

func (LinkFlags) SetDisableKnownFolderAlias

func (i LinkFlags) SetDisableKnownFolderAlias() LinkFlags

func (LinkFlags) SetDisableKnownFolderTracking

func (i LinkFlags) SetDisableKnownFolderTracking() LinkFlags

func (LinkFlags) SetDisableLinkPathTracking

func (i LinkFlags) SetDisableLinkPathTracking() LinkFlags

func (LinkFlags) SetEnableTargetMetadata

func (i LinkFlags) SetEnableTargetMetadata() LinkFlags

func (LinkFlags) SetForceNoLinkInfo

func (i LinkFlags) SetForceNoLinkInfo() LinkFlags

func (LinkFlags) SetForceNoLinkTrack

func (i LinkFlags) SetForceNoLinkTrack() LinkFlags

func (LinkFlags) SetHasArguments

func (i LinkFlags) SetHasArguments() LinkFlags

func (LinkFlags) SetHasDarwinID

func (i LinkFlags) SetHasDarwinID() LinkFlags

func (LinkFlags) SetHasExpIconLocation

func (i LinkFlags) SetHasExpIconLocation() LinkFlags

func (LinkFlags) SetHasExpString

func (i LinkFlags) SetHasExpString() LinkFlags

func (LinkFlags) SetHasIconLocation

func (i LinkFlags) SetHasIconLocation() LinkFlags

func (LinkFlags) SetHasLinkInfo

func (i LinkFlags) SetHasLinkInfo() LinkFlags

func (LinkFlags) SetHasLinkTargetIDList

func (i LinkFlags) SetHasLinkTargetIDList() LinkFlags

func (LinkFlags) SetHasName

func (i LinkFlags) SetHasName() LinkFlags

func (LinkFlags) SetHasRelativePath

func (i LinkFlags) SetHasRelativePath() LinkFlags

func (LinkFlags) SetHasWorkingDir

func (i LinkFlags) SetHasWorkingDir() LinkFlags

func (LinkFlags) SetIsUnicode

func (i LinkFlags) SetIsUnicode() LinkFlags

func (LinkFlags) SetKeepLocalIDListForUNCTarget

func (i LinkFlags) SetKeepLocalIDListForUNCTarget() LinkFlags

func (LinkFlags) SetNoPIDLAlias

func (i LinkFlags) SetNoPIDLAlias() LinkFlags

func (LinkFlags) SetPreferEnvironmentPath

func (i LinkFlags) SetPreferEnvironmentPath() LinkFlags

func (LinkFlags) SetRunAsUser

func (i LinkFlags) SetRunAsUser() LinkFlags

func (LinkFlags) SetRunInSeparateProcess

func (i LinkFlags) SetRunInSeparateProcess() LinkFlags

func (LinkFlags) SetRunWithShimLayer

func (i LinkFlags) SetRunWithShimLayer() LinkFlags

func (LinkFlags) SetUnaliasOnSave

func (i LinkFlags) SetUnaliasOnSave() LinkFlags

func (LinkFlags) String

func (i LinkFlags) String() string

func (LinkFlags) UnaliasOnSave

func (i LinkFlags) UnaliasOnSave() bool

type LinkInfoFlags

type LinkInfoFlags uint32

LinkInfoFlags represents the flags in the LinkInfo section.

const (
	LinkInfoFlagVolumeIDAndLocalBasePath  LinkInfoFlags = 0x00000001
	LinkInfoFlagCommonNetworkRelativeLink LinkInfoFlags = 0x00000002
)

func (LinkInfoFlags) ActiveFlags

func (i LinkInfoFlags) ActiveFlags() []string

func (LinkInfoFlags) String

func (i LinkInfoFlags) String() string

type LinkInfoHeader

type LinkInfoHeader struct {
	// SectionSize specifies the length of the LinkInfo field in bytes,
	// including the size field.
	SectionSize uint32

	// HeaderSize specifies the length of the LinkInfo header in bytes.
	HeaderSize uint32

	// Flags specify the flags in the LinkInfo section.
	Flags LinkInfoFlags

	// VolumeIDOffset specifies the offset of the VolumeID field
	// in bytes from the start of the LinkInfo section.
	VolumeIDOffset uint32

	// LocalBasePathOffset specifies the offset of the
	// LocalBasePath field in bytes from the start of the
	// LinkInfoSection structure.
	LocalBasePathOffset uint32

	// CommonNetworkRelativeLinkOffset specifies the offset of the
	// CommonNetworkRelativeLink field in bytes from the start of
	// the LinkInfo section.
	CommonNetworkRelativeLinkOffset uint32

	// CommonPathSuffixOffset specifies the offset of the
	// CommonPathSuffix field in bytes from the start of the
	// LinkInfo section.
	CommonPathSuffixOffset uint32

	// LocalBasePathOffsetUnicode specifies the location of the
	// LocalBasePathUnicode field. If the
	// LinkInfoFlagVolumeIDAndLocalBasePath flag is set, this value
	// is an offset, in bytes, from the start of the
	// LinkInfoSection structure; otherwise, this value MUST be
	// zero.
	//
	// This field is present only if the value of the
	// HeaderSize field is greater than or equal to 0x00000024.
	LocalBasePathOffsetUnicode *uint32

	// CommonPathSuffixOffsetUnicode specifies the location of the
	// CommonPathSuffixUnicode field. This value is an offset, in
	// bytes, from the start of the LinkInfoSection structure.
	//
	// This field is present only if the value of the
	// HeaderSize field is greater than or equal to 0x00000024.
	CommonPathSuffixOffsetUnicode *uint32
}

func (*LinkInfoHeader) ReadFrom

func (h *LinkInfoHeader) ReadFrom(rd io.Reader) (n int64, err error)

ReadFrom reads the LinkInfoHeader from the given io.Reader.

type LinkInfoSection

type LinkInfoSection struct {
	// Encoding specifies the character encoding used within
	// the LinkInfoSection structure.
	Encoding Encoding

	Header LinkInfoHeader

	// VolumeID specifies an optional VolumeIDSection structure that
	// specifies information about the volume that the link target
	// was on when the link was created.
	//
	// This field is present if the
	// LinkInfoFlagVolumeIDAndLocalBasePath flag is set.
	VolumeID *VolumeIDSection

	// LocalBasePath specifies an optional string, defined by the
	// system default code page, which is used to construct the
	// full path to the link item or link target by appending the
	// string in the CommonPathSuffix field.
	//
	// This field is present if the
	// LinkInfoFlagVolumeIDAndLocalBasePath flag is set.
	LocalBasePath *PlatformString

	// CommonNetworkRelativeLink specifies an optional
	// NetworkLocationSection structure that specifies
	// information about the network location where the link
	// target is stored.
	CommonNetworkRelativeLink *NetworkLocationSection

	// CommonPathSuffix is used to construct the full path to the
	// link item or link target by being appended to the string in
	// the LocalBasePath field.
	CommonPathSuffix *PlatformString
}

func (*LinkInfoSection) ReadFrom

func (s *LinkInfoSection) ReadFrom(rrd io.Reader) (n int64, err error)

type LinkTargetIDListSection

type LinkTargetIDListSection struct {
	// Size describes the length of the IDList field in bytes.
	Size uint16

	// ItemIDList contains the item ID list.
	ItemIDList IDList
}

func (*LinkTargetIDListSection) ReadFrom

func (s *LinkTargetIDListSection) ReadFrom(rd io.Reader) (n int64, err error)

ReadFrom reads the LinkTargetIDListSection from the given io.Reader.

type LnkFile

type LnkFile struct {
	// Encoding specifies the character encoding used within the LnkFile, enabling encoding and decoding operations.
	Encoding Encoding

	// Header represents the FileHeader containing metadata and configuration for the shortcut file.
	Header FileHeader

	// TargetIDList specifies the TargetIDList section.
	TargetIDList *LinkTargetIDListSection

	// LinkInfo specifies the LinkInfo section.
	LinkInfo *LinkInfoSection

	Name         *PlatformString
	RelativePath *PlatformString
	WorkingDir   *PlatformString
	Arguments    *PlatformString
	IconLocation *PlatformString

	ExtraData ExtraDataSection
}

LnkFile represents one lnk file.

func (*LnkFile) ReadFrom

func (l *LnkFile) ReadFrom(rd io.Reader) (n int64, err error)

type NetworkLocationFlags

type NetworkLocationFlags uint32
const (
	NetworkLocationFlagValidDevice  NetworkLocationFlags = 0x00000001
	NetworkLocationFlagValidNetType NetworkLocationFlags = 0x00000002
)

type NetworkLocationHeader

type NetworkLocationHeader struct {
	// SectionSize specifies the size, in bytes, of the
	// [NetworkLocationSection] structure. This value
	// MUST be greater than or equal to 0x00000014. All offsets
	// specified in this structure MUST be less than this value,
	// and all strings contained in this structure MUST fit within
	// the extent defined by this size.
	SectionSize uint32

	// Flags specify the contents of the
	// DeviceNameOffset and NetProviderType fields.
	Flags NetworkLocationFlags

	// NetNameOffset specifies the location of the NetName
	// field. This value is an offset, in bytes, from the start of
	// the [NetworkLocationSection] structure.
	NetNameOffset uint32

	// DeviceNameOffset specifies the location of the DeviceName
	// field. If the ValidDevice flag is set, this value is an
	// offset, in bytes, from the start of the
	// [NetworkLocationSection] structure; otherwise,
	// this value MUST be zero.
	DeviceNameOffset uint32

	// NetworkProviderType specifies the type of network provider.
	// If the ValidNetType flag is set, this value MUST be one of
	// [NetworkProviderType]; otherwise, this value MUST be ignored.
	NetworkProviderType NetworkProviderType

	// NetNameOffsetUnicode specifies the location of the
	// NetNameUnicode field. This value is an offset, in bytes,
	// from the start of the [NetworkLocationSection]
	// structure.
	//
	// This field MUST be present if the value of the
	// NetNameOffset field is greater than 0x00000014; otherwise,
	// this field MUST NOT be present.
	NetNameOffsetUnicode *uint32

	// DeviceNameOffsetUnicode specifies the location of
	// the DeviceNameUnicode field. This value is an offset, in bytes,
	// from the start of the CommonNetworkRelativeLink structure.
	//
	// This field MUST be present if the value of the
	// NetNameOffset field is greater than 0x00000014; otherwise,
	// this field MUST NOT be present.
	DeviceNameOffsetUnicode *uint32
}

NetworkLocationHeader represents a header describing network-relative link data.

func (*NetworkLocationHeader) ReadFrom

func (h *NetworkLocationHeader) ReadFrom(rd io.Reader) (n int64, err error)

type NetworkLocationSection

type NetworkLocationSection struct {
	Encoding Encoding

	// Header specifies the NetworkLocationHeader structure describing properties of network-relative link data.
	Header NetworkLocationHeader

	// NetName a NULL–terminated string, as defined by the system
	// default code page, which specifies a server share path; for
	// example, "\\server\share".
	NetName *PlatformString

	// DeviceName a NULL–terminated string, as defined by the system
	// default code page, which specifies a device; for example, the
	// drive letter "D:".
	DeviceName *PlatformString
}

func (*NetworkLocationSection) ReadFrom

func (s *NetworkLocationSection) ReadFrom(rd io.Reader) (n int64, err error)

type NetworkProviderType

type NetworkProviderType uint32
const (
	NetworkProviderTypeAVID        NetworkProviderType = 0x001A0000
	NetworkProviderTypeDOCUSPACE   NetworkProviderType = 0x001B0000
	NetworkProviderTypeMANGOSOFT   NetworkProviderType = 0x001C0000
	NetworkProviderTypeSERNET      NetworkProviderType = 0x001D0000
	NetworkProviderTypeRIVERFRONT1 NetworkProviderType = 0x001E0000
	NetworkProviderTypeRIVERFRONT2 NetworkProviderType = 0x001F0000
	NetworkProviderTypeDECORB      NetworkProviderType = 0x00200000
	NetworkProviderTypePROTSTOR    NetworkProviderType = 0x00210000
	NetworkProviderTypeFJREDIR     NetworkProviderType = 0x00220000
	NetworkProviderTypeDISTINCT    NetworkProviderType = 0x00230000
	NetworkProviderTypeTWINS       NetworkProviderType = 0x00240000
	NetworkProviderTypeRDR2SAMPLE  NetworkProviderType = 0x00250000
	NetworkProviderTypeCSCSAMPLE   NetworkProviderType = 0x00260000
	NetworkProviderType3IN1        NetworkProviderType = 0x00270000
	NetworkProviderTypeEXTENDNET   NetworkProviderType = 0x00290000
	NetworkProviderTypeSTACNET     NetworkProviderType = 0x002A0000
	NetworkProviderTypeFOXBAT      NetworkProviderType = 0x002B0000
	NetworkProviderTypeYAHOO       NetworkProviderType = 0x002C0000
	NetworkProviderTypeEXIFST      NetworkProviderType = 0x002D0000
	NetworkProviderTypeDAV         NetworkProviderType = 0x002E0000
	NetworkProviderTypeKNOWARE     NetworkProviderType = 0x002F0000
	NetworkProviderTypeOBJECTDIRE  NetworkProviderType = 0x00300000
	NetworkProviderTypeMASFAX      NetworkProviderType = 0x00310000
	NetworkProviderTypeHOBNFS      NetworkProviderType = 0x00320000
	NetworkProviderTypeSHIVA       NetworkProviderType = 0x00330000
	NetworkProviderTypeIBMAL       NetworkProviderType = 0x00340000
	NetworkProviderTypeLOCKNET     NetworkProviderType = 0x00350000
	NetworkProviderTypeTERMSRV     NetworkProviderType = 0x00360000
	NetworkProviderTypeSRT         NetworkProviderType = 0x00370000
	NetworkProviderTypeQUINCY      NetworkProviderType = 0x00380000
	NetworkProviderTypeOPENAFS     NetworkProviderType = 0x00390000
	NetworkProviderTypeAVID1       NetworkProviderType = 0x003A0000
	NetworkProviderTypeDFS         NetworkProviderType = 0x003B0000
	NetworkProviderTypeKWNP        NetworkProviderType = 0x003C0000
	NetworkProviderTypeZENWORKS    NetworkProviderType = 0x003D0000
	NetworkProviderTypeDRIVEONWEB  NetworkProviderType = 0x003E0000
	NetworkProviderTypeVMWARE      NetworkProviderType = 0x003F0000
	NetworkProviderTypeRSFX        NetworkProviderType = 0x00400000
	NetworkProviderTypeMFILES      NetworkProviderType = 0x00410000
	NetworkProviderTypeMSNFS       NetworkProviderType = 0x00420000
	NetworkProviderTypeGOOGLE      NetworkProviderType = 0x00430000
)

type PlatformGUID

type PlatformGUID struct {
	Data1 uint32
	Data2 uint16
	Data3 uint16
	Data4 [8]byte
}

PlatformGUID represents a Windows compatible GUID structure.

func (*PlatformGUID) MarshalText

func (g *PlatformGUID) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*PlatformGUID) ReadFrom

func (g *PlatformGUID) ReadFrom(rd io.Reader) (n int64, err error)

ReadFrom reads a PlatformGUID from the given io.Reader.

func (*PlatformGUID) String

func (g *PlatformGUID) String() string

type PlatformString

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

func (*PlatformString) HasNarrow

func (ps *PlatformString) HasNarrow() bool

func (*PlatformString) HasWideCharacter

func (ps *PlatformString) HasWideCharacter() bool

func (*PlatformString) IsNull

func (ps *PlatformString) IsNull() bool

func (*PlatformString) MarshalText

func (ps *PlatformString) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*PlatformString) String

func (ps *PlatformString) String() string

String implements the fmt.Stringer interface.

func (*PlatformString) Value

func (ps *PlatformString) Value() (string, error)

Value returns the string value.

type PlatformTime

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

PlatformTime represents a Windows FILETIME structure.

func (*PlatformTime) MarshalText

func (pt *PlatformTime) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*PlatformTime) ReadFrom

func (pt *PlatformTime) ReadFrom(rd io.Reader) (n int64, err error)

ReadFrom reads a FILETIME structure from the given io.Reader.

func (*PlatformTime) String

func (pt *PlatformTime) String() []byte

func (*PlatformTime) Time

func (pt *PlatformTime) Time() (t time.Time)

Time converts the PlatformTime to a time.Time object.

type ShowCommand

type ShowCommand uint32

ShowCommand represents the show command in the lnk header.

const (
	ShowCommandHide              ShowCommand = 0x00000000
	ShowCommandShowNormal        ShowCommand = 0x00000001
	ShowCommandShowMinimized     ShowCommand = 0x00000002
	ShowCommandShowMaximized     ShowCommand = 0x00000003
	ShowCommandShowNoActivate    ShowCommand = 0x00000004
	ShowCommandShow              ShowCommand = 0x00000005
	ShowCommandShowMinimize      ShowCommand = 0x00000006
	ShowCommandShowMinNoActive   ShowCommand = 0x00000007
	ShowCommandShowNA            ShowCommand = 0x00000008
	ShowCommandRestore           ShowCommand = 0x00000009
	ShowCommandShowDefault       ShowCommand = 0x0000000A
	ShowCommandShowForceMinimize ShowCommand = 0x0000000B
)

func (ShowCommand) String

func (i ShowCommand) String() string

type TextFontFamily

type TextFontFamily uint32
const (
	FontFamilyDontCare   TextFontFamily = 0x0000
	FontFamilyRoman      TextFontFamily = 0x0010
	FontFamilySwiss      TextFontFamily = 0x0020
	FontFamilyModern     TextFontFamily = 0x0030
	FontFamilyScript     TextFontFamily = 0x0040
	FontFamilyDecorative TextFontFamily = 0x0050
)

type TextFontPitch

type TextFontPitch uint32
const (
	PitchNone     TextFontPitch = 0x00
	PitchFixed    TextFontPitch = 0x01
	PitchVector   TextFontPitch = 0x02
	PitchTrueType TextFontPitch = 0x04
	PitchDevice   TextFontPitch = 0x08
)

type TrackerDataBlock

type TrackerDataBlock struct {
	Encoding Encoding

	Header ExtraDataBlockHead

	Length uint32

	Version uint32

	MachineID PlatformString

	VolumeDroid PlatformGUID
	FileDroid   PlatformGUID

	VolumeDroidBirth PlatformGUID
	FileDroidBirth   PlatformGUID
}

func (*TrackerDataBlock) ReadFrom

func (blk *TrackerDataBlock) ReadFrom(rd io.Reader) (n int64, err error)

ReadFrom implements the io.ReaderFrom interface.

type UTF8Encoding

type UTF8Encoding struct{}

func (UTF8Encoding) Decode

func (enc UTF8Encoding) Decode(b []byte) (string, error)

func (UTF8Encoding) Encode

func (enc UTF8Encoding) Encode(s string) ([]byte, error)

func (UTF8Encoding) NewDecoder

func (enc UTF8Encoding) NewDecoder() Decoder

func (UTF8Encoding) NewEncoder

func (enc UTF8Encoding) NewEncoder() Encoder

type UnknownBlock

type UnknownBlock struct {
	Header ExtraDataBlockHead
	Raw    []byte
}

UnknownBlock represents an unknown extra data block in the LNK file.

func (*UnknownBlock) ReadFrom

func (blk *UnknownBlock) ReadFrom(r io.Reader) (n int64, err error)

type VolumeIDHeader

type VolumeIDHeader struct {
	// SectionSize specifies the size, in bytes, of this section. This
	// value MUST be greater than 0x00000010. All offsets specified
	// in this structure MUST be less than this value, and all
	// strings contained in this structure MUST fit within the
	// extent defined by this size.
	SectionSize uint32

	// DriveType specifies the type of drive the link target is
	// stored on.
	DriveType DriveType

	// DriveSerialNumber specifies the drive serial number of
	// the volume the link target is stored on.
	DriveSerialNumber uint32

	// VolumeLabelOffset specifies the location of a string that
	// contains the volume label of the drive that the link target
	// is stored on. This value is an offset, in bytes, from the
	// start of the VolumeIDSection structure to a NULL-terminated
	// string of characters, defined by the system's default
	// code page. The volume label string is located in the Data
	// field of this structure.
	//
	// If the value of this field is 0x14, it MUST be ignored,
	// and the value of the VolumeLabelOffsetUnicode field MUST be
	// used to locate the volume label string.
	VolumeLabelOffset uint32

	// VolumeLabelOffsetUnicode specifies the location of a string
	// that contains the volume label of the drive that the
	// link target is stored on. This value is an offset, in bytes,
	// from the start of the [VolumeIDSection] structure to a
	// NULL-terminated string of Unicode characters. The volume
	// label string is located in the Data field of this structure.
	//
	// If the value of the VolumeLabelOffset field is not 0x00000014,
	// this field MUST NOT be present; instead, the value of the
	// VolumeLabelOffset field MUST be used to locate the volume
	// label string.
	VolumeLabelOffsetUnicode *uint32
}

func (*VolumeIDHeader) ReadFrom

func (h *VolumeIDHeader) ReadFrom(rd io.Reader) (n int64, err error)

ReadFrom reads the VolumeIDHeader from the given io.Reader.

type VolumeIDSection

type VolumeIDSection struct {
	// Encoding specifies the character encoding used within
	// the LinkInfoSection structure.
	Encoding Encoding

	// Header represents the VolumeIDHeader structure describing the section.
	Header VolumeIDHeader

	// VolumeLabel contains the volume label of the drive as a
	// string defined by the system default code page.
	VolumeLabel *PlatformString
}

VolumeIDSection specifies information about the volume that a link target was on when the link was created. This information is useful for resolving the link if the file is not found in its original location.

func (*VolumeIDSection) ReadFrom

func (s *VolumeIDSection) ReadFrom(rd io.Reader) (n int64, err error)

Jump to

Keyboard shortcuts

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