-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for exporting to proper deobfuscation mapping file formats #1505
Conversation
This pull request introduces 1 alert when merging d0fc80d into 9d88592 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging b5c7ad9 into 9d88592 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging d14c59a into fcd58ae - view on LGTM.com new alerts:
|
@skylot It's almost done now, but I need some help with the method args. How can I access them? I looked around the code, but couldn't find a solution. I mean, there's boolean wasLoaded = mth.isLoaded();
try {
mth.load();
for (RegisterArg arg : mth.getArgRegs()) {
if (mappedMethodArgsAndVars.contains(methodInfo.getDeclClass() + methodInfo.getShortId())) {
mappingTree.visitClass(classPath);
mappingTree.visitMethod(methodName, methodDesc);
mappingTree.visitMethodArg(arg.getRegNum(), 0, arg.getName());
mappingTree.visitDstName(MappedElementKind.METHOD_ARG, 0, arg.getName());
}
}
} catch (DecodeException e) {
LOG.error("Error while decompiling method " + methodInfo.getShortId());
}
if (!wasLoaded) {
mth.unload();
} |
@NebelNidas information you are trying to get available at decompilation stage, and accessible inside decompile passes only. jadx/jadx-gui/src/main/java/jadx/gui/ui/codearea/FridaAction.java Lines 117 to 138 in fa41874
(replace JavaMethod with MethodNode and method names to similar ones)
If you need to get only renamed args you need to filter that using |
Thank you! I've already gone down another route, which also works well so far, only issue is that for (RegisterArg arg : mth.getArgRegs()) {
arg.getSVar()
} always returns |
As I said in previous comment: that info not available at that point. And, yes, you can access reg and ssa numbers from |
Thank you for the help, method args work now :) One question though: What's the reason for using
|
Code generated only for top level classes, and inner classes can have any nesting level, i.e. parent class of inner can be not a top class. |
How would I do the same for method vars? I guess I would have to replace the jadx/jadx-gui/src/main/java/jadx/gui/ui/codearea/FridaAction.java Lines 123 to 124 in fa41874
|
I think you can stop if |
Good idea! I still need to get a few properties from the resulting
For the local variable index I already have code (which I think works correctly), see here: jadx/jadx-core/src/main/java/jadx/core/deobf/Deobfuscator.java Lines 254 to 266 in 235991f
Is there an easier way to get this result? And I have no idea yet how I can get the lv-start-offset .
|
Offset stored in metadata annotation with type
Variables array can be acquired using |
Can I use the |
You can, but I am not sure how you will match it with |
Well, I can miss something, that is why I give you a link to a code jadx using to read these values 🙂
I don't know, but this can happen. |
Tiny v2 allows specifying an optional
Would this help in such edge cases? |
Temporarily move to my mapping-io fork until this PR gets merged: FabricMC/mapping-io#19
Yeah, here should be alias pkg and name. Intention was to make aliased name while not using inner classes, i.e. replace back '.' with '$', but looks like this was not used anywhere. And to be honest, I have no idea why you may need this method.
It is hard to tell. Maybe variable declaration without code don't have offset (like |
I'm an absolute idiot... The returned offset was correct the entire time; it was just my test comment that was placed on the wrong line! 🤦 |
@NebelNidas please move all your changes to a new class into a jadx-gui module and
I understand that this will be make an import a little harder to implement (may need to add a new API to insert custom jadx passes), but result will be more modular (and less coupled). |
I purposefully left it in there, because I want to replace the JOBF format with Tiny v2 in the next PR (and JOBF is also partly handled in the |
Can you wait a few minutes before merging please? I'm making the exporting async |
Sure. You can mark PR as draft if it is not ready for merge :)
You don't need to replace jobf you're just adding support for other formats.
Please, don't mix mapping, deobfuscation and renames these are different things, yes they are related, but yet these are different features. Also, you don't need deobfuscator because node aliases can be accessed (and also updated) from |
Took a bit longer than expected, but it's ready to be merged now :) |
Adds support for exporting manually renamed classes/methods/fields etc. in the Tiny v2 format, which is the most versatile out there and can handle a lot more features than JADX's default
.jobf
format. For more details, see its spec.Depends on FabricMC's
mapping-io
library, which theoretically allows JADX to support many more formats in the future.This PR doesn't add Tiny v2 import support yet, as I don't need it personally atm, but it can be easily added later when needed.
Fixes #1491.
Currently working: