Ejemplo n.º 1
0
      static PyObject* Instruction_getOperands(PyObject* self, PyObject* noarg) {
        triton::arch::ImmediateOperand  imm;
        triton::arch::MemoryOperand     mem;
        triton::arch::RegisterOperand   reg;
        triton::arch::Instruction*      inst;
        triton::uint32                  opSize;
        PyObject*                       operands;

        inst     = PyInstruction_AsInstruction(self);
        opSize   = inst->operands.size();
        operands = xPyList_New(opSize);

        for (triton::uint32 index = 0; index < opSize; index++) {
          PyObject* obj = nullptr;

          if (inst->operands[index].getType() == triton::arch::OP_IMM) {
            imm = inst->operands[index].getImm();
            obj = PyImmediateOperand(imm);
          }
          else if (inst->operands[index].getType() == triton::arch::OP_MEM) {
            mem = inst->operands[index].getMem();
            obj = PyMemoryOperand(mem);
          }
          else if (inst->operands[index].getType() == triton::arch::OP_REG) {
            reg = inst->operands[index].getReg();
            obj = PyRegisterOperand(reg);
          }
          else
            continue;

          PyList_SetItem(operands, index, obj);
        }

        return operands;
      }
Ejemplo n.º 2
0
 static PyObject* MemoryOperand_getScale(PyObject* self, PyObject* noarg) {
   try {
     triton::arch::ImmediateOperand imm(PyMemoryOperand_AsMemoryOperand(self)->getScale());
     return PyImmediateOperand(imm);
   }
   catch (const std::exception& e) {
     return PyErr_Format(PyExc_TypeError, "%s", e.what());
   }
 }