diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2017-12-02 11:04:35 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2017-12-02 11:04:35 (GMT) |
commit | 2c988d3ec52cc4c949a35aca7ef335dac773df92 (patch) | |
tree | fe650d2fc8ddceb606abdf0d2e14e5ef6596be82 /plugins/arm/python | |
parent | 23abef53590bf3dd6f88ff4dbe81e306abfa4386 (diff) |
Created a plugin for the ARM support.
Diffstat (limited to 'plugins/arm/python')
-rw-r--r-- | plugins/arm/python/Makefile.am | 20 | ||||
-rw-r--r-- | plugins/arm/python/instruction.c | 111 | ||||
-rw-r--r-- | plugins/arm/python/instruction.h | 42 | ||||
-rw-r--r-- | plugins/arm/python/module.c | 105 | ||||
-rw-r--r-- | plugins/arm/python/module.h | 38 | ||||
-rw-r--r-- | plugins/arm/python/processor.c | 108 | ||||
-rw-r--r-- | plugins/arm/python/processor.h | 42 | ||||
-rw-r--r-- | plugins/arm/python/v7/Makefile.am | 16 | ||||
-rw-r--r-- | plugins/arm/python/v7/instruction.c | 109 | ||||
-rw-r--r-- | plugins/arm/python/v7/instruction.h | 42 | ||||
-rw-r--r-- | plugins/arm/python/v7/module.c | 93 | ||||
-rw-r--r-- | plugins/arm/python/v7/module.h | 39 | ||||
-rw-r--r-- | plugins/arm/python/v7/processor.c | 108 | ||||
-rw-r--r-- | plugins/arm/python/v7/processor.h | 42 |
14 files changed, 915 insertions, 0 deletions
diff --git a/plugins/arm/python/Makefile.am b/plugins/arm/python/Makefile.am new file mode 100644 index 0000000..63bc7be --- /dev/null +++ b/plugins/arm/python/Makefile.am @@ -0,0 +1,20 @@ + +noinst_LTLIBRARIES = libarmpython.la + +libarmpython_la_SOURCES = \ + instruction.h instruction.c \ + module.h module.c \ + processor.h processor.c + +libarmpython_la_LIBADD = \ + v7/libarmpythonv7.la + +libarmpython_la_LDFLAGS = + + +AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \ + -I$(top_srcdir)/src + +AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) + +SUBDIRS = v7 diff --git a/plugins/arm/python/instruction.c b/plugins/arm/python/instruction.c new file mode 100644 index 0000000..bbcde50 --- /dev/null +++ b/plugins/arm/python/instruction.c @@ -0,0 +1,111 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * instruction.c - équivalent Python du fichier "arch/arm/instruction.c" + * + * 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 "instruction.h" + + +#include <pygobject.h> + + +#include <plugins/pychrysa/helpers.h> +#include <plugins/pychrysa/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_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' */ + PyObject *dict; /* Dictionnaire du module */ + + py_arm_instruction_type = get_python_arm_instruction_type(); + + APPLY_ABSTRACT_FLAG(py_arm_instruction_type); + + dict = PyModule_GetDict(module); + + if (!register_class_for_pygobject(dict, G_TYPE_ARM_INSTRUCTION, + py_arm_instruction_type, get_python_arch_instruction_type())) + return false; + + return true; + +} diff --git a/plugins/arm/python/instruction.h b/plugins/arm/python/instruction.h new file mode 100644 index 0000000..fec82bb --- /dev/null +++ b/plugins/arm/python/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-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 + */ + + +#ifndef _PLUGINS_ARM_PYTHON_INSTRUCTION_H +#define _PLUGINS_ARM_PYTHON_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_ARM_PYTHON_INSTRUCTION_H */ diff --git a/plugins/arm/python/module.c b/plugins/arm/python/module.c new file mode 100644 index 0000000..6d71afe --- /dev/null +++ b/plugins/arm/python/module.c @@ -0,0 +1,105 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * module.c - intégration du répertoire arm 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/pychrysa/access.h> + + +#include "instruction.h" +#include "processor.h" +#include "v7/module.h" + + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Ajoute le module 'arm' au module Python. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool add_arch_arm_module_to_python_module(void) +{ + bool result; /* Bilan à retourner */ + PyObject *super; /* Module à compléter */ + 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; + + super = get_access_to_python_module("pychrysalide.arch"); + + 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/arm/python/module.h b/plugins/arm/python/module.h new file mode 100644 index 0000000..aeacd3d --- /dev/null +++ b/plugins/arm/python/module.h @@ -0,0 +1,38 @@ + +/* 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-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 + */ + + +#ifndef _PLUGINS_ARM_PYTHON_MODULE_H +#define _PLUGINS_ARM_PYTHON_MODULE_H + + +#include <stdbool.h> + + + +/* Ajoute le module 'arm' au module Python. */ +bool add_arch_arm_module_to_python_module(void); + + + +#endif /* _PLUGINS_ARM_PYTHON_MODULE_H */ diff --git a/plugins/arm/python/processor.c b/plugins/arm/python/processor.c new file mode 100644 index 0000000..818809d --- /dev/null +++ b/plugins/arm/python/processor.c @@ -0,0 +1,108 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * processor.c - équivalent Python du fichier "arch/arm/processor.c" + * + * 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 "processor.h" + + +#include <pygobject.h> + + +#include <plugins/pychrysa/helpers.h> +#include <plugins/pychrysa/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_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' */ + PyObject *dict; /* Dictionnaire du module */ + + py_arm_processor_type = get_python_arm_processor_type(); + + dict = PyModule_GetDict(module); + + if (!register_class_for_pygobject(dict, G_TYPE_ARM_PROCESSOR, py_arm_processor_type, get_python_arch_processor_type())) + return false; + + return true; + +} diff --git a/plugins/arm/python/processor.h b/plugins/arm/python/processor.h new file mode 100644 index 0000000..36512ff --- /dev/null +++ b/plugins/arm/python/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-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 + */ + + +#ifndef _PLUGINS_ARM_PYTHON_PROCESSOR_H +#define _PLUGINS_ARM_PYTHON_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_ARM_PYTHON_PROCESSOR_H */ diff --git a/plugins/arm/python/v7/Makefile.am b/plugins/arm/python/v7/Makefile.am new file mode 100644 index 0000000..f4f6df4 --- /dev/null +++ b/plugins/arm/python/v7/Makefile.am @@ -0,0 +1,16 @@ + +noinst_LTLIBRARIES = libarmpythonv7.la + +libarmpythonv7_la_SOURCES = \ + instruction.h instruction.c \ + module.h module.c \ + processor.h processor.c + + +libarmpythonv7_la_LDFLAGS = + + +AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \ + -I$(top_srcdir)/src + +AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) diff --git a/plugins/arm/python/v7/instruction.c b/plugins/arm/python/v7/instruction.c new file mode 100644 index 0000000..25a49bb --- /dev/null +++ b/plugins/arm/python/v7/instruction.c @@ -0,0 +1,109 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * instruction.c - équivalent Python du fichier "arch/arm/v7/instruction.c" + * + * 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 "instruction.h" + + +#include <pygobject.h> + + +#include <plugins/pychrysa/helpers.h> + + +#include "../instruction.h" +#include "../../v7/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' */ + PyObject *dict; /* Dictionnaire du module */ + + py_armv7_instruction_type = get_python_armv7_instruction_type(); + + dict = PyModule_GetDict(module); + + if (!register_class_for_pygobject(dict, G_TYPE_ARMV7_INSTRUCTION, + py_armv7_instruction_type, get_python_arm_instruction_type())) + return false; + + return true; + +} diff --git a/plugins/arm/python/v7/instruction.h b/plugins/arm/python/v7/instruction.h new file mode 100644 index 0000000..a1a04be --- /dev/null +++ b/plugins/arm/python/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-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 + */ + + +#ifndef _PLUGINS_ARM_PYTHON_V7_INSTRUCTION_H +#define _PLUGINS_ARM_PYTHON_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_ARM_PYTHON_V7_INSTRUCTION_H */ diff --git a/plugins/arm/python/v7/module.c b/plugins/arm/python/v7/module.c new file mode 100644 index 0000000..9188ae4 --- /dev/null +++ b/plugins/arm/python/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-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 "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/arm/python/v7/module.h b/plugins/arm/python/v7/module.h new file mode 100644 index 0000000..fc5ba8c --- /dev/null +++ b/plugins/arm/python/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-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 + */ + + +#ifndef _PLUGINS_ARM_PYTHON_V7_MODULE_H +#define _PLUGINS_ARM_PYTHON_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_ARM_PYTHON_V7_MODULE_H */ diff --git a/plugins/arm/python/v7/processor.c b/plugins/arm/python/v7/processor.c new file mode 100644 index 0000000..9a0911c --- /dev/null +++ b/plugins/arm/python/v7/processor.c @@ -0,0 +1,108 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * processor.c - équivalent Python du fichier "arch/arm/v7/processor.c" + * + * 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 "processor.h" + + +#include <pygobject.h> + + +#include <plugins/pychrysa/helpers.h> + + +#include "../processor.h" +#include "../../v7/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' */ + PyObject *dict; /* Dictionnaire du module */ + + py_armv7_processor_type = get_python_armv7_processor_type(); + + dict = PyModule_GetDict(module); + + if (!register_class_for_pygobject(dict, G_TYPE_ARMV7_PROCESSOR, py_armv7_processor_type, get_python_arm_processor_type())) + return false; + + return true; + +} diff --git a/plugins/arm/python/v7/processor.h b/plugins/arm/python/v7/processor.h new file mode 100644 index 0000000..3226abd --- /dev/null +++ b/plugins/arm/python/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-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 + */ + + +#ifndef _PLUGINS_ARM_PYTHON_V7_PROCESSOR_H +#define _PLUGINS_ARM_PYTHON_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_ARM_PYTHON_V7_PROCESSOR_H */ |