static PyObject *Triton_getMemValue(PyObject *self, PyObject *args) { PyObject *addr; PyObject *readSize; uint64 ad; uint64 rs; /* Extract arguments */ PyArg_ParseTuple(args, "O|O", &addr, &readSize); if (!ap.getCurrentCtxH()) return PyErr_Format(PyExc_TypeError, "getMemValue(): Can't call getMemValue() right now. You must run the program before."); if (!PyLong_Check(addr) && !PyInt_Check(addr)) return PyErr_Format(PyExc_TypeError, "getMemValue(): expected an address (integer) as argument"); ad = PyLong_AsLong(addr); rs = PyLong_AsLong(readSize); if (rs != DQWORD_SIZE && rs != QWORD_SIZE && rs != DWORD_SIZE && rs != WORD_SIZE && rs != BYTE_SIZE) return PyErr_Format(PyExc_TypeError, "getMemValue(): The readSize argument must be: DQWORD, QWORD, DWORD, WORD or BYTE"); if (PIN_CheckReadAccess(reinterpret_cast<void*>(ad)) == false) return PyErr_Format(PyExc_TypeError, "getMemValue(): The targeted address memory can not be read"); /* If this is a 128-bits read size, we must use uint128ToPyLongObject() */ if (rs == DQWORD_SIZE){ uint128 value = ap.getMemValue(ad, rs); return uint128ToPyLongObject(value); } return Py_BuildValue("k", ap.getMemValue(ad, rs)); }