Permalink
Browse files

Update for ART vm\'s and modern Android systems

  • Loading branch information...
strazzere committed Sep 13, 2017
1 parent edb9b31 commit 6847bd24fc8918b230b602b31c303dd53edeb55f
Showing with 32 additions and 5 deletions.
  1. +1 −1 Android.mk
  2. +29 −2 vm.c
  3. +2 −2 vm.h
View
@@ -11,7 +11,7 @@ LOCAL_MODULE_TAGS := optional
# Allow execution on android-16
LOCAL_CFLAGS += -pie -fPIE
LOCAL_LDFLAGS += -pie -fPIE
LOCAL_LDFLAGS += -pie -fPIE -Wl,--export-dynamic
APP_ABI := armeabi armeabi-v7a x86
View
31 vm.c
@@ -8,10 +8,13 @@ int init_jvm(JavaVM **p_vm, JNIEnv **p_env) {
opt[2].optionString = "-Djava.library.path=/data/local/tmp";
opt[3].optionString = "-verbose:jni"; // may want to remove this, it's noisy
// Add this option if you're hacking stuff and need it, not normally required
// opt[4].optionString = "-Xno-sig-chain"; // may not be require prior to ART vm, may even cause issues for DVM
JavaVMInitArgs args;
args.version = JNI_VERSION_1_6;
args.options = opt;
args.nOptions = 4;
args.nOptions = 4; // Uptick this to 5, it will pass in the no-sig-chain option
args.ignoreUnrecognized = JNI_FALSE;
void *libdvm_dso = dlopen("libdvm.so", RTLD_NOW);
@@ -34,7 +37,11 @@ int init_jvm(JavaVM **p_vm, JNIEnv **p_env) {
registerNatives_t registerNatives;
registerNatives = (registerNatives_t) dlsym(libandroid_runtime_dso, "Java_com_android_internal_util_WithFramework_registerNatives");
if (!registerNatives) {
return -3;
// Attempt non-legacy version
registerNatives = (registerNatives_t) dlsym(libandroid_runtime_dso, "registerFrameworkNatives");
if(!registerNatives) {
return -3;
}
}
if (JNI_CreateJavaVM(&(*p_vm), &(*p_env), &args)) {
@@ -47,3 +54,23 @@ int init_jvm(JavaVM **p_vm, JNIEnv **p_env) {
return 0;
}
JNIEXPORT void InitializeSignalChain() {
}
JNIEXPORT void ClaimSignalChain() {
}
JNIEXPORT void UnclaimSignalChain() {
}
JNIEXPORT void InvokeUserSignalHandler() {
}
JNIEXPORT void EnsureFrontOfChain() {
}
View
4 vm.h
@@ -4,9 +4,9 @@
#include <jni.h>
#include <dlfcn.h>
typedef int(*JNI_CreateJavaVM_t)(void *, void *, void *);
typedef int(*JNI_CreateJavaVM_t)(JavaVM **p_vm, JNIEnv **p_env, void *vm_args);
typedef jint(*registerNatives_t)(JNIEnv *env, jclass clazz);
int init_jvm(JavaVM **p_vm, JNIEnv **p_env);
#endif
#endif

0 comments on commit 6847bd2

Please sign in to comment.