I'm doing reverse engineering of a mobile application for android and I had a question how to find the executable code of the native method in the library * .so. From the code of the code, the native method void method(int i) is called. But it is not in the list of exported functions in the library!

I made a test project. The fact is that when we declare the native method in Java code, we write this:

extern "C"
        JNIEnv *env,
        jobject /* this */) {
    std::string hello = "Hello from C++";
    return env->NewStringUTF(hello.c_str());

in this case the method will be in the list of exported library methods. I do not understand how to define the native function so that it is not visible in the list of exported functions? And how to look for the source code for such functions?


1 Answer 1


There are two different ways to define JNI methods. The easiest way is to just give the functions special names like in the examples you've seen.

However, this is not necessary. JNI methods can also be registered dynamically with the RegisterNatives method. This is typically done in a function named JNI_OnLoad, which will automatically be called when the library is loaded. This lets you basically just pass a table of function pointers to the VM, so the methods don't even have to appear in the symbol table anywhere. In fact, you could theoretically write out the code at runtime and pass a pointer to that.

  • It is very interesting! Do you have examples of source codes for dynamic method registration? And how specifically to find the executable code of these methods? By pointers to the address?
    – Sergey Unk
    Jul 14, 2018 at 16:45
  • Wow. I am interested, too
    – realtebo
    Jul 15, 2018 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.