-
Notifications
You must be signed in to change notification settings - Fork 7
/
MemoryAnalysis.java
31 lines (27 loc) · 1.22 KB
/
MemoryAnalysis.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.ercatcher.memory;
import com.ercatcher.LOG;
import soot.SootMethod;
import soot.toolkits.graph.CompleteUnitGraph;
import soot.toolkits.graph.UnitGraph;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class MemoryAnalysis {
private Map<SootMethod, IntraAllocationAnalysis> methodToAllocInfo = new HashMap<>();
public MemoryAnalysis(Set<SootMethod> allAPKMethods, boolean isUAF){
LOG.startTimer("Memory Analysis", LOG.VERBOSE);
for(SootMethod sootMethod : allAPKMethods) {
if(!sootMethod.hasActiveBody())
continue;
if(sootMethod.getDeclaringClass().getName().startsWith("java") || sootMethod.getDeclaringClass().getName().startsWith("android"))
continue;
UnitGraph unitGraph = new CompleteUnitGraph(sootMethod.getActiveBody());
IntraAllocationAnalysis intraAllocationAnalysis = new IntraAllocationAnalysis(unitGraph, isUAF);
methodToAllocInfo.put(sootMethod, intraAllocationAnalysis);
}
LOG.endTimer("Memory Analysis", LOG.VERBOSE);
}
public IntraAllocationAnalysis getAllocInfo(SootMethod method){
return methodToAllocInfo.getOrDefault(method, null);
}
}