summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/arch
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-03-19 13:02:54 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-03-19 13:02:54 (GMT)
commit94fd405bb0c2e6dfa43324b04a336ffb611c58ce (patch)
treef3170587b4006fa358665a6bbfa301731503d3b3 /plugins/pychrysa/arch
parent499f00977cd7f50ce0c4cf24dd59b1e920e5b180 (diff)
Provided initial features for debugging using GDB.
Diffstat (limited to 'plugins/pychrysa/arch')
-rw-r--r--plugins/pychrysa/arch/vmpa.c62
-rw-r--r--plugins/pychrysa/arch/vmpa.h3
2 files changed, 65 insertions, 0 deletions
diff --git a/plugins/pychrysa/arch/vmpa.c b/plugins/pychrysa/arch/vmpa.c
index d747f8d..10acf35 100644
--- a/plugins/pychrysa/arch/vmpa.c
+++ b/plugins/pychrysa/arch/vmpa.c
@@ -729,6 +729,68 @@ PyObject *build_from_internal_vmpa(const vmpa2t *addr)
}
+/******************************************************************************
+* *
+* Paramètres : arg = argument quelconque à tenter de convertir. *
+* dst = destination des valeurs récupérées en cas de succès. *
+* *
+* Description : Tente de convertir en adresse n'importe quoi. *
+* *
+* Retour : Bilan de l'opération, voire indications supplémentaires. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+int convert_any_to_vmpa(PyObject *arg, void *dst)
+{
+ int result; /* Bilan à retourner */
+ int ret; /* Test intermédiaire */
+ vmpa2t *src; /* Modèle de données à copier */
+ PY_LONG_LONG value; /* Valeur de type générique */
+ int overflow; /* Détection d'une grosse val. */
+
+ result = 0;
+
+ /* Si l'objet est au bon format, rien à faire ! */
+
+ ret = PyObject_IsInstance(arg, (PyObject *)get_python_vmpa_type());
+
+ if (ret == 1)
+ {
+ src = get_internal_vmpa(arg);
+ copy_vmpa((vmpa2t *)dst, src);
+
+ result = 1;
+ goto catv_done;
+
+ }
+
+ /* Sinon on demande à Python... */
+
+ value = PyLong_AsLongLongAndOverflow(arg, &overflow);
+
+ if (value == -1 && (overflow == 1 || PyErr_Occurred()))
+ PyErr_Clear();
+
+ else
+ {
+ init_vmpa((vmpa2t *)dst, VMPA_NO_PHYSICAL, value);
+
+ result = 1;
+ goto catv_done;
+
+ }
+
+ PyErr_SetString(PyExc_TypeError, "unable to convert the provided argument to vmpa");
+
+ catv_done:
+
+ return result;
+
+}
+
+
/* ---------------------------------------------------------------------------------- */
/* DEFINITION D'UNE ZONE EN MEMOIRE */
diff --git a/plugins/pychrysa/arch/vmpa.h b/plugins/pychrysa/arch/vmpa.h
index 793f24a..46828f5 100644
--- a/plugins/pychrysa/arch/vmpa.h
+++ b/plugins/pychrysa/arch/vmpa.h
@@ -46,6 +46,9 @@ vmpa2t *get_internal_vmpa(PyObject *);
/* Convertit une structure de type 'vmpa2t' en objet Python. */
PyObject *build_from_internal_vmpa(const vmpa2t *);
+/* Tente de convertir en adresse n'importe quoi. */
+int convert_any_to_vmpa(PyObject *, void *);
+
/* ------------------------ DEFINITION D'UNE ZONE EN MEMOIRE ------------------------ */