Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FuncPatcher ¶
FuncPatcher applies binary patches to redirect function calls. Implementations receive a fully populated Request and must return a non-nil error if patching fails.
func GoMonkey ¶
func GoMonkey() FuncPatcher
GoMonkey returns a FuncPatcher that uses gomonkey to rewrite function entry points. It performs type validation before entering stop-the-world (STW) to ensure thread-safe binary patching. If patching fails partway through, all previously applied patches are rolled back.
type FuncPicker ¶
type FuncPicker func(dwarfAssembly assembly.DwarfAssembly) ([]string, error)
FuncPicker selects which functions should be hot-patched. Given a DwarfAssembly for runtime introspection, it returns the fully qualified names of the target functions.
func Any ¶
func Any(funcPickers ...FuncPicker) FuncPicker
Any combines multiple FuncPickers into one. The selected function names are concatenated in order. If any picker returns an error, the combined picker returns that error immediately.
func Classes ¶
func Classes(classNames ...string) FuncPicker
Classes returns a FuncPicker that selects all methods of the specified struct types. The className must be the fully qualified type name:
example/data.DataType — value receiver methods *example/data.DataType — pointer receiver methods
func Func ¶
func Func(funcNames ...string) FuncPicker
Func returns a FuncPicker that selects specific functions by their fully qualified names. Names must use the Go runtime format:
example/data.TestAdd example/data.(*DataType).TestHotfix example/data.testPrivateFunc
func Package ¶
func Package(pkgs ...string) FuncPicker
Package returns a FuncPicker that selects all functions and methods belonging to the specified package(s). The pkg must be the full import path:
example/data
type Request ¶
type Request struct {
// Logger receives debug log output during the patching process.
Logger *log.Logger
// Patch is the file path of the loaded plugin (.so).
Patch string
// Methods is the list of fully qualified function names to patch.
Methods []string
// Assembly provides DWARF-based access to runtime type and function information.
Assembly assembly.DwarfAssembly
// OldFuncEntrys contains the original function entry points from the main binary.
OldFuncEntrys []*proc.Function
// OldFunctions holds callable reflect.Values pointing to the original function entry points.
OldFunctions []reflect.Value
// NewFunctions holds callable reflect.Values from the loaded plugin.
NewFunctions []reflect.Value
}
Request contains all the information needed to apply a hot patch.
type Result ¶
type Result struct {
// Assembly is the DWARF assembly used during the operation.
Assembly assembly.DwarfAssembly
// Patch is the resolved file path of the loaded plugin.
Patch string
// Methods is the list of function names that were patched.
Methods []string
// Cost is the total wall-clock time of the operation.
Cost time.Duration
// Err is non-nil if the operation failed.
Err error
// Message contains the debug log output from the operation.
Message string
}
Result contains the outcome of a hotfix operation.
func DoHotfix ¶
func DoHotfix(libPath string, funcPicker FuncPicker, funcPatcher FuncPatcher) (result Result)
DoHotfix applies a hot patch using a custom FuncPatcher implementation.
func Hotfix ¶
func Hotfix(libPath string, funcPicker FuncPicker) Result
Hotfix applies a hot patch using the default gomonkey-based patcher. libPath is the file path of the plugin (.so) built from the fixed source. funcPicker selects which functions to patch.