libTriton version 1.0 build 1592
Loading...
Searching...
No Matches
pyInstruction.cpp
Go to the documentation of this file.
1
2/*
3** Copyright (C) - Triton
4**
5** This program is under the terms of the Apache License 2.0.
6*/
7
11#include <triton/coreUtils.hpp>
12#include <triton/exceptions.hpp>
14
15#include <iostream>
16
17
18
242namespace triton {
243 namespace bindings {
244 namespace python {
245
247 void Instruction_dealloc(PyObject* self) {
248 std::cout << std::flush;
249 delete PyInstruction_AsInstruction(self);
250 Py_TYPE(self)->tp_free((PyObject*)self);
251 }
252
253
254 static PyObject* Instruction_getAddress(PyObject* self, PyObject* noarg) {
255 try {
256 return PyLong_FromUint64(PyInstruction_AsInstruction(self)->getAddress());
257 }
258 catch (const triton::exceptions::Exception& e) {
259 return PyErr_Format(PyExc_TypeError, "%s", e.what());
260 }
261 }
262
263
264 static PyObject* Instruction_getCodeCondition(PyObject* self, PyObject* noarg) {
265 try {
266 return PyLong_FromUint32(PyInstruction_AsInstruction(self)->getCodeCondition());
267 }
268 catch (const triton::exceptions::Exception& e) {
269 return PyErr_Format(PyExc_TypeError, "%s", e.what());
270 }
271 }
272
273
274 static PyObject* Instruction_getDisassembly(PyObject* self, PyObject* noarg) {
275 try {
276 if (!PyInstruction_AsInstruction(self)->getDisassembly().empty())
277 return PyStr_FromFormat("%s", PyInstruction_AsInstruction(self)->getDisassembly().c_str());
278 Py_INCREF(Py_None);
279 return Py_None;
280 }
281 catch (const triton::exceptions::Exception& e) {
282 return PyErr_Format(PyExc_TypeError, "%s", e.what());
283 }
284 }
285
286
287 static PyObject* Instruction_getLoadAccess(PyObject* self, PyObject* noarg) {
288 try {
289 PyObject* ret;
290 triton::uint32 index = 0;
291 const auto& loadAccess = PyInstruction_AsInstruction(self)->getLoadAccess();
292
293 ret = xPyList_New(loadAccess.size());
294 for (auto it = loadAccess.cbegin(); it != loadAccess.cend(); it++) {
295 PyObject* item = xPyTuple_New(2);
296 PyTuple_SetItem(item, 0, PyMemoryAccess(std::get<0>(*it)));
297 PyTuple_SetItem(item, 1, PyAstNode(std::get<1>(*it)));
298 PyList_SetItem(ret, index++, item);
299 }
300
301 return ret;
302 }
303 catch (const triton::exceptions::Exception& e) {
304 return PyErr_Format(PyExc_TypeError, "%s", e.what());
305 }
306 }
307
308
309 static PyObject* Instruction_getNextAddress(PyObject* self, PyObject* noarg) {
310 try {
311 return PyLong_FromUint64(PyInstruction_AsInstruction(self)->getNextAddress());
312 }
313 catch (const triton::exceptions::Exception& e) {
314 return PyErr_Format(PyExc_TypeError, "%s", e.what());
315 }
316 }
317
318
319 static PyObject* Instruction_getOpcode(PyObject* self, PyObject* noarg) {
320 try {
321 const triton::uint8* opcode = PyInstruction_AsInstruction(self)->getOpcode();
322 triton::uint32 size = PyInstruction_AsInstruction(self)->getSize();
323 return PyBytes_FromStringAndSize(reinterpret_cast<const char*>(opcode), size);
324 }
325 catch (const triton::exceptions::Exception& e) {
326 return PyErr_Format(PyExc_TypeError, "%s", e.what());
327 }
328 }
329
330
331 static PyObject* Instruction_getSize(PyObject* self, PyObject* noarg) {
332 try {
333 return PyLong_FromUint32(PyInstruction_AsInstruction(self)->getSize());
334 }
335 catch (const triton::exceptions::Exception& e) {
336 return PyErr_Format(PyExc_TypeError, "%s", e.what());
337 }
338 }
339
340
341 static PyObject* Instruction_getStoreAccess(PyObject* self, PyObject* noarg) {
342 try {
343 PyObject* ret;
344 triton::uint32 index = 0;
345 const auto& storeAccess = PyInstruction_AsInstruction(self)->getStoreAccess();
346
347 ret = xPyList_New(storeAccess.size());
348 for (auto it = storeAccess.cbegin(); it != storeAccess.cend(); it++) {
349 PyObject* item = xPyTuple_New(2);
350 PyTuple_SetItem(item, 0, PyMemoryAccess(std::get<0>(*it)));
351 PyTuple_SetItem(item, 1, PyAstNode(std::get<1>(*it)));
352 PyList_SetItem(ret, index++, item);
353 }
354
355 return ret;
356 }
357 catch (const triton::exceptions::Exception& e) {
358 return PyErr_Format(PyExc_TypeError, "%s", e.what());
359 }
360 }
361
362
363 static PyObject* Instruction_getOperands(PyObject* self, PyObject* noarg) {
364 try {
366 triton::usize opSize;
367 PyObject* operands;
368
369 inst = PyInstruction_AsInstruction(self);
370 opSize = inst->operands.size();
371 operands = xPyList_New(opSize);
372
373 for (triton::usize index = 0; index < opSize; index++) {
374 PyObject* obj = nullptr;
375
376 if (inst->operands[index].getType() == triton::arch::OP_IMM) {
377 const triton::arch::Immediate& imm = inst->operands[index].getConstImmediate();
378 obj = PyImmediate(imm);
379 }
380 else if (inst->operands[index].getType() == triton::arch::OP_MEM) {
381 const triton::arch::MemoryAccess& mem = inst->operands[index].getConstMemory();
382 obj = PyMemoryAccess(mem);
383 }
384 else if (inst->operands[index].getType() == triton::arch::OP_REG) {
385 const triton::arch::Register& reg = inst->operands[index].getConstRegister();
386 obj = PyRegister(reg);
387 }
388 else
389 continue;
390
391 PyList_SetItem(operands, index, obj);
392 }
393
394 return operands;
395 }
396 catch (const triton::exceptions::Exception& e) {
397 return PyErr_Format(PyExc_TypeError, "%s", e.what());
398 }
399 }
400
401
402 static PyObject* Instruction_getPrefix(PyObject* self, PyObject* noarg) {
403 try {
404 return PyLong_FromUint32(PyInstruction_AsInstruction(self)->getPrefix());
405 }
406 catch (const triton::exceptions::Exception& e) {
407 return PyErr_Format(PyExc_TypeError, "%s", e.what());
408 }
409 }
410
411
412 static PyObject* Instruction_getReadImmediates(PyObject* self, PyObject* noarg) {
413 try {
414 PyObject* ret;
415 triton::uint32 index = 0;
416 const auto& readImmediates = PyInstruction_AsInstruction(self)->getReadImmediates();
417
418 ret = xPyList_New(readImmediates.size());
419 for (auto it = readImmediates.cbegin(); it != readImmediates.cend(); it++) {
420 PyObject* item = xPyTuple_New(2);
421 PyTuple_SetItem(item, 0, PyImmediate(std::get<0>(*it)));
422 PyTuple_SetItem(item, 1, PyAstNode(std::get<1>(*it)));
423 PyList_SetItem(ret, index++, item);
424 }
425
426 return ret;
427 }
428 catch (const triton::exceptions::Exception& e) {
429 return PyErr_Format(PyExc_TypeError, "%s", e.what());
430 }
431 }
432
433
434 static PyObject* Instruction_getReadRegisters(PyObject* self, PyObject* noarg) {
435 try {
436 PyObject* ret;
437 triton::uint32 index = 0;
438 const auto& readRegisters = PyInstruction_AsInstruction(self)->getReadRegisters();
439
440 ret = xPyList_New(readRegisters.size());
441 for (auto it = readRegisters.cbegin(); it != readRegisters.cend(); it++) {
442 PyObject* item = xPyTuple_New(2);
443 PyTuple_SetItem(item, 0, PyRegister(std::get<0>(*it)));
444 PyTuple_SetItem(item, 1, PyAstNode(std::get<1>(*it)));
445 PyList_SetItem(ret, index++, item);
446 }
447
448 return ret;
449 }
450 catch (const triton::exceptions::Exception& e) {
451 return PyErr_Format(PyExc_TypeError, "%s", e.what());
452 }
453 }
454
455
456 static PyObject* Instruction_getSymbolicExpressions(PyObject* self, PyObject* noarg) {
457 try {
459 triton::usize exprSize;
460 PyObject* symExprs;
461
462 inst = PyInstruction_AsInstruction(self);
463 exprSize = inst->symbolicExpressions.size();
464 symExprs = xPyList_New(exprSize);
465
466 for (triton::usize index = 0; index < exprSize; index++) {
467 PyObject* obj = PySymbolicExpression(inst->symbolicExpressions[index]);
468 PyList_SetItem(symExprs, index, obj);
469 }
470
471 return symExprs;
472 }
473 catch (const triton::exceptions::Exception& e) {
474 return PyErr_Format(PyExc_TypeError, "%s", e.what());
475 }
476 }
477
478
479 static PyObject* Instruction_getThreadId(PyObject* self, PyObject* noarg) {
480 try {
481 return PyLong_FromUint32(PyInstruction_AsInstruction(self)->getThreadId());
482 }
483 catch (const triton::exceptions::Exception& e) {
484 return PyErr_Format(PyExc_TypeError, "%s", e.what());
485 }
486 }
487
488
489 static PyObject* Instruction_getType(PyObject* self, PyObject* noarg) {
490 try {
491 return PyLong_FromUint32(PyInstruction_AsInstruction(self)->getType());
492 }
493 catch (const triton::exceptions::Exception& e) {
494 return PyErr_Format(PyExc_TypeError, "%s", e.what());
495 }
496 }
497
498
499 static PyObject* Instruction_getUndefinedRegisters(PyObject* self, PyObject* noarg) {
500 try {
501 PyObject* ret;
502 triton::uint32 index = 0;
503 const auto& undefinedRegisters = PyInstruction_AsInstruction(self)->getUndefinedRegisters();
504
505 ret = xPyList_New(undefinedRegisters.size());
506 for (auto it = undefinedRegisters.cbegin(); it != undefinedRegisters.cend(); it++) {
507 PyList_SetItem(ret, index++, PyRegister(*it));
508 }
509
510 return ret;
511 }
512 catch (const triton::exceptions::Exception& e) {
513 return PyErr_Format(PyExc_TypeError, "%s", e.what());
514 }
515 }
516
517
518 static PyObject* Instruction_getWrittenRegisters(PyObject* self, PyObject* noarg) {
519 try {
520 PyObject* ret;
521 triton::uint32 index = 0;
522 const auto& writtenRegisters = PyInstruction_AsInstruction(self)->getWrittenRegisters();
523
524 ret = xPyList_New(writtenRegisters.size());
525 for (auto it = writtenRegisters.cbegin(); it != writtenRegisters.cend(); it++) {
526 PyObject* item = xPyTuple_New(2);
527 PyTuple_SetItem(item, 0, PyRegister(std::get<0>(*it)));
528 PyTuple_SetItem(item, 1, PyAstNode(std::get<1>(*it)));
529 PyList_SetItem(ret, index++, item);
530 }
531
532 return ret;
533 }
534 catch (const triton::exceptions::Exception& e) {
535 return PyErr_Format(PyExc_TypeError, "%s", e.what());
536 }
537 }
538
539
540 static PyObject* Instruction_isBranch(PyObject* self, PyObject* noarg) {
541 try {
542 if (PyInstruction_AsInstruction(self)->isBranch() == true)
543 Py_RETURN_TRUE;
544 Py_RETURN_FALSE;
545 }
546 catch (const triton::exceptions::Exception& e) {
547 return PyErr_Format(PyExc_TypeError, "%s", e.what());
548 }
549 }
550
551
552 static PyObject* Instruction_isConditionTaken(PyObject* self, PyObject* noarg) {
553 try {
554 if (PyInstruction_AsInstruction(self)->isConditionTaken() == true)
555 Py_RETURN_TRUE;
556 Py_RETURN_FALSE;
557 }
558 catch (const triton::exceptions::Exception& e) {
559 return PyErr_Format(PyExc_TypeError, "%s", e.what());
560 }
561 }
562
563
564 static PyObject* Instruction_isControlFlow(PyObject* self, PyObject* noarg) {
565 try {
566 if (PyInstruction_AsInstruction(self)->isControlFlow() == true)
567 Py_RETURN_TRUE;
568 Py_RETURN_FALSE;
569 }
570 catch (const triton::exceptions::Exception& e) {
571 return PyErr_Format(PyExc_TypeError, "%s", e.what());
572 }
573 }
574
575
576 static PyObject* Instruction_isMemoryRead(PyObject* self, PyObject* noarg) {
577 try {
578 if (PyInstruction_AsInstruction(self)->isMemoryRead() == true)
579 Py_RETURN_TRUE;
580 Py_RETURN_FALSE;
581 }
582 catch (const triton::exceptions::Exception& e) {
583 return PyErr_Format(PyExc_TypeError, "%s", e.what());
584 }
585 }
586
587
588 static PyObject* Instruction_isMemoryWrite(PyObject* self, PyObject* noarg) {
589 try {
590 if (PyInstruction_AsInstruction(self)->isMemoryWrite() == true)
591 Py_RETURN_TRUE;
592 Py_RETURN_FALSE;
593 }
594 catch (const triton::exceptions::Exception& e) {
595 return PyErr_Format(PyExc_TypeError, "%s", e.what());
596 }
597 }
598
599
600 static PyObject* Instruction_isPrefixed(PyObject* self, PyObject* noarg) {
601 try {
602 if (PyInstruction_AsInstruction(self)->isPrefixed() == true)
603 Py_RETURN_TRUE;
604 Py_RETURN_FALSE;
605 }
606 catch (const triton::exceptions::Exception& e) {
607 return PyErr_Format(PyExc_TypeError, "%s", e.what());
608 }
609 }
610
611
612 static PyObject* Instruction_isSymbolized(PyObject* self, PyObject* noarg) {
613 try {
614 if (PyInstruction_AsInstruction(self)->isSymbolized() == true)
615 Py_RETURN_TRUE;
616 Py_RETURN_FALSE;
617 }
618 catch (const triton::exceptions::Exception& e) {
619 return PyErr_Format(PyExc_TypeError, "%s", e.what());
620 }
621 }
622
623
624 static PyObject* Instruction_isTainted(PyObject* self, PyObject* noarg) {
625 try {
626 if (PyInstruction_AsInstruction(self)->isTainted() == true)
627 Py_RETURN_TRUE;
628 Py_RETURN_FALSE;
629 }
630 catch (const triton::exceptions::Exception& e) {
631 return PyErr_Format(PyExc_TypeError, "%s", e.what());
632 }
633 }
634
635
636 static PyObject* Instruction_isWriteBack(PyObject* self, PyObject* noarg) {
637 try {
638 if (PyInstruction_AsInstruction(self)->isWriteBack() == true)
639 Py_RETURN_TRUE;
640 Py_RETURN_FALSE;
641 }
642 catch (const triton::exceptions::Exception& e) {
643 return PyErr_Format(PyExc_TypeError, "%s", e.what());
644 }
645 }
646
647
648 static PyObject* Instruction_isUpdateFlag(PyObject* self, PyObject* noarg) {
649 try {
650 if (PyInstruction_AsInstruction(self)->isUpdateFlag() == true)
651 Py_RETURN_TRUE;
652 Py_RETURN_FALSE;
653 }
654 catch (const triton::exceptions::Exception& e) {
655 return PyErr_Format(PyExc_TypeError, "%s", e.what());
656 }
657 }
658
659
660 static PyObject* Instruction_isThumb(PyObject* self, PyObject* noarg) {
661 try {
662 if (PyInstruction_AsInstruction(self)->isThumb() == true)
663 Py_RETURN_TRUE;
664 Py_RETURN_FALSE;
665 }
666 catch (const triton::exceptions::Exception& e) {
667 return PyErr_Format(PyExc_TypeError, "%s", e.what());
668 }
669 }
670
671
672 static PyObject* Instruction_setAddress(PyObject* self, PyObject* addr) {
673 try {
674 if (!PyLong_Check(addr) && !PyInt_Check(addr))
675 return PyErr_Format(PyExc_TypeError, "Instruction::setAddress(): Expected an integer as argument.");
676 PyInstruction_AsInstruction(self)->setAddress(PyLong_AsUint64(addr));
677 Py_INCREF(Py_None);
678 return Py_None;
679 }
680 catch (const triton::exceptions::Exception& e) {
681 return PyErr_Format(PyExc_TypeError, "%s", e.what());
682 }
683 }
684
685
686 static PyObject* Instruction_setOpcode(PyObject* self, PyObject* opc) {
687 try {
688 if (!PyBytes_Check(opc))
689 return PyErr_Format(PyExc_TypeError, "Instruction::setOpcode(): Expected bytes as argument.");
690
691 triton::uint8* opcode = reinterpret_cast<triton::uint8*>(PyBytes_AsString(opc));
692 triton::uint32 size = static_cast<triton::uint32>(PyBytes_Size(opc));
693
694 PyInstruction_AsInstruction(self)->setOpcode(opcode, size);
695 Py_INCREF(Py_None);
696 return Py_None;
697 }
698 catch (const triton::exceptions::Exception& e) {
699 return PyErr_Format(PyExc_TypeError, "%s", e.what());
700 }
701 }
702
703
704 static PyObject* Instruction_setThreadId(PyObject* self, PyObject* tid) {
705 try {
706 if (!PyLong_Check(tid) && !PyInt_Check(tid))
707 return PyErr_Format(PyExc_TypeError, "Instruction::setThreadId(): Expected an integer as argument.");
708
709 PyInstruction_AsInstruction(self)->setThreadId(PyLong_AsUint32(tid));
710 Py_INCREF(Py_None);
711 return Py_None;
712 }
713 catch (const triton::exceptions::Exception& e) {
714 return PyErr_Format(PyExc_TypeError, "%s", e.what());
715 }
716 }
717
718
719 #if !defined(IS_PY3_8) || !IS_PY3_8
720 static int Instruction_print(PyObject* self, void* io, int s) {
721 std::cout << PyInstruction_AsInstruction(self);
722 return 0;
723 }
724 #endif
725
726
727 static PyObject* Instruction_str(PyObject* self) {
728 try {
729 return PyStr_FromFormat("%s", triton::utils::toString(PyInstruction_AsInstruction(self)).c_str());
730 }
731 catch (const triton::exceptions::Exception& e) {
732 return PyErr_Format(PyExc_TypeError, "%s", e.what());
733 }
734 }
735
736
738 PyMethodDef Instruction_callbacks[] = {
739 {"getAddress", Instruction_getAddress, METH_NOARGS, ""},
740 {"getCodeCondition", Instruction_getCodeCondition, METH_NOARGS, ""},
741 {"getDisassembly", Instruction_getDisassembly, METH_NOARGS, ""},
742 {"getLoadAccess", Instruction_getLoadAccess, METH_NOARGS, ""},
743 {"getNextAddress", Instruction_getNextAddress, METH_NOARGS, ""},
744 {"getOpcode", Instruction_getOpcode, METH_NOARGS, ""},
745 {"getOperands", Instruction_getOperands, METH_NOARGS, ""},
746 {"getPrefix", Instruction_getPrefix, METH_NOARGS, ""},
747 {"getReadImmediates", Instruction_getReadImmediates, METH_NOARGS, ""},
748 {"getReadRegisters", Instruction_getReadRegisters, METH_NOARGS, ""},
749 {"getSize", Instruction_getSize, METH_NOARGS, ""},
750 {"getStoreAccess", Instruction_getStoreAccess, METH_NOARGS, ""},
751 {"getSymbolicExpressions", Instruction_getSymbolicExpressions, METH_NOARGS, ""},
752 {"getThreadId", Instruction_getThreadId, METH_NOARGS, ""},
753 {"getType", Instruction_getType, METH_NOARGS, ""},
754 {"getUndefinedRegisters", Instruction_getUndefinedRegisters, METH_NOARGS, ""},
755 {"getWrittenRegisters", Instruction_getWrittenRegisters, METH_NOARGS, ""},
756 {"isBranch", Instruction_isBranch, METH_NOARGS, ""},
757 {"isConditionTaken", Instruction_isConditionTaken, METH_NOARGS, ""},
758 {"isControlFlow", Instruction_isControlFlow, METH_NOARGS, ""},
759 {"isMemoryRead", Instruction_isMemoryRead, METH_NOARGS, ""},
760 {"isMemoryWrite", Instruction_isMemoryWrite, METH_NOARGS, ""},
761 {"isPrefixed", Instruction_isPrefixed, METH_NOARGS, ""},
762 {"isSymbolized", Instruction_isSymbolized, METH_NOARGS, ""},
763 {"isTainted", Instruction_isTainted, METH_NOARGS, ""},
764 {"isWriteBack", Instruction_isWriteBack, METH_NOARGS, ""},
765 {"isUpdateFlag", Instruction_isUpdateFlag, METH_NOARGS, ""},
766 {"isThumb", Instruction_isThumb, METH_NOARGS, ""},
767 {"setAddress", Instruction_setAddress, METH_O, ""},
768 {"setOpcode", Instruction_setOpcode, METH_O, ""},
769 {"setThreadId", Instruction_setThreadId, METH_O, ""},
770 {nullptr, nullptr, 0, nullptr}
771 };
772
773
774 PyTypeObject Instruction_Type = {
775 PyVarObject_HEAD_INIT(&PyType_Type, 0)
776 "Instruction", /* tp_name */
777 sizeof(Instruction_Object), /* tp_basicsize */
778 0, /* tp_itemsize */
779 (destructor)Instruction_dealloc, /* tp_dealloc */
780 #if IS_PY3_8
781 0, /* tp_vectorcall_offset */
782 #else
783 (printfunc)Instruction_print, /* tp_print */
784 #endif
785 0, /* tp_getattr */
786 0, /* tp_setattr */
787 0, /* tp_compare */
788 (reprfunc)Instruction_str, /* tp_repr */
789 0, /* tp_as_number */
790 0, /* tp_as_sequence */
791 0, /* tp_as_mapping */
792 0, /* tp_hash */
793 0, /* tp_call */
794 (reprfunc)Instruction_str, /* tp_str */
795 0, /* tp_getattro */
796 0, /* tp_setattro */
797 0, /* tp_as_buffer */
798 Py_TPFLAGS_DEFAULT, /* tp_flags */
799 "Instruction objects", /* tp_doc */
800 0, /* tp_traverse */
801 0, /* tp_clear */
802 0, /* tp_richcompare */
803 0, /* tp_weaklistoffset */
804 0, /* tp_iter */
805 0, /* tp_iternext */
806 Instruction_callbacks, /* tp_methods */
807 0, /* tp_members */
808 0, /* tp_getset */
809 0, /* tp_base */
810 0, /* tp_dict */
811 0, /* tp_descr_get */
812 0, /* tp_descr_set */
813 0, /* tp_dictoffset */
814 0, /* tp_init */
815 0, /* tp_alloc */
816 0, /* tp_new */
817 0, /* tp_free */
818 0, /* tp_is_gc */
819 0, /* tp_bases */
820 0, /* tp_mro */
821 0, /* tp_cache */
822 0, /* tp_subclasses */
823 0, /* tp_weaklist */
824 0, /* tp_del */
825 #if IS_PY3
826 0, /* tp_version_tag */
827 0, /* tp_finalize */
828 #if IS_PY3_8
829 0, /* tp_vectorcall */
830 #if !IS_PY3_9
831 0, /* bpo-37250: kept for backwards compatibility in CPython 3.8 only */
832 #endif
833 #endif
834 #else
835 0 /* tp_version_tag */
836 #endif
837 };
838
839
840 PyObject* PyInstruction(void) {
841 Instruction_Object* object;
842
843 PyType_Ready(&Instruction_Type);
844 object = PyObject_NEW(Instruction_Object, &Instruction_Type);
845 if (object != NULL)
846 object->inst = new triton::arch::Instruction();
847
848 return (PyObject*)object;
849 }
850
851
853 Instruction_Object* object;
854
855 PyType_Ready(&Instruction_Type);
856 object = PyObject_NEW(Instruction_Object, &Instruction_Type);
857 if (object != NULL)
858 object->inst = new triton::arch::Instruction(inst);
859
860 return (PyObject*)object;
861 }
862
863
864 PyObject* PyInstruction(const void* opcode, triton::uint32 opSize) {
865 Instruction_Object* object;
866
867 PyType_Ready(&Instruction_Type);
868 object = PyObject_NEW(Instruction_Object, &Instruction_Type);
869 if (object != NULL)
870 object->inst = new triton::arch::Instruction(opcode, opSize);
871
872 return (PyObject*)object;
873 }
874
875
876 PyObject* PyInstruction(triton::uint64 addr, const void* opcode, triton::uint32 opSize) {
877 Instruction_Object* object;
878
879 PyType_Ready(&Instruction_Type);
880 object = PyObject_NEW(Instruction_Object, &Instruction_Type);
881 if (object != NULL)
882 object->inst = new triton::arch::Instruction(addr, opcode, opSize);
883
884 return (PyObject*)object;
885 }
886
887 }; /* python namespace */
888 }; /* bindings namespace */
889}; /* triton namespace */
This class is used to represent an immediate.
Definition immediate.hpp:37
This class is used to represent an instruction.
std::vector< triton::arch::OperandWrapper > operands
A list of operands.
std::vector< triton::engines::symbolic::SharedSymbolicExpression > symbolicExpressions
The semantics set of the instruction.
This class is used to represent a memory access.
This class is used when an instruction has a register operand.
Definition register.hpp:44
The root class of all exceptions.
TRITON_EXPORT const char * what() const
Returns the exception message.
triton::uint64 PyLong_AsUint64(PyObject *vv)
Returns a triton::uint64 from a pyObject.
Definition utils.cpp:137
PyObject * PyImmediate(const triton::arch::Immediate &imm)
Creates the Immediate python class.
PyObject * xPyTuple_New(Py_ssize_t len)
Creates a PyTuple and raises an exception if it fails.
PyTypeObject Instruction_Type
pyInstruction type.
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.
PyObject * PyLong_FromUint64(triton::uint64 value)
Returns a pyObject from a triton::uint64.
Definition utils.cpp:328
PyObject * PyRegister(const triton::arch::Register &reg)
Creates the Register python class.
triton::uint32 PyLong_AsUint32(PyObject *vv)
Returns a triton::uint32 from a pyObject.
Definition utils.cpp:108
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 * PyLong_FromUint32(triton::uint32 value)
Returns a pyObject from a triton::uint32.
Definition utils.cpp:322
PyObject * PyAstNode(const triton::ast::SharedAbstractNode &node)
Creates the AstNode python class.
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
std::string toString(const T &obj)
Converts an object to a string.
Definition coreUtils.hpp:38
PyMethodDef Instruction_callbacks[]
Instruction methods.
void Instruction_dealloc(PyObject *self)
Instruction destructor.
The Triton namespace.
#define PyInstruction_AsInstruction(v)