Skip to content

simple PowerPC instruction encoder, and binary patcher

License

Notifications You must be signed in to change notification settings

wii-tools/powerpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

powerpc

A simple library to handle PowerPC instruction encoding, and to enable patching ranges of a binary. This allows simple reproduction of patches to a channel - perhaps ones downloaded via NUS.

Consider this example of a patch:

example := Patch{
	// A name describing this patch.
	Name: "Nullify access check",
	// The offset of the function in the binary - i.e. the DOL.
	AtOffset: 57236,

	// Instructions present previously.
	// In this example, we have a generic function prolog.
	Before: Instructions{
		STWU(R1, R1, 0xFC10),
	}.Bytes(),
	// Instructions present afterwards.
	// They must match the same length as what they are replacing.
	// In this example, we immediately return.
	After: Instructions{
		BLR(),
	}.Bytes(),
}
patched, err := ApplyPatch(example, binary)

You additionally have the option to use PatchSets, collections of patches that may be related to each other. Consider the following scenario:

example := PatchSet{
	Name: "Change domains",

	Patches: []Patch{
		Patch{
			Name: "Remove domain whitelist",
				// [...]
			},
			Patch{
				Name: "Use custom domain",
				// [...]
			},
		},
}
patched, err := ApplyPatchSet(example, binary)

It is recommended to import this package without a prefix in order to permit easier usage of instruction types. An example doing this is as follows:

import (
	. "github.com/wii-tools/powerpc"
)

Wishlist

  • Implement more instructions forms.
  • Use type constraints within structs to allow both byte and Instruction slices.

Resources

About

simple PowerPC instruction encoder, and binary patcher

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages