aimardcr/arthook ? reverse-engineered prompt

Reverse engineered prompt

Build me a self contained C++17 static library for Android that can hook Java methods at the ART level, without relying on Frida, Xposed, LSPlant, YAHFA, Pine, or SandHook. I want it to work on Android 8 through the latest versions, and I want the library to discover the needed runtime offsets automatically instead of using hardcoded tables.

The library should let me replace a Java method with my own JNI compatible C function, keep a callable backup to the original method, and install or remove hooks safely at runtime. It should also handle both native and non native methods, instance and static methods, and provide a simple RAII style wrapper for managing hooks.

Please include a small example payload that hooks something like Object.toString and logs when it is called, plus clear build instructions for NDK and CMake. If you need to check the current Android or NDK details online while implementing it, go ahead.