Example #1
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;
      }
Example #2
0
 static PyObject* RegisterOperand_getType(PyObject* self, PyObject* noarg) {
   try {
     return Py_BuildValue("k", PyRegisterOperand_AsRegisterOperand(self)->getType());
   }
   catch (const std::exception& e) {
     return PyErr_Format(PyExc_TypeError, "%s", e.what());
   }
 }
Example #3
0
 static PyObject* RegisterOperand_getConcreteValue(PyObject* self, PyObject* noarg) {
   try {
     return PyLong_FromUint512(PyRegisterOperand_AsRegisterOperand(self)->getConcreteValue());
   }
   catch (const std::exception& e) {
     return PyErr_Format(PyExc_TypeError, "%s", e.what());
   }
 }
Example #4
0
 static PyObject* RegisterOperand_getBitvector(PyObject* self, PyObject* noarg) {
   try {
     return PyBitvector(*PyRegisterOperand_AsRegisterOperand(self));
   }
   catch (const std::exception& e) {
     return PyErr_Format(PyExc_TypeError, "%s", e.what());
   }
 }
Example #5
0
 static PyObject* RegisterOperand_getParent(PyObject* self, PyObject* noarg) {
   try {
     triton::arch::RegisterOperand parent = PyRegisterOperand_AsRegisterOperand(self)->getParent();
     return PyRegisterOperand(parent);
   }
   catch (const std::exception& e) {
     return PyErr_Format(PyExc_TypeError, "%s", e.what());
   }
 }
Example #6
0
 static PyObject* RegisterOperand_str(PyObject* self) {
   try {
     std::stringstream str;
     str << PyRegisterOperand_AsRegisterOperand(self);
     return PyString_FromFormat("%s", str.str().c_str());
   }
   catch (const std::exception& e) {
     return PyErr_Format(PyExc_TypeError, "%s", e.what());
   }
 }
Example #7
0
 static PyObject* RegisterOperand_isFlag(PyObject* self, PyObject* noarg) {
   try {
     if (PyRegisterOperand_AsRegisterOperand(self)->isFlag())
       Py_RETURN_TRUE;
     Py_RETURN_FALSE;
   }
   catch (const std::exception& e) {
     return PyErr_Format(PyExc_TypeError, "%s", e.what());
   }
 }
Example #8
0
 static PyObject* RegisterOperand_setTrust(PyObject* self, PyObject* flag) {
   try {
     if (!PyBool_Check(flag))
       return PyErr_Format(PyExc_TypeError, "Register::setTrust(): Expected a boolean as argument.");
     PyRegisterOperand_AsRegisterOperand(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());
   }
 }
Example #9
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());
        }
      }
Example #10
0
      static PyObject* RegisterOperand_setConcreteValue(PyObject* self, PyObject* value) {
        try {
          triton::arch::RegisterOperand *reg;

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

          reg = PyRegisterOperand_AsRegisterOperand(self);
          if (reg->isFlag())
            return PyErr_Format(PyExc_TypeError, "Register::setConcreteValue(): You cannot set a concrete value on a flag.");

          reg->setConcreteValue(PyLong_AsUint512(value));
          Py_INCREF(Py_None);
          return Py_None;
        }
        catch (const std::exception& e) {
          return PyErr_Format(PyExc_TypeError, "%s", e.what());
        }
      }
Example #11
0
 //! Register destructor.
 void RegisterOperand_dealloc(PyObject* self) {
   std::cout << std::flush;
   delete PyRegisterOperand_AsRegisterOperand(self);
   Py_DECREF(self);
 }
Example #12
0
 static int RegisterOperand_print(PyObject* self) {
   std::cout << PyRegisterOperand_AsRegisterOperand(self);
   return 0;
 }