Substrate C API Overview

Substrate provides a set of APIs designed to solve the varied challenges that arise when attempting to instrument code on each of its target platforms and languages. Whether you are interested in modifying the behavior of C/C++, Objective-C (iOS), or Java (Android/Dalvik), Substrate has a workflow for making your changes in a way that coordinates with other developers who may be modifying similar functionality.

Conceptually, each platform consists of three common steps.

get a reference to the container (class/module/image) look up a specific function/method in that container replace that code with your modified implementation

After which, you likely care about being able to "proceed" to the original implementation (the one that existed before your modifications), possibly at a different time, or passing different arguments. Each of the APIs provided provide a way to do this, often by way of a pointer-to-a-function.

The developer calling these APIs, no matter which platform they are attempting to manipulate, does so at the level of C. The usual runtime-provided language bindings can then be used to transition back/forth between C and the higher-level language (such as to call Java code from your JNI-level hooks).