-
-
Notifications
You must be signed in to change notification settings - Fork 712
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2072 from MarcMil/fix-dex-annotations
Dalvik import/export: Save special type (direct/super) as tag
- Loading branch information
Showing
7 changed files
with
208 additions
and
2 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
47 changes: 47 additions & 0 deletions
47
src/main/java/soot/dexpler/instructions/InvokeSpecialDirectInstruction.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,47 @@ | ||
package soot.dexpler.instructions; | ||
|
||
/*- | ||
* #%L | ||
* Soot - a J*va Optimization Framework | ||
* %% | ||
* Copyright (C) 2012 Michael Markert, Frank Hartmann | ||
* | ||
* (c) 2012 University of Luxembourg - Interdisciplinary Centre for | ||
* Security Reliability and Trust (SnT) - All rights reserved | ||
* Alexandre Bartel | ||
* | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 2.1 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Lesser Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Lesser Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
* #L% | ||
*/ | ||
|
||
import org.jf.dexlib2.iface.instruction.Instruction; | ||
|
||
import soot.dexpler.DexBody; | ||
import soot.dexpler.tags.SpecialInvokeTypeTag; | ||
import soot.dexpler.tags.SpecialInvokeTypeTag.Type; | ||
|
||
public class InvokeSpecialDirectInstruction extends InvokeSpecialInstruction { | ||
|
||
public InvokeSpecialDirectInstruction(Instruction instruction, int codeAdress) { | ||
super(instruction, codeAdress); | ||
} | ||
|
||
@Override | ||
public void finalize(DexBody body, DexlibAbstractInstruction successor) { | ||
super.finalize(body, successor); | ||
getUnit().addTag(new SpecialInvokeTypeTag(Type.DIRECT)); | ||
} | ||
} |
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
47 changes: 47 additions & 0 deletions
47
src/main/java/soot/dexpler/instructions/InvokeSpecialSuperInstruction.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,47 @@ | ||
package soot.dexpler.instructions; | ||
|
||
/*- | ||
* #%L | ||
* Soot - a J*va Optimization Framework | ||
* %% | ||
* Copyright (C) 2012 Michael Markert, Frank Hartmann | ||
* | ||
* (c) 2012 University of Luxembourg - Interdisciplinary Centre for | ||
* Security Reliability and Trust (SnT) - All rights reserved | ||
* Alexandre Bartel | ||
* | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 2.1 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Lesser Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Lesser Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
* #L% | ||
*/ | ||
|
||
import org.jf.dexlib2.iface.instruction.Instruction; | ||
|
||
import soot.dexpler.DexBody; | ||
import soot.dexpler.tags.SpecialInvokeTypeTag; | ||
import soot.dexpler.tags.SpecialInvokeTypeTag.Type; | ||
|
||
public class InvokeSpecialSuperInstruction extends InvokeSpecialInstruction { | ||
|
||
public InvokeSpecialSuperInstruction(Instruction instruction, int codeAdress) { | ||
super(instruction, codeAdress); | ||
} | ||
|
||
@Override | ||
public void finalize(DexBody body, DexlibAbstractInstruction successor) { | ||
super.finalize(body, successor); | ||
getUnit().addTag(new SpecialInvokeTypeTag(Type.SUPER)); | ||
} | ||
} |
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,85 @@ | ||
// | ||
// (c) 2012 University of Luxembourg - Interdisciplinary Centre for | ||
// Security Reliability and Trust (SnT) - All rights reserved | ||
// | ||
// Author: Alexandre Bartel | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 2.1 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
package soot.dexpler.tags; | ||
|
||
/*- | ||
* #%L | ||
* Soot - a J*va Optimization Framework | ||
* %% | ||
* Copyright (C) 1997 - 2018 Raja Vallée-Rai and others | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 2.1 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Lesser Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Lesser Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
* #L% | ||
*/ | ||
|
||
import soot.tagkit.Tag; | ||
|
||
/** | ||
* Dalvik distinguishes between different type of special invocations, while soot does not. Soot tries to infer the proper | ||
* type upon writing out dex code, but fails sometimes in presence of obfuscated code or due to the Kotlin compiler. We try | ||
* to be as close to the original as possible | ||
* | ||
* @author Marc Miltenberger | ||
*/ | ||
public class SpecialInvokeTypeTag implements Tag { | ||
|
||
public static final String NAME = "SpecialInvokeTypeTag"; | ||
|
||
public static enum Type { | ||
UNKNOWN, DIRECT, SUPER; | ||
} | ||
|
||
private final Type type; | ||
|
||
public SpecialInvokeTypeTag() { | ||
type = Type.UNKNOWN; | ||
} | ||
|
||
public SpecialInvokeTypeTag(Type type) { | ||
this.type = type; | ||
} | ||
|
||
public Type getType() { | ||
return type; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return NAME; | ||
} | ||
|
||
@Override | ||
public byte[] getValue() { | ||
return new byte[1]; | ||
} | ||
} |
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