Skip to content

Commit

Permalink
Rename method names
Browse files Browse the repository at this point in the history
  • Loading branch information
luoyesiqiu committed Oct 11, 2024
1 parent 5169417 commit fe48f25
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion doc/HowItWorks.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ public class ShellClassLoader extends PathClassLoader {
这一步也非常重要。我们加载apk,dex或者jar,它是以Element方式存放在内存中的,合并dexElements目的是把我们新加载的dex放到dexElements数组开头,这样ClassLoader加载类时就会优先从我们的dex中查找。代码如下:

```cpp
void mergeDexElements(JNIEnv* env,jclass klass,jobject oldClassLoader,jobject newClassLoader){
void combineDexElements(JNIEnv* env,jclass klass,jobject oldClassLoader,jobject newClassLoader){
jclass BaseDexClassLoaderClass = env->FindClass("dalvik/system/BaseDexClassLoader");
jfieldID pathList = env->GetFieldID(BaseDexClassLoaderClass,"pathList","Ldalvik/system/DexPathList;");
jobject oldDexPathListObj = env->GetObjectField(oldClassLoader,pathList);
Expand Down
14 changes: 7 additions & 7 deletions shell/src/main/cpp/dpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ static JNINativeMethod gMethods[] = {
{"gap", "()Ljava/lang/String;", (void *) getApkPathExport},
{"gdp", "()Ljava/lang/String;", (void *) getCompressedDexesPathExport},
{"rcf", "()Ljava/lang/String;", (void *) readAppComponentFactory},
{"rapn", "()Ljava/lang/String;", (void *) readApplicationName},
{"mde", "(Ljava/lang/ClassLoader;)V", (void *) mergeDexElements},
{"rapn", "()Ljava/lang/String;", (void *) readApplicationName},
{"cbde", "(Ljava/lang/ClassLoader;)V", (void *) combineDexElements},
{"rde", "(Ljava/lang/ClassLoader;Ljava/lang/String;)V", (void *) removeDexElements},
{"ra", "(Ljava/lang/String;)Ljava/lang/Object;", (void *) replaceApplication}
};
Expand Down Expand Up @@ -57,7 +57,7 @@ DPT_ENCRYPT jobjectArray makePathElements(JNIEnv* env,const char *pathChs) {
return elements;
}

DPT_ENCRYPT void mergeDexElement(JNIEnv* env,jclass __unused, jobject targetClassLoader,const char* pathChs) {
DPT_ENCRYPT void combineDexElement(JNIEnv* env, jclass __unused, jobject targetClassLoader, const char* pathChs) {
jobjectArray extraDexElements = makePathElements(env,pathChs);

dalvik_system_BaseDexClassLoader targetBaseDexClassLoader(env,targetClassLoader);
Expand Down Expand Up @@ -87,19 +87,19 @@ DPT_ENCRYPT void mergeDexElement(JNIEnv* env,jclass __unused, jobject targetClas

targetDexPathList.setDexElements(newDexElements);

DLOGD("mergeDexElement success");
DLOGD("combineDexElement success");
}

DPT_ENCRYPT void mergeDexElements(JNIEnv* env,jclass klass, jobject targetClassLoader) {
DPT_ENCRYPT void combineDexElements(JNIEnv* env, jclass klass, jobject targetClassLoader) {
char compressedDexesPathChs[256] = {0};
getCompressedDexesPath(env,compressedDexesPathChs, ARRAY_LENGTH(compressedDexesPathChs));

mergeDexElement(env,klass,targetClassLoader,compressedDexesPathChs);
combineDexElement(env, klass, targetClassLoader, compressedDexesPathChs);

#ifndef DEBUG
junkCodeDexProtect(env);
#endif
DLOGD("mergeDexElements success");
DLOGD("combineDexElements success");
}

DPT_ENCRYPT void removeDexElements(JNIEnv* env,jclass __unused,jobject classLoader,jstring elementName){
Expand Down
4 changes: 2 additions & 2 deletions shell/src/main/cpp/dpt.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ void readCodeItem(uint8_t *data,size_t data_len);
jstring readAppComponentFactory(JNIEnv *env,jclass __unused);
jstring readApplicationName(JNIEnv *env, jclass __unused);
jobjectArray makePathElements(JNIEnv* env,const char *pathChs);
void mergeDexElement(JNIEnv* env,jclass __unused, jobject targetClassLoader,const char* pathChs);
void mergeDexElements(JNIEnv* env,jclass __unused,jobject targetClassLoader);
void combineDexElement(JNIEnv* env, jclass __unused, jobject targetClassLoader, const char* pathChs);
void combineDexElements(JNIEnv* env, jclass __unused klass, jobject targetClassLoader);
void removeDexElements(JNIEnv* env,jclass __unused,jobject classLoader,jstring elementName);
jobject replaceApplication(JNIEnv *env, jclass __unused, jstring originApplication);
void replaceApplicationOnActivityThread(JNIEnv *env,jclass __unused, jobject realApplication);
Expand Down
2 changes: 1 addition & 1 deletion shell/src/main/java/com/luoyesiqiu/shell/JniBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class JniBridge {
public static native void craa(Context context, String applicationClassName);
public static native void ia();
public static native String rcf();
public static native void mde(ClassLoader targetClassLoader);
public static native void cbde(ClassLoader targetClassLoader);
public static native void rde(ClassLoader classLoader,String elementName);
public static native String gap();
public static native String gdp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected void attachBaseContext(Context base) {
Log.d(TAG,"ProxyApplication init");
JniBridge.ia();
ClassLoader targetClassLoader = base.getClassLoader();
JniBridge.mde(targetClassLoader);
JniBridge.cbde(targetClassLoader);
Global.sIsReplacedClassLoader = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public Application instantiateApplication(@NonNull ClassLoader cl, @NonNull Stri
AppComponentFactory targetAppComponentFactory = null;
String applicationName = JniBridge.rapn();
if(!Global.sIsReplacedClassLoader){
JniBridge.mde(cl);
JniBridge.cbde(cl);
Global.sIsReplacedClassLoader = true;
targetAppComponentFactory = getTargetAppComponentFactory(cl);
}
Expand Down Expand Up @@ -133,7 +133,7 @@ public ClassLoader instantiateClassLoader(@NonNull ClassLoader cl, @NonNull Appl

AppComponentFactory targetAppComponentFactory = getTargetAppComponentFactory(cl);

JniBridge.mde(cl);
JniBridge.cbde(cl);

Global.sIsReplacedClassLoader = true;

Expand Down

0 comments on commit fe48f25

Please sign in to comment.