diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2019-04-19 20:29:34 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2019-04-19 20:29:34 (GMT) |
commit | 2769384a97478f4901157b71e67ec33496dd75cf (patch) | |
tree | ec6df834d97ae7222dc1695f35df5bd7b25d6f07 /plugins | |
parent | 627560def907ec62c38839457e6a018af27b6640 (diff) |
Given access to Dalvik architecture from the Python bindings
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/dalvik/Makefile.am | 27 | ||||
-rw-r--r-- | plugins/dalvik/core.c | 8 | ||||
-rw-r--r-- | plugins/dalvik/python/Makefile.am | 25 | ||||
-rw-r--r-- | plugins/dalvik/python/instruction.c | 110 | ||||
-rw-r--r-- | plugins/dalvik/python/instruction.h | 42 | ||||
-rw-r--r-- | plugins/dalvik/python/module.c | 87 | ||||
-rw-r--r-- | plugins/dalvik/python/module.h | 38 | ||||
-rw-r--r-- | plugins/dalvik/python/processor.c | 108 | ||||
-rw-r--r-- | plugins/dalvik/python/processor.h | 42 | ||||
-rw-r--r-- | plugins/dalvik/python/v35/Makefile.am | 20 | ||||
-rw-r--r-- | plugins/dalvik/python/v35/instruction.c | 109 | ||||
-rw-r--r-- | plugins/dalvik/python/v35/instruction.h | 42 | ||||
-rw-r--r-- | plugins/dalvik/python/v35/module.c | 76 | ||||
-rw-r--r-- | plugins/dalvik/python/v35/module.h | 39 | ||||
-rw-r--r-- | plugins/dalvik/python/v35/processor.c | 109 | ||||
-rw-r--r-- | plugins/dalvik/python/v35/processor.h | 42 |
16 files changed, 922 insertions, 2 deletions
diff --git a/plugins/dalvik/Makefile.am b/plugins/dalvik/Makefile.am index c3dd774..76ce098 100644 --- a/plugins/dalvik/Makefile.am +++ b/plugins/dalvik/Makefile.am @@ -4,6 +4,27 @@ lib_LTLIBRARIES = libdalvik.la libdir = $(pluginslibdir) +if BUILD_PYTHON3_BINDINGS + +PYTHON3_LIBADD = python/libdalvikpython.la + +if BUILD_DISCARD_LOCAL + +PYTHON3_LDFLAGS = -Wl,-rpath,$(pluginslibdir) \ + -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so + +else + +PYTHON3_LDFLAGS = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs \ + -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so + +endif + +PYTHON3_SUBDIRS = python + +endif + + libdalvik_la_SOURCES = \ context.h context.c \ core.h core.c \ @@ -21,11 +42,13 @@ libdalvik_la_SOURCES = \ libdalvik_la_LIBADD = \ operands/libdalvikoperands.la \ pseudo/libdalvikpseudo.la \ + $(PYTHON3_LIBADD) \ v35/libdalvik35.la libdalvik_la_LDFLAGS = \ -L$(top_srcdir)/src/.libs -lchrysacore \ - -L$(top_srcdir)/plugins/dex/.libs -ldex + -L$(top_srcdir)/plugins/dex/.libs -ldex \ + $(PYTHON3_LDFLAGS) devdir = $(includedir)/chrysalide-$(subdir) @@ -38,4 +61,4 @@ AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) -I$(top_srcdir)/src AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) -SUBDIRS = operands pseudo v35 +SUBDIRS = operands pseudo $(PYTHON3_SUBDIRS) v35 diff --git a/plugins/dalvik/core.c b/plugins/dalvik/core.c index 3220e2d..feb54ab 100644 --- a/plugins/dalvik/core.c +++ b/plugins/dalvik/core.c @@ -32,6 +32,9 @@ #include "operands/args.h" #include "operands/pool.h" #include "operands/register.h" +#ifdef HAVE_PYTHON3_BINDINGS +# include "python/module.h" +#endif #include "v35/core.h" @@ -96,6 +99,11 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin) result = init_dalvik35_core(); +#ifdef HAVE_PYTHON3_BINDINGS + if (result) + result = add_arch_dalvik_module_to_python_module(); +#endif + return result; } diff --git a/plugins/dalvik/python/Makefile.am b/plugins/dalvik/python/Makefile.am new file mode 100644 index 0000000..8156b92 --- /dev/null +++ b/plugins/dalvik/python/Makefile.am @@ -0,0 +1,25 @@ + +noinst_LTLIBRARIES = libdalvikpython.la + +libdalvikpython_la_SOURCES = \ + instruction.h instruction.c \ + module.h module.c \ + processor.h processor.c + +libdalvikpython_la_LIBADD = \ + v35/libdalvikpythonv35.la + +libdalvikpython_la_LDFLAGS = + + +devdir = $(includedir)/chrysalide-$(subdir) + +dev_HEADERS = $(libdalvikpython_la_SOURCES:%c=) + + +AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \ + -I$(top_srcdir)/src -DNO_IMPORT_PYGOBJECT + +AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) + +SUBDIRS = v35 diff --git a/plugins/dalvik/python/instruction.c b/plugins/dalvik/python/instruction.c new file mode 100644 index 0000000..c9d039f --- /dev/null +++ b/plugins/dalvik/python/instruction.c @@ -0,0 +1,110 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * instruction.c - équivalent Python du fichier "arch/dalvik/instruction.c" + * + * Copyright (C) 2019 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 "instruction.h" + + +#include <pygobject.h> + + +#include <plugins/pychrysalide/helpers.h> +#include <plugins/pychrysalide/arch/instruction.h> + + +#include "../instruction.h" + + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Fournit un accès à une définition de type à diffuser. * +* * +* Retour : Définition d'objet pour Python. * +* * +* Remarques : - * +* * +******************************************************************************/ + +PyTypeObject *get_python_dalvik_instruction_type(void) +{ + static PyMethodDef py_dalvik_instruction_methods[] = { + { NULL } + }; + + static PyGetSetDef py_dalvik_instruction_getseters[] = { + { NULL } + }; + + static PyTypeObject py_dalvik_instruction_type = { + + PyVarObject_HEAD_INIT(NULL, 0) + + .tp_name = "pychrysalide.arch.dalvik.DalvikInstruction", + .tp_basicsize = sizeof(PyGObject), + + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + + .tp_doc = "PyChrysalide instruction for an Dalvik architecture.", + + .tp_methods = py_dalvik_instruction_methods, + .tp_getset = py_dalvik_instruction_getseters, + + }; + + return &py_dalvik_instruction_type; + +} + + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Prend en charge l'objet 'pychrysalide.....DalvikInstruction'.* +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool register_python_dalvik_instruction(PyObject *module) +{ + PyTypeObject *type; /* Type Python '...Instruction'*/ + PyObject *dict; /* Dictionnaire du module */ + + type = get_python_dalvik_instruction_type(); + + APPLY_ABSTRACT_FLAG(type); + + dict = PyModule_GetDict(module); + + if (!register_class_for_pygobject(dict, G_TYPE_DALVIK_INSTRUCTION, type, get_python_arch_instruction_type())) + return false; + + return true; + +} diff --git a/plugins/dalvik/python/instruction.h b/plugins/dalvik/python/instruction.h new file mode 100644 index 0000000..b5050cf --- /dev/null +++ b/plugins/dalvik/python/instruction.h @@ -0,0 +1,42 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * instruction.h - prototypes pour l'équivalent Python du fichier "arch/dalvik/instruction.h" + * + * Copyright (C) 2019 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_DALVIK_PYTHON_INSTRUCTION_H +#define _PLUGINS_DALVIK_PYTHON_INSTRUCTION_H + + +#include <Python.h> +#include <stdbool.h> + + + +/* Fournit un accès à une définition de type à diffuser. */ +PyTypeObject *get_python_dalvik_instruction_type(void); + +/* Prend en charge l'objet 'pychrysalide.arch.dalvik.DalvikInstruction'. */ +bool register_python_dalvik_instruction(PyObject *); + + + +#endif /* _PLUGINS_DALVIK_PYTHON_INSTRUCTION_H */ diff --git a/plugins/dalvik/python/module.c b/plugins/dalvik/python/module.c new file mode 100644 index 0000000..38f4b4f --- /dev/null +++ b/plugins/dalvik/python/module.c @@ -0,0 +1,87 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * module.c - intégration du répertoire dalvik en tant que module + * + * Copyright (C) 2015-2017 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 <Python.h> + + +#include <plugins/pychrysalide/access.h> +#include <plugins/pychrysalide/helpers.h> + + +#include "instruction.h" +#include "processor.h" +#include "v35/module.h" + + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Ajoute le module 'dalvik' au module Python. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool add_arch_dalvik_module_to_python_module(void) +{ + bool result; /* Bilan à retourner */ + PyObject *super; /* Module à compléter */ + PyObject *module; /* Sous-module mis en place */ + + static PyModuleDef py_chrysalide_dalvik_module = { + + .m_base = PyModuleDef_HEAD_INIT, + + .m_name = "pychrysalide.arch.dalvik", + .m_doc = "Python module for Chrysalide.arch.dalvik", + + .m_size = -1, + + }; + + result = false; + + super = get_access_to_python_module("pychrysalide.arch"); + + module = build_python_module(super, &py_chrysalide_dalvik_module); + + result = (module != NULL); + + if (result) result = register_python_dalvik_instruction(module); + if (result) result = register_python_dalvik_processor(module); + + if (result) result = add_arch_dalvik_v35_module_to_python_module(module); + + assert(result); + + return result; + +} diff --git a/plugins/dalvik/python/module.h b/plugins/dalvik/python/module.h new file mode 100644 index 0000000..5551bf7 --- /dev/null +++ b/plugins/dalvik/python/module.h @@ -0,0 +1,38 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * module.h - prototypes pour l'intégration du répertoire dalvik en tant que module + * + * Copyright (C) 2019 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_DALVIK_PYTHON_MODULE_H +#define _PLUGINS_DALVIK_PYTHON_MODULE_H + + +#include <stdbool.h> + + + +/* Ajoute le module 'dalvik' au module Python. */ +bool add_arch_dalvik_module_to_python_module(void); + + + +#endif /* _PLUGINS_DALVIK_PYTHON_MODULE_H */ diff --git a/plugins/dalvik/python/processor.c b/plugins/dalvik/python/processor.c new file mode 100644 index 0000000..26fd8b7 --- /dev/null +++ b/plugins/dalvik/python/processor.c @@ -0,0 +1,108 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * processor.c - équivalent Python du fichier "arch/dalvik/processor.c" + * + * Copyright (C) 2019 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 "processor.h" + + +#include <pygobject.h> + + +#include <plugins/pychrysalide/helpers.h> +#include <plugins/pychrysalide/arch/processor.h> + + +#include "../processor.h" + + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Fournit un accès à une définition de type à diffuser. * +* * +* Retour : Définition d'objet pour Python. * +* * +* Remarques : - * +* * +******************************************************************************/ + +PyTypeObject *get_python_dalvik_processor_type(void) +{ + static PyMethodDef py_dalvik_processor_methods[] = { + { NULL } + }; + + static PyGetSetDef py_dalvik_processor_getseters[] = { + { NULL } + }; + + static PyTypeObject py_dalvik_processor_type = { + + PyVarObject_HEAD_INIT(NULL, 0) + + .tp_name = "pychrysalide.arch.dalvik.DalvikProcessor", + .tp_basicsize = sizeof(PyGObject), + + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + + .tp_doc = "PyChrysalide processor for an Dalvik architecture.", + + .tp_methods = py_dalvik_processor_methods, + .tp_getset = py_dalvik_processor_getseters, + + }; + + return &py_dalvik_processor_type; + +} + + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Prend en charge l'objet 'pychrysalide.....DalvikProcessor'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool register_python_dalvik_processor(PyObject *module) +{ + PyTypeObject *type; /* Type Python '...Processor' */ + PyObject *dict; /* Dictionnaire du module */ + + type = get_python_dalvik_processor_type(); + + dict = PyModule_GetDict(module); + + if (!register_class_for_pygobject(dict, G_TYPE_DALVIK_PROCESSOR, type, get_python_arch_processor_type())) + return false; + + return true; + +} diff --git a/plugins/dalvik/python/processor.h b/plugins/dalvik/python/processor.h new file mode 100644 index 0000000..ed2a672 --- /dev/null +++ b/plugins/dalvik/python/processor.h @@ -0,0 +1,42 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * processor.h - prototypes pour l'équivalent Python du fichier "arch/dalvik/processor.h" + * + * Copyright (C) 2019 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_DALVIK_PYTHON_PROCESSOR_H +#define _PLUGINS_DALVIK_PYTHON_PROCESSOR_H + + +#include <Python.h> +#include <stdbool.h> + + + +/* Fournit un accès à une définition de type à diffuser. */ +PyTypeObject *get_python_dalvik_processor_type(void); + +/* Prend en charge l'objet 'pychrysalide.arch.dalvik.DalvikProcessor'. */ +bool register_python_dalvik_processor(PyObject *); + + + +#endif /* _PLUGINS_DALVIK_PYTHON_PROCESSOR_H */ diff --git a/plugins/dalvik/python/v35/Makefile.am b/plugins/dalvik/python/v35/Makefile.am new file mode 100644 index 0000000..0a31db7 --- /dev/null +++ b/plugins/dalvik/python/v35/Makefile.am @@ -0,0 +1,20 @@ + +noinst_LTLIBRARIES = libdalvikpythonv35.la + +libdalvikpythonv35_la_SOURCES = \ + instruction.h instruction.c \ + module.h module.c \ + processor.h processor.c + +libdalvikpythonv35_la_LDFLAGS = + + +devdir = $(includedir)/chrysalide-$(subdir) + +dev_HEADERS = $(libdalvikpythonv35_la_SOURCES:%c=) + + +AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \ + -I$(top_srcdir)/src -DNO_IMPORT_PYGOBJECT + +AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) diff --git a/plugins/dalvik/python/v35/instruction.c b/plugins/dalvik/python/v35/instruction.c new file mode 100644 index 0000000..f5ccc2c --- /dev/null +++ b/plugins/dalvik/python/v35/instruction.c @@ -0,0 +1,109 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * instruction.c - équivalent Python du fichier "arch/dalvik/35/instruction.c" + * + * Copyright (C) 2019 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 "instruction.h" + + +#include <pygobject.h> + + +#include <plugins/pychrysalide/helpers.h> + + +#include "../instruction.h" +#include "../../v35/instruction.h" + + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Fournit un accès à une définition de type à diffuser. * +* * +* Retour : Définition d'objet pour Python. * +* * +* Remarques : - * +* * +******************************************************************************/ + +PyTypeObject *get_python_dalvik35_instruction_type(void) +{ + static PyMethodDef py_dalvik35_instruction_methods[] = { + { NULL } + }; + + static PyGetSetDef py_dalvik35_instruction_getseters[] = { + { NULL } + }; + + static PyTypeObject py_dalvik35_instruction_type = { + + PyVarObject_HEAD_INIT(NULL, 0) + + .tp_name = "pychrysalide.arch.dalvik.v35.Dalvik35Instruction", + .tp_basicsize = sizeof(PyGObject), + + .tp_flags = Py_TPFLAGS_DEFAULT, + + .tp_doc = "PyChrysalide instruction for an Dalvik 35 architecture.", + + .tp_methods = py_dalvik35_instruction_methods, + .tp_getset = py_dalvik35_instruction_getseters, + + }; + + return &py_dalvik35_instruction_type; + +} + + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Prend en charge l'objet 'pychrysalide...Dalvik35Instruction'.* +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool register_python_dalvik35_instruction(PyObject *module) +{ + PyTypeObject *type; /* Type Python '...Instruction'*/ + PyObject *dict; /* Dictionnaire du module */ + + type = get_python_dalvik35_instruction_type(); + + dict = PyModule_GetDict(module); + + if (!register_class_for_pygobject(dict, G_TYPE_DALVIK35_INSTRUCTION, + type, get_python_dalvik_instruction_type())) + return false; + + return true; + +} diff --git a/plugins/dalvik/python/v35/instruction.h b/plugins/dalvik/python/v35/instruction.h new file mode 100644 index 0000000..e38dfbe --- /dev/null +++ b/plugins/dalvik/python/v35/instruction.h @@ -0,0 +1,42 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * instruction.h - prototypes pour l'équivalent Python du fichier "arch/dalvik/v35/instruction.h" + * + * Copyright (C) 2019 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_DALVIK_PYTHON_V35_INSTRUCTION_H +#define _PLUGINS_DALVIK_PYTHON_V35_INSTRUCTION_H + + +#include <Python.h> +#include <stdbool.h> + + + +/* Fournit un accès à une définition de type à diffuser. */ +PyTypeObject *get_python_dalvik35_instruction_type(void); + +/* Prend en charge l'objet 'pychrysalide.arch.dalvik.v35.Dalvik35Instruction'. */ +bool register_python_dalvik35_instruction(PyObject *); + + + +#endif /* _PLUGINS_DALVIK_PYTHON_V35_INSTRUCTION_H */ diff --git a/plugins/dalvik/python/v35/module.c b/plugins/dalvik/python/v35/module.c new file mode 100644 index 0000000..91ed216 --- /dev/null +++ b/plugins/dalvik/python/v35/module.c @@ -0,0 +1,76 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * module.c - intégration du répertoire v35 en tant que module + * + * Copyright (C) 2019 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 <plugins/pychrysalide/access.h> +#include <plugins/pychrysalide/helpers.h> + + +#include "instruction.h" +#include "processor.h" + + + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Ajoute le module 'dalvik' au module Python. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool add_arch_dalvik_v35_module_to_python_module(PyObject *super) +{ + bool result; /* Bilan à retourner */ + PyObject *module; /* Sous-module mis en place */ + + static PyModuleDef py_chrysalide_v35_module = { + + .m_base = PyModuleDef_HEAD_INIT, + + .m_name = "pychrysalide.arch.dalvik.v35", + .m_doc = "Python module for Chrysalide.arch.dalvik.v35", + + .m_size = -1, + + }; + + module = build_python_module(super, &py_chrysalide_v35_module); + + result = (module != NULL); + + if (result) result = register_python_dalvik35_instruction(module); + if (result) result = register_python_dalvik35_processor(module); + + assert(result); + + return result; + +} diff --git a/plugins/dalvik/python/v35/module.h b/plugins/dalvik/python/v35/module.h new file mode 100644 index 0000000..a8de928 --- /dev/null +++ b/plugins/dalvik/python/v35/module.h @@ -0,0 +1,39 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * module.h - prototypes pour l'intégration du répertoire v35 en tant que module + * + * Copyright (C) 2019 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_DALVIK_PYTHON_V35_MODULE_H +#define _PLUGINS_DALVIK_PYTHON_V35_MODULE_H + + +#include <Python.h> +#include <stdbool.h> + + + +/* Ajoute le module 'dalvik' au module Python. */ +bool add_arch_dalvik_v35_module_to_python_module(PyObject *); + + + +#endif /* _PLUGINS_DALVIK_PYTHON_V35_MODULE_H */ diff --git a/plugins/dalvik/python/v35/processor.c b/plugins/dalvik/python/v35/processor.c new file mode 100644 index 0000000..fea342b --- /dev/null +++ b/plugins/dalvik/python/v35/processor.c @@ -0,0 +1,109 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * processor.c - équivalent Python du fichier "arch/dalvik/v35/processor.c" + * + * Copyright (C) 2019 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 "processor.h" + + +#include <pygobject.h> + + +#include <plugins/pychrysalide/helpers.h> + + +#include "../processor.h" +#include "../../v35/processor.h" + + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Fournit un accès à une définition de type à diffuser. * +* * +* Retour : Définition d'objet pour Python. * +* * +* Remarques : - * +* * +******************************************************************************/ + +PyTypeObject *get_python_dalvik35_processor_type(void) +{ + static PyMethodDef py_dalvik35_processor_methods[] = { + { NULL } + }; + + static PyGetSetDef py_dalvik35_processor_getseters[] = { + { NULL } + }; + + static PyTypeObject py_dalvik35_processor_type = { + + PyVarObject_HEAD_INIT(NULL, 0) + + .tp_name = "pychrysalide.arch.dalvik.v35.Dalvik35Processor", + .tp_basicsize = sizeof(PyGObject), + + .tp_flags = Py_TPFLAGS_DEFAULT, + + .tp_doc = "PyChrysalide processor for an Dalvik 35 architecture.", + + .tp_methods = py_dalvik35_processor_methods, + .tp_getset = py_dalvik35_processor_getseters, + + }; + + return &py_dalvik35_processor_type; + +} + + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Prend en charge l'objet 'pychrysalide.....Dalvik35Processor'.* +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool register_python_dalvik35_processor(PyObject *module) +{ + PyTypeObject *type; /* Type Python '...Processor' */ + PyObject *dict; /* Dictionnaire du module */ + + type = get_python_dalvik35_processor_type(); + + dict = PyModule_GetDict(module); + + if (!register_class_for_pygobject(dict, G_TYPE_DALVIK35_PROCESSOR, + type, get_python_dalvik_processor_type())) + return false; + + return true; + +} diff --git a/plugins/dalvik/python/v35/processor.h b/plugins/dalvik/python/v35/processor.h new file mode 100644 index 0000000..ff80f08 --- /dev/null +++ b/plugins/dalvik/python/v35/processor.h @@ -0,0 +1,42 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * processor.h - prototypes pour l'équivalent Python du fichier "arch/dalvik/v35/processor.h" + * + * Copyright (C) 2019 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_DALVIK_PYTHON_V35_PROCESSOR_H +#define _PLUGINS_DALVIK_PYTHON_V35_PROCESSOR_H + + +#include <Python.h> +#include <stdbool.h> + + + +/* Fournit un accès à une définition de type à diffuser. */ +PyTypeObject *get_python_dalvik35_processor_type(void); + +/* Prend en charge l'objet 'pychrysalide.arch.dalvik.v35.Dalvik35Processor'. */ +bool register_python_dalvik35_processor(PyObject *); + + + +#endif /* _PLUGINS_DALVIK_PYTHON_V35_PROCESSOR_H */ |