summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide')
-rw-r--r--plugins/pychrysalide/Makefile.am1
-rw-r--r--plugins/pychrysalide/helpers.c30
-rw-r--r--plugins/pychrysalide/pychrysa.c3
-rw-r--r--plugins/pychrysalide/star.c66
-rw-r--r--plugins/pychrysalide/star.h39
5 files changed, 139 insertions, 0 deletions
diff --git a/plugins/pychrysalide/Makefile.am b/plugins/pychrysalide/Makefile.am
index 0483b2a..8051bb9 100644
--- a/plugins/pychrysalide/Makefile.am
+++ b/plugins/pychrysalide/Makefile.am
@@ -10,6 +10,7 @@ pychrysalide_la_SOURCES = \
helpers.h helpers.c \
plugin.h plugin.c \
pychrysa.h pychrysa.c \
+ star.h star.c \
struct.h struct.c \
weak.h weak.c
diff --git a/plugins/pychrysalide/helpers.c b/plugins/pychrysalide/helpers.c
index 51c2f31..3a67e2b 100644
--- a/plugins/pychrysalide/helpers.c
+++ b/plugins/pychrysalide/helpers.c
@@ -458,6 +458,11 @@ bool _register_class_for_pygobject(PyObject *dict, GType gtype, PyTypeObject *ty
PyObject *static_bases; /* Base(s) de l'objet */
va_list ap; /* Parcours des arguments */
PyTypeObject *static_base; /* Base à rajouter à la liste */
+ PyObject *features; /* Module à recompléter */
+ PyObject *features_dict; /* Dictionnaire à compléter */
+ char *name; /* Désignation de la classe */
+ PyObject *item; /* Nouvel élément à exporter */
+ int ret; /* Bilan d'une insertion */
/**
* pygobject_register_class() définit type->tp_base à partir des arguments fournis,
@@ -531,6 +536,31 @@ bool _register_class_for_pygobject(PyObject *dict, GType gtype, PyTypeObject *ty
assert(PyErr_Occurred() == NULL);
+ /**
+ * Création d'un dictionnaire complet pour la simulation d'un "import *".
+ */
+
+ if (result)
+ {
+ features = get_access_to_python_module("pychrysalide.features");
+
+ features_dict = PyModule_GetDict(features);
+
+ name = strrchr(type->tp_name, '.');
+ assert(name != NULL);
+
+ name++;
+
+ item = PyDict_GetItemString(dict, name);
+ assert(item != NULL);
+
+ ret = PyDict_SetItemString(features_dict, name, item);
+ assert(ret == 0);
+
+ result = (ret == 0);
+
+ }
+
return result;
}
diff --git a/plugins/pychrysalide/pychrysa.c b/plugins/pychrysalide/pychrysa.c
index 785481b..514442a 100644
--- a/plugins/pychrysalide/pychrysa.c
+++ b/plugins/pychrysalide/pychrysa.c
@@ -47,6 +47,7 @@
#include "dt.h"
#include "helpers.h"
#include "plugin.h"
+#include "star.h"
#include "struct.h"
#include "analysis/module.h"
#include "arch/module.h"
@@ -371,6 +372,8 @@ PyMODINIT_FUNC PyInit_pychrysalide(void)
status = true;
+ if (status) status = add_features_module(result);
+
if (status) status = add_analysis_module(result);
if (status) status = add_arch_module(result);
if (status) status = add_common_module(result);
diff --git a/plugins/pychrysalide/star.c b/plugins/pychrysalide/star.c
new file mode 100644
index 0000000..5034d7c
--- /dev/null
+++ b/plugins/pychrysalide/star.c
@@ -0,0 +1,66 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * features.c - exportation complète de tous les éléments du greffon Python
+ *
+ * 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 "star.h"
+
+
+#include "helpers.h"
+
+
+
+/******************************************************************************
+* *
+* Paramètres : super = module dont la définition est à compléter. *
+* *
+* Description : Ajoute le module 'features' à un module Python. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool add_features_module(PyObject *super)
+{
+ bool result; /* Bilan à retourner */
+ PyObject *module; /* Sous-module mis en place */
+
+ static PyModuleDef py_chrysalide_features_module = {
+
+ .m_base = PyModuleDef_HEAD_INIT,
+
+ .m_name = "pychrysalide.features",
+ .m_doc = "Python pseudo-module to import all items from Chrysalide bindings",
+
+ .m_size = -1,
+
+ };
+
+ module = build_python_module(super, &py_chrysalide_features_module);
+
+ result = (module != NULL);
+
+ return result;
+
+}
diff --git a/plugins/pychrysalide/star.h b/plugins/pychrysalide/star.h
new file mode 100644
index 0000000..2a53d3e
--- /dev/null
+++ b/plugins/pychrysalide/star.h
@@ -0,0 +1,39 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * star.h - prototypes pour l'exportation complète de tous les éléments du greffon Python
+ *
+ * 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_STAR_H
+#define _PLUGINS_PYCHRYSALIDE_STAR_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Ajoute le module 'features'à un module Python. */
+bool add_features_module(PyObject *);
+
+
+
+#endif /* _PLUGINS_PYCHRYSALIDE_STAR_H */