patchlib

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package patchlib provides common functions related to patching binaries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BLX added in v0.12.0

func BLX(pc, target uint32) []byte

BLX assembles a BLX instruction and returns a byte slice which can be patched directly into a binary.

Types

type Patcher

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

Patcher applies patches to a byte array. All operations are done starting from cur.

func NewPatcher

func NewPatcher(in []byte) *Patcher

NewPatcher creates a new Patcher.

func (*Patcher) BaseAddress

func (p *Patcher) BaseAddress(offset int32) error

BaseAddress moves cur to an offset. The offset starts at 0.

func (*Patcher) ExtractZlib added in v0.7.0

func (p *Patcher) ExtractZlib() ([]ZlibItem, error)

ExtractZlib extracts all CSS zlib streams. It returns it as a map of offsets and strings.

func (*Patcher) FindBaseAddress

func (p *Patcher) FindBaseAddress(find []byte) error

FindBaseAddress moves cur to the offset of a sequence of bytes.

func (*Patcher) FindBaseAddressString

func (p *Patcher) FindBaseAddressString(find string) error

FindBaseAddressString moves cur to the offset of a string.

func (*Patcher) FindZlib added in v0.7.0

func (p *Patcher) FindZlib(find string) error

FindZlib finds the base address of a zlib css stream based on a substring (not sensitive to whitespace).

func (*Patcher) FindZlibHash added in v0.7.0

func (p *Patcher) FindZlibHash(hash string) error

FindZlibHash finds the base address of a zlib css stream based on it's SHA1 hash (can be found using the cssextract tool).

func (*Patcher) GetBytes

func (p *Patcher) GetBytes() []byte

GetBytes returns the current content of the Patcher.

func (*Patcher) GetCur added in v0.12.0

func (p *Patcher) GetCur() int32

GetCur gets the current base address.

func (*Patcher) ReplaceBLX added in v0.12.0

func (p *Patcher) ReplaceBLX(offset int32, find, replace uint32) error

ReplaceBLX replaces a BLX instruction at PC (offset). Find and Replace are the target offsets.

func (*Patcher) ReplaceBytes

func (p *Patcher) ReplaceBytes(offset int32, find, replace []byte) error

ReplaceBytes replaces the first occurrence of a sequence of bytes with another of the same length.

func (*Patcher) ReplaceBytesNOP added in v0.12.0

func (p *Patcher) ReplaceBytesNOP(offset int32, find []byte) error

ReplaceBytesNOP replaces an instruction with 0046 (MOV r0, r0) as many times as needed.

func (*Patcher) ReplaceFloat

func (p *Patcher) ReplaceFloat(offset int32, find, replace float64) error

ReplaceFloat replaces the first occurrence of a float.

func (*Patcher) ReplaceInt

func (p *Patcher) ReplaceInt(offset int32, find, replace uint8) error

ReplaceInt replaces the first occurrence of an integer between 0 and 255 inclusively.

func (*Patcher) ReplaceString

func (p *Patcher) ReplaceString(offset int32, find, replace string) error

ReplaceString replaces the first occurrence of a string with another of the same length.

func (*Patcher) ReplaceZlib added in v0.7.0

func (p *Patcher) ReplaceZlib(offset int32, find, replace string) error

ReplaceZlib replaces a part of a zlib css stream at the current offset.

func (*Patcher) ReplaceZlibGroup added in v0.11.0

func (p *Patcher) ReplaceZlibGroup(offset int32, repl []Replacement) error

ReplaceZlibGroup is the same as ReplaceZlib, but it replaces all at once.

func (*Patcher) ResetBaseAddress

func (p *Patcher) ResetBaseAddress()

ResetBaseAddress moves cur to 0.

type Replacement added in v0.11.0

type Replacement struct {
	Find, Replace string
}

Replacement is a replacement for ReplaceZlibGroup.

type ZlibItem added in v0.7.1

type ZlibItem struct {
	Offset int32
	CSS    string
}

Jump to

Keyboard shortcuts

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