binary

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBinaryNotFound    = errors.New("binary file not found")
	ErrInvalidExecutable = errors.New("invalid or unsupported executable format")
	ErrSymbolNotFound    = errors.New("symbol not found in binary")
)

Functions

This section is empty.

Types

type BinaryLoader added in v0.7.0

type BinaryLoader interface {
	// Load initializes the binary analysis from a file path
	Load(filePath string) error

	// LoadByPid initializes the binary analysis by process ID
	LoadByPid(pid int) error

	// GetSymbols returns all symbols from the binary
	GetSymbols() (map[string]uint64, error)

	// FindVariableAddress locates a specific variable's memory address
	FindVariableAddress(varName string) (uint64, error)

	// GetFile returns the underlying executable file object
	GetFile() interface{}

	// PtrSize returns the pointer size (4 for 32-bit, 8 for 64-bit)
	PtrSize() int

	PCToFuncLoc(addr uint64) *FuncLoc

	// GetDWARFLoader returns the DWARF loader if available
	GetDWARFLoader() (DWARFLoader, error)
}

func NewBinaryLoader added in v0.7.0

func NewBinaryLoader() BinaryLoader

type DWARFLoader added in v0.7.0

type DWARFLoader interface {
	// Check if binary has DWARF info
	HasDWARF() bool
	// Get struct field offset
	GetStructOffset(typeName, fieldName string) (uint64, error)
	// Get nested struct field offset
	GetNestedOffset(outerType, outerField, innerField string) (uint64, error)
	// Get size of a struct type
	GetStructSize(typeName string) (uint64, error)
}

BinaryLoader defines the interface for analyzing Go binaries

type FuncLoc added in v0.7.0

type FuncLoc struct {
	PC   uint64      // program counter
	File string      // source code file name, from dwarf info
	Line int         // soure code line, from dwarf info
	Func *gosym.Func // function name
	// contains filtered or unexported fields
}

func (*FuncLoc) Desc added in v0.7.0

func (f *FuncLoc) Desc() string

type LinuxBinaryLoader added in v0.7.0

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

func (*LinuxBinaryLoader) FindVariableAddress added in v0.7.0

func (l *LinuxBinaryLoader) FindVariableAddress(varName string) (uint64, error)

func (*LinuxBinaryLoader) GetDWARFLoader added in v0.7.0

func (l *LinuxBinaryLoader) GetDWARFLoader() (DWARFLoader, error)

func (*LinuxBinaryLoader) GetFile added in v0.7.0

func (l *LinuxBinaryLoader) GetFile() any

func (*LinuxBinaryLoader) GetSymbols added in v0.7.0

func (l *LinuxBinaryLoader) GetSymbols() (map[string]uint64, error)

func (*LinuxBinaryLoader) Load added in v0.7.0

func (l *LinuxBinaryLoader) Load(filePath string) error

func (*LinuxBinaryLoader) LoadByPid added in v0.7.0

func (l *LinuxBinaryLoader) LoadByPid(pid int) error

func (*LinuxBinaryLoader) PCToFuncLoc added in v0.7.0

func (l *LinuxBinaryLoader) PCToFuncLoc(addr uint64) *FuncLoc

func (*LinuxBinaryLoader) PtrSize added in v0.7.0

func (l *LinuxBinaryLoader) PtrSize() int

Jump to

Keyboard shortcuts

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