-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: working pure function analysis hash
- Loading branch information
1 parent
ee95cde
commit 3755e1a
Showing
23 changed files
with
1,012 additions
and
1,169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 5 additions & 51 deletions
56
...ator.pureanalysis/src/main/java/dev/skidfuscator/pureanalysis/ClassHierarchyAnalyzer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,12 @@ | ||
package dev.skidfuscator.pureanalysis; | ||
|
||
import org.objectweb.asm.ClassReader; | ||
import org.objectweb.asm.tree.ClassNode; | ||
|
||
import java.io.IOException; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
public class ClassHierarchyAnalyzer { | ||
private final ConcurrentHashMap<String, ClassNode> classCache = new ConcurrentHashMap<>(); | ||
private final ClassLoader classLoader; | ||
private final Set<String> analyzedClasses = ConcurrentHashMap.newKeySet(); | ||
|
||
public ClassHierarchyAnalyzer(ClassLoader classLoader) { | ||
this.classLoader = classLoader; | ||
} | ||
|
||
public ClassNode getClass(String className) throws IOException { | ||
return classCache.computeIfAbsent(className, this::loadClass); | ||
} | ||
|
||
private ClassNode loadClass(String className) { | ||
try { | ||
ClassReader reader = new ClassReader(classLoader.getResourceAsStream( | ||
className.replace('.', '/') + ".class")); | ||
ClassNode classNode = new ClassNode(); | ||
reader.accept(classNode, ClassReader.EXPAND_FRAMES); | ||
return classNode; | ||
} catch (IOException e) { | ||
throw new RuntimeException("Failed to load class: " + className, e); | ||
} | ||
} | ||
|
||
public Set<String> getAllSuperClasses(String className) throws IOException { | ||
Set<String> superClasses = new HashSet<>(); | ||
collectSuperClasses(className, superClasses); | ||
return superClasses; | ||
} | ||
|
||
private void collectSuperClasses(String className, Set<String> collected) throws IOException { | ||
if (className == null || className.equals("java/lang/Object")) return; | ||
|
||
ClassNode classNode = getClass(className); | ||
collected.add(className); | ||
|
||
// Collect superclass | ||
if (classNode.superName != null) { | ||
collectSuperClasses(classNode.superName, collected); | ||
} | ||
|
||
// Collect interfaces | ||
for (String interfaceName : classNode.interfaces) { | ||
collectSuperClasses(interfaceName, collected); | ||
} | ||
} | ||
} | ||
public interface ClassHierarchyAnalyzer { | ||
ClassNode getClass(String className) throws IOException; | ||
|
||
Set<String> getAllSuperClasses(String className) throws IOException; | ||
} |
60 changes: 60 additions & 0 deletions
60
...ureanalysis/src/main/java/dev/skidfuscator/pureanalysis/SimpleClassHierarchyAnalyzer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package dev.skidfuscator.pureanalysis; | ||
|
||
import org.objectweb.asm.ClassReader; | ||
import org.objectweb.asm.tree.ClassNode; | ||
|
||
import java.io.IOException; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
public class SimpleClassHierarchyAnalyzer implements ClassHierarchyAnalyzer { | ||
private final ConcurrentHashMap<String, ClassNode> classCache = new ConcurrentHashMap<>(); | ||
private final ClassLoader classLoader; | ||
private final Set<String> analyzedClasses = ConcurrentHashMap.newKeySet(); | ||
|
||
public SimpleClassHierarchyAnalyzer(ClassLoader classLoader) { | ||
this.classLoader = classLoader; | ||
} | ||
|
||
@Override | ||
public ClassNode getClass(String className) throws IOException { | ||
return classCache.computeIfAbsent(className, this::loadClass); | ||
} | ||
|
||
private ClassNode loadClass(String className) { | ||
try { | ||
ClassReader reader = new ClassReader(classLoader.getResourceAsStream( | ||
className.replace('.', '/') + ".class")); | ||
ClassNode classNode = new ClassNode(); | ||
reader.accept(classNode, ClassReader.EXPAND_FRAMES); | ||
return classNode; | ||
} catch (IOException e) { | ||
throw new RuntimeException("Failed to load class: " + className, e); | ||
} | ||
} | ||
|
||
@Override | ||
public Set<String> getAllSuperClasses(String className) throws IOException { | ||
Set<String> superClasses = new HashSet<>(); | ||
collectSuperClasses(className, superClasses); | ||
return superClasses; | ||
} | ||
|
||
private void collectSuperClasses(String className, Set<String> collected) throws IOException { | ||
if (className == null || className.equals("java/lang/Object")) return; | ||
|
||
ClassNode classNode = getClass(className); | ||
collected.add(className); | ||
|
||
// Collect superclass | ||
if (classNode.superName != null) { | ||
collectSuperClasses(classNode.superName, collected); | ||
} | ||
|
||
// Collect interfaces | ||
for (String interfaceName : classNode.interfaces) { | ||
collectSuperClasses(interfaceName, collected); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...uscator.pureanalysis/src/main/java/dev/skidfuscator/pureanalysis/vm/VirtualMachinery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package dev.skidfuscator.pureanalysis.vm; | ||
|
||
import org.objectweb.asm.Type; | ||
import org.objectweb.asm.tree.MethodNode; | ||
|
||
public class VirtualMachinery { | ||
|
||
|
||
public static class VirtualMachineReport { | ||
private MethodNode method; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.