changhuapeng / FrameworkPatcherGO

A Magisk/KernelSU/APatch module to modify framework.jar directly on the phone, to build a valid system-level certificate chain.
https://xdaforums.com/t/module-framework-patcher-go.4674536/
320 stars 34 forks source link

Overlay given classes5.dex instead of proposing set of patches #19

Closed bphd closed 3 weeks ago

bphd commented 3 weeks ago

I've put classes5.dex in META-INF/com/google/android/magisk/dex and the software wants to apply its own baked patches instead of the already patched classes5.dex I gave that I want overlayed into my system. How to put it in "apply mode" rather than "configuration mode"?

changhuapeng commented 3 weeks ago

Firstly, The file name should be classes.dex instead of classes5.dex. And since you've mentioned classes5.dex, I assumed you're confused about this module with the tutorial in FrameworkPatch.

There is no "apply mode" or "configuration mode" at all. This module simply automates the whole process of that tutorial so you don't have to do a thing, except adding your own keybox or fingerprint, if you want.

To add your own keybox and fingerprint, all you have to do is edit the relevant code sections in Keybox.java and Android.java with yours and compile the project in Android Studio. Then extract the compiled classes.dex from the release .apk file, before copying it into META-INF/com/google/android/magisk/dex/classes.dex. The classes.dex file contains nothing from your system but only the keybox and fingerprint that you edited into the compile FrameworkPatch project.

During the installation of this module, it will then ask if you want to patch your framewok.jar to use the keybox or fingerprint from your copied classes.dex.

bphd commented 3 weeks ago

@changhuapeng

you don't have to do a thing

Problem is that I need to actually do a thing because the specific CROM use specific methods, that were patched in given classes5.dex. And the given methods by the script are useless for my case

To add your own keybox and fingerprint

I add them with PIF and TS. Here I only want to inject patched the dex that throw UnsupportedOperationException() to UnsupportedOperationException() that stops from getting strong

the compiled classes.dex

It's not a classes.dex but the classes5.dex of the original framework that was already patched

The classes.dex file contains nothing from your system

Yeah I saw that it's applied as a supplementary classe6.dex and it just re take the original classes.dex, but I don't want it to take the original classes5.dex but rather pached mine, and I don't need supplementary classes.dex, all is in the patched 5

During the installation of this module

It auto detects the class, then ask me to apply some pre defined patch that don't work and I don't want, then idk what it does with my classes5.dex but it put all original classes.dex and then put a supplementary one with only the patches of the module and call it a day. And that would be wrong to have a new classes6.dex that is a modified classes5.dex with non useful supplementary patches applied to it

That part should make the framework.jar with all the original classes back apktool b "$TMP/framework" -api "$API" --copy-original --output "$TMP/framework-patched.jar" idk how to change it to replace the classes5.dex but keep other original ones

Or maybe that part is able to overwrite classes if modified mv "$classes_dex" "$TMP/framework-patched/$mod_dex_name" cd "$TMP/framework-patched" && zip -qr0 "$TMP/framework-patched.zip" . idk

changhuapeng commented 3 weeks ago

I can see what you're trying to do now. This module is not what you think it is, so it will not solve your problem. You have to edit your framework.jar manually to remove the code because this module does not do that.

bphd commented 3 weeks ago

@changhuapeng

I can see what you're trying to do now. This module is not what you think it is, so it will not solve your problem. You have to edit your framework.jar manually to remove the code because this module does not do that.

I'm okay producing a whole framework.jar, but I want to overlay it, not hard replacing it. /data/adb/modules_update/FrameworkPatcherGo/system/framework/framework.jar don't seem to be applied whatever I put there. And I don't even know if FPG is active or even installed, it's not listed in module list. But I know it does something because bootloop when I let it apply its patches as is

ChiteroMan only say

How can I make my system rw?

If you don't know how to do that just use a module for Magisk, KernelSU or APatch.

Also, in modern devices, you must format data because modifying super partition breaks AVB.

Now move framework.jar to /system/framework, you can use a module to replace it or mount /system as read-write and replace it.

just use a module for Magisk, KernelSU or APatch.

you can use a module to replace

That part isn't explained. So maybe that mod_framework="$MODPATH$stock_framework" /data/adb/modules_update/FrameworkPatcherGo/system/framework/framework.jar could be the module support part, but it's difficult to understand as that part don't seem to be applied

changhuapeng commented 3 weeks ago

You cannot take a classes.dex from somewhere willy-nilly and transplant it into somewhere else. You mentioned about using PIF and TS but not passing strong integrity so I think you're having some misunderstandings about what this module does and what is it that you're trying to do.

To do what you want achieve, you have to edit your framework.jar and remove the particular codes that throw the UnsupportedOperationException() which you mentioned. Once that is edited out, you have to overlay or overwrite your system with the patched framework.jar. This module will not help you overlay your edited framework.jar or classes.dex, like you think what it is.

Read Magisk Developer Guides, specifically the section on "The system folder" to know what you need to do and create your own module.

bphd commented 3 weeks ago

take a classes.dex from somewhere willy-nilly

It's my original classes5.dex modified, not something brought from dark web or idk

transplant it into somewhere else

I want it to replace the orginal classes5.dex, that's all

PIF and TS but not passing strong integrity

Because CROM throw UnsupportedOperationException() to onEngineGetCertificateChain() that stops from getting strong

what this module does

Adding some pre defined patches to a new classes.dex added to framework.jar to then overlaying it

what is it that you're trying to do

Overlaying classes5.dex patched out of that bad onEngineGetCertificateChain() logic

edit your framework.jar

Already done, the classes5.dex of it was edited

remove the particular codes that throw the UnsupportedOperationException() which you mentioned

Already done, resulting classes5.dex

have to overlay or overwrite your system with the patched framework.jar

Overlay please. Tried /data/adb/modules_update/FrameworkPatcherGo/system/framework/framework.jar but to no avail. I don't even know if that place does soemthing. The module isn't even listed among other modules, weird

This module will not help you overlay

That module don't hard modify framework.jar, so it overlays it. So it should be able

like you think what it is

Well I think

what this module does

Adding some pre defined patches to a new classes.dex added to framework.jar to then overlaying it

And I want

have to overlay or overwrite your system with the patched framework.jar

Overlay please. Tried /data/adb/modules_update/FrameworkPatcherGo/system/framework/framework.jar but to no avail. I don't even know if that place does soemthing. The module isn't even listed among other modules, weird

create your own module.

It's faster to replace /data/adb/modules_update/FrameworkPatcherGo/system/framework/framework.jar and reboot but that don't seem to have any effects mysteriously