Skip to content

Commit 144d573

Browse files
committed
update libs, refactor
1 parent 0320003 commit 144d573

File tree

8 files changed

+24
-51
lines changed

8 files changed

+24
-51
lines changed

deobfuscator-api/pom.xml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,11 @@
1616
<maven.compiler.target>17</maven.compiler.target>
1717
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1818

19-
<!--
20-
We need to use a snapshot version of asm lib as there are some recent important changes to it
21-
that are not in a release version yet:
22-
- https://gitlab.ow2.org/asm/asm/-/merge_requests/418
23-
-->
24-
<asm.version>9.8-SNAPSHOT</asm.version>
19+
<asm.version>9.8</asm.version>
2520

2621
<log4j.version>2.23.1</log4j.version>
2722
<slf4j.version>2.0.13</slf4j.version>
28-
<cafedude.version>2.1.4</cafedude.version>
23+
<cafedude.version>2.2.0</cafedude.version>
2924
<ssvm.version>ca3c3ab713</ssvm.version>
3025
<jlinker.version>205d8eaa1f</jlinker.version>
3126
</properties>
@@ -35,11 +30,6 @@
3530
<id>jitpack.io</id>
3631
<url>https://jitpack.io</url>
3732
</repository>
38-
39-
<repository>
40-
<id>ow2-repo</id>
41-
<url>https://repository.ow2.org/nexus/content/repositories/snapshots</url>
42-
</repository>
4333
</repositories>
4434

4535
<dependencies>

deobfuscator-api/src/main/java/org/objectweb/asm/tree/AbstractInsnNode.java

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@
3737

3838
import org.jetbrains.annotations.Nullable;
3939
import org.objectweb.asm.MethodVisitor;
40-
import org.objectweb.asm.Opcodes;
4140
import org.objectweb.asm.tree.analysis.Frame;
42-
import org.objectweb.asm.tree.analysis.OriginalSourceValue;
43-
import org.objectweb.asm.tree.analysis.SourceValue;
4441
import org.objectweb.asm.tree.analysis.Value;
4542
import uwu.narumi.deobfuscator.api.asm.NamedOpcodes;
4643
import org.objectweb.asm.Type;
@@ -451,13 +448,9 @@ public boolean isVarStore() {
451448
return this.getOpcode() >= ISTORE && this.getOpcode() <= ASTORE;
452449
}
453450

454-
public int sizeOnStack() {
455-
if (this.isLong() || this.isDouble()) {
456-
// Only long and double values take up two stack values
457-
return 2;
458-
} else {
459-
return 1;
460-
}
451+
public boolean isCompare() {
452+
return (this.getOpcode() >= IFEQ && this.getOpcode() <= IF_ACMPNE)
453+
|| (this.getOpcode() >= IFNULL && this.getOpcode() <= IFNONNULL);
461454
}
462455

463456
public boolean isJump() {
@@ -468,15 +461,6 @@ public JumpInsnNode asJump() {
468461
return (JumpInsnNode) this;
469462
}
470463

471-
public int conditionStackSize() {
472-
if (this.getOpcode() >= IF_ICMPEQ && this.getOpcode() <= IF_ICMPLE) return 2;
473-
474-
if ((this.getOpcode() >= IFEQ && this.getOpcode() <= IFLE)
475-
|| (this.getOpcode() == IFNULL || this.getOpcode() == IFNONNULL)) return 1;
476-
477-
return 0;
478-
}
479-
480464
public MethodInsnNode asMethodInsn() {
481465
return (MethodInsnNode) this;
482466
}
@@ -654,9 +638,9 @@ public String namedOpcode() {
654638
}
655639

656640
/**
657-
* Returns the number of stack values required by this instruction.
641+
* Returns the number of stack values consumed by this instruction
658642
*/
659-
public int getRequiredStackValuesCount(Frame<? extends Value> frame) {
643+
public int sizeOnStack(Frame<? extends Value> frame) {
660644
return switch (this.getOpcode()) {
661645
// Unary operations (one value)
662646
case ISTORE, LSTORE, FSTORE, DSTORE, ASTORE, POP, DUP, DUP_X1, SWAP, INEG,

deobfuscator-api/src/main/java/uwu/narumi/deobfuscator/api/asm/InsnContext.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ public MethodContext methodContext() {
4444
return methodContext;
4545
}
4646

47-
public int getRequiredStackValuesCount() {
48-
return this.insn.getRequiredStackValuesCount(this.frame());
47+
public int sizeOnStack() {
48+
return this.insn.sizeOnStack(this.frame());
4949
}
5050

5151
/**
5252
* Places POPs instructions before current instruction to remove source values from the stack.
5353
* This method automatically calculates how many stack values to pop.
5454
*/
5555
public void placePops() {
56-
for (int i = 0; i < this.getRequiredStackValuesCount(); i++) {
56+
for (int i = 0; i < this.sizeOnStack(); i++) {
5757
int stackValueIdx = frame().getStackSize() - (i + 1);
5858
OriginalSourceValue sourceValue = frame().getStack(stackValueIdx);
5959

deobfuscator-api/src/main/java/uwu/narumi/deobfuscator/api/context/Context.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ public void addCompiledClass(String pathInJar, byte[] bytes) {
8585
// Fix class bytes
8686
bytes = ClassHelper.fixClass(bytes);
8787

88+
// Class is always a file, not a directory. Remove last slash if it exists
89+
pathInJar = pathInJar.replaceAll("/$", "");
90+
8891
ClassWrapper classWrapper = ClassHelper.loadClass(pathInJar, bytes, ClassReader.SKIP_FRAMES);
8992
this.classesMap.putIfAbsent(classWrapper.name(), classWrapper);
9093

deobfuscator-api/src/main/java/uwu/narumi/deobfuscator/api/helper/MethodHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public static Map<AbstractInsnNode, Set<AbstractInsnNode>> computeConsumersMap(M
121121
if (frame == null) continue;
122122

123123
// Loop through stack values and add consumer to them
124-
for (int i = 0; i < consumer.getRequiredStackValuesCount(frame); i++) {
124+
for (int i = 0; i < consumer.sizeOnStack(frame); i++) {
125125
// Get the value from the stack (first consumed value is at the top)
126126
OriginalSourceValue sourceValue = frame.getStack(frame.getStackSize() - (i + 1));
127127

deobfuscator-transformers/src/main/java/uwu/narumi/deobfuscator/core/other/impl/qprotect/qProtectFieldFlowTransformer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class qProtectFieldFlowTransformer extends Transformer {
1818
// Compare
1919
NumberMatch.of(),
2020
OpcodeMatch.of(GETSTATIC),
21-
OpcodeMatch.of(IF_ICMPGT)
21+
Match.of(ctx -> ctx.insn().isCompare())
2222
);
2323

2424
@Override

deobfuscator-transformers/src/main/java/uwu/narumi/deobfuscator/core/other/impl/universal/number/InlineConstantValuesTransformer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ protected void transform() throws Exception {
2020
FramedInstructionsStream.of(this)
2121
.forceSync()
2222
.forEach(insnContext -> {
23-
int stackCount = insnContext.getRequiredStackValuesCount();
23+
int stackSize = insnContext.sizeOnStack();
2424

2525
// Iterate over stack values
26-
for (int i = 0; i < stackCount; i++) {
26+
for (int i = 0; i < stackSize; i++) {
2727
// Using "originalSource" ensures that we don't replace DUPs or var loads
2828
OriginalSourceValue sourceValue = insnContext.frame().getStack(insnContext.frame().getStackSize() - (i + 1)).originalSource;
2929

testData/results/custom-classes/qprotect/sample1/XML.dec

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ public class XML {
117117
} else if (var5 == '[') {
118118
var10 = var0.nextToken();
119119
if ("CDATA".equals(var10) && var0.next() == '[') {
120-
String var16 = var0.nextCDATA();
121-
if (var16.length() > 0) {
122-
var1.accumulate(var3.getcDataTagName(), var16);
120+
String var14 = var0.nextCDATA();
121+
if (var14.length() > 0) {
122+
var1.accumulate(var3.getcDataTagName(), var14);
123123
}
124124

125125
return false;
@@ -212,12 +212,12 @@ public class XML {
212212
}
213213

214214
if (var10 instanceof String) {
215-
String var15 = (String)var10;
216-
if (var15.length() > 0) {
215+
String var13 = (String)var10;
216+
if (var13.length() > 0) {
217217
if (var11 != null) {
218-
var7.accumulate(var3.getcDataTagName(), stringToValue(var15, var11));
218+
var7.accumulate(var3.getcDataTagName(), stringToValue(var13, var11));
219219
} else {
220-
var7.accumulate(var3.getcDataTagName(), var3.isKeepStrings() ? var15 : stringToValue(var15));
220+
var7.accumulate(var3.getcDataTagName(), var3.isKeepStrings() ? var13 : stringToValue(var13));
221221
}
222222
}
223223
} else if (var10 == LT) {
@@ -238,10 +238,6 @@ public class XML {
238238
var1.accumulate(var9, "");
239239
} else if (var7.length() == 1 && var7.opt(var3.getcDataTagName()) != null) {
240240
var1.accumulate(var9, var7.opt(var3.getcDataTagName()));
241-
int var14 = 19118812;
242-
IIlllllIIIllllIl = var14;
243-
if (333213067 < IIlllllIIIllllIl) {
244-
}
245241
} else {
246242
if (!var3.shouldTrimWhiteSpace()) {
247243
removeEmpty(var7, var3);

0 commit comments

Comments
 (0)