Documentation ¶
Index ¶
- Constants
- func HasSignatureInHeader(hdr []byte, pos int64, sig []byte) bool
- func ReadBytesFrom(file *os.File, pos int64, size int64) []byte
- func ReadBytesUntilNewline(file *os.File, pos int64) ([]byte, int64, error)
- func ReadToMap(file *os.File, dataType DataType, pos int64, i interface{}) (string, error)
- func ReadUint16be(file *os.File, pos int64) (uint16, error)
- func ReadUint16le(file *os.File, pos int64) (uint16, error)
- func ReadUint32be(file *os.File, pos int64) (uint32, error)
- func ReadUint32le(file *os.File, pos int64) (uint32, error)
- func ReadUint64be(file *os.File, pos int64) (uint64, error)
- func ReadUint8(file *os.File, pos int64) (uint8, error)
- func ReadUnsignedInt(file *os.File, field *Layout) uint32
- func ReadZeroTerminatedASCIIUntil(file *os.File, pos int64, maxLen int64) (string, int64, error)
- type BrowseMode
- type ByLayout
- type Checker
- type DataType
- type FileKind
- type HexFormatting
- type HexViewState
- type Layout
- type LineEnding
- type Mask
- type ParsedLayout
- func (pl *ParsedLayout) DecodeBitfieldFromInfo(file *os.File, info string) uint32
- func (pl *ParsedLayout) FullListing() string
- func (pl *ParsedLayout) GetASCII(file *os.File, hexView HexViewState) (string, error)
- func (pl *ParsedLayout) GetHex(file *os.File, hexView HexViewState) (string, error)
- func (pl *ParsedLayout) PercentMapped(totalSize int64) float64
- func (pl *ParsedLayout) PercentUnmapped(totalSize int64) float64
- func (pl *ParsedLayout) PrettyASCIIView(file *os.File, hexView HexViewState) string
- func (pl *ParsedLayout) PrettyHexView(file *os.File, hexView HexViewState) string
- func (pl *ParsedLayout) PrettyOffsetView(file *os.File, hexView HexViewState) string
- func (pl *ParsedLayout) PrettyPrint() string
- func (pl *ParsedLayout) ReadUint32leFromInfo(file *os.File, info string) (uint32, error)
- func (pl *ParsedLayout) ShortPrint() string
- func (pl *ParsedLayout) Sort()
- func (pl *ParsedLayout) TypeSummary() string
- type TextEncoding
Constants ¶
const ( Crlf = 1 + iota // windows Cr // old mac os Lf // linux + modern mac os )
line endings
Variables ¶
This section is empty.
Functions ¶
func HasSignatureInHeader ¶
HasSignatureInHeader returns true if `sig` is found in `hdr`
func ReadBytesFrom ¶
ReadBytesFrom reads `size` bytes from `file`
func ReadBytesUntilNewline ¶
ReadBytesUntilNewline is used to process text
func ReadUint16be ¶
ReadUint16be reads big endian Uint16 from `file`
func ReadUint16le ¶
ReadUint16le reads little endian Uint16 from `file`
func ReadUint32be ¶
ReadUint32be reads big endian Uint32 from `file`
func ReadUint32le ¶
ReadUint32le reads little endian Uint32 from `file`
func ReadUint64be ¶
ReadUint64be reads big endian Uint64 from `file`
func ReadUnsignedInt ¶
ReadUnsignedInt reads field value, as an uint32
Types ¶
type BrowseMode ¶
type BrowseMode int
BrowseMode ...
const ( ByGroup BrowseMode = 1 + iota ByFieldInGroup )
browse modes
type Checker ¶
type Checker struct { Header []byte File *os.File ParsedLayout ParsedLayout }
Checker (parse checker)
type DataType ¶
type DataType int
DataType ...
const ( Group DataType = 1 + iota // container // single bytes Int8 Uint8 // little endian Int16le Int32le Uint16le Uint24le Uint32le Uint64le // big endian Uint16be Uint32be Uint64be // version MajorMinor8 // high nibble = major, low = minor MinorMajor8Five // high 5 bits = minor, low 3 = major MajorMinor16le // first byte = major, last = minor MajorMinor16be // first byte = major, last = minor MajorMinor32le // first word = major, last = minor MinorMajor16le // first byte = minor, last = major // timestamps DOSDateTime // 4 bytes ArjDateTime // 4 bytes // positions DOSOffsetSegment // ip:cs, 4 bytes // groups of bytes Bytes ASCII ASCIIC ASCIIZ RGB )
...
type FileKind ¶
type FileKind int
FileKind ...
type HexFormatting ¶
HexFormatting ...
type HexViewState ¶
type HexViewState struct { BrowseMode BrowseMode StartingRow int64 VisibleRows int RowWidth int CurrentGroup int CurrentField int }
HexViewState ...
func (*HexViewState) CurrentFieldInfo ¶
func (state *HexViewState) CurrentFieldInfo(f *os.File, pl ParsedLayout) string
CurrentFieldInfo renders info of current field
func (*HexViewState) NextFieldInGroup ¶
func (f *HexViewState) NextFieldInGroup(layout []Layout)
NextFieldInGroup moves to the next field in current group
func (*HexViewState) NextGroup ¶
func (f *HexViewState) NextGroup(layout []Layout)
NextGroup moves focus to the next group
func (*HexViewState) PrevFieldInGroup ¶
func (f *HexViewState) PrevFieldInGroup()
PrevFieldInGroup moves to the previous field in current group
func (*HexViewState) PrevGroup ¶
func (f *HexViewState) PrevGroup()
PrevGroup moves focus to the previous group
type Layout ¶
type Layout struct { Offset int64 Length int64 Type DataType Info string // user friendly field name Spec string // field name according to specs Childs []Layout Masks []Mask }
Layout represents a parsed file structure
func (*Layout) CalcLength ¶
func (l *Layout) CalcLength()
CalcLength calculates the .Length property from childs
func (*Layout) GetBitSize ¶
GetBitSize returns the bit size of the data type for the layout
type Mask ¶
type Mask struct { Low int Length int Info string // user friendly field name Spec string // field name according to specs }
Mask represents how to decode a bit field
type ParsedLayout ¶
type ParsedLayout struct { FormatName string FileName string FileSize int64 FileKind FileKind MimeType string TextEncoding TextEncoding Layout []Layout }
ParsedLayout ...
func (*ParsedLayout) DecodeBitfieldFromInfo ¶
func (pl *ParsedLayout) DecodeBitfieldFromInfo(file *os.File, info string) uint32
DecodeBitfieldFromInfo decodes a bitfield value
func (*ParsedLayout) FullListing ¶
func (pl *ParsedLayout) FullListing() string
FullListing lists the parsed layout
func (*ParsedLayout) GetASCII ¶
func (pl *ParsedLayout) GetASCII(file *os.File, hexView HexViewState) (string, error)
GetASCII returns the ASCII values of the currently visible area of the parsed layout
func (*ParsedLayout) GetHex ¶
func (pl *ParsedLayout) GetHex(file *os.File, hexView HexViewState) (string, error)
GetHex dumps a row of hex
func (*ParsedLayout) PercentMapped ¶
func (pl *ParsedLayout) PercentMapped(totalSize int64) float64
PercentMapped returns the % of total file size mapped to known structures
func (*ParsedLayout) PercentUnmapped ¶
func (pl *ParsedLayout) PercentUnmapped(totalSize int64) float64
PercentUnmapped returns the % of total file size not mapped to known structures
func (*ParsedLayout) PrettyASCIIView ¶
func (pl *ParsedLayout) PrettyASCIIView(file *os.File, hexView HexViewState) string
PrettyASCIIView returns pretty ASCII of the currently visible area of the parsed layout
func (*ParsedLayout) PrettyHexView ¶
func (pl *ParsedLayout) PrettyHexView(file *os.File, hexView HexViewState) string
PrettyHexView returns the hex values of the currently visible area of the parsed layout
func (*ParsedLayout) PrettyOffsetView ¶
func (pl *ParsedLayout) PrettyOffsetView(file *os.File, hexView HexViewState) string
PrettyOffsetView returns the offsets of the currently visible area of the parsed layout
func (*ParsedLayout) PrettyPrint ¶
func (pl *ParsedLayout) PrettyPrint() string
PrettyPrint returns the output for cmd/prober
func (*ParsedLayout) ReadUint32leFromInfo ¶
ReadUint32leFromInfo returns a little-endian 32-bit value
func (*ParsedLayout) ShortPrint ¶
func (pl *ParsedLayout) ShortPrint() string
ShortPrint returns the output for cmd/prober --short
func (*ParsedLayout) TypeSummary ¶
func (pl *ParsedLayout) TypeSummary() string
TypeSummary returns a summary of the parsed layout
type TextEncoding ¶
type TextEncoding int
TextEncoding ...
const ( None TextEncoding = iota ASCIIUS UTF8 UTF16le UTF16be UTF32le UTF32be )
text encodings
func (TextEncoding) String ¶
func (e TextEncoding) String() string