Skip to content

Commit

Permalink
mark ZelixParametersTransformer as experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
EpicPlayerA10 committed Oct 7, 2024
1 parent ba50189 commit e5bb812
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public static Type getTypeFromPrimitiveCast(MethodInsnNode insn) {
if (insn.owner.equals("java/lang/Long") && insn.name.equals("longValue")) return Type.LONG_TYPE;
if (insn.owner.equals("java/lang/Double") && insn.name.equals("doubleValue")) return Type.DOUBLE_TYPE;
if (insn.owner.equals("java/lang/Float") && insn.name.equals("floatValue")) return Type.FLOAT_TYPE;
if (insn.owner.equals("java/lang/Boolean") && insn.name.equals("booleanValue")) return Type.BOOLEAN_TYPE;

throw new IllegalStateException("Unexpected value: " + insn.owner+"."+insn.name+insn.desc);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
import java.util.List;
import java.util.function.Supplier;

import org.jetbrains.annotations.Nullable;
import uwu.narumi.deobfuscator.api.asm.ClassWrapper;
import uwu.narumi.deobfuscator.api.context.Context;

public class ComposedTransformer extends Transformer {

private final List<Supplier<Transformer>> transformers;
private final List<Supplier<@Nullable Transformer>> transformers;

@SafeVarargs
public ComposedTransformer(Supplier<Transformer>... transformers) {
public ComposedTransformer(Supplier<@Nullable Transformer>... transformers) {
this.transformers = List.of(transformers);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,22 @@ public String name() {
* @param context The context
* @return If the transformation changed something
*/
public static boolean transform(Supplier<Transformer> transformerSupplier, @Nullable ClassWrapper scope, Context context) {
public static boolean transform(Supplier<@Nullable Transformer> transformerSupplier, @Nullable ClassWrapper scope, Context context) {
return transform(transformerSupplier, scope, context, false);
}

private static boolean transform(
Supplier<Transformer> transformerSupplier,
Supplier<@Nullable Transformer> transformerSupplier,
@Nullable ClassWrapper scope,
Context context,
boolean reran
) {
Transformer transformer = transformerSupplier.get();
if (transformer == null) {
// Null means that transformer is disabled. Skip it
return false;
}

if (transformer.hasRan) {
throw new IllegalArgumentException("transformerSupplier tried to reuse transformer instance. You must pass a new instance of transformer");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected void registerAll() {
register("Some flow obf sample", InputType.CUSTOM_CLASS, List.of(ComposedGeneralFlowTransformer::new), Source.of("FlowObfSample"));

// Zelix
register("Zelix (22.0.3) Sample 1", InputType.CUSTOM_CLASS, List.of(ComposedZelixTransformer::new),
register("Zelix (22.0.3) Sample 1", InputType.CUSTOM_CLASS, List.of(() -> new ComposedZelixTransformer(true)),
Source.of("zkm/sample1/ExampleClass"),
Source.of("zkm/sample1/ILongDecrypter", false),
Source.of("zkm/sample1/LongDecrypter1", false),
Expand Down Expand Up @@ -69,7 +69,7 @@ protected void registerAll() {
*/
register("Zelix (22.0.3) Sample 2 - Class initialization order", InputType.CUSTOM_CLASS,
List.of(
() -> new ComposedZelixTransformer(
() -> new ComposedZelixTransformer(true,
// During obfuscation was specified classInitializationOrder option,
// so we need to also pass it here for correct decrypted values
Map.of("a.a.a.a.a4", "a.a.a.a.bc")
Expand Down Expand Up @@ -103,7 +103,7 @@ protected void registerAll() {
obfuscateParameters=normal;
*/
register("Zelix (21) Snake Game", InputType.CUSTOM_JAR,
List.of(ComposedZelixTransformer::new),
List.of(() -> new ComposedZelixTransformer(true)),
Source.of("SnakeGame-obf-zkm")
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@
*/
public class ComposedZelixTransformer extends ComposedTransformer {
public ComposedZelixTransformer() {
this(new HashMap<>());
this(false);
}

public ComposedZelixTransformer(Map<String, String> classInitializationOrder) {
public ComposedZelixTransformer(boolean experimental) {
this(experimental, new HashMap<>());
}

public ComposedZelixTransformer(boolean experimental, Map<String, String> classInitializationOrder) {
super(
// Initial cleanup
JsrInlinerTransformer::new,
Expand All @@ -31,7 +35,7 @@ public ComposedZelixTransformer(Map<String, String> classInitializationOrder) {
ZelixUselessTryCatchRemoverTransformer::new,

// Decompose method parameters
ZelixParametersTransformer::new,
() -> experimental ? new ZelixParametersTransformer() : null,

// Decrypt longs
() -> new ZelixLongEncryptionMPCTransformer(classInitializationOrder),
Expand Down

0 comments on commit e5bb812

Please sign in to comment.