Ejemplo n.º 1
0
 static PyObject* MemoryOperand_getLeaAst(PyObject* self, PyObject* noarg) {
   try {
     if (PyMemoryOperand_AsMemoryOperand(self)->getLeaAst() == nullptr) {
       Py_INCREF(Py_None);
       return Py_None;
     }
     return PyAstNode(PyMemoryOperand_AsMemoryOperand(self)->getLeaAst());
   }
   catch (const std::exception& e) {
     return PyErr_Format(PyExc_TypeError, "%s", e.what());
   }
 }
Ejemplo n.º 2
0
      static PyObject* Instruction_updateContext(PyObject* self, PyObject* ctx) {
        triton::arch::Instruction*     inst;
        triton::arch::MemoryOperand*   memCtx;
        triton::arch::RegisterOperand* regCtx;

        if (!PyMemoryOperand_Check(ctx) && !PyRegisterOperand_Check(ctx))
          return PyErr_Format(PyExc_TypeError, "updateContext(): expected a Memory or Register as argument");

        inst = PyInstruction_AsInstruction(self);

        if (PyMemoryOperand_Check(ctx)) {
          memCtx = PyMemoryOperand_AsMemoryOperand(ctx);
          inst->updateContext(*memCtx);
        }

        else if (PyRegisterOperand_Check(ctx)) {
          regCtx = PyRegisterOperand_AsRegisterOperand(ctx);
          if (regCtx->isFlag())
            return PyErr_Format(PyExc_TypeError, "updateContext(): You cannot update the context on an isolated flag.");
          inst->updateContext(*regCtx);
        }

        Py_INCREF(Py_None);
        return Py_None;
      }
Ejemplo n.º 3
0
 static PyObject* MemoryOperand_getType(PyObject* self, PyObject* noarg) {
   try {
     return Py_BuildValue("k", PyMemoryOperand_AsMemoryOperand(self)->getType());
   }
   catch (const std::exception& e) {
     return PyErr_Format(PyExc_TypeError, "%s", e.what());
   }
 }
Ejemplo n.º 4
0
 static PyObject* MemoryOperand_getConcreteValue(PyObject* self, PyObject* noarg) {
   try {
     return PyLong_FromUint512(PyMemoryOperand_AsMemoryOperand(self)->getConcreteValue());
   }
   catch (const std::exception& e) {
     return PyErr_Format(PyExc_TypeError, "%s", e.what());
   }
 }
Ejemplo n.º 5
0
 static PyObject* MemoryOperand_getBitvector(PyObject* self, PyObject* noarg) {
   try {
     return PyBitvector(*PyMemoryOperand_AsMemoryOperand(self));
   }
   catch (const std::exception& e) {
     return PyErr_Format(PyExc_TypeError, "%s", e.what());
   }
 }
Ejemplo n.º 6
0
 static PyObject* MemoryOperand_getSegmentRegister(PyObject* self, PyObject* noarg) {
   try {
     triton::arch::RegisterOperand reg(PyMemoryOperand_AsMemoryOperand(self)->getSegmentRegister());
     return PyRegisterOperand(reg);
   }
   catch (const std::exception& e) {
     return PyErr_Format(PyExc_TypeError, "%s", e.what());
   }
 }
Ejemplo n.º 7
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());
   }
 }
Ejemplo n.º 8
0
 static PyObject* MemoryOperand_str(PyObject* self) {
   try {
     std::stringstream str;
     str << PyMemoryOperand_AsMemoryOperand(self);
     return PyString_FromFormat("%s", str.str().c_str());
   }
   catch (const std::exception& e) {
     return PyErr_Format(PyExc_TypeError, "%s", e.what());
   }
 }
Ejemplo n.º 9
0
 static PyObject* MemoryOperand_isTrusted(PyObject* self, PyObject* noarg) {
   try {
     if (PyMemoryOperand_AsMemoryOperand(self)->isTrusted())
       Py_RETURN_TRUE;
     Py_RETURN_FALSE;
   }
   catch (const std::exception& e) {
     return PyErr_Format(PyExc_TypeError, "%s", e.what());
   }
 }
Ejemplo n.º 10
0
 static PyObject* MemoryOperand_setTrust(PyObject* self, PyObject* flag) {
   try {
     if (!PyBool_Check(flag))
       return PyErr_Format(PyExc_TypeError, "Memory::setTrust(): Expected a boolean as argument.");
     PyMemoryOperand_AsMemoryOperand(self)->setTrust(PyLong_AsUint(flag));
     Py_INCREF(Py_None);
     return Py_None;
   }
   catch (const std::exception& e) {
     return PyErr_Format(PyExc_TypeError, "%s", e.what());
   }
 }
Ejemplo n.º 11
0
      static PyObject* MemoryOperand_setSegmentRegister(PyObject* self, PyObject* reg) {
        try {
          triton::arch::MemoryOperand *mem;

          if (!PyRegisterOperand_Check(reg))
            return PyErr_Format(PyExc_TypeError, "Memory::setSegmentRegister(): Expected a Register as argument.");

          mem = PyMemoryOperand_AsMemoryOperand(self);
          mem->setSegmentRegister(*PyRegisterOperand_AsRegisterOperand(reg));
          Py_INCREF(Py_None);
          return Py_None;
        }
        catch (const std::exception& e) {
          return PyErr_Format(PyExc_TypeError, "%s", e.what());
        }
      }
Ejemplo n.º 12
0
      static PyObject* MemoryOperand_setScale(PyObject* self, PyObject* imm) {
        try {
          triton::arch::MemoryOperand *mem;

          if (!PyImmediateOperand_Check(imm))
            return PyErr_Format(PyExc_TypeError, "Memory::setScale(): Expected an Immediate as argument.");

          mem = PyMemoryOperand_AsMemoryOperand(self);
          mem->setScale(*PyImmediateOperand_AsImmediateOperand(imm));
          Py_INCREF(Py_None);
          return Py_None;
        }
        catch (const std::exception& e) {
          return PyErr_Format(PyExc_TypeError, "%s", e.what());
        }
      }
Ejemplo n.º 13
0
      static PyObject* MemoryOperand_setConcreteValue(PyObject* self, PyObject* value) {
        try {
          triton::arch::MemoryOperand *mem;

          if (!PyLong_Check(value) && !PyInt_Check(value))
            return PyErr_Format(PyExc_TypeError, "Memory::setConcretevalue(): Expected an integer as argument.");

          mem = PyMemoryOperand_AsMemoryOperand(self);
          mem->setConcreteValue(PyLong_AsUint512(value));
          Py_INCREF(Py_None);
          return Py_None;
        }
        catch (const std::exception& e) {
          return PyErr_Format(PyExc_TypeError, "%s", e.what());
        }
      }
Ejemplo n.º 14
0
 static int MemoryOperand_print(PyObject* self) {
   std::cout << PyMemoryOperand_AsMemoryOperand(self);
   return 0;
 }
Ejemplo n.º 15
0
 //! Memory destructor.
 void MemoryOperand_dealloc(PyObject* self) {
   std::cout << std::flush;
   delete PyMemoryOperand_AsMemoryOperand(self);
   Py_DECREF(self);
 }