hooks

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FT_CondJmp  = 1
	FT_JMP      = 2
	FT_CALL     = 3
	FT_RET      = 4
	FT_OTHER    = 5
	FT_INVALID  = 6
	FT_SKIP     = 7
	FT_OVERFLOW = 8
)

Variables

This section is empty.

Functions

func CopyFunction

func CopyFunction(allowCall bool, from, to interface{}, info *CodeInfo) ([]byte, error)

func CopyInstruction

func CopyInstruction(location uintptr, data []byte)

func FixOneInstruction

func FixOneInstruction(mode int, fix_recursive_call bool, startAddr, curAddr uintptr, code []byte, to uintptr, to_sz int) (int, int, []byte)

func GetArchMode

func GetArchMode() int

func GetFuncAddr

func GetFuncAddr(f interface{}) uintptr

func GetFuncInstSize

func GetFuncInstSize(f interface{}) uint32

func GetFuncSizeByGuess

func GetFuncSizeByGuess(mode int, start uintptr, minimal bool) (uint32, error)

func GetInsLenGreaterThan

func GetInsLenGreaterThan(mode int, data []byte, least int) int

func Hook

func Hook(target, replacement, trampoline interface{}) error

func HookByIndirectJmp

func HookByIndirectJmp(target, replacement, trampoline interface{}) error

func HookMethod

func HookMethod(instance interface{}, method string, replacement, trampoline interface{}) error

func ResetFuncPrologue

func ResetFuncPrologue()

func SetFuncPrologue

func SetFuncPrologue(mode int, data []byte)

func SetMinJmpCodeSize

func SetMinJmpCodeSize(sz int)

func ShowDebugInfo

func ShowDebugInfo() string

func UnHook

func UnHook(target interface{}) error

func UnHookMethod

func UnHookMethod(instance interface{}, methodName string) error

Types

type CodeFix

type CodeFix struct {
	Code    []byte
	Addr    uintptr
	Foreign bool
}

func FixTargetFuncCode

func FixTargetFuncCode(mode int, start uintptr, funcSz uint32, to uintptr, move_sz int) ([]CodeFix, error)

FixTargetFuncCode fix function code starting at address [start] parameter 'funcSz' may not specify, in which case, we need to find out the end by scanning next prologue or finding invalid instruction. 'to' specifys a new location, to which 'move_sz' bytes instruction will be copied since move_sz byte instructions will be copied, those relative jump instruction need to be fixed.

type CodeInfo

type CodeInfo struct {
	How            string
	Origin         []byte
	Fix            []CodeFix
	TrampolineOrig []byte
}

type ElfInfo

type ElfInfo struct {
	CurFile string
	Symbol  SymbolSlice
}

func NewElfInfo

func NewElfInfo() (*ElfInfo, error)

func (*ElfInfo) GetFuncSize

func (ei *ElfInfo) GetFuncSize(addr uintptr) (uint32, error)

type HookInfo

type HookInfo struct {
	Mode        int
	Info        *CodeInfo
	Target      reflect.Value
	Replacement reflect.Value
	Trampoline  reflect.Value
}

type SymbolSlice

type SymbolSlice []elf.Symbol

func (SymbolSlice) Len

func (a SymbolSlice) Len() int

func (SymbolSlice) Less

func (a SymbolSlice) Less(i, j int) bool

func (SymbolSlice) Swap

func (a SymbolSlice) Swap(i, j int)

Jump to

Keyboard shortcuts

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