本文整理汇总了Java中soot.jimple.InvokeExpr类的典型用法代码示例。如果您正苦于以下问题:Java InvokeExpr类的具体用法?Java InvokeExpr怎么用?Java InvokeExpr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InvokeExpr类属于soot.jimple包,在下文中一共展示了InvokeExpr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareAlarmManagerSet
import soot.jimple.InvokeExpr; //导入依赖的package包/类
private void prepareAlarmManagerSet(Body body, InvokeStmt setStmt, SootMethodRef reportRef) {
Value oldVal = setStmt.getInvokeExpr().getArg(1);
Local longLocal = UtilInstrumenter.generateFreshLocal(body, LongType.v());
SootMethod currentTimeMillis = Scene.v().getMethod("<java.lang.System: long currentTimeMillis()>");
StaticInvokeExpr timeInvoke = Jimple.v().newStaticInvokeExpr(currentTimeMillis.makeRef());
AssignStmt timeInitalize = Jimple.v().newAssignStmt(longLocal, timeInvoke);
AddExpr addTime = Jimple.v().newAddExpr(longLocal, LongConstant.v(2000L));
AssignStmt timeAssign = Jimple.v().newAssignStmt(longLocal, addTime);
body.getUnits().insertBefore(timeInitalize, setStmt);
body.getUnits().insertBefore(timeAssign, setStmt);
InvokeExpr expr = setStmt.getInvokeExpr();
expr.setArg(0, IntConstant.v(0));
expr.setArg(1, longLocal);
// Report the change
InvokeStmt reportStmt = Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr(
reportRef, oldVal, longLocal));
reportStmt.addTag(new InstrumentedCodeTag());
body.getUnits().insertAfter(reportStmt, setStmt);
}
示例2: isStringOperationSupportedBySMT
import soot.jimple.InvokeExpr; //导入依赖的package包/类
private boolean isStringOperationSupportedBySMT(InvokeExpr invokeExpr) {
String methodSignature = invokeExpr.getMethod().getSignature();
if(methodSignature.equals("<java.lang.String: java.lang.String substring(int,int)>")
|| methodSignature.equals("<java.lang.String: java.lang.String substring(int)>")
|| methodSignature.equals("<java.lang.String: boolean equals(java.lang.Object)>")
|| methodSignature.equals("<java.lang.String: boolean equalsIgnoreCase(java.lang.String)>")
|| methodSignature.equals("<java.lang.String: int indexOf(java.lang.String)>")
|| methodSignature.equals("<java.lang.String: int indexOf(int,int)>")
|| methodSignature.equals("<java.lang.String: boolean startsWith(java.lang.String)>")
|| methodSignature.equals("<java.lang.String: boolean matches(java.lang.String)>")
|| methodSignature.equals("<java.lang.String: java.lang.String replaceAll(java.lang.String,java.lang.String)>")
|| methodSignature.equals("<java.lang.String: boolean contains(java.lang.CharSequence)>")
|| methodSignature.equals("<java.lang.String: java.lang.String[] split(java.lang.String)>")
|| methodSignature.equals("<java.lang.StringBuilder: java.lang.StringBuilder append(java.lang.String)>")
)
return true;
return false;
}
示例3: isExpressionThatNeedsToBeConvertedToSMT
import soot.jimple.InvokeExpr; //导入依赖的package包/类
public boolean isExpressionThatNeedsToBeConvertedToSMT(InvokeExpr invokeExpr) {
String methodSignature = invokeExpr.getMethod().getSignature();
if(methodSignature.equals("<java.lang.Integer: int parseInt(java.lang.String)>")
|| methodSignature.equals("<org.apache.http.client.methods.HttpGet: void <init>(java.lang.String)>")
|| methodSignature.equals("<java.net.URL: void <init>(java.lang.String)>")
|| methodSignature.equals("<android.telephony.SmsManager: void sendTextMessage(java.lang.String,java.lang.String,java.lang.String,android.app.PendingIntent,android.app.PendingIntent)>")
|| methodSignature.equals("<android.telephony.gsm.SmsManager: void sendTextMessage(java.lang.String,java.lang.String,java.lang.String,android.app.PendingIntent,android.app.PendingIntent)>")
|| methodSignature.equals("<android.telephony.SmsMessage: java.lang.String getDisplayOriginatingAddress()>")
|| methodSignature.equals("<java.util.Map: java.lang.Object put(java.lang.Object,java.lang.Object)>")
|| methodSignature.equals("<java.util.Map: java.lang.Object get(java.lang.Object)>")
|| methodSignature.equals("<android.telephony.TelephonyManager: java.lang.String getNetworkOperator()>")
|| methodSignature.equals("<android.telephony.TelephonyManager: java.lang.String getSimOperator()>")
)
return true;
return false;
}
示例4: fixSMTSolverIntegerOutput
import soot.jimple.InvokeExpr; //导入依赖的package包/类
private String fixSMTSolverIntegerOutput(String loggingPoint, Stmt stmt) {
if(stmt.containsInvokeExpr()) {
InvokeExpr inv = stmt.getInvokeExpr();
String metSig = inv.getMethod().getSignature();
if(metSig.equals("<android.telephony.TelephonyManager: java.lang.String getSimOperator()>")
|| metSig.equals("<android.telephony.TelephonyManager: java.lang.String getNetworkOperator()>")
) {
String newLoggingPoint = "";
for(char c : loggingPoint.toCharArray()) {
if(c < '0' || c > '9') {
Random rand = new Random();
int num = rand.nextInt(10);
newLoggingPoint += num;
}
else
newLoggingPoint += c;
}
return newLoggingPoint;
}
}
return loggingPoint;
}
示例5: isSemanticallyCorrect
import soot.jimple.InvokeExpr; //导入依赖的package包/类
private boolean isSemanticallyCorrect(String loggingPoint, Stmt stmt) {
if(loggingPoint == null)
return false;
if(stmt.containsInvokeExpr()) {
InvokeExpr inv = stmt.getInvokeExpr();
String metSig = inv.getMethod().getSignature();
if(metSig.equals("<android.telephony.TelephonyManager: java.lang.String getSimOperator()>")
|| metSig.equals("<android.telephony.TelephonyManager: java.lang.String getNetworkOperator()>")
) {
for(char c : loggingPoint.toCharArray()) {
if(c < '0' || c > '9')
return false;
}
}
}
return true;
}
示例6: getFileFormatFromDataflow
import soot.jimple.InvokeExpr; //导入依赖的package包/类
private AnalysisDecision getFileFormatFromDataflow(int codePosID ) {
Unit unit = codePositionManager.getUnitForCodePosition(codePosID);
if(unit instanceof Stmt) {
Stmt stmt = (Stmt)unit;
if(stmt.containsInvokeExpr()) {
InvokeExpr inv = stmt.getInvokeExpr();
SootMethod sm = inv.getMethod();
Pair<Integer, Object> paramValue = retrieveCorrectFileInformation(sm);
ServerResponse response = new ServerResponse();
response.setAnalysisName(getAnalysisName());
response.setResponseExist(true);
response.setParamValues(Collections.singleton(paramValue));
AnalysisDecision finalDecision = new AnalysisDecision();
finalDecision.setAnalysisName(getAnalysisName());
finalDecision.setDecisionWeight(8);
finalDecision.setServerResponse(response);
return finalDecision;
}
else
return noResults();
}
else {
return noResults();
}
}
示例7: getUnitInBetween
import soot.jimple.InvokeExpr; //导入依赖的package包/类
private static void getUnitInBetween(UnitGraph ug, List<Unit>inBetween, Unit u) {
for (Unit succ: ug.getSuccsOf(u)) {
Stmt s = (Stmt)succ;
if (inBetween.contains(succ)) {
continue;
}
if (s.containsInvokeExpr()) {
InvokeExpr ie = s.getInvokeExpr();
if (ie.getMethodRef().name().contains("restoreCallingIdentity")) {
return;
}
}
inBetween.add(succ);
getUnitInBetween(ug, inBetween, succ);
}
}
示例8: hasGetInstanceMethod
import soot.jimple.InvokeExpr; //导入依赖的package包/类
private SootMethod hasGetInstanceMethod(SootClass sc) {
String cname = sc.getName();
if (!(cname.startsWith("android") || cname.startsWith("com.android")))
return null;
for (SootMethod sm: sc.getMethods()) {
if (sm.isConcrete() && sm.getName().equals(("getInstance"))) {
Body b = sm.retrieveActiveBody();
for (Unit u: b.getUnits()){
Stmt s = (Stmt)u;
if (s.containsInvokeExpr()) {
InvokeExpr ie = (InvokeExpr)s.getInvokeExpr();
String name = ie.getMethodRef().name();
if (name.equals("getService"))
return sm;
if (name.equals("getSystemService"))
return sm;
}
}
}
}
return null;
}
示例9: getNameFromGetInstance
import soot.jimple.InvokeExpr; //导入依赖的package包/类
private String getNameFromGetInstance(SootMethod sm) {
Body b = sm.retrieveActiveBody();
for (Unit u: b.getUnits()){
Stmt s = (Stmt)u;
if (s.containsInvokeExpr()) {
InvokeExpr ie = (InvokeExpr)s.getInvokeExpr();
String name = ie.getMethodRef().name();
if (name.equals("getService")|| name.equals("getSystemService")) {
List<Value> args = ie.getArgs();
int size = args.size();
Value v = args.get(size-1);
if (v instanceof StringConstant) {
StringConstant c = (StringConstant)v;
return c.value;
} else {
throw new RuntimeException("error: expected constant string: "+ b);
}
}
}
}
throw new RuntimeException("error: nothing found, expected constant string: "+ b);
}
示例10: hasCallToGetSystem
import soot.jimple.InvokeExpr; //导入依赖的package包/类
/**
* To get a service (not to be confused with getSystemService)
* @param b
* @return
*/
public List<Unit> hasCallToGetSystem(Body b) {
List<Unit> calls = new ArrayList<Unit>();
for (Unit u: b.getUnits()) {
Stmt s = (Stmt)u;
if (s.containsInvokeExpr()) {
try {
InvokeExpr ie = s.getInvokeExpr();
String mName = ie.getMethodRef().name();
//System.out.println("m : "+ ie.getMethodRef());
//System.out.println("mName: "+ mName);
if (mName.equals("getService") && ie.getArgs().size() > 0) {
calls.add(u);
}
} catch (Throwable t) {
continue;
}
}
}
return calls;
}
示例11: hasCallToSystemServices
import soot.jimple.InvokeExpr; //导入依赖的package包/类
/**
* To get a manager (not to be confused with getSystem)
*
* @param b
* @return
*/
public List<Unit> hasCallToSystemServices(Body b) {
List<Unit> calls = new ArrayList<Unit>();
for (Unit u : b.getUnits()) {
Stmt s = (Stmt) u;
if (s.containsInvokeExpr()) {
try {
InvokeExpr ie = s.getInvokeExpr();
String mName = ie.getMethodRef().name();
// System.out.println("m : "+ ie.getMethodRef());
// System.out.println("mName: "+ mName);
if (mName.equals("getSystemService")) {
calls.add(u);
}
} catch (Throwable t) {
continue;
}
}
}
return calls;
}
示例12: hasCallToService
import soot.jimple.InvokeExpr; //导入依赖的package包/类
/**
* To get a service (not to be confused with getSystemService)
*
* @param b
* @return
*/
public List<Unit> hasCallToService(Body b) {
List<Unit> calls = new ArrayList<Unit>();
for (Unit u : b.getUnits()) {
Stmt s = (Stmt) u;
if (s.containsInvokeExpr()) {
try {
InvokeExpr ie = s.getInvokeExpr();
String mName = ie.getMethodRef().name();
String cName = ie.getMethodRef().declaringClass().getName();
// System.out.println("m : "+ ie.getMethodRef());
// System.out.println("mName: "+ mName);
if (mName.equals("getService")
&& cName.equals("android.os.ServiceManager")) {
calls.add(u);
}
} catch (Throwable t) {
continue;
}
}
}
return calls;
}
示例13: createTasksForCall
import soot.jimple.InvokeExpr; //导入依赖的package包/类
@Override
protected Set<Task> createTasksForCall(Unit call, Set<SootMethod> chaTargets) {
Set<Task> tasksForCall = new HashSet<Task>();
Set<SootMethod> targets = new HashSet<SootMethod>();
// SootMethod caller = icfg.getMethodOf(call);
SootMethod caller = projectInformation.startPoint();
InvokeExpr callExpr = ((Stmt) call).getInvokeExpr();
if (callExpr.getMethod().isNative())
return tasksForCall;
for (SootMethod potentialTarget : chaTargets) {
// If not in same package
if (!inSamePackage(potentialTarget.getDeclaringClass(), caller.getDeclaringClass())
&& inProject(potentialTarget.getDeclaringClass().getName()))
targets.add(potentialTarget);
}
// check for polymorphism
if (!targets.isEmpty() && targets.size() > 1) {
Task newTask = new Task(Layer.PROJECT_POLYMORPHIC, caller, call, new HashSet<FlowAbstraction>(), targets);
tasksForCall.add(newTask);
}
return tasksForCall;
}
示例14: createTasksForCall
import soot.jimple.InvokeExpr; //导入依赖的package包/类
@Override
protected Set<Task> createTasksForCall(Unit call, Set<SootMethod> chaTargets) {
Set<Task> tasksForCall = new HashSet<Task>();
InvokeExpr callExpr = ((Stmt) call).getInvokeExpr();
if (callExpr.getMethod().isNative())
return tasksForCall;
// SootMethod caller = icfg.getMethodOf(call);
SootMethod caller = projectInformation.startPoint();
for (SootMethod potentialTarget : chaTargets) {
// if same class
if (caller.getDeclaringClass() == potentialTarget.getDeclaringClass()) {
Set<SootMethod> targets = new HashSet<SootMethod>();
targets.add(potentialTarget);
Task newTask = new Task(Layer.CLASS, caller, call, new HashSet<FlowAbstraction>(), targets);
tasksForCall.add(newTask);
}
}
return tasksForCall;
}
示例15: invokesSetContentView
import soot.jimple.InvokeExpr; //导入依赖的package包/类
/**
* Checks whether this invocation calls Android's Activity.setContentView
* method
*
* @param inv
* The invocaton to check
* @return True if this invocation calls setContentView, otherwise false
*/
private boolean invokesSetContentView(InvokeExpr inv) {
String methodName = SootMethodRepresentationParser.v()
.getMethodNameFromSubSignature(inv.getMethodRef().getSubSignature().getString());
if (!methodName.equals("setContentView"))
return false;
// In some cases, the bytecode points the invocation to the current
// class even though it does not implement setContentView, instead
// of using the superclass signature
SootClass curClass = inv.getMethod().getDeclaringClass();
while (curClass != null) {
if (curClass.getName().equals("android.app.Activity")
|| curClass.getName().equals("android.support.v7.app.ActionBarActivity"))
return true;
if (curClass.declaresMethod("void setContentView(int)"))
return false;
curClass = curClass.hasSuperclass() ? curClass.getSuperclass() : null;
}
return false;
}