Ejemplo n.º 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;
      }
Ejemplo n.º 2
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());
        }
      }