summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/arch/module.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-03-26 10:53:53 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-03-26 10:53:53 (GMT)
commit4319c0ae542b60f225d0f6ce373fe8d2e5f1475d (patch)
tree2fb50b16c5a3d0120ffba1ab6270dcd603797e94 /plugins/pychrysa/arch/module.c
parenta2f149e5d151dcd937351f6e54229e508123c3ad (diff)
Extended the Python bindings to immediate operands.
Diffstat (limited to 'plugins/pychrysa/arch/module.c')
-rw-r--r--plugins/pychrysa/arch/module.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/plugins/pychrysa/arch/module.c b/plugins/pychrysa/arch/module.c
index 8ef9590..68f702d 100644
--- a/plugins/pychrysa/arch/module.c
+++ b/plugins/pychrysa/arch/module.c
@@ -28,16 +28,74 @@
#include <assert.h>
+#include <arch/archbase.h>
+
+
+#include "immediate.h"
#include "instriter.h"
#include "instruction.h"
+#include "operand.h"
#include "processor.h"
#include "vmpa.h"
#include "arm/module.h"
+#include "../helpers.h"
+
+
+
+/* Définit les constantes de base pour une architecture. */
+static bool py_base_define_constants(PyTypeObject *);
/******************************************************************************
* *
+* Paramètres : obj_type = type dont le dictionnaire est à compléter. *
+* *
+* Description : Définit les constantes de base pour une architecture. *
+* *
+* Retour : true en cas de succès de l'opération, false sinon. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool py_base_define_constants(PyTypeObject *obj_type)
+{
+ bool result; /* Bilan à retourner */
+
+ result = true;
+
+ result &= PyDict_AddIntMacro(obj_type, MDS_UNDEFINED);
+
+ result &= PyDict_AddIntMacro(obj_type, MDS_4_BITS_UNSIGNED);
+ result &= PyDict_AddIntMacro(obj_type, MDS_8_BITS_UNSIGNED);
+ result &= PyDict_AddIntMacro(obj_type, MDS_16_BITS_UNSIGNED);
+ result &= PyDict_AddIntMacro(obj_type, MDS_32_BITS_UNSIGNED);
+ result &= PyDict_AddIntMacro(obj_type, MDS_64_BITS_UNSIGNED);
+
+ result &= PyDict_AddIntMacro(obj_type, MDS_4_BITS_SIGNED);
+ result &= PyDict_AddIntMacro(obj_type, MDS_8_BITS_SIGNED);
+ result &= PyDict_AddIntMacro(obj_type, MDS_16_BITS_SIGNED);
+ result &= PyDict_AddIntMacro(obj_type, MDS_32_BITS_SIGNED);
+ result &= PyDict_AddIntMacro(obj_type, MDS_64_BITS_SIGNED);
+
+ result &= PyDict_AddIntMacro(obj_type, MDS_4_BITS);
+ result &= PyDict_AddIntMacro(obj_type, MDS_8_BITS);
+ result &= PyDict_AddIntMacro(obj_type, MDS_16_BITS);
+ result &= PyDict_AddIntMacro(obj_type, MDS_32_BITS);
+ result &= PyDict_AddIntMacro(obj_type, MDS_64_BITS);
+
+ result &= PyDict_AddIntMacro(obj_type, ASX_INTEL);
+ result &= PyDict_AddIntMacro(obj_type, ASX_ATT);
+ result &= PyDict_AddIntMacro(obj_type, ASX_COUNT);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : module = module dont la définition est à compléter. *
* *
* Description : Ajoute le module 'arch' au module Python. *
@@ -82,12 +140,17 @@ bool add_arch_module_to_python_module(PyObject *super)
result = true;
+ result &= py_base_define_constants(Py_TYPE(module));
+
result &= register_python_arch_instruction(module);
+ result &= register_python_arch_operand(module);
result &= register_python_arch_processor(module);
result &= register_python_instr_iterator(module);
result &= register_python_vmpa(module);
result &= register_python_mrange(module);
+ result &= register_python_imm_operand(module);
+
result &= add_arch_arm_module_to_python_module(module);
loading_failed: