diff options
Diffstat (limited to 'plugins/pychrysalide/analysis/binary.c')
-rw-r--r-- | plugins/pychrysalide/analysis/binary.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/plugins/pychrysalide/analysis/binary.c b/plugins/pychrysalide/analysis/binary.c index e137f87..98b20dc 100644 --- a/plugins/pychrysalide/analysis/binary.c +++ b/plugins/pychrysalide/analysis/binary.c @@ -38,12 +38,16 @@ #include "../access.h" #include "../helpers.h" #include "../format/executable.h" +#include "db/item.h" /* Crée un nouvel objet Python de type 'LoadedBinary'. */ static PyObject *py_loaded_binary_new(PyTypeObject *, PyObject *, PyObject *); +/* Demande l'intégration d'une modification dans une collection. */ +static PyObject *py_loaded_binary_add_to_collection(PyObject *, PyObject *); + /* Fournit le nom associé à l'élément binaire. */ static PyObject *py_loaded_binary_get_name(PyObject *, void *); @@ -96,6 +100,59 @@ static PyObject *py_loaded_binary_new(PyTypeObject *type, PyObject *args, PyObje /****************************************************************************** * * +* Paramètres : self = objet représentant un binaire chargé. * +* args = arguments fournis pour l'opération. * +* * +* Description : Demande l'intégration d'une modification dans une collection.* +* * +* Retour : Bilan partiel de l'opération demandée. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_loaded_binary_add_to_collection(PyObject *self, PyObject *args) +{ + PyObject *result; /* Bilan à retourner */ + GDbItem *item; /* Elément à intégrer */ + int ret; /* Bilan de lecture des args. */ + GLoadedBinary *binary; /* Binaire en cours d'analyse */ + bool status; /* Bilan de l'opération */ + +#define LOADED_BINARY_ADD_TO_COLLECTION_METHOD PYTHON_METHOD_DEF \ +( \ + add_to_collection, "$self, item, /", \ + METH_VARARGS, py_loaded_binary, \ + "Ask a server to include the given item into the update database." \ + "\n" \ + "The server type (internal or remote) depends on the collection type" \ + " linked to the item and the user configuration." \ + "\n" \ + "The item has to be a subclass of pychrysalide.analysis.db.DbItem." \ + "\n" \ + "The method returns True if the item has been successfully forwarded" \ + " to a server, False otherwise." \ +) + + ret = PyArg_ParseTuple(args, "O&", convert_to_db_item, &item); + if (!ret) return NULL; + + binary = G_LOADED_BINARY(pygobject_get(self)); + + g_object_ref(G_OBJECT(item)); + + status = g_loaded_binary_add_to_collection(binary, item); + + result = status ? Py_True : Py_False; + Py_INCREF(result); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : self = objet Python concerné par l'appel. * * closure = non utilisé ici. * * * @@ -246,6 +303,7 @@ static PyObject *py_loaded_binary_get_disassembled_cache(PyObject *self, void *c PyTypeObject *get_python_loaded_binary_type(void) { static PyMethodDef py_loaded_binary_methods[] = { + LOADED_BINARY_ADD_TO_COLLECTION_METHOD, { NULL } }; |