diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-12-12 02:37:58 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-12-12 02:37:58 (GMT) |
commit | cdfc8c13fdd78c4af6e0ad120a8369e5fcb2e78d (patch) | |
tree | 02e84c98d3ebb264f5f96b0b984faef91138f41a /plugins/pychrysalide/core | |
parent | 9d74efa39abcbe68b102ceff79c8d61766387f53 (diff) |
Implemented the Python bindings to load unknown binaries.
Diffstat (limited to 'plugins/pychrysalide/core')
-rw-r--r-- | plugins/pychrysalide/core/Makefile.am | 3 | ||||
-rw-r--r-- | plugins/pychrysalide/core/module.c | 2 | ||||
-rw-r--r-- | plugins/pychrysalide/core/params.c | 4 | ||||
-rw-r--r-- | plugins/pychrysalide/core/queue.c | 103 | ||||
-rw-r--r-- | plugins/pychrysalide/core/queue.h | 39 |
5 files changed, 148 insertions, 3 deletions
diff --git a/plugins/pychrysalide/core/Makefile.am b/plugins/pychrysalide/core/Makefile.am index b431dcc..4018012 100644 --- a/plugins/pychrysalide/core/Makefile.am +++ b/plugins/pychrysalide/core/Makefile.am @@ -6,7 +6,8 @@ libpychrysacore_la_SOURCES = \ global.h global.c \ logs.h logs.c \ module.h module.c \ - params.h params.c + params.h params.c \ + queue.h queue.c libpychrysacore_la_LDFLAGS = diff --git a/plugins/pychrysalide/core/module.c b/plugins/pychrysalide/core/module.c index 71fa508..aade384 100644 --- a/plugins/pychrysalide/core/module.c +++ b/plugins/pychrysalide/core/module.c @@ -32,6 +32,7 @@ #include "global.h" #include "logs.h" #include "params.h" +#include "queue.h" #include "../helpers.h" @@ -95,6 +96,7 @@ bool populate_core_module(void) if (result) result = ensure_python_global_is_registered(); if (result) result = ensure_python_logs_is_registered(); if (result) result = ensure_python_params_is_registered(); + if (result) result = populate_core_module_with_queue(); assert(result); diff --git a/plugins/pychrysalide/core/params.c b/plugins/pychrysalide/core/params.c index 94d55b1..e31c129 100644 --- a/plugins/pychrysalide/core/params.c +++ b/plugins/pychrysalide/core/params.c @@ -51,7 +51,7 @@ static bool py_params_define_constants(PyTypeObject *); * * * Description : Fournit la version du programme global. * * * -* Retour : Numéro de révision. * +* Retour : Configuration prête à emploi ou None si aucune définie. * * * * Remarques : - * * * @@ -107,7 +107,7 @@ PyTypeObject *get_python_params_type(void) .tp_doc = "Python object for parameters", - .tp_methods = py_params_methods + .tp_methods = py_params_methods }; diff --git a/plugins/pychrysalide/core/queue.c b/plugins/pychrysalide/core/queue.c new file mode 100644 index 0000000..9c1365a --- /dev/null +++ b/plugins/pychrysalide/core/queue.c @@ -0,0 +1,103 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * queue.c - équivalent Python du fichier "core/queue.c" + * + * Copyright (C) 2018 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "queue.h" + + +#include <pygobject.h> + + +#include <core/queue.h> + + +#include "../access.h" +#include "../helpers.h" + + + +/* Attend que toutes les tâches de tout groupe soient traitées. */ +static PyObject *py_queue_wait_for_all_global_works(PyObject *, PyObject *); + + + +/****************************************************************************** +* * +* Paramètres : self = NULL car méthode statique. * +* args = non utilisé ici. * +* * +* Description : Attend que toutes les tâches de tout groupe soient traitées. * +* * +* Retour : None. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_queue_wait_for_all_global_works(PyObject *self, PyObject *args) +{ + wait_for_all_global_works(); + + Py_RETURN_NONE; + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Définit une extension du module 'core' à compléter. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool populate_core_module_with_queue(void) +{ + bool result; /* Bilan à retourner */ + PyObject *module; /* Module à recompléter */ + int ret; /* Bilan d'un appel */ + + static PyMethodDef py_queue_methods[] = { + + { "wait_for_all_global_works", py_queue_wait_for_all_global_works, + METH_NOARGS, + "wait_for_all_global_works(, /)\n--\n\nWait for all tasks being processed." + }, + { NULL } + + }; + + module = get_access_to_python_module("pychrysalide.core"); + + ret = PyModule_AddFunctions(module, py_queue_methods); + + result = (ret == 0); + + return result; + +} + diff --git a/plugins/pychrysalide/core/queue.h b/plugins/pychrysalide/core/queue.h new file mode 100644 index 0000000..36da0ca --- /dev/null +++ b/plugins/pychrysalide/core/queue.h @@ -0,0 +1,39 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * queue.h - prototypes pour l'équivalent Python du fichier "core/queue.h" + * + * Copyright (C) 2018 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef _PLUGINS_PYCHRYSALIDE_CORE_QUEUE_H +#define _PLUGINS_PYCHRYSALIDE_CORE_QUEUE_H + + +#include <Python.h> +#include <stdbool.h> + + + +/* Définit une extension du module 'core' à compléter. */ +bool populate_core_module_with_queue(void); + + + +#endif /* _PLUGINS_PYCHRYSALIDE_CORE_QUEUE_H */ |