binarypatch

package module
v0.0.0-...-71de106 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2016 License: MIT Imports: 3 Imported by: 0

README

binarypatch

Storing & retrieving arbitrary data from program headers

Usage

Appending some data to an OSX/Darwin program:

package main

import(
  "github.com/matiasinsaurralde/binarypatch"
)

func main() {
  b := binarypatch.New( "myprogram", "darwin" )
  index := b.Locate()
  b.Write( []byte("hello"), index )

  b.WriteFile( "myprogram_with_data")
}

myprogram does the following:

package main
import(
  "fmt"
  "github.com/matiasinsaurralde/binarypatch"
)

func main() {
  b := binarypatch.ReadMyself(5, -1, "darwin")
  fmt.Println("Reading from myself: ", b, string(b) )
}

The output of the original program is:

% ./myprogram
Reading from myself:  [0 0 0 0 0] 

Then, the output of the "patched" program:

% ./myprogram_with_data
Reading from myself:  [104 101 108 108 111] hello

Supported architectures

  • OSX/Darwin
  • Windows

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadMyself

func ReadMyself(length int, index int, arch string) []byte

Types

type Binarypatch

type Binarypatch struct {
	Filename string
	Filedata []byte
	Arch     string
}

func New

func New(filename string, arch string) *Binarypatch

func (*Binarypatch) Locate

func (b *Binarypatch) Locate() (index int)

func (*Binarypatch) Read

func (b *Binarypatch) Read(index int, length int) []byte

func (*Binarypatch) Write

func (b *Binarypatch) Write(data []byte, index int)

func (*Binarypatch) WriteFile

func (b *Binarypatch) WriteFile(name string) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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