value

package
v0.0.0-...-697c72d Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsDosTimeDate

func AsDosTimeDate(v uint32) time.Time

func AsFileTime

func AsFileTime(b []byte) time.Time

func AsInt64

func AsInt64(kind string, b []byte) int64

decodes value in network byte order (big) to signed integer

func AsUint64

func AsUint64(kind string, b []byte) uint64

decodes value in network byte order (big) to unsigned integer

func AsUint64Raw

func AsUint64Raw(b []byte) (v uint64)

decodes value in network byte order (big) to unsigned integer

func AsciiPrintableString

func AsciiPrintableString(b []byte, maxLength int) (string, uint64)

ascii text encoding (non-printable is replaced by "·") returns decoded string and length in bytes

func AsciiZString

func AsciiZString(b []byte, maxLength int) (string, uint64)

ascii text encoding (00-terminated) returns decoded string and length in bytes

func ParseHexString

func ParseHexString(in string) ([]byte, error)

parses a textual representation of data into a byte array

func ParseHexStringToUint64

func ParseHexStringToUint64(in string) (uint64, error)

func ReverseBytes

func ReverseBytes(b []byte, unitLength int) []byte

reverse byte order in groups of `unitLength` to handle u16/u32 ordering

func ShiftJISString

func ShiftJISString(b []byte) string

decodes ShiftJIS into a utf8 string

func SingleUnitSize

func SingleUnitSize(kind string) int64

func U64toBytesBigEndian

func U64toBytesBigEndian(val uint64, unitSize uint64) []byte

func Utf16String

func Utf16String(b []byte) string

text encoding used by Windows

func Utf16zString

func Utf16zString(b []byte) string

text encoding used by Windows (00 00-terminated)

func Utf8zString

func Utf8zString(b []byte) string

text encoding used by Windows (00 00-terminated)

Types

type DataField

type DataField struct {
	// data type: u8, ascii etc
	Kind string

	// ranged value if set. data field is type Kind[Length] or Kind[Start:Length]
	Range string

	// XXX make this unexported
	RangeVal int64

	// a slice type if true. data field is type Kind[]
	Slice bool

	// field label
	Label string

	// tracks the index of this DataField in it's parent array
	Index int

	// if set, endianness override for this field
	Endian string
}

a parsed data field

func ParseDataField

func ParseDataField(in string) (DataField, error)

func (*DataField) IsPatternableUnit

func (df *DataField) IsPatternableUnit() bool

returns true if unit is a single u8, u16, u32 or u64 that can have eq/bit field as child

func (*DataField) IsSimpleUnit

func (df *DataField) IsSimpleUnit() bool

returns true if unit is a single u8, u16, u32 or u64 that can be used in IF statements

func (*DataField) SingleUnitSize

func (df *DataField) SingleUnitSize() int64

type DataPattern

type DataPattern struct {
	// if false, data value was described as "??"
	Known bool

	// if true, holds the expected pattern
	Pattern []byte

	// holds the value (for custom values like in "endian: big")
	Value string
}

func ParseDataPattern

func ParseDataPattern(in string) (DataPattern, error)

parses a "structs" data value (used by structs parser)

type DosDate

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

MS-DOS 16-bit "dos date" value. Identical to the Date-part of a 32-Bit Windows Time+Date field

func AsDosDate

func AsDosDate(v uint16) DosDate

func (DosDate) String

func (dt DosDate) String() string

type DosTime

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

MS-DOS 16-bit "dos time" value Identical to the Time-part of a 32-Bit Windows Time+Date field

func AsDosTime

func AsDosTime(v uint16) DosTime

func (DosTime) String

func (dt DosTime) String() string

type MatchedPattern

type MatchedPattern struct {
	Label string

	// for debugging
	Operation string

	// parsed value of bit field
	Value []byte

	// parsed value for display
	Parsed string

	// size of bitfield, in bits
	Size int8

	// index bit
	Index int8
}

A match for values of a fileField. Based on template.MatchPattern data from file template.

Jump to

Keyboard shortcuts

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