Skip to content

Commit

Permalink
- updated asm version
Browse files Browse the repository at this point in the history
- improved performance in Dexpler by not creating empty annotation lists where unnecessary
- removed some Java warnings
  • Loading branch information
StevenArzt committed Jul 10, 2014
1 parent 1d40c9e commit 3dbfe3d
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .classpath
Expand Up @@ -10,11 +10,11 @@
<classpathentry combineaccessrules="false" kind="src" path="/jasmin"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/heros"/>
<classpathentry kind="lib" path="libs/polyglot.jar"/>
<classpathentry kind="lib" path="libs/asm-debug-all-4.0.jar"/>
<classpathentry kind="lib" path="libs/AXMLPrinter2.jar"/>
<classpathentry kind="lib" path="libs/hamcrest-all-1.3.jar"/>
<classpathentry kind="lib" path="libs/junit-4.11.jar"/>
<classpathentry kind="lib" path="libs/dexlib2-2.0.3-dev.jar" sourcepath="D:/Arbeit/smali/dexlib2/src/main/java"/>
<classpathentry kind="lib" path="libs/util-2.0.3-dev.jar"/>
<classpathentry kind="lib" path="libs/asm-debug-all-5.0.3.jar"/>
<classpathentry kind="output" path="classes"/>
</classpath>
2 changes: 1 addition & 1 deletion ant.settings.template
@@ -1,4 +1,4 @@
asm.jar=libs/asm-debug-all-4.0.jar
asm.jar=libs/asm-debug-all-5.0.3.jar

xmlprinter.jar=libs/AXMLPrinter2.jar

Expand Down
Binary file removed libs/asm-debug-all-4.0.jar
Binary file not shown.
Binary file added libs/asm-debug-all-5.0.3.jar
Binary file not shown.
48 changes: 24 additions & 24 deletions src/soot/dexpler/DexAnnotation.java
Expand Up @@ -89,11 +89,11 @@ void handleClassAnnotation(Host h, ClassDef classDef) {
Set<? extends Annotation> aSet = classDef.getAnnotations();
if (aSet == null || aSet.isEmpty())
return;
for (Tag t : handleAnnotation(aSet, classDef.getType())) {
h.addTag(t);
Debug.printDbg("add class annotation: ", t, " type: ", t.getClass());
}

for (Tag t : handleAnnotation(aSet, classDef.getType()))
if (t != null) {
h.addTag(t);
Debug.printDbg("add class annotation: ", t, " type: ", t.getClass());
}
}

/**
Expand All @@ -105,10 +105,11 @@ void handleFieldAnnotation(Host h, Field f) {
Set<? extends Annotation> aSet = f.getAnnotations();
if (aSet == null || aSet.isEmpty()) {
} else {
for (Tag t : handleAnnotation(aSet, null)) {
h.addTag(t);
Debug.printDbg("add field annotation: ", t);
}
for (Tag t : handleAnnotation(aSet, null))
if (t != null ){
h.addTag(t);
Debug.printDbg("add field annotation: ", t);
}
}
}

Expand All @@ -121,10 +122,11 @@ void handleMethodAnnotation(Host h, Method method) {

Set<? extends Annotation> aSet = method.getAnnotations();
if (!(aSet == null || aSet.isEmpty())) {
for (Tag t : handleAnnotation(aSet, null)) {
h.addTag(t);
Debug.printDbg("add method annotation: ", t);
}
for (Tag t : handleAnnotation(aSet, null))
if (t != null ){
h.addTag(t);
Debug.printDbg("add method annotation: ", t);
}
}

// Is there any parameter annotation?
Expand All @@ -143,6 +145,9 @@ void handleMethodAnnotation(Host h, Method method) {
List<Tag> tags = handleAnnotation(p.getAnnotations(), null);
boolean hasAnnotation = false;
for (Tag t : tags) {
if (t == null)
continue;

VisibilityAnnotationTag vat = null;

if (!(t instanceof VisibilityAnnotationTag)) {
Expand Down Expand Up @@ -206,18 +211,14 @@ public void add(AnnotationTag a, int visibility) {
* @return
*/
List<Tag> handleAnnotation(Set<? extends org.jf.dexlib2.iface.Annotation> annotations, String classType) {
if (annotations.size() == 0)
return null;

List<Tag> tags = new ArrayList<Tag>();

ArrayList<Tag> innerClassList = new ArrayList<Tag>();

if (annotations.size() == 0)
return tags;

int v = -1; // visibility

for (Annotation a: annotations) {

v = getVisibility(a.getVisibility());
int v = getVisibility(a.getVisibility());

Tag t = null;
//AnnotationTag aTag = new AnnotationTag(DexType.toSoot(a.getType()).toString());
Expand Down Expand Up @@ -372,8 +373,7 @@ private ArrayList<AnnotationElem> getElements(Set<? extends AnnotationElement> s
return aelemList;
}

private ArrayList<AnnotationElem> handleAnnotationElement(AnnotationElement ae, List<EncodedValue> evList) {

private ArrayList<AnnotationElem> handleAnnotationElement(AnnotationElement ae, List<? extends EncodedValue> evList) {
ArrayList<AnnotationElem> aelemList = new ArrayList<AnnotationElem>();

for (EncodedValue ev: evList) {
Expand Down Expand Up @@ -481,7 +481,7 @@ private ArrayList<AnnotationElem> handleAnnotationElement(AnnotationElement ae,
case 0x1c: // ARRAY
{
ArrayEncodedValue v = (ArrayEncodedValue)ev;
ArrayList<AnnotationElem> l = handleAnnotationElement(ae, (List<EncodedValue>) v.getValue());
ArrayList<AnnotationElem> l = handleAnnotationElement(ae, v.getValue());
elem = new AnnotationArrayElem(l, '[', ae.getName());
break;
}
Expand Down
16 changes: 7 additions & 9 deletions src/soot/dexpler/DexBody.java
Expand Up @@ -118,7 +118,6 @@ public class DexBody {
private int numParameterRegisters;
private List<Type> parameterTypes;
private boolean isStatic;
private String methodString = "";
private String methodSignature = "";

private JimpleBody jBody;
Expand Down Expand Up @@ -149,7 +148,6 @@ public DexBody(String dexFile, Method method, RefType declaringClassType) {
throw new RuntimeException("error: no code for method "+ method.getName());
this.declaringClassType = declaringClassType;
tries = code.getTryBlocks();
methodString = method.getName();
methodSignature = method.getDefiningClass() +": "+ method.getReturnType() +" "+ method.getName() +"(";
for (MethodParameter mp: method.getParameters())
methodSignature += mp.getType() +",";
Expand Down Expand Up @@ -327,6 +325,7 @@ public DexlibAbstractInstruction instructionAtAddress(int address) {
// }

// check if it is a jump to pseudo-instructions data (=obfuscation)
/*
PseudoInstruction pi = null; // TODO: isAddressInData(address);
if (pi != null && !pi.isLoaded()) {
System.out.println("warning: attempting to jump to pseudo-instruction data at address 0x"+ Integer.toHexString(address));
Expand All @@ -337,6 +336,7 @@ public DexlibAbstractInstruction instructionAtAddress(int address) {
e.printStackTrace();
System.out.println();
}
*/

DexlibAbstractInstruction i = null;
while (i == null && address >= 0) {
Expand All @@ -357,6 +357,7 @@ public DexlibAbstractInstruction instructionAtAddress(int address) {
return i;
}

/*
private ArrayList<DexlibAbstractInstruction> decodeInstructions(PseudoInstruction pi) {
final ArrayList<Instruction> instructionList = new ArrayList<Instruction>();
ArrayList<DexlibAbstractInstruction> dexInstructions = new ArrayList<DexlibAbstractInstruction>();
Expand All @@ -381,7 +382,7 @@ private ArrayList<DexlibAbstractInstruction> decodeInstructions(PseudoInstructio
}
return dexInstructions;
}

*/

/**
* Return the jimple equivalent of this body.
Expand Down Expand Up @@ -773,7 +774,7 @@ public List<DexlibAbstractInstruction> instructionsBefore(DexlibAbstractInstruct
* Should only be called at the end jimplify.
*/
private void addTraps() {
for (TryBlock tryItem : tries) {
for (TryBlock<? extends ExceptionHandler> tryItem : tries) {
int startAddress = tryItem.getStartCodeAddress();
Debug.printDbg(" start : 0x", Integer.toHexString(startAddress));
int length = tryItem.getCodeUnitCount();//.getTryLength();
Expand All @@ -790,8 +791,7 @@ private void addTraps() {
Debug.printDbg("end instruction (0x", Integer.toHexString(endAddress) ,"): ", instructionAtAddress (endAddress).getUnit() ," --- ", instructionAtAddress (endAddress).getUnit());


List<ExceptionHandler> hList = tryItem.getExceptionHandlers();

List<? extends ExceptionHandler> hList = tryItem.getExceptionHandlers();
for (ExceptionHandler handler: hList) {
int handlerAddress = handler.getHandlerCodeAddress();
Debug.printDbg("handler (0x", Integer.toHexString(handlerAddress) ,"): ", instructionAtAddress (handlerAddress).getUnit() ," --- ", instructionAtAddress (handlerAddress-1).getUnit());
Expand All @@ -814,7 +814,5 @@ private void addTraps() {
}
}
}




}

0 comments on commit 3dbfe3d

Please sign in to comment.