summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/analysis
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-04-14 21:04:32 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-04-14 21:04:32 (GMT)
commit627560def907ec62c38839457e6a018af27b6640 (patch)
treeb41b389c5b3505090cf648fba0160e7b80cd0f37 /plugins/pychrysalide/analysis
parent94fc32b6e4d985df049a33bd2c31f6932a1e292c (diff)
Provided a link to routines from Dex methods.
Diffstat (limited to 'plugins/pychrysalide/analysis')
-rw-r--r--plugins/pychrysalide/analysis/routine.c45
-rw-r--r--plugins/pychrysalide/analysis/routine.h3
2 files changed, 48 insertions, 0 deletions
diff --git a/plugins/pychrysalide/analysis/routine.c b/plugins/pychrysalide/analysis/routine.c
index d8b0eb7..0dea2a0 100644
--- a/plugins/pychrysalide/analysis/routine.c
+++ b/plugins/pychrysalide/analysis/routine.c
@@ -689,3 +689,48 @@ bool ensure_python_binary_routine_is_registered(void)
return true;
}
+
+
+/******************************************************************************
+* *
+* 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 routine de binaire. *
+* *
+* Retour : Bilan de l'opération, voire indications supplémentaires. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+int convert_to_binary_routine(PyObject *arg, void *dst)
+{
+ int result; /* Bilan à retourner */
+
+ result = PyObject_IsInstance(arg, (PyObject *)get_python_binary_routine_type());
+
+ switch (result)
+ {
+ case -1:
+ /* L'exception est déjà fixée par Python */
+ result = 0;
+ break;
+
+ case 0:
+ PyErr_SetString(PyExc_TypeError, "unable to convert the provided argument to loaded binary");
+ break;
+
+ case 1:
+ *((GBinRoutine **)dst) = G_BIN_ROUTINE(pygobject_get(arg));
+ break;
+
+ default:
+ assert(false);
+ break;
+
+ }
+
+ return result;
+
+}
diff --git a/plugins/pychrysalide/analysis/routine.h b/plugins/pychrysalide/analysis/routine.h
index 702cbd8..bb85ff0 100644
--- a/plugins/pychrysalide/analysis/routine.h
+++ b/plugins/pychrysalide/analysis/routine.h
@@ -37,6 +37,9 @@ PyTypeObject *get_python_binary_routine_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.BinRoutine'. */
bool ensure_python_binary_routine_is_registered(void);
+/* Tente de convertir en routine de binaire. */
+int convert_to_binary_routine(PyObject *, void *);
+
#endif /* _PLUGINS_PYCHRYSALIDE_ANALYSIS_ROUTINE_H */