-
Notifications
You must be signed in to change notification settings - Fork 632
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix crash when hooked static method invokes class initialization
- Loading branch information
Showing
17 changed files
with
185 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
edxp-common/src/main/java/com/elderdrivers/riru/edxp/art/ClassLinker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,24 @@ | ||
package com.elderdrivers.riru.edxp.art; | ||
|
||
import com.elderdrivers.riru.common.KeepAll; | ||
import com.elderdrivers.riru.edxp.core.Yahfa; | ||
|
||
import java.lang.reflect.Member; | ||
import java.util.function.Consumer; | ||
|
||
import de.robv.android.xposed.PendingHooks; | ||
|
||
public class ClassLinker implements KeepAll { | ||
|
||
public static native void setEntryPointsToInterpreter(Member method); | ||
|
||
public static void onPreFixupStaticTrampolines(Class clazz) { | ||
// remove modified native flags to let FixupStaticTrampolines fill in right entrypoints | ||
PendingHooks.removeNativeFlags(clazz); | ||
} | ||
|
||
public static void onPostFixupStaticTrampolines(Class clazz) { | ||
// native flags will be re-set in hooking logic | ||
PendingHooks.hookPendingMethod(clazz); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
edxp-core/src/main/cpp/main/src/jni/edxp_pending_hooks.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
#include <nativehelper/jni_macros.h> | ||
#include <set> | ||
#include <string> | ||
#include "jni.h" | ||
#include "native_util.h" | ||
#include "edxp_pending_hooks.h" | ||
|
||
namespace edxp { | ||
|
||
static std::set<std::string> class_descs_; | ||
|
||
bool IsClassPending(const char *class_desc) { | ||
return class_descs_.find(class_desc) != class_descs_.end(); | ||
} | ||
|
||
static void PendingHooks_recordPendingMethodNative(JNI_START, jstring class_desc) { | ||
const char *class_desc_chars = env->GetStringUTFChars(class_desc, JNI_FALSE); | ||
class_descs_.insert(class_desc_chars); | ||
} | ||
|
||
static JNINativeMethod gMethods[] = { | ||
NATIVE_METHOD(PendingHooks, recordPendingMethodNative, "(Ljava/lang/String;)V"), | ||
}; | ||
|
||
void RegisterPendingHooks(JNIEnv *env) { | ||
REGISTER_EDXP_NATIVE_METHODS("de.robv.android.xposed.PendingHooks"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
#pragma once | ||
|
||
#include "jni.h" | ||
|
||
namespace edxp { | ||
|
||
bool IsClassPending(const char *); | ||
|
||
void RegisterPendingHooks(JNIEnv *); | ||
|
||
} // namespace edxp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.