Skip to content

Commit

Permalink
fix: CorePatch handleLoadPackage load failed for Android 15
Browse files Browse the repository at this point in the history
  • Loading branch information
lingqiqi5211 committed Oct 7, 2024
1 parent 1c19163 commit 8ec3671
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 36 deletions.
8 changes: 7 additions & 1 deletion app/src/main/java/com/sevtinge/hyperceiler/XposedInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,18 @@ public void initZygote(IXposedHookZygoteInit.StartupParam startupParam) throws T

@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
EzXHelper.initHandleLoadPackage(lpparam);
EzXHelper.setLogTag(TAG);
EzXHelper.setToastTag(TAG);
// load CorePatch
new SystemFrameworkForCorePatch().handleLoadPackage(lpparam);

if ("com.miui.contentcatcher".equals(lpparam.packageName) ||
"com.miui.catcherpatch".equals(lpparam.packageName)) {
return;
}
// load Module hook apps
init(lpparam);
new SystemFrameworkForCorePatch().handleLoadPackage(lpparam);
if (mPrefsMap.getBoolean("system_framework_network_flightmode_hotspot"))
new FlightModeHotSpot().handleLoadPackage(lpparam);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@ protected void afterHookedMethod(MethodHookParam param) {
}
}

@Override
Class<?> getIsVerificationEnabledClass(ClassLoader classLoader) {
return XposedHelpers.findClass("com.android.server.pm.PackageManagerService", classLoader);
}

Class<?> getParsedPackage(ClassLoader classLoader) {
return XposedHelpers.findClassIfExists("com.android.server.pm.parsing.pkg.ParsedPackage", classLoader);
}
Expand All @@ -143,4 +138,9 @@ protected Object SharedUserSetting_packages(Object sharedUser) {
protected Object SigningDetails_mergeLineageWith(Object self, Object other) {
return XposedHelpers.callMethod(self, "mergeLineageWith", other, 2 /*MERGE_RESTRICTED_CAPABILITY*/);
}

@Override
Class<?> getIsVerificationEnabledClass(ClassLoader classLoader) {
return XposedHelpers.findClass("com.android.server.pm.PackageManagerService", classLoader);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,35 +49,34 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam loadPackageParam)
"android.content.pm.PackageInfoLite",
new ReturnConstant(prefs, "prefs_key_system_framework_core_patch_downgr", null));

findAndHookMethod("com.android.server.pm.ScanPackageUtils", loadPackageParam.classLoader,
"assertMinSignatureSchemeIsValid",
"com.android.server.pm.pkg.AndroidPackage", int.class,
new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) {
if (prefs.getBoolean("prefs_key_system_framework_core_patch_auth_creak", true)) {
param.setResult(null);
}
}
});

findAndHookMethod("com.android.server.pm.InstallPackageHelper", loadPackageParam.classLoader,
"doesSignatureMatchForPermissions", String.class,
"com.android.server.pm.parsing.pkg.ParsedPackage", int.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) {
if (prefs.getBoolean("prefs_key_system_framework_core_patch_digest_creak", true) && prefs.getBoolean("prefs_key_system_framework_core_patch_use_pre_signature", false)) {
//If we decide to crack this then at least make sure they are same apks, avoid another one that tries to impersonate.
if (param.getResult().equals(false)) {
String pPname = (String) XposedHelpers.callMethod(param.args[1], "getPackageName");
if (pPname.contentEquals((String) param.args[0])) {
param.setResult(true);
"doesSignatureMatchForPermissions", String.class,
"com.android.server.pm.parsing.pkg.ParsedPackage", int.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) {
if (prefs.getBoolean("prefs_key_system_framework_core_patch_digest_creak", true) && prefs.getBoolean("prefs_key_system_framework_core_patch_use_pre_signature", false)) {
//If we decide to crack this then at least make sure they are same apks, avoid another one that tries to impersonate.
if (param.getResult().equals(false)) {
String pPname = (String) XposedHelpers.callMethod(param.args[1], "getPackageName");
if (pPname.contentEquals((String) param.args[0])) {
param.setResult(true);
}
}
}
}
}
});

findAndHookMethod("com.android.server.pm.ScanPackageUtils", loadPackageParam.classLoader,
"assertMinSignatureSchemeIsValid",
"com.android.server.pm.pkg.AndroidPackage", int.class,
new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) {
if (prefs.getBoolean("prefs_key_system_framework_core_patch_auth_creak", true)) {
param.setResult(null);
}
}
});
});

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
*/
package com.sevtinge.hyperceiler.module.skip;

import static com.sevtinge.hyperceiler.BuildConfig.DEBUG;

import android.os.Build;

import com.github.kyuubiran.ezxhelper.EzXHelper;
import com.sevtinge.hyperceiler.module.hook.systemframework.corepatch.CorePatchForR;
import com.sevtinge.hyperceiler.module.hook.systemframework.corepatch.CorePatchForS;
import com.sevtinge.hyperceiler.module.hook.systemframework.corepatch.CorePatchForT;
Expand All @@ -38,9 +39,7 @@ public class SystemFrameworkForCorePatch implements IXposedHookLoadPackage, IXpo
@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
if (("android".equals(lpparam.packageName)) && (lpparam.processName.equals("android"))) {
EzXHelper.initHandleLoadPackage(lpparam);
// EzXHelper.setLogTag(TAG);
// EzXHelper.setToastTag(TAG);
if (DEBUG) XposedLogUtils.logD(TAG, "android", "handleLoadPackage: Current sdk version " + Build.VERSION.SDK_INT);
switch (Build.VERSION.SDK_INT) {
case Build.VERSION_CODES.VANILLA_ICE_CREAM -> // 35
new CorePatchForV().handleLoadPackage(lpparam);
Expand All @@ -55,14 +54,15 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Th
case Build.VERSION_CODES.R -> // 30
new CorePatchForR().handleLoadPackage(lpparam);
default ->
XposedLogUtils.logW("CorePatch", "android", "Unsupported Version of Android " + Build.VERSION.SDK_INT);
XposedLogUtils.logW(TAG, "android", "Unsupported Version of Android " + Build.VERSION.SDK_INT);
}
}
}

@Override
public void initZygote(StartupParam startupParam) {
if (startupParam.startsSystemServer) {
if (DEBUG) XposedLogUtils.logD(TAG, "android", "initZygote: Current sdk version " + Build.VERSION.SDK_INT);
switch (Build.VERSION.SDK_INT) {
case Build.VERSION_CODES.UPSIDE_DOWN_CAKE -> // 34
new CorePatchForU().initZygote(startupParam);
Expand All @@ -75,7 +75,7 @@ public void initZygote(StartupParam startupParam) {
case Build.VERSION_CODES.R -> // 30
new CorePatchForR().initZygote(startupParam);
default ->
XposedLogUtils.logW("CorePatch", "android", "Unsupported Version of Android " + Build.VERSION.SDK_INT);
XposedLogUtils.logW(TAG, "android", "Unsupported Version of Android " + Build.VERSION.SDK_INT);
}
}
}
Expand Down

0 comments on commit 8ec3671

Please sign in to comment.