コード例 #1
0
Method* dvmFindInlinableMethod(const char* classDescriptor,
    const char* methodName, const char* methodSignature)
{
    /*
     * Find the class.
     */
    ClassObject* clazz = dvmFindClassNoInit(classDescriptor, NULL);
    if (clazz == NULL) {
        ALOGE("dvmFindInlinableMethod: can't find class '%s'",
            classDescriptor);
        dvmClearException(dvmThreadSelf());
        return NULL;
    }

    /*
     * Method could be virtual or direct.  Try both.  Don't use
     * the "hier" versions.
     */
    Method* method = dvmFindDirectMethodByDescriptor(clazz, methodName,
        methodSignature);
    if (method == NULL) {
        method = dvmFindVirtualMethodByDescriptor(clazz, methodName,
            methodSignature);
    }
    if (method == NULL) {
        ALOGE("dvmFindInlinableMethod: can't find method %s.%s %s",
            clazz->descriptor, methodName, methodSignature);
        return NULL;
    }

    /*
     * Check that the method is appropriate for inlining.
     */
    if (!dvmIsFinalClass(clazz) && !dvmIsFinalMethod(method)) {
        ALOGE("dvmFindInlinableMethod: can't inline non-final method %s.%s",
            clazz->descriptor, method->name);
        return NULL;
    }
    if (dvmIsSynchronizedMethod(method) ||
            dvmIsDeclaredSynchronizedMethod(method)) {
        ALOGE("dvmFindInlinableMethod: can't inline synchronized method %s.%s",
            clazz->descriptor, method->name);
        return NULL;
    }

    return method;
}
コード例 #2
0
ファイル: xposed.cpp プロジェクト: BillKalin/Xposed
bool xposedOnVmCreated(JNIEnv* env, const char* className) {
    startClassName = className;

    keepLoadingXposed = keepLoadingXposed && xposedInitMemberOffsets(env);
    if (!keepLoadingXposed)
        return false;

    jclass miuiResourcesClass = env->FindClass(MIUI_RESOURCES_CLASS);
    if (miuiResourcesClass != NULL) {
        ClassObject* clazz = (ClassObject*)dvmDecodeIndirectRef(dvmThreadSelf(), miuiResourcesClass);
        if (dvmIsFinalClass(clazz)) {
            ALOGD("Removing final flag for class '%s'", MIUI_RESOURCES_CLASS);
            clazz->accessFlags &= ~ACC_FINAL;
        }
    }
    env->ExceptionClear();

    jclass xTypedArrayClass = env->FindClass(XTYPEDARRAY_CLASS);
    if (xTypedArrayClass == NULL) {
        ALOGE("Error while loading XTypedArray class '%s':\n", XTYPEDARRAY_CLASS);
        dvmLogExceptionStackTrace();
        env->ExceptionClear();
        return false;
    }
    xposedPrepareSubclassReplacement(xTypedArrayClass);

    xposedClass = env->FindClass(XPOSED_CLASS);
    xposedClass = reinterpret_cast<jclass>(env->NewGlobalRef(xposedClass));
    
    if (xposedClass == NULL) {
        ALOGE("Error while loading Xposed class '%s':\n", XPOSED_CLASS);
        dvmLogExceptionStackTrace();
        env->ExceptionClear();
        return false;
    }
    
    ALOGI("Found Xposed class '%s', now initializing\n", XPOSED_CLASS);
    if (register_de_robv_android_xposed_XposedBridge(env) != JNI_OK) {
        ALOGE("Could not register natives for '%s'\n", XPOSED_CLASS);
        env->ExceptionClear();
        return false;
    }
    return true;
}
コード例 #3
0
ファイル: xposed.cpp プロジェクト: BurgerZ/Xposed
bool xposedOnVmCreated(JNIEnv* env, const char* className) {
	startClassName = className;

	keepLoadingXposed = keepLoadingXposed && xposedInitMemberOffsets(env);
	if (!keepLoadingXposed)
		return false;

	// disable some access checks
	patchReturnTrue((uintptr_t) & dvmCheckClassAccess);
	patchReturnTrue((uintptr_t) & dvmCheckFieldAccess);
	patchReturnTrue((uintptr_t) & dvmInSamePackage);
	if (access(XPOSED_DIR "conf/do_not_hook_dvmCheckMethodAccess", F_OK) != 0)
		patchReturnTrue((uintptr_t) & dvmCheckMethodAccess);

	jclass miuiResourcesClass = env->FindClass(MIUI_RESOURCES_CLASS);
	if (miuiResourcesClass != NULL) {
		ClassObject* clazz = (ClassObject*) dvmDecodeIndirectRef(
				dvmThreadSelf(), miuiResourcesClass);
		if (dvmIsFinalClass(clazz)) {
			ALOGD("Removing final flag for class '%s'", MIUI_RESOURCES_CLASS);
			clazz->accessFlags &= ~ACC_FINAL;
		}
	}
	env->ExceptionClear();

	xposedClass = env->FindClass(XPOSED_CLASS);
	xposedClass = reinterpret_cast<jclass>(env->NewGlobalRef(xposedClass));

	if (xposedClass == NULL) {
		ALOGE("Error while loading Xposed class '%s':\n", XPOSED_CLASS);
		dvmLogExceptionStackTrace();
		env->ExceptionClear();
		return false;
	}

	ALOGI("Found Xposed class '%s', now initializing\n", XPOSED_CLASS);
	if (register_de_robv_android_xposed_XposedBridge(env) != JNI_OK) {
		ALOGE("Could not register natives for '%s'\n", XPOSED_CLASS);
		return false;
	}

	return true;
}