summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/arch/processor.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/arch/processor.c')
-rw-r--r--plugins/pychrysalide/arch/processor.c87
1 files changed, 73 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;
+
+}