Skip to content

A plugin for WUPS that dynamically applies user-provided code patches to the current application.

License

Notifications You must be signed in to change notification settings

theawesomecoder61/CodePatchPlugin

Repository files navigation

Code Patch Plugin

This plugin loads user-provided code patches (stored in the hax format) and dynamically applies them to the current application. It supports WUPS and Aroma (alternative environment to Tiramisu) and was inspired by CafeLoader. The application's executable file remains untouched by the plugin.

Code Patch will load all .hax files in a folder and apply all patches found therein. Unlike CafeLoader, you do not need to compile a project in order to create patches.

Currently, only .hax files are supported. The addr/code .bin files and network loading features that CafeLoader has may be included in a future version.


Note: New/additional instructions or routines are not supported. Only instruction replacements are allowed.

Note: Code Patch will not run on system applications or applets.


Installation

Be sure you fully installed and configured Tiramisu and Aroma on your Wii U. You should have NotificationModule and KernelModule in /fs/vol/external01/wiiu/environments/aroma/modules.

  1. Copy CodePatchPlugin.wps into /fs/vol/external01/wiiu/environments/aroma/plugins.
  2. Create a folder in /fs/vol/external01/wiiu/ called codepatches.

Usage

For each application you wish to apply patches, create a folder with the base title ID in the path /fs/vol/external01/wiiu/codepatches/[title ID], where [title ID] is the base title ID, and place .hax files in there.

Patching can be enabled/disabled globally via the WUPS config menu (press L, DPAD Down and Minus on the GamePad, Pro Controller or Classic Controller).

When loading and applying patches, the plugin will display messages in the top left. These too can be enabled/disabled in the WUPS config menu.

I tested the plugin on a 32 GB US model running 5.5.5. This plugin will work on all 5.5.X versions that Tiramisu supports.

hax files

A .hax file is a format that contains individual code replacements with corresponding addresses. Such files are big-endian. I did not invent this format; I use it since CafeLoader used it.

For reference, here is a breakdown of the format.

Offset Type Description
0 uint16 number of patches
2 Patch patches

Patch

Offset Type Description
0 uint16 size of code (should be 4)
2 uint32 address (for BotW, this value minus 0xA900000 = original address)
6 uint32 code

Python script

I included a Python script that converts an .txt file to a .hax file. Using this is not required. Before running the script, install keystone from pip.

Run the script like so: python txt_to_hax.py [txt file]. The resulting .hax file will appear in the same directory with the same name as the .hax file.

The input file must have patches in this format, seperated by newlines. Any line not in this format will be ignored. Lines beginning with ; are treated as comments and are also ignored.

[address in hex starting with 0x] = [PPC instruction]

Building

To build, you need:

Install them with their dependencies in this order according to their READMEs. After, compile the plugin using make (with no logging) or make DEBUG=1 (with logging).

Buildflags

Logging

You can build the plugin in one of three ways:

  • make Logs errors only (via OSReport).
  • make DEBUG=1 Enables information and error logging via LoggingModule.
  • make DEBUG=VERBOSE Enables verbose information and error logging via LoggingModule.

If the LoggingModule is not present, it will fallback to UDP (port 4405) and CafeOS logging. You can use udplogserver (/opt/devkitpro/tools/bin/udplogserver) to view logs.

Credits