summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/analysis/disass
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/analysis/disass')
-rw-r--r--plugins/pychrysalide/analysis/disass/Makefile.am21
-rw-r--r--plugins/pychrysalide/analysis/disass/block.c127
-rw-r--r--plugins/pychrysalide/analysis/disass/block.h45
-rw-r--r--plugins/pychrysalide/analysis/disass/module.c100
-rw-r--r--plugins/pychrysalide/analysis/disass/module.h42
5 files changed, 335 insertions, 0 deletions
diff --git a/plugins/pychrysalide/analysis/disass/Makefile.am b/plugins/pychrysalide/analysis/disass/Makefile.am
new file mode 100644
index 0000000..874ee6b
--- /dev/null
+++ b/plugins/pychrysalide/analysis/disass/Makefile.am
@@ -0,0 +1,21 @@
+
+noinst_LTLIBRARIES = libpychrysaanalysisdisass.la
+
+libpychrysaanalysisdisass_la_SOURCES = \
+ block.h block.c \
+ module.h module.c
+
+libpychrysaanalysisdisass_la_LDFLAGS =
+
+
+devdir = $(includedir)/chrysalide-$(subdir)
+
+dev_HEADERS = $(libpychrysaanalysisdisass_la_SOURCES:%c=)
+
+
+AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \
+ -I$(top_srcdir)/src
+
+AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
+
+SUBDIRS =
diff --git a/plugins/pychrysalide/analysis/disass/block.c b/plugins/pychrysalide/analysis/disass/block.c
new file mode 100644
index 0000000..6855368
--- /dev/null
+++ b/plugins/pychrysalide/analysis/disass/block.c
@@ -0,0 +1,127 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * block.c - équivalent Python du fichier "analysis/disass/block.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 "block.h"
+
+
+#include <pygobject.h>
+
+
+#include <analysis/disass/block.h>
+
+
+#include "../block.h"
+#include "../../access.h"
+#include "../../helpers.h"
+
+
+
+/* ------------------------ MISE EN PLACE DES BLOCS BASIQUES ------------------------ */
+
+
+
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* MISE EN PLACE DES BLOCS BASIQUES */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Fournit un accès à une définition de type à diffuser. *
+* *
+* Retour : Définition d'objet pour Python. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyTypeObject *get_python_basic_block_type(void)
+{
+ static PyMethodDef py_basic_block_methods[] = {
+ { NULL }
+ };
+
+ static PyGetSetDef py_basic_block_getseters[] = {
+ { NULL }
+ };
+
+ static PyTypeObject py_basic_block_type = {
+
+ PyVarObject_HEAD_INIT(NULL, 0)
+
+ .tp_name = "pychrysalide.analysis.disass.BasicBlock",
+
+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+
+ .tp_doc = "PyChrysalide basic block",
+
+ .tp_methods = py_basic_block_methods,
+ .tp_getset = py_basic_block_getseters,
+
+ };
+
+ return &py_basic_block_type;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Prend en charge l'objet 'pychrysalide.....BasicBlock'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool ensure_python_basic_block_is_registered(void)
+{
+ PyTypeObject *type; /* Type Python 'InstrBlock' */
+ PyObject *module; /* Module à recompléter */
+ PyObject *dict; /* Dictionnaire du module */
+
+ type = get_python_basic_block_type();
+
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis.disass");
+
+ dict = PyModule_GetDict(module);
+
+ if (!register_class_for_pygobject(dict, G_TYPE_BASIC_BLOCK, type, get_python_code_block_type()))
+ return false;
+
+ }
+
+ return true;
+
+}
diff --git a/plugins/pychrysalide/analysis/disass/block.h b/plugins/pychrysalide/analysis/disass/block.h
new file mode 100644
index 0000000..5f0fc78
--- /dev/null
+++ b/plugins/pychrysalide/analysis/disass/block.h
@@ -0,0 +1,45 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * block.h - prototypes pour l'équivalent Python du fichier "analysis/disass/block.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_ANALYSIS_DISASS_BLOCK_H
+#define _PLUGINS_PYCHRYSALIDE_ANALYSIS_DISASS_BLOCK_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* ------------------------ MISE EN PLACE DES BLOCS BASIQUES ------------------------ */
+
+
+/* Fournit un accès à une définition de type à diffuser. */
+PyTypeObject *get_python_basic_block_type(void);
+
+/* Prend en charge l'objet 'pychrysalide.analysis.disass.BasicBlock'. */
+bool ensure_python_basic_block_is_registered(void);
+
+
+
+#endif /* _PLUGINS_PYCHRYSALIDE_ANALYSIS_DISASS_BLOCK_H */
diff --git a/plugins/pychrysalide/analysis/disass/module.c b/plugins/pychrysalide/analysis/disass/module.c
new file mode 100644
index 0000000..b02b031
--- /dev/null
+++ b/plugins/pychrysalide/analysis/disass/module.c
@@ -0,0 +1,100 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * module.c - intégration du répertoire disass en tant que module
+ *
+ * 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 "module.h"
+
+
+#include <assert.h>
+
+
+#include "block.h"
+#include "../../helpers.h"
+
+
+
+/******************************************************************************
+* *
+* Paramètres : super = module dont la définition est à compléter. *
+* *
+* Description : Ajoute le module 'analysis.disass' à un module Python. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool add_analysis_disass_module(PyObject *super)
+{
+ bool result; /* Bilan à retourner */
+ PyObject *module; /* Sous-module mis en place */
+
+ static PyModuleDef py_chrysalide_analysis_disass_module = {
+
+ .m_base = PyModuleDef_HEAD_INIT,
+
+ .m_name = "pychrysalide.analysis.disass",
+ .m_doc = "Python module for Chrysalide.analysis.disass",
+
+ .m_size = -1,
+
+ };
+
+ module = build_python_module(super, &py_chrysalide_analysis_disass_module);
+
+ result = (module != NULL);
+
+ if (!result)
+ Py_XDECREF(module);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Intègre les objets du module 'analysis.disass'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool populate_analysis_disass_module(void)
+{
+ bool result; /* Bilan à retourner */
+
+ result = true;
+
+ if (result) result = ensure_python_basic_block_is_registered();
+
+ assert(result);
+
+ return result;
+
+}
diff --git a/plugins/pychrysalide/analysis/disass/module.h b/plugins/pychrysalide/analysis/disass/module.h
new file mode 100644
index 0000000..7f6b9bf
--- /dev/null
+++ b/plugins/pychrysalide/analysis/disass/module.h
@@ -0,0 +1,42 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * module.h - prototypes pour l'intégration du répertoire disass en tant que module
+ *
+ * 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_ANALYSIS_DISASS_MODULE_H
+#define _PLUGINS_PYCHRYSALIDE_ANALYSIS_DISASS_MODULE_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Ajoute le module 'analysis.disass' à un module Python. */
+bool add_analysis_disass_module(PyObject *);
+
+/* Intègre les objets du module 'analysis.disass'. */
+bool populate_analysis_disass_module(void);
+
+
+
+#endif /* _PLUGINS_PYCHRYSALIDE_ANALYSIS_DISASS_MODULE_H */