diff options
Diffstat (limited to 'plugins/pychrysalide/analysis/binary.c')
-rw-r--r-- | plugins/pychrysalide/analysis/binary.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/plugins/pychrysalide/analysis/binary.c b/plugins/pychrysalide/analysis/binary.c index f73684b..bc57ab4 100644 --- a/plugins/pychrysalide/analysis/binary.c +++ b/plugins/pychrysalide/analysis/binary.c @@ -330,3 +330,48 @@ bool ensure_python_loaded_binary_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 ensemble de binaire chargé. * +* * +* Retour : Bilan de l'opération, voire indications supplémentaires. * +* * +* Remarques : - * +* * +******************************************************************************/ + +int convert_to_loaded_binary(PyObject *arg, void *dst) +{ + int result; /* Bilan à retourner */ + + result = PyObject_IsInstance(arg, (PyObject *)get_python_loaded_binary_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: + *((GLoadedBinary **)dst) = G_LOADED_BINARY(pygobject_get(arg)); + break; + + default: + assert(false); + break; + + } + + return result; + +} |