@@ -60,9 +60,9 @@ protected void transform() throws Exception {
6060 });
6161
6262 /** Example
63- * ldc 952006311
64- * invokestatic ikjlkypytwnvkuzi/erfobcthglyygbhq.jwmyqfvhltjhsidh (I)I
65- * */
63+ * ldc 952006311
64+ * invokestatic ikjlkypytwnvkuzi/erfobcthglyygbhq.jwmyqfvhltjhsidh (I)I
65+ * */
6666 staticDecryption .findAllMatches (methodContext ).forEach (matchContext -> {
6767 MethodInsnNode methodInsnNode = matchContext .captures ().get ("predicate-method" ).insn ().asMethodInsn ();
6868 AbstractInsnNode salt = matchContext .captures ().get ("salt" ).insn ();
@@ -76,10 +76,12 @@ protected void transform() throws Exception {
7676 JumpMatch .of ().capture ("jump" ).findAllMatches (methodContext ).forEach (matchContext -> {
7777 JumpInsnNode jumpInsnNode = matchContext .captures ().get ("jump" ).insn ().asJump ();
7878 if (jumpInsnNode .label .getNext () instanceof LdcInsnNode intLdc && jumpInsnNode .label .getNext (2 ) instanceof VarInsnNode varStore && jumpInsnNode .label .getNext (3 ) instanceof JumpInsnNode jump1 ) {
79+ if (blessedJumpLabels .contains (jump1 .label )) return ;
7980 methodNode .instructions .remove (varStore );
8081 methodNode .instructions .remove (intLdc );
8182 methodNode .instructions .insert (jump1 .label , varStore );
8283 methodNode .instructions .insert (jump1 .label , intLdc );
84+ blessedJumpLabels .add (jump1 .label );
8385 markChange ();
8486 }
8587 LdcInsnNode lastLdcOfLabel = null ;
@@ -95,45 +97,49 @@ protected void transform() throws Exception {
9597 setVarJump .findAllMatches (methodContext ).forEach (matchContext1 -> {
9698 if (finalLastLdcOfLabel .cst instanceof Integer && matchContext1 .captures ().get ("salt1" ).insn ().asInteger () == (int ) finalLastLdcOfLabel .cst ) {
9799 VarInsnNode var = (VarInsnNode ) matchContext1 .captures ().get ("var" ).insn ();
100+ LabelNode blessedLabel = matchContext1 .captures ().get ("jump" ).insn ().asJump ().label ;
101+ if (blessedJumpLabels .contains (blessedLabel )) return ;
98102 methodNode .instructions .insert (matchContext1 .captures ().get ("jump" ).insn ().asJump ().label , new VarInsnNode (ISTORE , var .var ));
99103 methodNode .instructions .insert (matchContext1 .captures ().get ("jump" ).insn ().asJump ().label , new LdcInsnNode (finalLastLdcOfLabel .cst ));
104+ blessedJumpLabels .add (blessedLabel );
100105 }
101106 });
102107 }
103108 });
104109
105110 if (!isChanged ()) {
106- MatchContext matchContext = SequenceMatch .of (NumberMatch .numInteger ().capture ("hash" ), OpcodeMatch .of (ISTORE ).capture ("param" ), Match .of (ctx -> ctx .insn () instanceof LabelNode ).capture ("label" )).doNotSkipLabels ().findFirstMatch (methodContext );
107- if (matchContext != null ) {
108- int salt = matchContext .captures ().get ("hash" ).insn ().asInteger ();
109- int param = ((VarInsnNode )matchContext .captures ().get ("param" ).insn ()).var ;
110- LabelNode label = (LabelNode ) matchContext .captures ().get ("label" ).insn ();
111- if (label .getNext () instanceof JumpInsnNode jumpInsnNode ) label = jumpInsnNode .label ;
112- if (blessedLabels .contains (label )) return ;
113- LabelNode finalLabel = label ;
114- methodNode .tryCatchBlocks .forEach (tcb -> {
115- if (finalLabel .equals (tcb .start ) || finalLabel .equals (tcb .handler ) || finalLabel .equals (tcb .end )) {
116- methodNode .instructions .insert (tcb .start , new VarInsnNode (ISTORE , param ));
117- methodNode .instructions .insert (tcb .start , new LdcInsnNode (salt ));
118- methodNode .instructions .insert (tcb .handler , new VarInsnNode (ISTORE , param ));
119- methodNode .instructions .insert (tcb .handler , new LdcInsnNode (salt ));
120- methodNode .instructions .insert (tcb .end , new VarInsnNode (ISTORE , param ));
121- methodNode .instructions .insert (tcb .end , new LdcInsnNode (salt ));
122- blessedLabels .add (tcb .start );
123- blessedLabels .add (tcb .handler );
124- blessedLabels .add (tcb .end );
125- }
126- });
127- methodNode .instructions .insert (label , new VarInsnNode (ISTORE , param ));
128- methodNode .instructions .insert (label , new LdcInsnNode (salt ));
129- markChange ();
130- blessedLabels .add (label );
131- }
111+ MatchContext matchContext = SequenceMatch .of (NumberMatch .numInteger ().capture ("hash" ), OpcodeMatch .of (ISTORE ).capture ("param" ), Match .of (ctx -> ctx .insn () instanceof LabelNode ).capture ("label" )).doNotSkipLabels ().findFirstMatch (methodContext );
112+ if (matchContext != null ) {
113+ int salt = matchContext .captures ().get ("hash" ).insn ().asInteger ();
114+ int param = ((VarInsnNode )matchContext .captures ().get ("param" ).insn ()).var ;
115+ LabelNode label = (LabelNode ) matchContext .captures ().get ("label" ).insn ();
116+ if (label .getNext () instanceof JumpInsnNode jumpInsnNode ) label = jumpInsnNode .label ;
117+ if (blessedLabels .contains (label )) return ;
118+ LabelNode finalLabel = label ;
119+ methodNode .tryCatchBlocks .forEach (tcb -> {
120+ if (finalLabel .equals (tcb .start ) || finalLabel .equals (tcb .handler ) || finalLabel .equals (tcb .end )) {
121+ methodNode .instructions .insert (tcb .start , new VarInsnNode (ISTORE , param ));
122+ methodNode .instructions .insert (tcb .start , new LdcInsnNode (salt ));
123+ methodNode .instructions .insert (tcb .handler , new VarInsnNode (ISTORE , param ));
124+ methodNode .instructions .insert (tcb .handler , new LdcInsnNode (salt ));
125+ methodNode .instructions .insert (tcb .end , new VarInsnNode (ISTORE , param ));
126+ methodNode .instructions .insert (tcb .end , new LdcInsnNode (salt ));
127+ blessedLabels .add (tcb .start );
128+ blessedLabels .add (tcb .handler );
129+ blessedLabels .add (tcb .end );
130+ }
131+ });
132+ methodNode .instructions .insert (label , new VarInsnNode (ISTORE , param ));
133+ methodNode .instructions .insert (label , new LdcInsnNode (salt ));
134+ markChange ();
135+ blessedLabels .add (label );
136+ }
132137 }
133138 }));
134139 }
135140
136141 private final static Set <LabelNode > blessedLabels = new HashSet <>();
142+ private final static Set <LabelNode > blessedJumpLabels = new HashSet <>();
137143
138144 public int m1 (int n ) {
139145 if (n != 0 ) {
@@ -145,4 +151,4 @@ public int m1(int n) {
145151 public int m2_m3 (int n ) {
146152 return (n & 0xE0000000 ) >> 29 | n << 3 ;
147153 }
148- }
154+ }
0 commit comments