diff options
Diffstat (limited to 'plugins/pychrysa/arch/arm')
-rw-r--r-- | plugins/pychrysa/arch/arm/Makefile.am | 20 | ||||
-rw-r--r-- | plugins/pychrysa/arch/arm/instruction.c | 120 | ||||
-rw-r--r-- | plugins/pychrysa/arch/arm/instruction.h | 42 | ||||
-rw-r--r-- | plugins/pychrysa/arch/arm/module.c | 96 | ||||
-rw-r--r-- | plugins/pychrysa/arch/arm/module.h | 39 | ||||
-rw-r--r-- | plugins/pychrysa/arch/arm/processor.c | 120 | ||||
-rw-r--r-- | plugins/pychrysa/arch/arm/processor.h | 42 | ||||
-rw-r--r-- | plugins/pychrysa/arch/arm/v7/Makefile.am | 16 | ||||
-rw-r--r-- | plugins/pychrysa/arch/arm/v7/instruction.c | 117 | ||||
-rw-r--r-- | plugins/pychrysa/arch/arm/v7/instruction.h | 42 | ||||
-rw-r--r-- | plugins/pychrysa/arch/arm/v7/module.c | 93 | ||||
-rw-r--r-- | plugins/pychrysa/arch/arm/v7/module.h | 39 | ||||
-rw-r--r-- | plugins/pychrysa/arch/arm/v7/processor.c | 117 | ||||
-rw-r--r-- | plugins/pychrysa/arch/arm/v7/processor.h | 42 |
14 files changed, 945 insertions, 0 deletions
diff --git a/plugins/pychrysa/arch/arm/Makefile.am b/plugins/pychrysa/arch/arm/Makefile.am new file mode 100644 index 0000000..b081061 --- /dev/null +++ b/plugins/pychrysa/arch/arm/Makefile.am @@ -0,0 +1,20 @@ + +noinst_LTLIBRARIES = libpychrysaarcharm.la + +libpychrysaarcharm_la_SOURCES = \ + instruction.h instruction.c \ + module.h module.c \ + processor.h processor.c + +libpychrysaarcharm_la_LIBADD = \ + v7/libpychrysaarcharmv7.la + +libpychrysaarcharm_la_LDFLAGS = + + +AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \ + -I../../../../src + +AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) + +SUBDIRS = v7 diff --git a/plugins/pychrysa/arch/arm/instruction.c b/plugins/pychrysa/arch/arm/instruction.c new file mode 100644 index 0000000..ed53386 --- /dev/null +++ b/plugins/pychrysa/arch/arm/instruction.c @@ -0,0 +1,120 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * instruction.c - équivalent Python du fichier "arch/arm/instruction.c" + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * OpenIDA 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. + * + * OpenIDA 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 <arch/arm/instruction.h> + + +#include "../instruction.h" +#include "../../helpers.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_arm_instruction_type(void) +{ + static PyMethodDef py_arm_instruction_methods[] = { + { NULL } + }; + + static PyGetSetDef py_arm_instruction_getseters[] = { + { NULL } + }; + + static PyTypeObject py_arm_instruction_type = { + + PyVarObject_HEAD_INIT(NULL, 0) + + .tp_name = "pychrysalide.arch.arm.ArmInstruction", + .tp_basicsize = sizeof(PyGObject), + + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + + .tp_doc = "PyChrysalide instruction for an ARM architecture.", + + .tp_methods = py_arm_instruction_methods, + .tp_getset = py_arm_instruction_getseters, + + }; + + return &py_arm_instruction_type; + +} + + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Prend en charge l'objet 'pychrysalide....arm.ArmInstruction'.* +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool register_python_arm_instruction(PyObject *module) +{ + PyTypeObject *py_arm_instruction_type; /* Type Python 'BinContent' */ + int ret; /* Bilan d'un appel */ + PyObject *dict; /* Dictionnaire du module */ + + py_arm_instruction_type = get_python_arm_instruction_type(); + + py_arm_instruction_type->tp_base = get_python_arch_instruction_type(); + py_arm_instruction_type->tp_basicsize = py_arm_instruction_type->tp_base->tp_basicsize; + + APPLY_ABSTRACT_FLAG(py_arm_instruction_type); + + if (PyType_Ready(py_arm_instruction_type) != 0) + return false; + + Py_INCREF(py_arm_instruction_type); + ret = PyModule_AddObject(module, "ArmInstruction", (PyObject *)py_arm_instruction_type); + if (ret != 0) return false; + + dict = PyModule_GetDict(module); + pygobject_register_class(dict, "ArmInstruction", G_TYPE_ARM_INSTRUCTION, py_arm_instruction_type, + Py_BuildValue("(O)", py_arm_instruction_type->tp_base)); + + return true; + +} diff --git a/plugins/pychrysa/arch/arm/instruction.h b/plugins/pychrysa/arch/arm/instruction.h new file mode 100644 index 0000000..daec429 --- /dev/null +++ b/plugins/pychrysa/arch/arm/instruction.h @@ -0,0 +1,42 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * instruction.h - prototypes pour l'équivalent Python du fichier "arch/arm/instruction.h" + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * OpenIDA 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. + * + * OpenIDA 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_ARCH_ARM_INSTRUCTION_H +#define _PLUGINS_PYCHRYSALIDE_ARCH_ARM_INSTRUCTION_H + + +#include <Python.h> +#include <stdbool.h> + + + +/* Fournit un accès à une définition de type à diffuser. */ +PyTypeObject *get_python_arm_instruction_type(void); + +/* Prend en charge l'objet 'pychrysalide.arch.arm.ArmInstruction'. */ +bool register_python_arm_instruction(PyObject *); + + + +#endif /* _PLUGINS_PYCHRYSALIDE_ARCH_ARM_INSTRUCTION_H */ diff --git a/plugins/pychrysa/arch/arm/module.c b/plugins/pychrysa/arch/arm/module.c new file mode 100644 index 0000000..d1d7adc --- /dev/null +++ b/plugins/pychrysa/arch/arm/module.c @@ -0,0 +1,96 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * module.c - intégration du répertoire arm en tant que module + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * OpenIDA 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. + * + * OpenIDA 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 "instruction.h" +#include "processor.h" +#include "v7/module.h" + + + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Ajoute le module 'arm' au module Python. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool add_arch_arm_module_to_python_module(PyObject *super) +{ + bool result; /* Bilan à retourner */ + PyObject *module; /* Sous-module mis en place */ + int ret; /* Bilan d'un appel */ + + static PyModuleDef py_chrysalide_arm_module = { + + .m_base = PyModuleDef_HEAD_INIT, + + .m_name = "pychrysalide.arch.arm", + .m_doc = "Python module for Chrysalide.arch.arm", + + .m_size = -1, + + }; + + result = false; + + module = PyModule_Create(&py_chrysalide_arm_module); + if (module == NULL) return false; + + ret = PyState_AddModule(super, &py_chrysalide_arm_module); + if (ret != 0) goto aaamtpm_exit; + + ret = _PyImport_FixupBuiltin(module, "pychrysalide.arch.arm"); + if (ret != 0) goto aaamtpm_exit; + + Py_INCREF(module); + ret = PyModule_AddObject(super, "arm", module); + if (ret != 0) goto aaamtpm_exit; + + result = true; + + result &= register_python_arm_instruction(module); + result &= register_python_arm_processor(module); + + result &= add_arch_arm_v7_module_to_python_module(module); + + aaamtpm_exit: + + if (!result) + { + printf("something went wrong in %s...\n", __FUNCTION__); + /* ... */ + + } + + return result; + +} diff --git a/plugins/pychrysa/arch/arm/module.h b/plugins/pychrysa/arch/arm/module.h new file mode 100644 index 0000000..eed753f --- /dev/null +++ b/plugins/pychrysa/arch/arm/module.h @@ -0,0 +1,39 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * module.h - prototypes pour l'intégration du répertoire arm en tant que module + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * OpenIDA 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. + * + * OpenIDA 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_ARCH_ARM_MODULE_H +#define _PLUGINS_PYCHRYSALIDE_ARCH_ARM_MODULE_H + + +#include <Python.h> +#include <stdbool.h> + + + +/* Ajoute le module 'arm' au module Python. */ +bool add_arch_arm_module_to_python_module(PyObject *); + + + +#endif /* _PLUGINS_PYCHRYSALIDE_ARCH_ARM_MODULE_H */ diff --git a/plugins/pychrysa/arch/arm/processor.c b/plugins/pychrysa/arch/arm/processor.c new file mode 100644 index 0000000..049dcb3 --- /dev/null +++ b/plugins/pychrysa/arch/arm/processor.c @@ -0,0 +1,120 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * processor.c - équivalent Python du fichier "arch/arm/processor.c" + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * OpenIDA 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. + * + * OpenIDA 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 <arch/arm/processor.h> + + +#include "../processor.h" +#include "../../helpers.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_arm_processor_type(void) +{ + static PyMethodDef py_arm_processor_methods[] = { + { NULL } + }; + + static PyGetSetDef py_arm_processor_getseters[] = { + { NULL } + }; + + static PyTypeObject py_arm_processor_type = { + + PyVarObject_HEAD_INIT(NULL, 0) + + .tp_name = "pychrysalide.arch.arm.ArmProcessor", + .tp_basicsize = sizeof(PyGObject), + + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + + .tp_doc = "PyChrysalide processor for an ARM architecture.", + + .tp_methods = py_arm_processor_methods, + .tp_getset = py_arm_processor_getseters, + + }; + + return &py_arm_processor_type; + +} + + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Prend en charge l'objet 'pychrysalide.arch.arm.ArmProcessor'.* +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool register_python_arm_processor(PyObject *module) +{ + PyTypeObject *py_arm_processor_type; /* Type Python 'BinContent' */ + int ret; /* Bilan d'un appel */ + PyObject *dict; /* Dictionnaire du module */ + + py_arm_processor_type = get_python_arm_processor_type(); + + py_arm_processor_type->tp_base = get_python_arch_processor_type(); + py_arm_processor_type->tp_basicsize = py_arm_processor_type->tp_base->tp_basicsize; + + APPLY_ABSTRACT_FLAG(py_arm_processor_type); + + if (PyType_Ready(py_arm_processor_type) != 0) + return false; + + Py_INCREF(py_arm_processor_type); + ret = PyModule_AddObject(module, "ArmProcessor", (PyObject *)py_arm_processor_type); + if (ret != 0) return false; + + dict = PyModule_GetDict(module); + pygobject_register_class(dict, "ArmProcessor", G_TYPE_ARM_PROCESSOR, py_arm_processor_type, + Py_BuildValue("(O)", py_arm_processor_type->tp_base)); + + return true; + +} diff --git a/plugins/pychrysa/arch/arm/processor.h b/plugins/pychrysa/arch/arm/processor.h new file mode 100644 index 0000000..594f0e6 --- /dev/null +++ b/plugins/pychrysa/arch/arm/processor.h @@ -0,0 +1,42 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * processor.h - prototypes pour l'équivalent Python du fichier "arch/arm/processor.h" + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * OpenIDA 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. + * + * OpenIDA 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_ARCH_ARM_PROCESSOR_H +#define _PLUGINS_PYCHRYSALIDE_ARCH_ARM_PROCESSOR_H + + +#include <Python.h> +#include <stdbool.h> + + + +/* Fournit un accès à une définition de type à diffuser. */ +PyTypeObject *get_python_arm_processor_type(void); + +/* Prend en charge l'objet 'pychrysalide.arch.arm.ArmProcessor'. */ +bool register_python_arm_processor(PyObject *); + + + +#endif /* _PLUGINS_PYCHRYSALIDE_ARCH_ARM_PROCESSOR_H */ diff --git a/plugins/pychrysa/arch/arm/v7/Makefile.am b/plugins/pychrysa/arch/arm/v7/Makefile.am new file mode 100644 index 0000000..d95aff3 --- /dev/null +++ b/plugins/pychrysa/arch/arm/v7/Makefile.am @@ -0,0 +1,16 @@ + +noinst_LTLIBRARIES = libpychrysaarcharmv7.la + +libpychrysaarcharmv7_la_SOURCES = \ + instruction.h instruction.c \ + module.h module.c \ + processor.h processor.c + + +libpychrysaarcharmv7_la_LDFLAGS = + + +AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \ + -I../../../../../src + +AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) diff --git a/plugins/pychrysa/arch/arm/v7/instruction.c b/plugins/pychrysa/arch/arm/v7/instruction.c new file mode 100644 index 0000000..8a19259 --- /dev/null +++ b/plugins/pychrysa/arch/arm/v7/instruction.c @@ -0,0 +1,117 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * instruction.c - équivalent Python du fichier "arch/arm/v7/instruction.c" + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * OpenIDA 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. + * + * OpenIDA 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 <arch/arm/v7/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_armv7_instruction_type(void) +{ + static PyMethodDef py_armv7_instruction_methods[] = { + { NULL } + }; + + static PyGetSetDef py_armv7_instruction_getseters[] = { + { NULL } + }; + + static PyTypeObject py_armv7_instruction_type = { + + PyVarObject_HEAD_INIT(NULL, 0) + + .tp_name = "pychrysalide.arch.arm.v7.ArmV7Instruction", + .tp_basicsize = sizeof(PyGObject), + + .tp_flags = Py_TPFLAGS_DEFAULT, + + .tp_doc = "PyChrysalide instruction for an ARMv7 architecture.", + + .tp_methods = py_armv7_instruction_methods, + .tp_getset = py_armv7_instruction_getseters, + + }; + + return &py_armv7_instruction_type; + +} + + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Prend en charge l'objet 'pychrysalide....arm.ArmInstruction'.* +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool register_python_armv7_instruction(PyObject *module) +{ + PyTypeObject *py_armv7_instruction_type;/* Type Python 'BinContent' */ + int ret; /* Bilan d'un appel */ + PyObject *dict; /* Dictionnaire du module */ + + py_armv7_instruction_type = get_python_armv7_instruction_type(); + + py_armv7_instruction_type->tp_base = get_python_arm_instruction_type(); + py_armv7_instruction_type->tp_basicsize = py_armv7_instruction_type->tp_base->tp_basicsize; + + if (PyType_Ready(py_armv7_instruction_type) != 0) + return false; + + Py_INCREF(py_armv7_instruction_type); + ret = PyModule_AddObject(module, "ArmV7Instruction", (PyObject *)py_armv7_instruction_type); + if (ret != 0) return false; + + dict = PyModule_GetDict(module); + pygobject_register_class(dict, "ArmV7Instruction", G_TYPE_ARMV7_INSTRUCTION, py_armv7_instruction_type, + Py_BuildValue("(O)", py_armv7_instruction_type->tp_base)); + + return true; + +} diff --git a/plugins/pychrysa/arch/arm/v7/instruction.h b/plugins/pychrysa/arch/arm/v7/instruction.h new file mode 100644 index 0000000..9eac361 --- /dev/null +++ b/plugins/pychrysa/arch/arm/v7/instruction.h @@ -0,0 +1,42 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * instruction.h - prototypes pour l'équivalent Python du fichier "arch/arm/v7/instruction.h" + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * OpenIDA 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. + * + * OpenIDA 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_ARCH_ARM_V7_INSTRUCTION_H +#define _PLUGINS_PYCHRYSALIDE_ARCH_ARM_V7_INSTRUCTION_H + + +#include <Python.h> +#include <stdbool.h> + + + +/* Fournit un accès à une définition de type à diffuser. */ +PyTypeObject *get_python_armv7_instruction_type(void); + +/* Prend en charge l'objet 'pychrysalide.arch.arm.v7.ArmV7Instruction'. */ +bool register_python_armv7_instruction(PyObject *); + + + +#endif /* _PLUGINS_PYCHRYSALIDE_ARCH_ARM_V7_INSTRUCTION_H */ diff --git a/plugins/pychrysa/arch/arm/v7/module.c b/plugins/pychrysa/arch/arm/v7/module.c new file mode 100644 index 0000000..7c0aabf --- /dev/null +++ b/plugins/pychrysa/arch/arm/v7/module.c @@ -0,0 +1,93 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * module.c - intégration du répertoire v7 en tant que module + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * OpenIDA 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. + * + * OpenIDA 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 "instruction.h" +#include "processor.h" + + + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Ajoute le module 'arm' au module Python. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool add_arch_arm_v7_module_to_python_module(PyObject *super) +{ + bool result; /* Bilan à retourner */ + PyObject *module; /* Sous-module mis en place */ + int ret; /* Bilan d'un appel */ + + static PyModuleDef py_chrysalide_v7_module = { + + .m_base = PyModuleDef_HEAD_INIT, + + .m_name = "pychrysalide.arch.arm.v7", + .m_doc = "Python module for Chrysalide.arch.arm.v7", + + .m_size = -1, + + }; + + result = false; + + module = PyModule_Create(&py_chrysalide_v7_module); + if (module == NULL) return false; + + ret = PyState_AddModule(super, &py_chrysalide_v7_module); + if (ret != 0) goto aaamtpm_exit; + + ret = _PyImport_FixupBuiltin(module, "pychrysalide.arch.arm.v7"); + if (ret != 0) goto aaamtpm_exit; + + Py_INCREF(module); + ret = PyModule_AddObject(super, "v7", module); + if (ret != 0) goto aaamtpm_exit; + + result = true; + + result &= register_python_armv7_instruction(module); + result &= register_python_armv7_processor(module); + + aaamtpm_exit: + + if (!result) + { + printf("something went wrong in %s...\n", __FUNCTION__); + /* ... */ + + } + + return result; + +} diff --git a/plugins/pychrysa/arch/arm/v7/module.h b/plugins/pychrysa/arch/arm/v7/module.h new file mode 100644 index 0000000..61ad126 --- /dev/null +++ b/plugins/pychrysa/arch/arm/v7/module.h @@ -0,0 +1,39 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * module.h - prototypes pour l'intégration du répertoire v7 en tant que module + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * OpenIDA 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. + * + * OpenIDA 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_ARCH_ARM_V7_MODULE_H +#define _PLUGINS_PYCHRYSALIDE_ARCH_ARM_V7_MODULE_H + + +#include <Python.h> +#include <stdbool.h> + + + +/* Ajoute le module 'arm' au module Python. */ +bool add_arch_arm_v7_module_to_python_module(PyObject *); + + + +#endif /* _PLUGINS_PYCHRYSALIDE_ARCH_ARM_V7_MODULE_H */ diff --git a/plugins/pychrysa/arch/arm/v7/processor.c b/plugins/pychrysa/arch/arm/v7/processor.c new file mode 100644 index 0000000..1844066 --- /dev/null +++ b/plugins/pychrysa/arch/arm/v7/processor.c @@ -0,0 +1,117 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * processor.c - équivalent Python du fichier "arch/arm/v7/processor.c" + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * OpenIDA 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. + * + * OpenIDA 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 <arch/arm/v7/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_armv7_processor_type(void) +{ + static PyMethodDef py_armv7_processor_methods[] = { + { NULL } + }; + + static PyGetSetDef py_armv7_processor_getseters[] = { + { NULL } + }; + + static PyTypeObject py_armv7_processor_type = { + + PyVarObject_HEAD_INIT(NULL, 0) + + .tp_name = "pychrysalide.arch.arm.v7.ArmV7Processor", + .tp_basicsize = sizeof(PyGObject), + + .tp_flags = Py_TPFLAGS_DEFAULT, + + .tp_doc = "PyChrysalide processor for an ARMv7 architecture.", + + .tp_methods = py_armv7_processor_methods, + .tp_getset = py_armv7_processor_getseters, + + }; + + return &py_armv7_processor_type; + +} + + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Prend en charge l'objet 'pychrysalide.arch.arm.ArmProcessor'.* +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool register_python_armv7_processor(PyObject *module) +{ + PyTypeObject *py_armv7_processor_type; /* Type Python 'BinContent' */ + int ret; /* Bilan d'un appel */ + PyObject *dict; /* Dictionnaire du module */ + + py_armv7_processor_type = get_python_armv7_processor_type(); + + py_armv7_processor_type->tp_base = get_python_arm_processor_type(); + py_armv7_processor_type->tp_basicsize = py_armv7_processor_type->tp_base->tp_basicsize; + + if (PyType_Ready(py_armv7_processor_type) != 0) + return false; + + Py_INCREF(py_armv7_processor_type); + ret = PyModule_AddObject(module, "ArmV7Processor", (PyObject *)py_armv7_processor_type); + if (ret != 0) return false; + + dict = PyModule_GetDict(module); + pygobject_register_class(dict, "ArmV7Processor", G_TYPE_ARMV7_PROCESSOR, py_armv7_processor_type, + Py_BuildValue("(O)", py_armv7_processor_type->tp_base)); + + return true; + +} diff --git a/plugins/pychrysa/arch/arm/v7/processor.h b/plugins/pychrysa/arch/arm/v7/processor.h new file mode 100644 index 0000000..268a025 --- /dev/null +++ b/plugins/pychrysa/arch/arm/v7/processor.h @@ -0,0 +1,42 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * processor.h - prototypes pour l'équivalent Python du fichier "arch/arm/v7/processor.h" + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * OpenIDA 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. + * + * OpenIDA 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_ARCH_ARM_V7_PROCESSOR_H +#define _PLUGINS_PYCHRYSALIDE_ARCH_ARM_V7_PROCESSOR_H + + +#include <Python.h> +#include <stdbool.h> + + + +/* Fournit un accès à une définition de type à diffuser. */ +PyTypeObject *get_python_armv7_processor_type(void); + +/* Prend en charge l'objet 'pychrysalide.arch.arm.v7.ArmV7Processor'. */ +bool register_python_armv7_processor(PyObject *); + + + +#endif /* _PLUGINS_PYCHRYSALIDE_ARCH_ARM_V7_PROCESSOR_H */ |