summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/arch
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-10-27 22:54:30 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-10-27 22:54:30 (GMT)
commitce27af7f442d1fa580311eac83bc44d7db4e0d05 (patch)
tree64a897f76e84ef401a0d5987eb56422e95606b09 /plugins/pychrysalide/arch
parent7932fbf156fc357139638a342a46189450f7f484 (diff)
Accepted integer values as usable addresses for some Python bindings.
Diffstat (limited to 'plugins/pychrysalide/arch')
-rw-r--r--plugins/pychrysalide/arch/processor.c87
-rw-r--r--plugins/pychrysalide/arch/processor.h25
2 files changed, 98 insertions, 14 deletions
diff --git a/plugins/pychrysalide/arch/processor.c b/plugins/pychrysalide/arch/processor.c
index 3ac18fa..6466fc9 100644
--- a/plugins/pychrysalide/arch/processor.c
+++ b/plugins/pychrysalide/arch/processor.c
@@ -32,9 +32,6 @@
#include <i18n.h>
-#include <arch/processor.h>
-
-
#include "instriter.h"
#include "instruction.h"
#include "vmpa.h"
@@ -49,6 +46,7 @@
+/* ---------------------------- DEFINITION DE PROCESSEUR ---------------------------- */
/* Indique si l'architecture possède un espace virtuel ou non. */
@@ -349,22 +347,19 @@ static int py_arch_processor_set_instrs(PyObject *self, PyObject *value, void *c
static PyObject *py_arch_processor_find_instr_by_addr(PyObject *self, PyObject *args)
{
PyObject *result; /* Instance à retourner */
- PyObject *addr_obj; /* Objet pour une localisation */
- int ret; /* Bilan de lecture des args. */
GArchProcessor *proc; /* Processeur manipulé */
- vmpa2t *addr; /* Localisation à retrouver */
+ proc_cv_info_t conv; /* Informations de conversion */
+ int ret; /* Bilan de lecture des args. */
GArchInstruction *found; /* Instruction liée trouvée */
- ret = PyArg_ParseTuple(args, "O", &addr_obj);
- if (!ret) return NULL;
+ proc = G_ARCH_PROCESSOR(pygobject_get(self));
- ret = PyObject_IsInstance(addr_obj, (PyObject *)get_python_vmpa_type());
- if (!ret) return NULL;
+ conv.proc = proc;
- proc = G_ARCH_PROCESSOR(pygobject_get(self));
- addr = get_internal_vmpa(addr_obj);
+ ret = PyArg_ParseTuple(args, "O&", convert_to_vmpa_using_processor, &conv);
+ if (!ret) return NULL;
- found = g_arch_processor_find_instr_by_address(proc, addr);
+ found = g_arch_processor_find_instr_by_address(proc, conv.vmpa);
if (found != NULL)
{
@@ -384,7 +379,9 @@ static PyObject *py_arch_processor_find_instr_by_addr(PyObject *self, PyObject *
-
+/* ---------------------------------------------------------------------------------- */
+/* DEFINITION DE PROCESSEUR */
+/* ---------------------------------------------------------------------------------- */
/******************************************************************************
@@ -515,3 +512,65 @@ bool ensure_python_arch_processor_is_registered(void)
return true;
}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* TRADUCTION D'EMPLACEMENT */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : obj = objet Python à convertir en emplacement. *
+* info = informations utiles à l'opération. *
+* *
+* Description : Réalise une conversion d'un objet Python en localisation. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+int convert_to_vmpa_using_processor(PyObject *obj, proc_cv_info_t *info)
+{
+ int result; /* Bilan à retourner */
+ int ret; /* Bilan d'une consultation */
+
+ ret = PyObject_IsInstance(obj, (PyObject *)get_python_vmpa_type());
+
+ if (ret)
+ {
+ info->vmpa = get_internal_vmpa(obj);
+ result = 1;
+ }
+
+ else
+ {
+ ret = PyObject_IsInstance(obj, (PyObject *)&PyLong_Type);
+
+ if (ret)
+ {
+ info->vmpa = &info->tmp;
+
+ if (g_arch_processor_has_virtual_space(info->proc))
+ init_vmpa(info->vmpa, VMPA_NO_PHYSICAL, PyLong_AsUnsignedLongLong(obj));
+ else
+ init_vmpa(info->vmpa, PyLong_AsUnsignedLongLong(obj), VMPA_NO_VIRTUAL);
+
+ result = 1;
+
+ }
+
+ else
+ result = 0;
+
+ }
+
+ if (result == 0)
+ PyErr_Format(PyExc_TypeError, _("unable to convert object to VMPA location"));
+
+ return result;
+
+}
diff --git a/plugins/pychrysalide/arch/processor.h b/plugins/pychrysalide/arch/processor.h
index 2db8950..22331fc 100644
--- a/plugins/pychrysalide/arch/processor.h
+++ b/plugins/pychrysalide/arch/processor.h
@@ -30,6 +30,12 @@
#include <stdbool.h>
+#include <arch/processor.h>
+
+
+
+/* ---------------------------- DEFINITION DE PROCESSEUR ---------------------------- */
+
/* Fournit un accès à une définition de type à diffuser. */
PyTypeObject *get_python_arch_processor_type(void);
@@ -39,4 +45,23 @@ bool ensure_python_arch_processor_is_registered(void);
+/* ---------------------------- TRADUCTION D'EMPLACEMENT ---------------------------- */
+
+
+/* Informations utiles à une traduction */
+typedef struct _proc_cv_info_t
+{
+ GArchProcessor *proc; /* Eventuel processeur indiqué */
+ vmpa2t *vmpa; /* Emplacement à définir */
+
+ vmpa2t tmp; /* Eventuel stockage temporaire*/
+
+} proc_cv_info_t;
+
+
+/* Réalise une conversion d'un objet Python en localisation. */
+int convert_to_vmpa_using_processor(PyObject *, proc_cv_info_t *);
+
+
+
#endif /* _PLUGINS_PYCHRYSALIDE_ARCH_PROCESSOR_H */