Any suggestions here? I have set a break point in the JNIEnv_ExceptionOccurred for my module, clearly the native code is attempting to create an instance of the FileSystem class (in the com.king.core package), a JNIEnv_NewObjectV and then JNIEnv_NewGlobalRef call are made, but then the native code makes an internal call to CJava::CheckForErrors which triggers JNIEnv_ExceptionOccurred. At the moment, I am wondering if the native code is inspecting the JNIEnv to ensure no errors/exceptions have occurred, and deciding that there are errors (by whatever means). Ultimately I don't know for sure how bad this is (check error, find one and continue, or check error, find one and abort function):
JNIEnv_FindClass('com/king/core/FileSystem')
JNIEnv_GetMethodID(88aa0, 'getHomeDirectory', '()Ljava/lang/String;')
JNIEnv_GetMethodID(88aa0, 'getCacheDirectory', '()Ljava/lang/String;')
JNIEnv_GetMethodID(88aa0, '<init>', '(Landroid/content/Context
V')
JNIEnv_NewObjectV(88aa0, <init>)
JNIEnv_NewGlobalRef(4f718)
Breakpoint 1, candycrashsaga_JNIEnv_ExceptionOccurred (p0=0x3177c) at modules/candycrushsaga.c:88
88 modules/candycrushsaga.c: No such file or directory.
in modules/candycrushsaga.c
(gdb) bt
#0 candycrashsaga_JNIEnv_ExceptionOccurred (p0=0x3177c) at modules/candycrushsaga.c:88
#1 0x4057ad4c in CJava::CheckForErrors(_JNIEnv*) () from ./lib/armeabi-v7a/libcandycrushsaga.so
#2 0x40588348 in CFileSystemAndroid::CFileSystemAndroid(_JavaVM*, _jobject*) ()
from ./lib/armeabi-v7a/libcandycrushsaga.so
#3 0x405871e8 in CAndroidApp::Create(IPlatformProxy*, _JavaVM*, _jobject*, _jobject*) ()
from ./lib/armeabi-v7a/libcandycrushsaga.so
#4 0x40d19bd8 in candycrushsaga_init (self=0x53378, width=800, height=480,
home=0xbeffeb7c "./data/Candy Crush Saga_1.0.10.apk/") at modules/candycrushsaga.c:149
#5 0x0000fef4 in main (argc=2, argv=0xbefffd14) at apkenv.c:544
(gdb)
I thought anyone who has already tackled a module may have some ideas? For what it is worth, here is the disassembly of CheckForErrors:
00169d38 <_ZN5CJava14CheckForErrorsEP7_JNIEnv>:
169d38: e5903000 ldr r3, [r0]
169d3c: e92d4010 push {r4, lr}
169d40: e1a04000 mov r4, r0
169d44: e593303c ldr r3, [r3, #60] ; 0x3c
169d48: e12fff33 blx r3
169d4c: e3500000 cmp r0, #0
169d50: 08bd8010 popeq {r4, pc}
169d54: e5943000 ldr r3, [r4]
169d58: e1a00004 mov r0, r4
169d5c: e5933040 ldr r3, [r3, #64] ; 0x40
169d60: e12fff33 blx r3
169d64: e5943000 ldr r3, [r4]
169d68: e1a00004 mov r0, r4
169d6c: e5933044 ldr r3, [r3, #68] ; 0x44
169d70: e12fff33 blx r3
169d74: e8bd8010 pop {r4, pc}
I haven't tried NOPing the function out yet to see what happens.