-
Notifications
You must be signed in to change notification settings - Fork 65
Non-null filtering, because sometimes insn's are null and transformer… #76
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If instruction is null then some transformer is badly designed. But if you really want, i've requested some small changes.
@@ -19,7 +20,8 @@ public class CompareInstructionsTransformer extends FramedInstructionsTransforme | |||
@Override | |||
protected Stream<AbstractInsnNode> getInstructionsStream(Stream<AbstractInsnNode> stream) { | |||
return stream | |||
.filter(insn -> AsmMathHelper.isMathCompare(insn.getOpcode())); | |||
.filter(Objects::nonNull) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to check here if it is null as you already check it in FramedInstructionsTransformer
@@ -19,7 +20,8 @@ public class MathOperationsTransformer extends FramedInstructionsTransformer { | |||
@Override | |||
protected Stream<AbstractInsnNode> getInstructionsStream(Stream<AbstractInsnNode> stream) { | |||
return stream | |||
.filter(insn -> AsmMathHelper.isMathOperation(insn.getOpcode())); | |||
.filter(Objects::nonNull) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
@@ -18,7 +19,8 @@ public class NumberCastsTransformer extends FramedInstructionsTransformer { | |||
@Override | |||
protected Stream<AbstractInsnNode> getInstructionsStream(Stream<AbstractInsnNode> stream) { | |||
return stream | |||
.filter(insn -> AsmMathHelper.isNumberCast(insn.getOpcode())); | |||
.filter(Objects::nonNull) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
And for future reference, don't commit from a master branch, but create a new fresh branch for your PR. This will make it easier for you in your future PRs to any open-source repository. |
You wrote universalnumbertransformer, and i occured many nullpointers, so just inserted a check and now everything is fine. |
Hmm. That's unexpected behaviour. Maybe i do some sanity checks after each transformer if any transformer didn't accidentally break. |
im now deobfuscating pretty heavily obfuscated jar, so maybe it has some as null presented insn's if its even possible |
If jar is valid and it is running well, then there shouldn't be any null instructions. Some transformer might broke it. |
i never had to check an instruction being null with asm api except for getNext()/gtPrevious() |
Perhaps better solution would be attaching the jar in question as a test suite? |
@Animowany Your issue should be partially resolved by 521c096 . Now the deobfuscator will throw an error which transformer did something bad in instructions list, instead of acting this weird behaviour with replacing all instructions with nulls. By this change you can then find the root cause of an error very easily. |
… catches error.