Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

Commit

Permalink
refactor: init in nesec packed app ( #35
Browse files Browse the repository at this point in the history
  • Loading branch information
SakuraKooi committed Dec 1, 2022
1 parent c059636 commit d53884d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
36 changes: 31 additions & 5 deletions app/src/main/java/sakura/kooi/dglabunlocker/XposedModuleInit.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package sakura.kooi.dglabunlocker;

import static sakura.kooi.dglabunlocker.utils.DgLabVersion.V_1_2_6;
import static sakura.kooi.dglabunlocker.utils.DgLabVersion.V_1_3_1;
import static sakura.kooi.dglabunlocker.utils.DgLabVersion.V_1_3_2;
import static sakura.kooi.dglabunlocker.utils.DgLabVersion.*;

import android.content.Context;
import android.util.Log;
Expand Down Expand Up @@ -40,6 +38,10 @@ private static AbstractVersionedCompatibilityProvider detectAppVersion(Context c
int versionCode = ModuleUtils.getAppVersion(context);
HookRegistry.versionCode = versionCode;
switch (versionCode) {
case V_1_3_3:
versionedFieldInitializer = new Version132(); // FIXME
StatusDialog.currentLoadedVersion = "1.3.3";
break;
case V_1_3_2:
versionedFieldInitializer = new Version132();
StatusDialog.currentLoadedVersion = "1.3.2";
Expand Down Expand Up @@ -67,6 +69,24 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) {
return;
}
Log.i("DgLabUnlocker", "Init Loading: found target app " + lpparam.packageName);

try {
Class.forName("com.netease.nis.wrapper.MyApplication", false, lpparam.classLoader);

XposedHelpers.findAndHookMethod("com.netease.nis.wrapper.MyApplication", lpparam.classLoader,
"attachBaseContext", Context.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Context context = (Context) param.args[0];
ClassLoader classLoader = context.getClassLoader();
onAppLoaded(context, classLoader);
}
});
return;
} catch (ClassNotFoundException e) {
Log.i("DgLabUnlocker", "nesec packer not found, try hook as tencent packed...");
}

try {
Class.forName("com.wrapper.proxyapplication.WrapperProxyApplication", false, lpparam.classLoader);

Expand All @@ -79,8 +99,12 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
onAppLoaded(context, classLoader);
}
});
return;
} catch (ClassNotFoundException e) {
Log.i("DgLabUnlocker", "Possible unpacked app, try hook activity directly");
Log.i("DgLabUnlocker", "tencent packer not found, try hook as unpacked app...");
}

try {
XposedHelpers.findAndHookMethod("com.bjsm.dungeonlab.global.BaseLocalApplication", lpparam.classLoader, "onCreate", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) {
Expand All @@ -89,6 +113,8 @@ protected void afterHookedMethod(MethodHookParam param) {
onAppLoaded(context, classLoader);
}
});
} catch (Exception e) {

}
}

Expand Down Expand Up @@ -185,7 +211,7 @@ private void onAppLoaded(Context context, ClassLoader classLoader) {
// endregion
// region test features
Log.i("DgLabUnlocker", "Hook Loading: Testing features...");
for(AbstractFeature feature : HookRegistry.featureInstances.values()) {
for (AbstractFeature feature : HookRegistry.featureInstances.values()) {
try {
if (feature.isUnsupported())
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ public class DgLabVersion {
public static final int V_1_2_6 = 19;
public static final int V_1_3_1 = 21;
public static final int V_1_3_2 = 22;
public static final int V_1_3_3 = 23;
}

0 comments on commit d53884d

Please sign in to comment.