org.jf.dexlib2.iface.instruction.formats.ArrayPayload Java Examples

The following examples show how to use org.jf.dexlib2.iface.instruction.formats.ArrayPayload. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InstructionMethodItemFactory.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
public static InstructionMethodItem makeInstructionFormatMethodItem(
        MethodDefinition methodDef, int codeAddress, Instruction instruction) {

    if (instruction instanceof OffsetInstruction) {
        return new OffsetInstructionFormatMethodItem(methodDef.classDef.options, methodDef, codeAddress,
                (OffsetInstruction)instruction);
    }

    if (instruction instanceof UnresolvedOdexInstruction) {
        return new UnresolvedOdexInstructionMethodItem(methodDef, codeAddress,
                (UnresolvedOdexInstruction)instruction);
    }

    switch (instruction.getOpcode().format) {
        case ArrayPayload:
            return new ArrayDataMethodItem(methodDef, codeAddress, (ArrayPayload)instruction);
        case PackedSwitchPayload:
            return new PackedSwitchMethodItem(methodDef, codeAddress, (PackedSwitchPayload)instruction);
        case SparseSwitchPayload:
            return new SparseSwitchMethodItem(methodDef, codeAddress, (SparseSwitchPayload)instruction);
        default:
            return new InstructionMethodItem<Instruction>(methodDef, codeAddress, instruction);
    }
}
 
Example #2
Source File: InstructionMethodItemFactory.java    From atlas with Apache License 2.0 6 votes vote down vote up
public static InstructionMethodItem makeInstructionFormatMethodItem(
        MethodDefinition methodDef, int codeAddress, Instruction instruction) {

    if (instruction instanceof OffsetInstruction) {
        return new OffsetInstructionFormatMethodItem(methodDef.classDef.options, methodDef, codeAddress,
                (OffsetInstruction)instruction);
    }

    if (instruction instanceof UnresolvedOdexInstruction) {
        return new UnresolvedOdexInstructionMethodItem(methodDef, codeAddress,
                (UnresolvedOdexInstruction)instruction);
    }

    switch (instruction.getOpcode().format) {
        case ArrayPayload:
            return new ArrayDataMethodItem(methodDef, codeAddress, (ArrayPayload)instruction);
        case PackedSwitchPayload:
            return new PackedSwitchMethodItem(methodDef, codeAddress, (PackedSwitchPayload)instruction);
        case SparseSwitchPayload:
            return new SparseSwitchMethodItem(methodDef, codeAddress, (SparseSwitchPayload)instruction);
        default:
            return new InstructionMethodItem<Instruction>(methodDef, codeAddress, instruction);
    }
}
 
Example #3
Source File: InstructionMethodItemFactory.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
public static InstructionMethodItem makeInstructionFormatMethodItem(
        MethodDefinition methodDef, int codeAddress, Instruction instruction) {

    if (instruction instanceof OffsetInstruction) {
        return new OffsetInstructionFormatMethodItem(methodDef.classDef.options, methodDef, codeAddress,
                (OffsetInstruction)instruction);
    }

    if (instruction instanceof UnresolvedOdexInstruction) {
        return new UnresolvedOdexInstructionMethodItem(methodDef, codeAddress,
                (UnresolvedOdexInstruction)instruction);
    }

    switch (instruction.getOpcode().format) {
        case ArrayPayload:
            return new ArrayDataMethodItem(methodDef, codeAddress, (ArrayPayload)instruction);
        case PackedSwitchPayload:
            return new PackedSwitchMethodItem(methodDef, codeAddress, (PackedSwitchPayload)instruction);
        case SparseSwitchPayload:
            return new SparseSwitchMethodItem(methodDef, codeAddress, (SparseSwitchPayload)instruction);
        default:
            return new InstructionMethodItem<Instruction>(methodDef, codeAddress, instruction);
    }
}
 
Example #4
Source File: InstructionMethodItemFactory.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
public static InstructionMethodItem makeInstructionFormatMethodItem(
        MethodDefinition methodDef, int codeAddress, Instruction instruction) {

    if (instruction instanceof OffsetInstruction) {
        return new OffsetInstructionFormatMethodItem(methodDef.classDef.options, methodDef, codeAddress,
                (OffsetInstruction)instruction);
    }

    if (instruction instanceof UnresolvedOdexInstruction) {
        return new UnresolvedOdexInstructionMethodItem(methodDef, codeAddress,
                (UnresolvedOdexInstruction)instruction);
    }

    switch (instruction.getOpcode().format) {
        case ArrayPayload:
            return new ArrayDataMethodItem(methodDef, codeAddress, (ArrayPayload)instruction);
        case PackedSwitchPayload:
            return new PackedSwitchMethodItem(methodDef, codeAddress, (PackedSwitchPayload)instruction);
        case SparseSwitchPayload:
            return new SparseSwitchMethodItem(methodDef, codeAddress, (SparseSwitchPayload)instruction);
        default:
            return new InstructionMethodItem<Instruction>(methodDef, codeAddress, instruction);
    }
}
 
Example #5
Source File: InstructionMethodItemFactory.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
public static InstructionMethodItem makeInstructionFormatMethodItem(
        MethodDefinition methodDef, int codeAddress, Instruction instruction) {

    if (instruction instanceof OffsetInstruction) {
        return new OffsetInstructionFormatMethodItem(methodDef.classDef.options, methodDef, codeAddress,
                (OffsetInstruction)instruction);
    }

    if (instruction instanceof UnresolvedOdexInstruction) {
        return new UnresolvedOdexInstructionMethodItem(methodDef, codeAddress,
                (UnresolvedOdexInstruction)instruction);
    }

    switch (instruction.getOpcode().format) {
        case ArrayPayload:
            return new ArrayDataMethodItem(methodDef, codeAddress, (ArrayPayload)instruction);
        case PackedSwitchPayload:
            return new PackedSwitchMethodItem(methodDef, codeAddress, (PackedSwitchPayload)instruction);
        case SparseSwitchPayload:
            return new SparseSwitchMethodItem(methodDef, codeAddress, (SparseSwitchPayload)instruction);
        default:
            return new InstructionMethodItem<Instruction>(methodDef, codeAddress, instruction);
    }
}
 
Example #6
Source File: ImmutableArrayPayload.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static ImmutableArrayPayload of(ArrayPayload instruction) {
    if (instruction instanceof ImmutableArrayPayload) {
        return (ImmutableArrayPayload)instruction;
    }
    return new ImmutableArrayPayload(
            instruction.getElementWidth(),
            instruction.getArrayElements());
}
 
Example #7
Source File: ImmutableArrayPayload.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static ImmutableArrayPayload of(ArrayPayload instruction) {
    if (instruction instanceof ImmutableArrayPayload) {
        return (ImmutableArrayPayload)instruction;
    }
    return new ImmutableArrayPayload(
            instruction.getElementWidth(),
            instruction.getArrayElements());
}
 
Example #8
Source File: ImmutableArrayPayload.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static ImmutableArrayPayload of(ArrayPayload instruction) {
    if (instruction instanceof ImmutableArrayPayload) {
        return (ImmutableArrayPayload)instruction;
    }
    return new ImmutableArrayPayload(
            instruction.getElementWidth(),
            instruction.getArrayElements());
}
 
Example #9
Source File: ImmutableArrayPayload.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static ImmutableArrayPayload of(ArrayPayload instruction) {
    if (instruction instanceof ImmutableArrayPayload) {
        return (ImmutableArrayPayload)instruction;
    }
    return new ImmutableArrayPayload(
            instruction.getElementWidth(),
            instruction.getArrayElements());
}
 
Example #10
Source File: ArrayDataMethodItem.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
public ArrayDataMethodItem(MethodDefinition methodDef, int codeAddress, ArrayPayload instruction) {
    super(methodDef, codeAddress, instruction);
}
 
Example #11
Source File: ArrayDataMethodItem.java    From atlas with Apache License 2.0 4 votes vote down vote up
public ArrayDataMethodItem(MethodDefinition methodDef, int codeAddress, ArrayPayload instruction) {
    super(methodDef, codeAddress, instruction);
}
 
Example #12
Source File: ArrayDataMethodItem.java    From zjdroid with Apache License 2.0 4 votes vote down vote up
public ArrayDataMethodItem(MethodDefinition methodDef, int codeAddress, ArrayPayload instruction) {
    super(methodDef, codeAddress, instruction);
}
 
Example #13
Source File: FillArrayDataInstruction.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
public void jimplify (DexBody body) {
  if(!(instruction instanceof Instruction31t))
    throw new IllegalArgumentException("Expected Instruction31t but got: "+instruction.getClass());

  Instruction31t fillArrayInstr = (Instruction31t)instruction;
  int destRegister = fillArrayInstr.getRegisterA();
  int offset = fillArrayInstr.getCodeOffset();
  int targetAddress = codeAddress + offset;

  Instruction referenceTable = body.instructionAtAddress(targetAddress).instruction;

  if(!(referenceTable instanceof ArrayPayload)) {
    throw new RuntimeException("Address " + targetAddress + "refers to an invalid PseudoInstruction.");
  }

  ArrayPayload arrayTable = (ArrayPayload)referenceTable;

  //        NopStmt nopStmtBeginning = Jimple.v().newNopStmt();
  //        body.add(nopStmtBeginning);

  Local arrayReference = body.getRegisterLocal(destRegister);
  List<Number> elements = arrayTable.getArrayElements();
  int numElements = elements.size();

  Stmt firstAssign = null;
  for (int i = 0; i < numElements; i++) {
    ArrayRef arrayRef = Jimple.v().newArrayRef(arrayReference, IntConstant.v(i));
    NumericConstant element = getArrayElement(elements.get(i),body,destRegister);
    if (element == null) //array was not defined -> element type can not be found (obfuscated bytecode?)
      break;
    AssignStmt assign = Jimple.v().newAssignStmt(arrayRef, element);
    addTags(assign);
    body.add(assign);
    if (i == 0) {
      firstAssign = assign;
    }
  }
  if (firstAssign == null) { // if numElements == 0. Is it possible?
      firstAssign = Jimple.v().newNopStmt();
      body.add (firstAssign);
  }

  //        NopStmt nopStmtEnd = Jimple.v().newNopStmt();
  //        body.add(nopStmtEnd);

  //        defineBlock(nopStmtBeginning, nopStmtEnd);
  setUnit (firstAssign);

}
 
Example #14
Source File: ArrayDataMethodItem.java    From HeyGirl with Apache License 2.0 4 votes vote down vote up
public ArrayDataMethodItem(MethodDefinition methodDef, int codeAddress, ArrayPayload instruction) {
    super(methodDef, codeAddress, instruction);
}
 
Example #15
Source File: ArrayDataMethodItem.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
public ArrayDataMethodItem(MethodDefinition methodDef, int codeAddress, ArrayPayload instruction) {
    super(methodDef, codeAddress, instruction);
}