java-deobfuscator / deobfuscator

The real deal
https://javadeobfuscator.com
Apache License 2.0
1.54k stars 288 forks source link

Nullpointer when Deobfuscating #700

Closed byBackfish closed 3 years ago

byBackfish commented 3 years ago

Hey, when trying to decompile a Minecraft Forge Mod, i come across this Error

        Deobfuscation failed. Please open a ticket on GitHub and provide the following error:
        java.lang.NullPointerException: Cannot invoke "com.javadeobfuscator.deobfuscator.executor.defined.types.JavaMethod.getDeclaringClass()" because the return value of "com.javadeobfuscator.deobfuscator.executor.values.JavaValue.as(java.lang.Class)" is null
        at com.javadeobfuscator.deobfuscator.executor.defined.JVMMethodProvider$1$43.lambda$3(JVMMethodProvider.java:605)
        at com.javadeobfuscator.deobfuscator.executor.defined.JVMMethodProvider$Function3.applyUnchecked(JVMMethodProvider.java:977)
        at com.javadeobfuscator.deobfuscator.executor.defined.JVMMethodProvider.invokeMethod(JVMMethodProvider.java:892)        at com.javadeobfuscator.deobfuscator.executor.providers.DelegatingProvider.invokeMethod(DelegatingProvider.java:35)
        at com.javadeobfuscator.deobfuscator.executor.MethodExecutor.execute(MethodExecutor.java:1200)
        at com.javadeobfuscator.deobfuscator.executor.MethodExecutor.execute(MethodExecutor.java:78)
        at com.javadeobfuscator.deobfuscator.transformers.stringer.HideAccessObfuscationTransformer.lambda$4(HideAccessObfuscationTransformer.java:145)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
        at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
        at com.javadeobfuscator.deobfuscator.transformers.stringer.HideAccessObfuscationTransformer.lambda$2(HideAccessObfuscationTransformer.java:127)
        at java.base/java.util.HashMap$Values.forEach(HashMap.java:1067)
        at com.javadeobfuscator.deobfuscator.transformers.stringer.HideAccessObfuscationTransformer.transform(HideAccessObfuscationTransformer.java:126)
        at com.javadeobfuscator.deobfuscator.Deobfuscator.runFromConfig(Deobfuscator.java:410)
        at com.javadeobfuscator.deobfuscator.Deobfuscator.start(Deobfuscator.java:367)
        at com.javadeobfuscator.deobfuscator.DeobfuscatorMain.run(DeobfuscatorMain.java:120)
        at com.javadeobfuscator.deobfuscator.DeobfuscatorMain.run(DeobfuscatorMain.java:113)
        at com.javadeobfuscator.deobfuscator.DeobfuscatorMain.main(DeobfuscatorMain.java:50)

My Config:

input: input.jar
output: output.jar
path:
 - C:/Program Files/Java/jdk1.8.0_271/jre/lib/rt.jar
libraries:
  - C:\Users\***\Desktop\deobf\libary\forgeBin-1.8.9-11.15.1.2318-1.8.9.jar
transformers:
  - com.javadeobfuscator.deobfuscator.transformers.stringer.StringEncryptionTransformer
  - com.javadeobfuscator.deobfuscator.transformers.stringer.HideAccessObfuscationTransformer
  - com.javadeobfuscator.deobfuscator.transformers.zelix.string.EnhancedStringEncryptionTransformer
  - com.javadeobfuscator.deobfuscator.transformers.normalizer.SourceFileClassNormalizer
byBackfish commented 3 years ago

I saw that @ThisTestUser helped a Guy in #386 with a similar Minecraft Mod, by changing some Code in the Transformer. I would appreciate if you could tell me what to change / send me the fixed Transformer Class (HideAccessObfuscationTransformer). Thanks in advance!

ThisTestUser commented 3 years ago

The first thing you should do is to add all the libraries (look them up from the previous issue). Then, you should wrap the switch statement (starting from line 172) with a try-catch block and also wrap everything inside the if statement at line 131 with another try-catch block.

byBackfish commented 3 years ago

So. Its not skipping the errors (bc of the try catch), but its still not changing the Names of the Classes, and not fully working still. Its saying something like "Error: failed to compute frames". But why exactly? Thanks

fee1-dead commented 3 years ago

Why exactly? The program will tell you. You might see classes that are not found. How can we tell?

byBackfish commented 3 years ago

[SourceFileClassNormalizer] Recovered 885 source filenames [main] INFO com.javadeobfuscator.deobfuscator.Deobfuscator - Writing Error: failed to compute frames Error: failed to compute frames Error: failed to compute frames Error: failed to compute frames Error: failed to compute frames Error: failed to compute frames Error: failed to compute frames Error: failed to compute frames Error: failed to compute frames Error: failed to compute frames

Thats the only thing i get. Above that its just saying Decrypted string and then the String name

byBackfish commented 3 years ago

And alot of NPE's from the HideAccessObfuscationTransformer. But i got told they are not that problematic.

byBackfish commented 3 years ago

Now its saying something like "[ClassLoader] An attempt was made to load the library awt.dll [Filesystem] Could not find null.accessibility.properties [Filesystem] Could not find C:\java_home_dir\lib\accessibility.properties". Why is it using java_home_dir when my JAVA_HOME path is set to my jdk 1.8. Or what JDK do you recommend using?

Janmm14 commented 3 years ago

I think it is using a virtual java home dir aka emulated file system

byBackfish commented 3 years ago

Could this be causing the Error tho? With "error" i mean, that its not changing the Class File names? And not changing anything in the Code at all. The Output is exactly the same as the Input

byBackfish commented 3 years ago

Or what else could cause this?

ThisTestUser commented 3 years ago

You can't get the original class file names back because they've been removed. Use ClassNormalizer if you want generic names for the classes.