465 static void TritonContext_dealloc(PyObject* self) {
466 if (((TritonContext_Object*)self)->ref ==
false)
468 Py_XDECREF(((TritonContext_Object*)self)->regAttr);
469 Py_TYPE(self)->tp_free((PyObject*)self);
473 static void TritonContext_fillRegistersAttribute(PyObject* self) {
478 for (
auto& reg : regs)
481 Py_XDECREF(((TritonContext_Object*)(self))->regAttr);
486 static PyObject* TritonContext_addCallback(PyObject* self, PyObject* args) {
487 PyObject* function =
nullptr;
488 PyObject* mode =
nullptr;
489 PyObject* cb =
nullptr;
490 PyObject* cb_self =
nullptr;
493 if (PyArg_ParseTuple(args,
"|OO", &mode, &function) ==
false) {
494 return PyErr_Format(PyExc_TypeError,
"TritonContext::addCallback(): Invalid number of arguments");
497 if (mode ==
nullptr || (!PyLong_Check(mode) && !PyInt_Check(mode)))
498 return PyErr_Format(PyExc_TypeError,
"TritonContext::addCallback(): Expects a CALLBACK as first argument.");
500 if (function ==
nullptr || !PyCallable_Check(function))
501 return PyErr_Format(PyExc_TypeError,
"TritonContext::addCallback(): Expects a function as second argument.");
503 if (PyMethod_Check(function)) {
504 cb_self = PyMethod_GET_SELF(function);
505 cb = PyMethod_GET_FUNCTION(function);
517 PyObject* args =
nullptr;
522 PyTuple_SetItem(args, 0, cb_self);
534 PyObject* ret = PyObject_CallObject(cb, args);
540 if (ret ==
nullptr) {
550 PyObject* args =
nullptr;
555 PyTuple_SetItem(args, 0, cb_self);
567 PyObject* ret = PyObject_CallObject(cb, args);
573 if (ret ==
nullptr) {
583 PyObject* args =
nullptr;
588 PyTuple_SetItem(args, 0, cb_self);
602 PyObject* ret = PyObject_CallObject(cb, args);
608 if (ret ==
nullptr) {
618 PyObject* args =
nullptr;
623 PyTuple_SetItem(args, 0, cb_self);
637 PyObject* ret = PyObject_CallObject(cb, args);
643 if (ret ==
nullptr) {
653 PyObject* args =
nullptr;
658 PyTuple_SetItem(args, 0, cb_self);
670 PyObject* ret = PyObject_CallObject(cb, args);
676 if (ret ==
nullptr) {
692 return PyErr_Format(PyExc_TypeError,
"Callbacks::addCallback(): Invalid kind of callback.");
699 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
707 static PyObject* TritonContext_assignSymbolicExpressionToMemory(PyObject* self, PyObject* args) {
708 PyObject* se =
nullptr;
709 PyObject* mem =
nullptr;
712 if (PyArg_ParseTuple(args,
"|OO", &se, &mem) ==
false) {
713 return PyErr_Format(PyExc_TypeError,
"TritonContext::assignSymbolicExpressionToMemory(): Invalid number of arguments");
717 return PyErr_Format(PyExc_TypeError,
"TritonContext::assignSymbolicExpressionToMemory(): Expects a SymbolicExpression as first argument.");
720 return PyErr_Format(PyExc_TypeError,
"TritonContext::assignSymbolicExpressionToMemory(): Expects a MemoryAccess as second argument.");
732 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
740 static PyObject* TritonContext_assignSymbolicExpressionToRegister(PyObject* self, PyObject* args) {
741 PyObject* se =
nullptr;
742 PyObject* reg =
nullptr;
745 if (PyArg_ParseTuple(args,
"|OO", &se, ®) ==
false) {
746 return PyErr_Format(PyExc_TypeError,
"TritonContext::assignSymbolicExpressionToRegister(): Invalid number of arguments");
750 return PyErr_Format(PyExc_TypeError,
"TritonContext::assignSymbolicExpressionToRegister(): Expects a SymbolicExpression as first argument.");
753 return PyErr_Format(PyExc_TypeError,
"TritonContext::assignSymbolicExpressionToRegister(): Expects a Register as second argument.");
765 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
773 static PyObject* TritonContext_buildSemantics(PyObject* self, PyObject* inst) {
775 return PyErr_Format(PyExc_TypeError,
"TritonContext::buildSemantics(): Expects an Instruction as argument.");
784 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
789 static PyObject* TritonContext_clearCallbacks(PyObject* self, PyObject* noarg) {
797 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
805 static PyObject* TritonContext_clearModes(PyObject* self, PyObject* noarg) {
813 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
821 static PyObject* TritonContext_clearConcreteMemoryValue(PyObject* self, PyObject* args) {
822 PyObject* baseAddr =
nullptr;
823 PyObject* size =
nullptr;
826 if (PyArg_ParseTuple(args,
"|OO", &baseAddr, &size) ==
false) {
827 return PyErr_Format(PyExc_TypeError,
"TritonContext::clearConcreteMemoryValue(): Invalid number of arguments");
834 else if (baseAddr && (PyLong_Check(baseAddr) || PyInt_Check(baseAddr))) {
835 if (size && (PyLong_Check(size) || PyInt_Check(size))) {
839 return PyErr_Format(PyExc_TypeError,
"TritonContext::clearConcreteMemoryValue(): Expects a size (integer) as second argument.");
843 return PyErr_Format(PyExc_TypeError,
"TritonContext::clearConcreteMemoryValue(): Expects a base address (integer) as arguments or a memory cells.");
850 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
858 static PyObject* TritonContext_clearPathConstraints(PyObject* self, PyObject* noarg) {
863 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
871 static PyObject* TritonContext_concretizeAllMemory(PyObject* self, PyObject* noarg) {
879 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
887 static PyObject* TritonContext_concretizeAllRegister(PyObject* self, PyObject* noarg) {
895 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
903 static PyObject* TritonContext_concretizeMemory(PyObject* self, PyObject* mem) {
905 if (PyLong_Check(mem) || PyInt_Check(mem)) {
913 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
926 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
932 return PyErr_Format(PyExc_TypeError,
"TritonContext::concretizeMemory(): Expects an integer or MemoryAccess as argument.");
939 static PyObject* TritonContext_concretizeRegister(PyObject* self, PyObject* reg) {
941 return PyErr_Format(PyExc_TypeError,
"TritonContext::concretizeRegister(): Expects a Register as argument.");
950 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
958 static PyObject* TritonContext_createSymbolicMemoryExpression(PyObject* self, PyObject* args) {
959 PyObject* inst =
nullptr;
960 PyObject* node =
nullptr;
961 PyObject* mem =
nullptr;
962 PyObject* comment =
nullptr;
963 std::string ccomment =
"";
966 if (PyArg_ParseTuple(args,
"|OOOO", &inst, &node, &mem, &comment) ==
false) {
967 return PyErr_Format(PyExc_TypeError,
"TritonContext::createSymbolicMemoryExpression(): Invalid number of arguments");
971 return PyErr_Format(PyExc_TypeError,
"TritonContext::createSymbolicMemoryExpression(): Expects an Instruction as first argument.");
974 return PyErr_Format(PyExc_TypeError,
"TritonContext::createSymbolicMemoryExpression(): Expects a AstNode as second argument.");
977 return PyErr_Format(PyExc_TypeError,
"TritonContext::createSymbolicMemoryExpression(): Expects a MemoryAccess as third argument.");
979 if (comment !=
nullptr && !PyStr_Check(comment))
980 return PyErr_Format(PyExc_TypeError,
"TritonContext::createSymbolicMemoryExpression(): Expects a sting as fourth argument.");
982 if (comment !=
nullptr)
983 ccomment = PyStr_AsString(comment);
996 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1001 static PyObject* TritonContext_createSymbolicRegisterExpression(PyObject* self, PyObject* args) {
1002 PyObject* inst =
nullptr;
1003 PyObject* node =
nullptr;
1004 PyObject* reg =
nullptr;
1005 PyObject* comment =
nullptr;
1006 std::string ccomment =
"";
1009 if (PyArg_ParseTuple(args,
"|OOOO", &inst, &node, ®, &comment) ==
false) {
1010 return PyErr_Format(PyExc_TypeError,
"TritonContext::createSymbolicRegisterExpression(): Invalid number of arguments");
1014 return PyErr_Format(PyExc_TypeError,
"TritonContext::createSymbolicRegisterExpression(): Expects an Instruction as first argument.");
1017 return PyErr_Format(PyExc_TypeError,
"TritonContext::createSymbolicRegisterExpression(): Expects a AstNode as second argument.");
1020 return PyErr_Format(PyExc_TypeError,
"TritonContext::createSymbolicRegisterExpression(): Expects a Register as third argument.");
1022 if (comment !=
nullptr && !PyStr_Check(comment))
1023 return PyErr_Format(PyExc_TypeError,
"TritonContext::createSymbolicRegisterExpression(): Expects a sting as fourth argument.");
1025 if (comment !=
nullptr)
1026 ccomment = PyStr_AsString(comment);
1039 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1044 static PyObject* TritonContext_createSymbolicVolatileExpression(PyObject* self, PyObject* args) {
1045 PyObject* inst =
nullptr;
1046 PyObject* node =
nullptr;
1047 PyObject* comment =
nullptr;
1048 std::string ccomment =
"";
1051 if (PyArg_ParseTuple(args,
"|OOO", &inst, &node, &comment) ==
false) {
1052 return PyErr_Format(PyExc_TypeError,
"TritonContext::createSymbolicVolatileExpression(): Invalid number of arguments");
1056 return PyErr_Format(PyExc_TypeError,
"TritonContext::createSymbolicVolatileExpression(): Expects an Instruction as first argument.");
1059 return PyErr_Format(PyExc_TypeError,
"TritonContext::createSymbolicVolatileExpression(): Expects a AstNode as second argument.");
1061 if (comment !=
nullptr && !PyStr_Check(comment))
1062 return PyErr_Format(PyExc_TypeError,
"TritonContext::createSymbolicVolatileExpression(): Expects a sting as third argument.");
1064 if (comment !=
nullptr)
1065 ccomment = PyStr_AsString(comment);
1077 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1082 static PyObject* TritonContext_disassembly(PyObject* self, PyObject* args) {
1083 PyObject* arg0 =
nullptr;
1084 PyObject* arg1 =
nullptr;
1085 PyObject* ret =
nullptr;
1089 if (PyArg_ParseTuple(args,
"|OO", &arg0, &arg1) ==
false) {
1090 return PyErr_Format(PyExc_TypeError,
"TritonContext::disassembly(): Invalid number of arguments.");
1101 if (arg1 !=
nullptr && (PyLong_Check(arg1) || PyInt_Check(arg1))) {
1108 if ((arg0 !=
nullptr && (PyLong_Check(arg0) || PyInt_Check(arg0))) &&
1109 (arg1 ==
nullptr || PyLong_Check(arg1) || PyInt_Check(arg1))) {
1111 std::vector<triton::arch::Instruction> insts;
1115 for (
auto& inst : insts)
1124 return PyErr_Format(PyExc_TypeError,
"TritonContext::disassembly(): Expects an Instruction or two integers as arguments.");
1131 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1136 static PyObject* TritonContext_evaluateAstViaSolver(PyObject* self, PyObject* node) {
1138 return PyErr_Format(PyExc_TypeError,
"TritonContext::evaluateAstViaSolver(): Expects a AstNode as argument.");
1147 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1155 static PyObject* TritonContext_getAllRegisters(PyObject* self, PyObject* noarg) {
1156 PyObject* ret =
nullptr;
1163 for (
auto& reg: regs)
1164 PyList_SetItem(ret, index++,
PyRegister(reg.second));
1170 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1177 static PyObject* TritonContext_getArchitecture(PyObject* self, PyObject* noarg) {
1185 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1190 static PyObject* TritonContext_getAstContext(PyObject* self, PyObject* noarg) {
1198 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1203 static PyObject* TritonContext_getAstRepresentationMode(PyObject* self, PyObject* noarg) {
1211 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1216 static PyObject* TritonContext_getConcreteMemoryAreaValue(PyObject* self, PyObject* args, PyObject* kwargs) {
1218 PyObject* ret =
nullptr;
1219 PyObject* addr =
nullptr;
1220 PyObject* size =
nullptr;
1221 PyObject* execCallbacks =
nullptr;
1223 static char* keywords[] = {
1231 if (PyArg_ParseTupleAndKeywords(args, kwargs,
"OO|O", keywords, &addr, &size, &execCallbacks) ==
false) {
1232 return PyErr_Format(PyExc_TypeError,
"TritonContext::getConcreteMemoryAreaValue(): Invalid keyword argument");
1235 if (addr ==
nullptr || (!PyLong_Check(addr) && !PyInt_Check(addr))) {
1236 return PyErr_Format(PyExc_TypeError,
"TritonContext::getConcreteMemoryAreaValue(): Expects an integer as addr keyword.");
1239 if (size ==
nullptr || (!PyLong_Check(size) && !PyInt_Check(size))) {
1240 return PyErr_Format(PyExc_TypeError,
"TritonContext::getConcreteMemoryAreaValue(): Expects an integer as size keyword.");
1243 if (execCallbacks !=
nullptr && !PyBool_Check(execCallbacks)) {
1244 return PyErr_Format(PyExc_TypeError,
"TritonContext::getConcreteMemoryAreaValue(): Expects a boolean as execCallbacks keyword.");
1247 if (execCallbacks ==
nullptr) {
1256 area[index] = vv[index];
1258 ret = PyBytes_FromStringAndSize(
reinterpret_cast<const char*
>(area), vv.size());
1267 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1274 static PyObject* TritonContext_getConcreteMemoryValue(PyObject* self, PyObject* args, PyObject* kwargs) {
1275 PyObject* mem =
nullptr;
1276 PyObject* execCallbacks =
nullptr;
1278 static char* keywords[] = {
1285 if (PyArg_ParseTupleAndKeywords(args, kwargs,
"O|O", keywords, &mem, &execCallbacks) ==
false) {
1286 return PyErr_Format(PyExc_TypeError,
"TritonContext::getConcreteMemoryValue(): Invalid keyword argument");
1289 if (mem ==
nullptr || (!PyLong_Check(mem) && !PyInt_Check(mem) && !
PyMemoryAccess_Check(mem))) {
1290 return PyErr_Format(PyExc_TypeError,
"TritonContext::getConcreteMemoryValue(): Expects a MemoryAccess or an integer as mem keyword.");
1293 if (execCallbacks !=
nullptr && !PyBool_Check(execCallbacks)) {
1294 return PyErr_Format(PyExc_TypeError,
"TritonContext::getConcreteMemoryValue(): Expects a boolean as execCallbacks keyword.");
1297 if (execCallbacks ==
nullptr) {
1302 if (PyLong_Check(mem) || PyInt_Check(mem))
1307 return PyErr_Format(PyExc_TypeError,
"TritonContext::getConcreteMemoryValue(): Something wrong.");
1313 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1318 static PyObject* TritonContext_getConcreteRegisterValue(PyObject* self, PyObject* args, PyObject* kwargs) {
1319 PyObject* reg =
nullptr;
1320 PyObject* execCallbacks =
nullptr;
1322 static char* keywords[] = {
1329 if (PyArg_ParseTupleAndKeywords(args, kwargs,
"O|O", keywords, ®, &execCallbacks) ==
false) {
1330 return PyErr_Format(PyExc_TypeError,
"TritonContext::getConcreteRegisterValue(): Invalid keyword argument");
1334 return PyErr_Format(PyExc_TypeError,
"TritonContext::getConcreteRegisterValue(): Expects a Register as reg keyword.");
1337 if (execCallbacks !=
nullptr && !PyBool_Check(execCallbacks)) {
1338 return PyErr_Format(PyExc_TypeError,
"TritonContext::getConcreteRegisterValue(): Expects a boolean as execCallbacks keyword.");
1341 if (execCallbacks ==
nullptr) {
1352 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1357 static PyObject* TritonContext_getConcreteVariableValue(PyObject* self, PyObject* symVar) {
1359 return PyErr_Format(PyExc_TypeError,
"TritonContext::getConcreteVariableValue(): Expects a SymbolicVariable as argument.");
1368 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1373 static PyObject* TritonContext_getGprBitSize(PyObject* self, PyObject* noarg) {
1381 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1386 static PyObject* TritonContext_getGprSize(PyObject* self, PyObject* noarg) {
1394 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1399 static PyObject* TritonContext_getImmediateAst(PyObject* self, PyObject* imm) {
1401 return PyErr_Format(PyExc_TypeError,
"TritonContext::getImmediateAst(): Expects an Immediate as argument.");
1410 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1415 static PyObject* TritonContext_getMemoryAst(PyObject* self, PyObject* mem) {
1417 return PyErr_Format(PyExc_TypeError,
"TritonContext::getMemoryAst(): Expects an MemoryAccess as argument.");
1426 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1431 static PyObject* TritonContext_getModel(PyObject* self, PyObject* args, PyObject* kwargs) {
1436 PyObject* dict =
nullptr;
1437 PyObject* node =
nullptr;
1438 PyObject* wb =
nullptr;
1439 PyObject* timeout =
nullptr;
1441 static char* keywords[] = {
1449 if (PyArg_ParseTupleAndKeywords(args, kwargs,
"|OOO", keywords, &node, &wb, &timeout) ==
false) {
1450 return PyErr_Format(PyExc_TypeError,
"TritonContext::getModel(): Invalid keyword argument.");
1454 return PyErr_Format(PyExc_TypeError,
"TritonContext::getModel(): Expects a AstNode as node argument.");
1457 if (wb !=
nullptr && !PyBool_Check(wb)) {
1458 return PyErr_Format(PyExc_TypeError,
"TritonContext::getModel(): Expects a boolean as status keyword.");
1461 if (timeout !=
nullptr && (!PyLong_Check(timeout) && !PyInt_Check(timeout))) {
1462 return PyErr_Format(PyExc_TypeError,
"TritonContext::getModel(): Expects a integer as timeout keyword.");
1465 if (timeout !=
nullptr) {
1472 for (
auto it = model.begin(); it != model.end(); it++) {
1480 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1485 PyTuple_SetItem(tuple, 0, dict);
1495 static PyObject* TritonContext_getModels(PyObject* self, PyObject* args, PyObject* kwargs) {
1500 PyObject* ret =
nullptr;
1501 PyObject* node =
nullptr;
1502 PyObject* limit =
nullptr;
1503 PyObject* wb =
nullptr;
1504 PyObject* timeout =
nullptr;
1506 static char* keywords[] = {
1515 if (PyArg_ParseTupleAndKeywords(args, kwargs,
"|OOOO", keywords, &node, &limit, &wb, &timeout) ==
false) {
1516 return PyErr_Format(PyExc_TypeError,
"TritonContext::getModels(): Invalid keyword argument.");
1520 return PyErr_Format(PyExc_TypeError,
"TritonContext::getModels(): Expects a AstNode as node argument.");
1523 if (limit ==
nullptr || (!PyLong_Check(limit) && !PyInt_Check(limit))) {
1524 return PyErr_Format(PyExc_TypeError,
"TritonContext::getModels(): Expects an integer as limit argument.");
1527 if (wb !=
nullptr && !PyBool_Check(wb)) {
1528 return PyErr_Format(PyExc_TypeError,
"TritonContext::getModels(): Expects a boolean as status keyword.");
1531 if (timeout !=
nullptr && (!PyLong_Check(timeout) && !PyInt_Check(timeout))) {
1532 return PyErr_Format(PyExc_TypeError,
"TritonContext::getModels(): Expects a integer as timeout keyword.");
1535 if (timeout !=
nullptr) {
1544 for (
auto it = models.begin(); it != models.end(); it++) {
1548 for (
auto it2 = model.begin(); it2 != model.end(); it2++) {
1551 if (model.size() > 0)
1552 PyList_SetItem(ret, index++, mdict);
1559 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1564 PyTuple_SetItem(tuple, 0, ret);
1574 static PyObject* TritonContext_getParentRegisters(PyObject* self, PyObject* noarg) {
1575 PyObject* ret =
nullptr;
1582 for (
const auto* reg: regs) {
1583 PyList_SetItem(ret, index++,
PyRegister(*reg));
1590 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1597 static PyObject* TritonContext_getPathConstraints(PyObject* self, PyObject* noarg) {
1598 PyObject* ret =
nullptr;
1605 for (
auto it = pc.begin(); it != pc.end(); it++) {
1613 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1620 static PyObject* TritonContext_getPathPredicate(PyObject* self, PyObject* noarg) {
1628 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1633 static PyObject* TritonContext_getPathPredicateSize(PyObject* self, PyObject* noarg) {
1642 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1647 static PyObject* TritonContext_getPredicatesToReachAddress(PyObject* self, PyObject* addr) {
1648 PyObject* ret =
nullptr;
1650 if (addr ==
nullptr || (!PyLong_Check(addr) && !PyInt_Check(addr)))
1651 return PyErr_Format(PyExc_TypeError,
"TritonContext::getPredicatesToReachAddress(): Expects an address as argument.");
1658 for (
auto it = preds.begin(); it != preds.end(); it++) {
1659 PyList_SetItem(ret, index++,
PyAstNode(*it));
1666 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1673 static PyObject* TritonContext_getRegister(PyObject* self, PyObject* regIn) {
1675 if (regIn !=
nullptr && (PyLong_Check(regIn) || PyInt_Check(regIn))) {
1681 else if (regIn !=
nullptr && (PyStr_Check(regIn))) {
1682 std::string name = std::string(PyStr_AsString(regIn));
1688 return PyErr_Format(PyExc_TypeError,
"TritonContext::getRegister(): Expects an integer or a string as argument.");
1695 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1700 static PyObject* TritonContext_getRegisterAst(PyObject* self, PyObject* reg) {
1702 return PyErr_Format(PyExc_TypeError,
"TritonContext::getRegisterAst(): Expects an Register as argument.");
1711 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1716 static PyObject* TritonContext_getSolver(PyObject* self, PyObject* noarg) {
1724 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1729 static PyObject* TritonContext_getSymbolicExpression(PyObject* self, PyObject* symExprId) {
1730 if (!PyLong_Check(symExprId) && !PyInt_Check(symExprId))
1731 return PyErr_Format(PyExc_TypeError,
"TritonContext::getSymbolicExpression(): Expects an integer as argument.");
1740 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1745 static PyObject* TritonContext_getSymbolicExpressions(PyObject* self, PyObject* noarg) {
1746 PyObject* ret =
nullptr;
1752 for (
auto it = expressions.begin(); it != expressions.end(); it++)
1759 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1766 static PyObject* TritonContext_getSymbolicMemory(PyObject* self, PyObject* args) {
1767 PyObject* ret =
nullptr;
1768 PyObject* addr =
nullptr;
1771 if (PyArg_ParseTuple(args,
"|O", &addr) ==
false) {
1772 return PyErr_Format(PyExc_TypeError,
"TritonContext::getSymbolicMemory(): Invalid number of arguments");
1776 if (addr ==
nullptr) {
1780 for (
auto it = regs.begin(); it != regs.end(); it++) {
1784 else if (addr !=
nullptr && (PyLong_Check(addr) || PyInt_Check(addr))) {
1788 return PyErr_Format(PyExc_TypeError,
"TritonContext::getSymbolicMemory(): Expects an integer or nothing as argument.");
1794 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1801 static PyObject* TritonContext_getSymbolicMemoryValue(PyObject* self, PyObject* mem) {
1803 return PyErr_Format(PyExc_TypeError,
"TritonContext::getSymbolicMemoryValue(): Expects an integer or a MemoryAccess as argument.");
1806 if (PyLong_Check(mem) || PyInt_Check(mem))
1814 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1819 static PyObject* TritonContext_getSymbolicRegisters(PyObject* self, PyObject* noarg) {
1820 PyObject* ret =
nullptr;
1826 for (
auto it = regs.begin(); it != regs.end(); it++) {
1834 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1841 static PyObject* TritonContext_getSymbolicRegister(PyObject* self, PyObject* reg) {
1843 return PyErr_Format(PyExc_TypeError,
"TritonContext::getSymbolicRegister(): Expects a Register as argument.");
1852 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1857 static PyObject* TritonContext_getSymbolicRegisterValue(PyObject* self, PyObject* reg) {
1859 return PyErr_Format(PyExc_TypeError,
"TritonContext::getSymbolicRegisterValue(): Expects a Register as argument.");
1868 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1873 static PyObject* TritonContext_getSymbolicVariable(PyObject* self, PyObject* arg) {
1875 if (PyLong_Check(arg) || PyInt_Check(arg))
1878 else if (PyStr_Check(arg))
1882 return PyErr_Format(PyExc_TypeError,
"TritonContext::getSymbolicVariable(): Expects an integer or a string as argument.");
1888 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1893 static PyObject* TritonContext_getSymbolicVariables(PyObject* self, PyObject* noarg) {
1894 PyObject* ret =
nullptr;
1900 for (
auto sv: variables)
1907 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1914 static PyObject* TritonContext_getTaintedMemory(PyObject* self, PyObject* noarg) {
1915 PyObject* ret =
nullptr;
1921 size = addresses.size();
1923 for (
auto it = addresses.begin(); it != addresses.end(); it++) {
1932 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1939 static PyObject* TritonContext_getTaintedRegisters(PyObject* self, PyObject* noarg) {
1940 PyObject* ret =
nullptr;
1946 size = registers.size();
1948 for (
const auto* reg: registers) {
1949 PyList_SetItem(ret, index,
PyRegister(*reg));
1957 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1964 static PyObject* TritonContext_getTaintedSymbolicExpressions(PyObject* self, PyObject* noarg) {
1965 PyObject* ret =
nullptr;
1971 size = expressions.size();
1973 for (
auto it = expressions.begin(); it != expressions.end(); it++) {
1982 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
1989 static PyObject* TritonContext_isArchitectureValid(PyObject* self, PyObject* noarg) {
1999 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2004 static PyObject* TritonContext_isConcreteMemoryValueDefined(PyObject* self, PyObject* args) {
2005 PyObject* baseAddr =
nullptr;
2006 PyObject* size =
nullptr;
2009 if (PyArg_ParseTuple(args,
"|OO", &baseAddr, &size) ==
false) {
2010 return PyErr_Format(PyExc_TypeError,
"TritonContext::isConcreteMemoryValueDefined(): Invalid number of arguments");
2019 else if (baseAddr && (PyLong_Check(baseAddr) || PyInt_Check(baseAddr))) {
2020 if (size && (PyLong_Check(size) || PyInt_Check(size))) {
2026 return PyErr_Format(PyExc_TypeError,
"TritonContext::isConcreteMemoryValueDefined(): Expects a size (integer) as second argument.");
2030 return PyErr_Format(PyExc_TypeError,
"TritonContext::isConcreteMemoryValueDefined(): Expects a base address (integer) as arguments or a memory cells.");
2037 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2042 static PyObject* TritonContext_isFlag(PyObject* self, PyObject* reg) {
2044 return PyErr_Format(PyExc_TypeError,
"TritonContext::isFlag(): Expects a Register as argument.");
2055 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2060 static PyObject* TritonContext_isMemorySymbolized(PyObject* self, PyObject* mem) {
2067 else if (PyLong_Check(mem) || PyInt_Check(mem)) {
2073 return PyErr_Format(PyExc_TypeError,
"TritonContext::isMemorySymbolized(): Expects a MemoryAccess or an integer as argument.");
2079 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2086 static PyObject* TritonContext_isMemoryTainted(PyObject* self, PyObject* mem) {
2093 else if (PyLong_Check(mem) || PyInt_Check(mem)) {
2099 return PyErr_Format(PyExc_TypeError,
"TritonContext::isMemoryTainted(): Expects a MemoryAccess or an integer as argument.");
2105 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2112 static PyObject* TritonContext_isRegister(PyObject* self, PyObject* reg) {
2114 return PyErr_Format(PyExc_TypeError,
"TritonContext::isRegister(): Expects a Register as argument.");
2125 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2130 static PyObject* TritonContext_isRegisterSymbolized(PyObject* self, PyObject* reg) {
2132 return PyErr_Format(PyExc_TypeError,
"TritonContext::isRegisterSymbolized(): Expects a Register as argument.");
2143 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2148 static PyObject* TritonContext_isRegisterTainted(PyObject* self, PyObject* reg) {
2150 return PyErr_Format(PyExc_TypeError,
"TritonContext::isRegisterTainted(): Expects a Register as argument.");
2161 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2166 static PyObject* TritonContext_isRegisterValid(PyObject* self, PyObject* reg) {
2168 return PyErr_Format(PyExc_TypeError,
"TritonContext::isRegisterValid(): Expects a Register as argument.");
2179 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2184 static PyObject* TritonContext_isSat(PyObject* self, PyObject* node) {
2186 return PyErr_Format(PyExc_TypeError,
"TritonContext::isSat(): Expects a AstNode as argument.");
2197 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2202 static PyObject* TritonContext_isSymbolicExpressionExists(PyObject* self, PyObject* symExprId) {
2203 if (!PyInt_Check(symExprId) && !PyLong_Check(symExprId))
2204 return PyErr_Format(PyExc_TypeError,
"TritonContext::isSymbolicExpressionExists(): Expects an integer as argument.");
2215 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2220 static PyObject* TritonContext_isModeEnabled(PyObject* self, PyObject* mode) {
2221 if (!PyInt_Check(mode) && !PyLong_Check(mode))
2222 return PyErr_Format(PyExc_TypeError,
"TritonContext::isModeEnabled(): Expects a MODE as argument.");
2233 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2238 static PyObject* TritonContext_isThumb(PyObject* self, PyObject* noarg) {
2248 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2253 static PyObject* TritonContext_liftToDot(PyObject* self, PyObject* node) {
2255 return PyErr_Format(PyExc_TypeError,
"TritonContext::liftToDot(): Expects an AstNode or a SymbolicExpression as first argument.");
2258 std::ostringstream stream;
2273 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2281 static PyObject* TritonContext_liftToLLVM(PyObject* self, PyObject* args, PyObject* kwargs) {
2282 PyObject* node =
nullptr;
2283 PyObject* fname =
nullptr;
2284 PyObject* optimize =
nullptr;
2286 static char* keywords[] = {
2294 if (PyArg_ParseTupleAndKeywords(args, kwargs,
"|OOO", keywords, &node, &fname, &optimize) ==
false) {
2295 return PyErr_Format(PyExc_TypeError,
"TritonContext::liftToLLVM(): Invalid number of arguments");
2299 return PyErr_Format(PyExc_TypeError,
"TritonContext::liftToLLVM(): Expects a SymbolicExpression or a AstNode as node argument.");
2301 if (fname !=
nullptr && !PyStr_Check(fname))
2302 return PyErr_Format(PyExc_TypeError,
"TritonContext::liftToLLVM(): Expects a string as fname argument.");
2304 if (optimize !=
nullptr && !PyBool_Check(optimize))
2305 return PyErr_Format(PyExc_TypeError,
"TritonContext::liftToLLVM(): Expects a boolean as optimize argument.");
2307 if (fname ==
nullptr)
2308 fname = PyStr_FromString(
"__triton");
2310 if (optimize ==
nullptr)
2314 std::ostringstream stream;
2327 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2335 static PyObject* TritonContext_liftToPython(PyObject* self, PyObject* args, PyObject* kwargs) {
2336 PyObject* expr =
nullptr;
2337 PyObject* icomment =
nullptr;
2339 static char* keywords[] = {
2346 if (PyArg_ParseTupleAndKeywords(args, kwargs,
"|OO", keywords, &expr, &icomment) ==
false) {
2347 return PyErr_Format(PyExc_TypeError,
"TritonContext::liftToPython(): Invalid number of arguments");
2351 return PyErr_Format(PyExc_TypeError,
"TritonContext::liftToPython(): Expects a SymbolicExpression as expr argument.");
2353 if (icomment !=
nullptr && !PyBool_Check(icomment))
2354 return PyErr_Format(PyExc_TypeError,
"TritonContext::liftToPython(): Expects a boolean as icomment argument.");
2356 if (icomment ==
nullptr)
2360 std::ostringstream stream;
2368 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2376 static PyObject* TritonContext_liftToSMT(PyObject* self, PyObject* args, PyObject* kwargs) {
2377 PyObject* expr =
nullptr;
2378 PyObject* assert =
nullptr;
2379 PyObject* icomment =
nullptr;
2381 static char* keywords[] = {
2389 if (PyArg_ParseTupleAndKeywords(args, kwargs,
"|OO", keywords, &expr, &assert, &icomment) ==
false) {
2390 return PyErr_Format(PyExc_TypeError,
"TritonContext::liftToSMT(): Invalid number of arguments");
2394 return PyErr_Format(PyExc_TypeError,
"TritonContext::liftToSMT(): Expects a SymbolicExpression as expr argument.");
2396 if (assert !=
nullptr && !PyBool_Check(assert))
2397 return PyErr_Format(PyExc_TypeError,
"TritonContext::liftToSMT(): Expects a boolean as assert_ argument.");
2399 if (assert ==
nullptr)
2402 if (icomment !=
nullptr && !PyBool_Check(icomment))
2403 return PyErr_Format(PyExc_TypeError,
"TritonContext::liftToSMT(): Expects a boolean as icomment argument.");
2405 if (icomment ==
nullptr)
2409 std::ostringstream stream;
2417 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2425 static PyObject* TritonContext_newSymbolicExpression(PyObject* self, PyObject* args) {
2426 PyObject* node =
nullptr;
2427 PyObject* comment =
nullptr;
2428 std::string ccomment =
"";
2431 if (PyArg_ParseTuple(args,
"|OO", &node, &comment) ==
false) {
2432 return PyErr_Format(PyExc_TypeError,
"TritonContext::newSymbolicExpression(): Invalid number of arguments");
2436 return PyErr_Format(PyExc_TypeError,
"TritonContext::newSymbolicExpression(): Expects a AstNode as first argument.");
2438 if (comment !=
nullptr && !PyStr_Check(comment))
2439 return PyErr_Format(PyExc_TypeError,
"TritonContext::newSymbolicExpression(): Expects a sting as second argument.");
2441 if (comment !=
nullptr)
2442 ccomment = PyStr_AsString(comment);
2451 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2456 static PyObject* TritonContext_newSymbolicVariable(PyObject* self, PyObject* args) {
2457 PyObject* size =
nullptr;
2458 PyObject* alias =
nullptr;
2459 std::string calias =
"";
2462 if (PyArg_ParseTuple(args,
"|OO", &size, &alias) ==
false) {
2463 return PyErr_Format(PyExc_TypeError,
"TritonContext::newSymbolicVariable(): Invalid number of arguments");
2466 if (size ==
nullptr || (!PyLong_Check(size) && !PyInt_Check(size)))
2467 return PyErr_Format(PyExc_TypeError,
"TritonContext::newSymbolicVariable(): Expects an integer as first argument.");
2469 if (alias !=
nullptr && !PyStr_Check(alias))
2470 return PyErr_Format(PyExc_TypeError,
"TritonContext::newSymbolicVariable(): Expects a sting as second argument.");
2472 if (alias !=
nullptr)
2473 calias = PyStr_AsString(alias);
2482 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2487 static PyObject* TritonContext_popPathConstraint(PyObject* self, PyObject* noarg) {
2495 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2502 static PyObject* TritonContext_processing(PyObject* self, PyObject* args) {
2503 PyObject* obj =
nullptr;
2504 PyObject* addr =
nullptr;
2507 if (PyArg_ParseTuple(args,
"|OO", &obj, &addr) ==
false) {
2508 return PyErr_Format(PyExc_TypeError,
"TritonContext::processing(): Invalid number of arguments");
2517 if (addr !=
nullptr && (PyLong_Check(addr) || PyInt_Check(addr))) {
2522 return PyErr_Format(PyExc_TypeError,
"TritonContext::processing(): Expects an Instruction or a BasicBlock as argument.");
2528 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2533 static PyObject* TritonContext_pushPathConstraint(PyObject* self, PyObject* args, PyObject* kwargs) {
2534 PyObject* node =
nullptr;
2535 PyObject* comment =
nullptr;
2536 std::string ccomment =
"";
2538 static char* keywords[] = {
2545 if (PyArg_ParseTupleAndKeywords(args, kwargs,
"|OO", keywords, &node, &comment) ==
false) {
2546 return PyErr_Format(PyExc_TypeError,
"TritonContext::pushPathConstraint(): Invalid keyword argument.");
2550 return PyErr_Format(PyExc_TypeError,
"TritonContext::pushPathConstraint(): Expects an AstNode as first argument.");
2552 if (comment !=
nullptr && !PyStr_Check(comment))
2553 return PyErr_Format(PyExc_TypeError,
"TritonContext::pushPathConstraint(): Expects a string as second argument.");
2555 if (comment !=
nullptr)
2556 ccomment = PyStr_AsString(comment);
2565 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2573 static PyObject* TritonContext_removeCallback(PyObject* self, PyObject* args) {
2574 PyObject* cb =
nullptr;
2575 PyObject* cb_self =
nullptr;
2576 PyObject* function =
nullptr;
2577 PyObject* mode =
nullptr;
2580 if (PyArg_ParseTuple(args,
"|OO", &mode, &function) ==
false) {
2581 return PyErr_Format(PyExc_TypeError,
"TritonContext::removeCallback(): Invalid number of arguments");
2584 if (mode ==
nullptr || (!PyLong_Check(mode) && !PyInt_Check(mode)))
2585 return PyErr_Format(PyExc_TypeError,
"TritonContext::removeCallback(): Expects a CALLBACK as first argument.");
2587 if (function ==
nullptr || !PyCallable_Check(function))
2588 return PyErr_Format(PyExc_TypeError,
"TritonContext::removeCallback(): Expects a function as second argument.");
2591 if (PyMethod_Check(function)) {
2592 cb_self = PyMethod_GET_SELF(function);
2593 cb = PyMethod_GET_FUNCTION(function);
2617 return PyErr_Format(PyExc_TypeError,
"TritonContext::removeCallback(): Invalid kind of callback.");
2624 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2632 static PyObject* TritonContext_reset(PyObject* self, PyObject* noarg) {
2640 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2648 static PyObject* TritonContext_setArchitecture(PyObject* self, PyObject* arg) {
2649 if (!PyLong_Check(arg) && !PyInt_Check(arg))
2650 return PyErr_Format(PyExc_TypeError,
"TritonContext::setArchitecture(): Expects an ARCH as argument.");
2655 TritonContext_fillRegistersAttribute(self);
2661 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2669 static PyObject* TritonContext_setAstRepresentationMode(PyObject* self, PyObject* arg) {
2670 if (!PyLong_Check(arg) && !PyInt_Check(arg))
2671 return PyErr_Format(PyExc_TypeError,
"TritonContext::setAstRepresentationMode(): Expects an AST_REPRESENTATION as argument.");
2680 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2688 static PyObject* TritonContext_setConcreteMemoryAreaValue(PyObject* self, PyObject* args, PyObject* kwargs) {
2689 std::vector<triton::uint8> vv;
2690 PyObject* baseAddr =
nullptr;
2691 PyObject* values =
nullptr;
2692 PyObject* execCallbacks =
nullptr;
2694 static char* keywords[] = {
2702 if (PyArg_ParseTupleAndKeywords(args, kwargs,
"OO|O", keywords, &baseAddr, &values, &execCallbacks) ==
false) {
2703 return PyErr_Format(PyExc_TypeError,
"TritonContext::setConcreteMemoryAreaValue(): Invalid keyword argument");
2706 if (baseAddr ==
nullptr || (!PyLong_Check(baseAddr) && !PyInt_Check(baseAddr))) {
2707 return PyErr_Format(PyExc_TypeError,
"TritonContext::setConcreteMemoryAreaValue(): Expects an integer as baseAddr keyword.");
2710 if (values ==
nullptr || (!PyList_Check(values) && !PyBytes_Check(values) && !PyByteArray_Check(values))) {
2711 return PyErr_Format(PyExc_TypeError,
"TritonContext::setConcreteMemoryAreaValue(): Expects a list or bytes as values keyword.");
2714 if (execCallbacks !=
nullptr && !PyBool_Check(execCallbacks)) {
2715 return PyErr_Format(PyExc_TypeError,
"TritonContext::setConcreteMemoryAreaValue(): Expects a boolean as execCallbacks keyword.");
2718 if (execCallbacks ==
nullptr) {
2723 if (PyList_Check(values)) {
2724 for (Py_ssize_t i = 0; i < PyList_Size(values); i++) {
2725 PyObject* item = PyList_GetItem(values, i);
2727 if ((!PyLong_Check(item) && !PyInt_Check(item)) ||
PyLong_AsUint32(item) > 0xff)
2728 return PyErr_Format(PyExc_TypeError,
"TritonContext::setConcreteMemoryAreaValue(): Each item of the list must be a 8-bits integer.");
2740 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2745 else if (PyBytes_Check(values)) {
2756 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2761 else if (PyByteArray_Check(values)) {
2772 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2778 return PyErr_Format(PyExc_TypeError,
"TritonContext::setConcreteMemoryAreaValue(): Something wrong.");
2785 static PyObject* TritonContext_setConcreteMemoryValue(PyObject* self, PyObject* args, PyObject* kwargs) {
2786 PyObject* mem =
nullptr;
2787 PyObject* value =
nullptr;
2788 PyObject* execCallbacks =
nullptr;
2790 static char* keywords[] = {
2798 if (PyArg_ParseTupleAndKeywords(args, kwargs,
"OO|O", keywords, &mem, &value, &execCallbacks) ==
false) {
2799 return PyErr_Format(PyExc_TypeError,
"TritonContext::setConcreteMemoryValue(): Invalid keyword argument");
2802 if (mem ==
nullptr || (!PyLong_Check(mem) && !PyInt_Check(mem) && !
PyMemoryAccess_Check(mem))) {
2803 return PyErr_Format(PyExc_TypeError,
"TritonContext::setConcreteMemoryValue(): Expects a MemoryAccess or an integer as mem keyword.");
2806 if (value ==
nullptr || (!PyLong_Check(value) && !PyInt_Check(value))) {
2807 return PyErr_Format(PyExc_TypeError,
"TritonContext::setConcreteMemoryValue(): Expects an integer as value keyword.");
2810 if (execCallbacks !=
nullptr && !PyBool_Check(execCallbacks)) {
2811 return PyErr_Format(PyExc_TypeError,
"TritonContext::setConcreteMemoryAreaValue(): Expects a boolean as execCallbacks keyword.");
2814 if (execCallbacks ==
nullptr) {
2819 if (PyLong_Check(mem) || PyInt_Check(mem)) {
2824 return PyErr_Format(PyExc_TypeError,
"TritonContext::setConcreteMemoryValue(): Value must be on 8 bits.");
2833 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2848 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2854 return PyErr_Format(PyExc_TypeError,
"TritonContext::setConcreteMemoryValue(): something wrong.");
2861 static PyObject* TritonContext_setConcreteRegisterValue(PyObject* self, PyObject* args, PyObject* kwargs) {
2862 PyObject* reg =
nullptr;
2863 PyObject* value =
nullptr;
2864 PyObject* execCallbacks =
nullptr;
2866 static char* keywords[] = {
2874 if (PyArg_ParseTupleAndKeywords(args, kwargs,
"OO|O", keywords, ®, &value, &execCallbacks) ==
false) {
2875 return PyErr_Format(PyExc_TypeError,
"TritonContext::setConcreteRegisterValue(): Invalid keyword argument");
2879 return PyErr_Format(PyExc_TypeError,
"TritonContext::setConcreteRegisterValue(): Expects a Register as reg keyword.");
2882 if (value ==
nullptr || (!PyLong_Check(value) && !PyInt_Check(value))) {
2883 return PyErr_Format(PyExc_TypeError,
"TritonContext::setConcreteRegisterValue(): Expects an integer as value keyword.");
2886 if (execCallbacks !=
nullptr && !PyBool_Check(execCallbacks)) {
2887 return PyErr_Format(PyExc_TypeError,
"TritonContext::setConcreteMemoryAreaValue(): Expects a boolean as execCallbacks keyword.");
2890 if (execCallbacks ==
nullptr) {
2902 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2910 static PyObject* TritonContext_setConcreteVariableValue(PyObject* self, PyObject* args) {
2911 PyObject* symVar =
nullptr;
2912 PyObject* value =
nullptr;
2915 if (PyArg_ParseTuple(args,
"|OO", &symVar, &value) ==
false) {
2916 return PyErr_Format(PyExc_TypeError,
"TritonContext::setConcreteVariableValue(): Invalid number of arguments");
2920 return PyErr_Format(PyExc_TypeError,
"TritonContext::setConcreteVariableValue(): Bad argument type.");
2922 if (value ==
nullptr)
2923 return PyErr_Format(PyExc_TypeError,
"TritonContext::setConcreteVariableValue(): Expects a second argument as integer value.");
2932 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2940 static PyObject* TritonContext_setMode(PyObject* self, PyObject* args) {
2941 PyObject* mode =
nullptr;
2942 PyObject*
flag =
nullptr;
2945 if (PyArg_ParseTuple(args,
"|OO", &mode, &flag) ==
false) {
2946 return PyErr_Format(PyExc_TypeError,
"TritonContext::setMode(): Invalid number of arguments");
2949 if (mode ==
nullptr || (!PyLong_Check(mode) && !PyInt_Check(mode)))
2950 return PyErr_Format(PyExc_TypeError,
"TritonContext::setMode(): Expects a MODE as argument.");
2952 if (flag ==
nullptr || !PyBool_Check(flag))
2953 return PyErr_Format(PyExc_TypeError,
"TritonContext::setMode(): Expects an boolean flag as second argument.");
2962 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2970 static PyObject* TritonContext_setSolver(PyObject* self, PyObject* solver) {
2971 if (solver ==
nullptr || (!PyLong_Check(solver) && !PyInt_Check(solver)))
2972 return PyErr_Format(PyExc_TypeError,
"TritonContext::setSolver(): Expects a SOLVER as argument.");
2978 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
2986 static PyObject* TritonContext_setSolverMemoryLimit(PyObject* self, PyObject* megabytes) {
2987 if (megabytes ==
nullptr || (!PyLong_Check(megabytes) && !PyInt_Check(megabytes)))
2988 return PyErr_Format(PyExc_TypeError,
"TritonContext::setSolverMemoryLimit(): Expects an integer as argument.");
2994 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
3002 static PyObject* TritonContext_setSolverTimeout(PyObject* self, PyObject* ms) {
3003 if (ms ==
nullptr || (!PyLong_Check(ms) && !PyInt_Check(ms)))
3004 return PyErr_Format(PyExc_TypeError,
"TritonContext::setSolverTimeout(): Expects an integer as argument.");
3010 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
3018 static PyObject* TritonContext_setTaintMemory(PyObject* self, PyObject* args) {
3019 PyObject* mem =
nullptr;
3020 PyObject*
flag =
nullptr;
3023 if (PyArg_ParseTuple(args,
"|OO", &mem, &flag) ==
false) {
3024 return PyErr_Format(PyExc_TypeError,
"TritonContext::setTaintMemory(): Invalid number of arguments");
3028 return PyErr_Format(PyExc_TypeError,
"TritonContext::setTaintMemory(): Expects a MemoryAccess as first argument.");
3030 if (flag ==
nullptr || !PyBool_Check(flag))
3031 return PyErr_Format(PyExc_TypeError,
"TritonContext::setTaintMemory(): Expects a boolean as second argument.");
3042 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
3047 static PyObject* TritonContext_setTaintRegister(PyObject* self, PyObject* args) {
3048 PyObject* reg =
nullptr;
3049 PyObject*
flag =
nullptr;
3052 if (PyArg_ParseTuple(args,
"|OO", ®, &flag) ==
false) {
3053 return PyErr_Format(PyExc_TypeError,
"TritonContext::setTaintRegister(): Invalid number of arguments");
3057 return PyErr_Format(PyExc_TypeError,
"TritonContext::setTaintRegister(): Expects a Register as first argument.");
3059 if (flag ==
nullptr || !PyBool_Check(flag))
3060 return PyErr_Format(PyExc_TypeError,
"TritonContext::setTaintRegister(): Expects a boolean as second argument.");
3071 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
3076 static PyObject* TritonContext_setThumb(PyObject* self, PyObject* state) {
3077 if (state ==
nullptr || !PyBool_Check(state))
3078 return PyErr_Format(PyExc_TypeError,
"TritonContext::setThumb(): Expects an boolean as argument.");
3084 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
3092 static PyObject* TritonContext_simplify(PyObject* self, PyObject* args, PyObject* kwargs) {
3093 PyObject* obj =
nullptr;
3094 PyObject* solver =
nullptr;
3095 PyObject* llvm =
nullptr;
3096 PyObject* padding =
nullptr;
3098 static char* keywords[] = {
3107 if (PyArg_ParseTupleAndKeywords(args, kwargs,
"|OOOO", keywords, &obj, &solver, &llvm, &padding) ==
false) {
3108 return PyErr_Format(PyExc_TypeError,
"TritonContext::simplify(): Invalid number of arguments");
3112 return PyErr_Format(PyExc_TypeError,
"TritonContext::simplify(): Expects a AstNode or a BasicBlock as obj argument.");
3114 if (solver !=
nullptr && !PyBool_Check(solver))
3115 return PyErr_Format(PyExc_TypeError,
"TritonContext::simplify(): Expects a boolean as solver argument.");
3117 if (llvm !=
nullptr && !PyBool_Check(llvm))
3118 return PyErr_Format(PyExc_TypeError,
"TritonContext::simplify(): Expects a boolean as llvm argument.");
3120 if (padding !=
nullptr && !PyBool_Check(padding))
3121 return PyErr_Format(PyExc_TypeError,
"TritonContext::simplify(): Expects a boolean as padding argument.");
3123 if (solver ==
nullptr)
3126 if (llvm ==
nullptr)
3129 if (padding ==
nullptr)
3140 return PyErr_Format(PyExc_TypeError,
"TritonContext::simplify(): Something wrong.");
3146 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
3151 static PyObject* TritonContext_sliceExpressions(PyObject* self, PyObject* expr) {
3152 PyObject* ret =
nullptr;
3155 return PyErr_Format(PyExc_TypeError,
"TritonContext::sliceExpressions(): Expects a SymbolicExpression as argument.");
3161 for (
auto it = exprs.begin(); it != exprs.end(); it++)
3168 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
3175 static PyObject* TritonContext_symbolizeExpression(PyObject* self, PyObject* args) {
3176 PyObject* exprId =
nullptr;
3177 PyObject* symVarSize =
nullptr;
3178 PyObject* symVarAlias =
nullptr;
3179 std::string calias =
"";
3182 if (PyArg_ParseTuple(args,
"|OOO", &exprId, &symVarSize, &symVarAlias) ==
false) {
3183 return PyErr_Format(PyExc_TypeError,
"TritonContext::symbolizeExpression(): Invalid number of arguments");
3186 if (exprId ==
nullptr || (!PyLong_Check(exprId) && !PyInt_Check(exprId)))
3187 return PyErr_Format(PyExc_TypeError,
"TritonContext::symbolizeExpression(): Expects an integer as first argument.");
3189 if (symVarSize ==
nullptr || (!PyLong_Check(symVarSize) && !PyInt_Check(symVarSize)))
3190 return PyErr_Format(PyExc_TypeError,
"TritonContext::symbolizeExpression(): Expects an integer as second argument.");
3192 if (symVarAlias !=
nullptr && !PyStr_Check(symVarAlias))
3193 return PyErr_Format(PyExc_TypeError,
"TritonContext::symbolizeExpression(): Expects a sting as third argument.");
3195 if (symVarAlias !=
nullptr)
3196 calias = PyStr_AsString(symVarAlias);
3205 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
3210 static PyObject* TritonContext_symbolizeMemory(PyObject* self, PyObject* args) {
3211 PyObject* mem =
nullptr;
3212 PyObject* symVarAlias =
nullptr;
3213 std::string calias =
"";
3216 if (PyArg_ParseTuple(args,
"|OO", &mem, &symVarAlias) ==
false) {
3217 return PyErr_Format(PyExc_TypeError,
"TritonContext::symbolizeMemory(): Invalid number of arguments");
3221 return PyErr_Format(PyExc_TypeError,
"TritonContext::symbolizeMemory(): Expects a MemoryAccess as first argument.");
3223 if (symVarAlias !=
nullptr && !PyStr_Check(symVarAlias))
3224 return PyErr_Format(PyExc_TypeError,
"TritonContext::symbolizeMemory(): Expects a sting as second argument.");
3226 if (symVarAlias !=
nullptr)
3227 calias = PyStr_AsString(symVarAlias);
3236 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
3241 static PyObject* TritonContext_symbolizeRegister(PyObject* self, PyObject* args) {
3242 PyObject* reg =
nullptr;
3243 PyObject* symVarAlias =
nullptr;
3244 std::string calias =
"";
3247 if (PyArg_ParseTuple(args,
"|OO", ®, &symVarAlias) ==
false) {
3248 return PyErr_Format(PyExc_TypeError,
"TritonContext::symbolizeRegister(): Invalid number of arguments");
3252 return PyErr_Format(PyExc_TypeError,
"TritonContext::symbolizeRegister(): Expects a Register as first argument.");
3254 if (symVarAlias !=
nullptr && !PyStr_Check(symVarAlias))
3255 return PyErr_Format(PyExc_TypeError,
"TritonContext::symbolizeRegister(): Expects a sting as second argument.");
3257 if (symVarAlias !=
nullptr)
3258 calias = PyStr_AsString(symVarAlias);
3267 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
3272 static PyObject* TritonContext_synthesize(PyObject* self, PyObject* args, PyObject* kwargs) {
3273 PyObject* node =
nullptr;
3274 PyObject* constant =
nullptr;
3275 PyObject* subexpr =
nullptr;
3276 PyObject* opaque =
nullptr;
3278 static char* keywords[] = {
3287 if (PyArg_ParseTupleAndKeywords(args, kwargs,
"|OOOO", keywords, &node, &constant, &subexpr, &opaque) ==
false) {
3288 return PyErr_Format(PyExc_TypeError,
"TritonContext::synthesize(): Invalid number of arguments");
3292 return PyErr_Format(PyExc_TypeError,
"TritonContext::synthesize(): Expects a AstNode as node argument.");
3294 if (constant !=
nullptr && !PyBool_Check(constant))
3295 return PyErr_Format(PyExc_TypeError,
"TritonContext::synthesize(): Expects a boolean as constant argument.");
3297 if (subexpr !=
nullptr && !PyBool_Check(subexpr))
3298 return PyErr_Format(PyExc_TypeError,
"TritonContext::synthesize(): Expects a boolean as subexpr argument.");
3300 if (opaque !=
nullptr && !PyBool_Check(opaque))
3301 return PyErr_Format(PyExc_TypeError,
"TritonContext::synthesize(): Expects a boolean as opaque argument.");
3303 if (constant ==
nullptr)
3306 if (subexpr ==
nullptr)
3309 if (opaque ==
nullptr)
3314 if (result.successful()) {
3326 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
3331 static PyObject* TritonContext_taintAssignment(PyObject* self, PyObject* args) {
3332 PyObject* op1 =
nullptr;
3333 PyObject* op2 =
nullptr;
3337 if (PyArg_ParseTuple(args,
"OO", &op1, &op2) ==
false) {
3338 return PyErr_Format(PyExc_TypeError,
"TritonContext::taintAssignment(): Invalid number of arguments");
3361 return PyErr_Format(PyExc_TypeError,
"TritonContext::taintAssignment(): Invalid kind of parameter.");
3372 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
3377 static PyObject* TritonContext_taintMemory(PyObject* self, PyObject* mem) {
3384 else if (PyLong_Check(mem) || PyInt_Check(mem)) {
3390 return PyErr_Format(PyExc_TypeError,
"TritonContext::taintMemory(): Expects a MemoryAccess or an integer as argument.");
3396 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
3402 static PyObject* TritonContext_taintRegister(PyObject* self, PyObject* reg) {
3404 return PyErr_Format(PyExc_TypeError,
"TritonContext::taintRegister(): Expects a Register as argument.");
3415 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
3420 static PyObject* TritonContext_taintUnion(PyObject* self, PyObject* args) {
3421 PyObject* op1 =
nullptr;
3422 PyObject* op2 =
nullptr;
3426 if (PyArg_ParseTuple(args,
"OO", &op1, &op2) ==
false) {
3427 return PyErr_Format(PyExc_TypeError,
"TritonContext::taintUnion(): Invalid number of arguments");
3450 return PyErr_Format(PyExc_TypeError,
"TritonContext::taintUnion(): Invalid kind of parameter.");
3461 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
3466 static PyObject* TritonContext_untaintMemory(PyObject* self, PyObject* mem) {
3473 else if (PyLong_Check(mem) || PyInt_Check(mem)) {
3479 return PyErr_Format(PyExc_TypeError,
"TritonContext::untaintMemory(): Expects a MemoryAccess or an integer as argument.");
3485 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
3491 static PyObject* TritonContext_untaintRegister(PyObject* self, PyObject* reg) {
3493 return PyErr_Format(PyExc_TypeError,
"TritonContext::untaintRegister(): Expects a Register as argument.");
3504 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
3509 static PyObject* TritonContext_getParentRegister(PyObject* self, PyObject* reg) {
3511 return PyErr_Format(PyExc_TypeError,
"TritonContext::getParentRegister(): Expects a Register as argument.");
3520 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
3525 static PyObject* TritonContext_getattro(PyObject* self, PyObject* name) {
3528 if (std::string(PyStr_AsString(name)) ==
"registers") {
3532 return PyErr_Format(PyExc_TypeError,
"__getattr__.registers: Architecture is not defined.");
3535 if (((TritonContext_Object*)(self))->regAttr ==
nullptr)
3536 TritonContext_fillRegistersAttribute(self);
3538 Py_INCREF(((TritonContext_Object*)(self))->regAttr);
3539 return ((TritonContext_Object*)(self))->regAttr;
3546 return PyErr_Format(PyExc_TypeError,
"%s", e.
what());
3549 return PyObject_GenericGetAttr((PyObject *)self, name);
3555 {
"addCallback", (PyCFunction)TritonContext_addCallback, METH_VARARGS,
""},
3556 {
"assignSymbolicExpressionToMemory", (PyCFunction)TritonContext_assignSymbolicExpressionToMemory, METH_VARARGS,
""},
3557 {
"assignSymbolicExpressionToRegister", (PyCFunction)TritonContext_assignSymbolicExpressionToRegister, METH_VARARGS,
""},
3558 {
"buildSemantics", (PyCFunction)TritonContext_buildSemantics, METH_O,
""},
3559 {
"clearCallbacks", (PyCFunction)TritonContext_clearCallbacks, METH_NOARGS,
""},
3560 {
"clearModes", (PyCFunction)TritonContext_clearModes, METH_NOARGS,
""},
3561 {
"clearConcreteMemoryValue", (PyCFunction)TritonContext_clearConcreteMemoryValue, METH_VARARGS,
""},
3562 {
"clearPathConstraints", (PyCFunction)TritonContext_clearPathConstraints, METH_NOARGS,
""},
3563 {
"concretizeAllMemory", (PyCFunction)TritonContext_concretizeAllMemory, METH_NOARGS,
""},
3564 {
"concretizeAllRegister", (PyCFunction)TritonContext_concretizeAllRegister, METH_NOARGS,
""},
3565 {
"concretizeMemory", (PyCFunction)TritonContext_concretizeMemory, METH_O,
""},
3566 {
"concretizeRegister", (PyCFunction)TritonContext_concretizeRegister, METH_O,
""},
3567 {
"createSymbolicMemoryExpression", (PyCFunction)TritonContext_createSymbolicMemoryExpression, METH_VARARGS,
""},
3568 {
"createSymbolicRegisterExpression", (PyCFunction)TritonContext_createSymbolicRegisterExpression, METH_VARARGS,
""},
3569 {
"createSymbolicVolatileExpression", (PyCFunction)TritonContext_createSymbolicVolatileExpression, METH_VARARGS,
""},
3570 {
"disassembly", (PyCFunction)TritonContext_disassembly, METH_VARARGS,
""},
3571 {
"evaluateAstViaSolver", (PyCFunction)TritonContext_evaluateAstViaSolver, METH_O,
""},
3572 {
"getAllRegisters", (PyCFunction)TritonContext_getAllRegisters, METH_NOARGS,
""},
3573 {
"getArchitecture", (PyCFunction)TritonContext_getArchitecture, METH_NOARGS,
""},
3574 {
"getAstContext", (PyCFunction)TritonContext_getAstContext, METH_NOARGS,
""},
3575 {
"getAstRepresentationMode", (PyCFunction)TritonContext_getAstRepresentationMode, METH_NOARGS,
""},
3576 {
"getConcreteMemoryAreaValue", (PyCFunction)(
void*)(PyCFunctionWithKeywords)TritonContext_getConcreteMemoryAreaValue, METH_VARARGS | METH_KEYWORDS,
""},
3577 {
"getConcreteMemoryValue", (PyCFunction)(
void*)(PyCFunctionWithKeywords)TritonContext_getConcreteMemoryValue, METH_VARARGS | METH_KEYWORDS,
""},
3578 {
"getConcreteRegisterValue", (PyCFunction)(
void*)(PyCFunctionWithKeywords)TritonContext_getConcreteRegisterValue, METH_VARARGS | METH_KEYWORDS,
""},
3579 {
"getConcreteVariableValue", (PyCFunction)TritonContext_getConcreteVariableValue, METH_O,
""},
3580 {
"getGprBitSize", (PyCFunction)TritonContext_getGprBitSize, METH_NOARGS,
""},
3581 {
"getGprSize", (PyCFunction)TritonContext_getGprSize, METH_NOARGS,
""},
3582 {
"getImmediateAst", (PyCFunction)TritonContext_getImmediateAst, METH_O,
""},
3583 {
"getMemoryAst", (PyCFunction)TritonContext_getMemoryAst, METH_O,
""},
3584 {
"getModel", (PyCFunction)(
void*)(PyCFunctionWithKeywords)TritonContext_getModel, METH_VARARGS | METH_KEYWORDS,
""},
3585 {
"getModels", (PyCFunction)(
void*)(PyCFunctionWithKeywords)TritonContext_getModels, METH_VARARGS | METH_KEYWORDS,
""},
3586 {
"getParentRegister", (PyCFunction)TritonContext_getParentRegister, METH_O,
""},
3587 {
"getParentRegisters", (PyCFunction)TritonContext_getParentRegisters, METH_NOARGS,
""},
3588 {
"getPathConstraints", (PyCFunction)TritonContext_getPathConstraints, METH_NOARGS,
""},
3589 {
"getPathPredicate", (PyCFunction)TritonContext_getPathPredicate, METH_NOARGS,
""},
3590 {
"getPathPredicateSize", (PyCFunction)TritonContext_getPathPredicateSize, METH_NOARGS,
""},
3591 {
"getPredicatesToReachAddress", (PyCFunction)TritonContext_getPredicatesToReachAddress, METH_O,
""},
3592 {
"getRegister", (PyCFunction)TritonContext_getRegister, METH_O,
""},
3593 {
"getRegisterAst", (PyCFunction)TritonContext_getRegisterAst, METH_O,
""},
3594 {
"getSolver", (PyCFunction)TritonContext_getSolver, METH_NOARGS,
""},
3595 {
"getSymbolicExpression", (PyCFunction)TritonContext_getSymbolicExpression, METH_O,
""},
3596 {
"getSymbolicExpressions", (PyCFunction)TritonContext_getSymbolicExpressions, METH_NOARGS,
""},
3597 {
"getSymbolicMemory", (PyCFunction)TritonContext_getSymbolicMemory, METH_VARARGS,
""},
3598 {
"getSymbolicMemoryValue", (PyCFunction)TritonContext_getSymbolicMemoryValue, METH_O,
""},
3599 {
"getSymbolicRegister", (PyCFunction)TritonContext_getSymbolicRegister, METH_O,
""},
3600 {
"getSymbolicRegisterValue", (PyCFunction)TritonContext_getSymbolicRegisterValue, METH_O,
""},
3601 {
"getSymbolicRegisters", (PyCFunction)TritonContext_getSymbolicRegisters, METH_NOARGS,
""},
3602 {
"getSymbolicVariable", (PyCFunction)TritonContext_getSymbolicVariable, METH_O,
""},
3603 {
"getSymbolicVariables", (PyCFunction)TritonContext_getSymbolicVariables, METH_NOARGS,
""},
3604 {
"getTaintedMemory", (PyCFunction)TritonContext_getTaintedMemory, METH_NOARGS,
""},
3605 {
"getTaintedRegisters", (PyCFunction)TritonContext_getTaintedRegisters, METH_NOARGS,
""},
3606 {
"getTaintedSymbolicExpressions", (PyCFunction)TritonContext_getTaintedSymbolicExpressions, METH_NOARGS,
""},
3607 {
"isArchitectureValid", (PyCFunction)TritonContext_isArchitectureValid, METH_NOARGS,
""},
3608 {
"isConcreteMemoryValueDefined", (PyCFunction)TritonContext_isConcreteMemoryValueDefined, METH_VARARGS,
""},
3609 {
"isFlag", (PyCFunction)TritonContext_isFlag, METH_O,
""},
3610 {
"isMemorySymbolized", (PyCFunction)TritonContext_isMemorySymbolized, METH_O,
""},
3611 {
"isMemoryTainted", (PyCFunction)TritonContext_isMemoryTainted, METH_O,
""},
3612 {
"isModeEnabled", (PyCFunction)TritonContext_isModeEnabled, METH_O,
""},
3613 {
"isRegister", (PyCFunction)TritonContext_isRegister, METH_O,
""},
3614 {
"isRegisterSymbolized", (PyCFunction)TritonContext_isRegisterSymbolized, METH_O,
""},
3615 {
"isRegisterTainted", (PyCFunction)TritonContext_isRegisterTainted, METH_O,
""},
3616 {
"isRegisterValid", (PyCFunction)TritonContext_isRegisterValid, METH_O,
""},
3617 {
"isSat", (PyCFunction)TritonContext_isSat, METH_O,
""},
3618 {
"isSymbolicExpressionExists", (PyCFunction)TritonContext_isSymbolicExpressionExists, METH_O,
""},
3619 {
"isThumb", (PyCFunction)TritonContext_isThumb, METH_NOARGS,
""},
3620 {
"liftToDot", (PyCFunction)TritonContext_liftToDot, METH_O,
""},
3621 {
"liftToLLVM", (PyCFunction)(
void*)(PyCFunctionWithKeywords)TritonContext_liftToLLVM, METH_VARARGS | METH_KEYWORDS,
""},
3622 {
"liftToPython", (PyCFunction)(
void*)(PyCFunctionWithKeywords)TritonContext_liftToPython, METH_VARARGS | METH_KEYWORDS,
""},
3623 {
"liftToSMT", (PyCFunction)(
void*)(PyCFunctionWithKeywords)TritonContext_liftToSMT, METH_VARARGS | METH_KEYWORDS,
""},
3624 {
"newSymbolicExpression", (PyCFunction)TritonContext_newSymbolicExpression, METH_VARARGS,
""},
3625 {
"newSymbolicVariable", (PyCFunction)TritonContext_newSymbolicVariable, METH_VARARGS,
""},
3626 {
"popPathConstraint", (PyCFunction)TritonContext_popPathConstraint, METH_NOARGS,
""},
3627 {
"processing", (PyCFunction)TritonContext_processing, METH_VARARGS,
""},
3628 {
"pushPathConstraint", (PyCFunction)(
void*)(PyCFunctionWithKeywords)TritonContext_pushPathConstraint, METH_VARARGS | METH_KEYWORDS,
""},
3629 {
"removeCallback", (PyCFunction)TritonContext_removeCallback, METH_VARARGS,
""},
3630 {
"reset", (PyCFunction)TritonContext_reset, METH_NOARGS,
""},
3631 {
"setArchitecture", (PyCFunction)TritonContext_setArchitecture, METH_O,
""},
3632 {
"setAstRepresentationMode", (PyCFunction)TritonContext_setAstRepresentationMode, METH_O,
""},
3633 {
"setConcreteMemoryAreaValue", (PyCFunction)(
void*)(PyCFunctionWithKeywords)TritonContext_setConcreteMemoryAreaValue, METH_VARARGS | METH_KEYWORDS,
""},
3634 {
"setConcreteMemoryValue", (PyCFunction)(
void*)(PyCFunctionWithKeywords)TritonContext_setConcreteMemoryValue, METH_VARARGS | METH_KEYWORDS,
""},
3635 {
"setConcreteRegisterValue", (PyCFunction)(
void*)(PyCFunctionWithKeywords)TritonContext_setConcreteRegisterValue, METH_VARARGS | METH_KEYWORDS,
""},
3636 {
"setConcreteVariableValue", (PyCFunction)TritonContext_setConcreteVariableValue, METH_VARARGS,
""},
3637 {
"setMode", (PyCFunction)TritonContext_setMode, METH_VARARGS,
""},
3638 {
"setSolver", (PyCFunction)TritonContext_setSolver, METH_O,
""},
3639 {
"setSolverMemoryLimit", (PyCFunction)TritonContext_setSolverMemoryLimit, METH_O,
""},
3640 {
"setSolverTimeout", (PyCFunction)TritonContext_setSolverTimeout, METH_O,
""},
3641 {
"setTaintMemory", (PyCFunction)TritonContext_setTaintMemory, METH_VARARGS,
""},
3642 {
"setTaintRegister", (PyCFunction)TritonContext_setTaintRegister, METH_VARARGS,
""},
3643 {
"setThumb", (PyCFunction)TritonContext_setThumb, METH_O,
""},
3644 {
"simplify", (PyCFunction)(
void*)(PyCFunctionWithKeywords)TritonContext_simplify, METH_VARARGS | METH_KEYWORDS,
""},
3645 {
"sliceExpressions", (PyCFunction)TritonContext_sliceExpressions, METH_O,
""},
3646 {
"symbolizeExpression", (PyCFunction)TritonContext_symbolizeExpression, METH_VARARGS,
""},
3647 {
"symbolizeMemory", (PyCFunction)TritonContext_symbolizeMemory, METH_VARARGS,
""},
3648 {
"symbolizeRegister", (PyCFunction)TritonContext_symbolizeRegister, METH_VARARGS,
""},
3649 {
"synthesize", (PyCFunction)(
void*)(PyCFunctionWithKeywords)TritonContext_synthesize, METH_VARARGS | METH_KEYWORDS,
""},
3650 {
"taintAssignment", (PyCFunction)TritonContext_taintAssignment, METH_VARARGS,
""},
3651 {
"taintMemory", (PyCFunction)TritonContext_taintMemory, METH_O,
""},
3652 {
"taintRegister", (PyCFunction)TritonContext_taintRegister, METH_O,
""},
3653 {
"taintUnion", (PyCFunction)TritonContext_taintUnion, METH_VARARGS,
""},
3654 {
"untaintMemory", (PyCFunction)TritonContext_untaintMemory, METH_O,
""},
3655 {
"untaintRegister", (PyCFunction)TritonContext_untaintRegister, METH_O,
""},
3656 {
nullptr,
nullptr, 0,
nullptr}
3662 PyVarObject_HEAD_INIT(&PyType_Type, 0)
3666 (destructor)TritonContext_dealloc,
3678 (getattrofunc)TritonContext_getattro,
3682 "TritonContext objects",
3727 if (
object !=
nullptr) {
3729 object->ref =
false;
3730 object->regAttr =
nullptr;
3733 return (PyObject*)object;
3741 if (
object !=
nullptr) {
3743 object->ref =
false;
3744 object->regAttr =
nullptr;
3747 return (PyObject*)object;
3755 if (
object !=
nullptr) {
3758 object->regAttr =
nullptr;
3761 return (PyObject*)object;
This is the main Triton Context class.
This class is used to represent an instruction.
This class is used to represent a memory access.
This class is used when an instruction has a register operand.
The exception class used by callbacks.
The root class of all exceptions.
TRITON_EXPORT const char * what() const
Returns the exception message.
register_e
Types of register.
std::shared_ptr< triton::ast::AbstractNode > SharedAbstractNode
Shared Abstract Node.
constexpr triton::uint32 flag
flag size in bit
ComparableFunctor< void(triton::Context &, const triton::arch::Register &)> getConcreteRegisterValueCallback
The prototype of a GET_CONCRETE_REGISTER_VALUE callback.
ComparableFunctor< triton::ast::SharedAbstractNode(triton::Context &, const triton::ast::SharedAbstractNode &)> symbolicSimplificationCallback
The prototype of a SYMBOLIC_SIMPLIFICATION callback.
ComparableFunctor< void(triton::Context &, const triton::arch::Register &, const triton::uint512 &value)> setConcreteRegisterValueCallback
The prototype of a SET_CONCRETE_REGISTER_VALUE callback.
ComparableFunctor< void(triton::Context &, const triton::arch::MemoryAccess &, const triton::uint512 &value)> setConcreteMemoryValueCallback
The prototype of a SET_CONCRETE_MEMORY_VALUE callback.
ComparableFunctor< void(triton::Context &, const triton::arch::MemoryAccess &)> getConcreteMemoryValueCallback
The prototype of a GET_CONCRETE_MEMORY_VALUE callback.
@ SYMBOLIC_SIMPLIFICATION
@ GET_CONCRETE_REGISTER_VALUE
@ GET_CONCRETE_MEMORY_VALUE
@ SET_CONCRETE_MEMORY_VALUE
@ SET_CONCRETE_REGISTER_VALUE
mode_e
Enumerates all kinds of mode.
PyObject * PyTritonContextRef(triton::Context &ctx)
Creates a TritonContext python class which is a reference to another Context.
PyObject * xPyClass_New(PyObject *b, PyObject *d, PyObject *n)
Creates a PyClass and raises an exception if it fails. dict is copied in Py3 ! All references are dec...
PyObject * PyPathConstraint(const triton::engines::symbolic::PathConstraint &pc)
Creates the PathConstraint python class.
PyObject * PySymbolicVariable(const triton::engines::symbolic::SharedSymbolicVariable &symVar)
Creates the SymbolicVariable python class.
PyObject * PySolverModel(const triton::engines::solver::SolverModel &model)
Creates the SolverModel python class.
triton::uint64 PyLong_AsUint64(PyObject *vv)
Returns a triton::uint64 from a pyObject.
PyObject * PyLong_FromUsize(triton::usize value)
Returns a pyObject from a triton::usize.
PyObject * xPyTuple_New(Py_ssize_t len)
Creates a PyTuple and raises an exception if it fails.
PyObject * xPyString_FromString(const char *v)
Creates a PyString and raises an exception if it fails.
bool PyLong_AsBool(PyObject *obj)
Returns a bool from a pyObject.
PyObject * PyLong_FromUint512(triton::uint512 value)
Returns a pyObject from a triton::uint512.
triton::uint512 PyLong_AsUint512(PyObject *vv)
Returns a triton::uint512 from a pyObject.
PyObject * PyAstContext(const triton::ast::SharedAstContext &actx)
Creates an AstContext python class.
PyObject * PyBasicBlock(void)
Creates the BasicBlock python class.
PyObject * PyInstruction(void)
Creates the Instruction python class.
PyObject * xPyList_New(Py_ssize_t len)
Creates a PyList and raises an exception if it fails.
int xPyDict_SetItem(PyObject *p, PyObject *key, PyObject *val)
Same as PyDict_SetItem but decrements reference on object and key.
PyObject * PyLong_FromUint64(triton::uint64 value)
Returns a pyObject from a triton::uint64.
PyObject * PyRegister(const triton::arch::Register ®)
Creates the Register python class.
PyObject * PyTritonContext(void)
Creates the new TritonContext python class.
triton::uint32 PyLong_AsUint32(PyObject *vv)
Returns a triton::uint32 from a pyObject.
triton::usize PyLong_AsUsize(PyObject *vv)
Returns a triton::usize from a pyObject.
PyObject * PySymbolicExpression(const triton::engines::symbolic::SharedSymbolicExpression &symExpr)
Creates the SymbolicExpression python class.
PyObject * PyMemoryAccess(const triton::arch::MemoryAccess &mem)
Creates the Memory python class.
PyObject * xPyDict_New(void)
Creates a PyDict and raises an exception if it fails.
PyObject * PyLong_FromUint32(triton::uint32 value)
Returns a pyObject from a triton::uint32.
PyObject * PyAstNode(const triton::ast::SharedAbstractNode &node)
Creates the AstNode python class.
mode_e
All types of representation mode.
std::shared_ptr< triton::engines::symbolic::SymbolicExpression > SharedSymbolicExpression
Shared Symbolic Expression.
std::size_t usize
unsigned MAX_INT 32 or 64 bits according to the CPU.
std::uint64_t uint64
unisgned 64-bits
std::uint32_t uint32
unisgned 32-bits
std::uint8_t uint8
unisgned 8-bits
PyTypeObject TritonContext_Type
Description of the python representation of a TritonContext.
PyMethodDef TritonContext_callbacks[]
TritonContext methods.
#define PySymbolicVariable_Check(v)
#define PyImmediate_Check(v)
#define PyRegister_AsRegister(v)
#define PyMemoryAccess_Check(v)
#define PyTritonContext_AsTritonContext(v)
#define PyInstruction_AsInstruction(v)
#define PyImmediate_AsImmediate(v)
#define PyInstruction_Check(v)
#define PyAstNode_Check(v)
#define PyMemoryAccess_AsMemoryAccess(v)
#define PyBasicBlock_AsBasicBlock(v)
#define PyRegister_Check(v)
#define PyBasicBlock_Check(v)
#define PySymbolicExpression_Check(v)
#define PySymbolicVariable_AsSymbolicVariable(v)
#define PyAstNode_AsAstNode(v)
#define PySymbolicExpression_AsSymbolicExpression(v)