Enigma icon indicating copy to clipboard operation
Enigma copied to clipboard

Support user defined "is entry obfuscated" condition

Open NZSmartie opened this issue 5 years ago • 4 comments

Using Enigma with StarMade. Their obfuscated classes are namespaced under obfuscated.

image

Investigating how Enigma splits classes between Obfuscated Classes and De-obfuscated Classes, the Gui Controller invokes Deobfuscator.getSeperateClasses(...): https://github.com/FabricMC/Enigma/blob/19a77fbb472592e116f2f6654657eeec81d40b18/src/main/java/cuchaz/enigma/Deobfuscator.java#L159-L179

Since the obfuscated entries in this case have a package name, they are marked as deobfuscated.

Would it be a good ideal to support comparing against a regular expression to force entries as obfuscated? What are some options to work around this?

NZSmartie avatar Mar 16 '19 11:03 NZSmartie

Probably easiest way to work around would be to process the jar to move all the obfuscated classes out of that package, and then import that jar into Enigma.

On Enigma's side, I'm quite unsure what would be the best way to support jars like this. We could just hardcode checking for an obfuscated package, but it's quite arbitrary.

Gegy avatar Mar 16 '19 11:03 Gegy

What tool can I use to move the classes out of that package?

NZSmartie avatar Mar 16 '19 11:03 NZSmartie

None that would exist already -- you'd have to make your own

Gegy avatar Mar 16 '19 11:03 Gegy

On Enigma's side, I'm quite unsure what would be the best way to support jars like this. We could just hardcode checking for an obfuscated package, but it's quite arbitrary.

any more arbitrary than checking if an entry has no package, which would mean doing something like the following patch would be considered okay?

diff --git a/src/main/java/cuchaz/enigma/Deobfuscator.java b/src/main/java/cuchaz/enigma/Deobfuscator.java
index b4736d8..00f95ae 100644
--- a/src/main/java/cuchaz/enigma/Deobfuscator.java
+++ b/src/main/java/cuchaz/enigma/Deobfuscator.java
@@ -168,7 +168,7 @@ public class Deobfuscator {
                        if (!deobfClassEntry.equals(obfClassEntry)) {
                                // if the class has a mapping, clearly it's deobfuscated
                                deobfClasses.add(obfClassEntry);
-                       } else if (obfClassEntry.getPackageName() != null) {
+                       } else if (obfClassEntry.getPackageName() != null && !obfClassEntry.getPackageName().equals("obfuscated")) {
                                // also call it deobufscated if it's not in the none package
                                deobfClasses.add(obfClassEntry);
                        } else {

NZSmartie avatar Mar 16 '19 12:03 NZSmartie

Modern Enigma by default treats all classes as obfuscated, regardless of package, so this issue can be closed

NebelNidas avatar Sep 21 '22 21:09 NebelNidas