diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2012-03-17 20:29:47 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2012-03-17 20:29:47 (GMT) |
commit | bbad297e902022ecac9fab21c01dc109560db8eb (patch) | |
tree | 6d9703e7dda8c0a61b0a3a015be89612df3bf198 /plugins/pyoida/arch/processor.c | |
parent | d1f5881c1f4ad53781fdadfe5ce6cac24cee3bab (diff) |
Created the 'pychrysa' Python plugin from the 'pyoida' one.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@240 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'plugins/pyoida/arch/processor.c')
-rw-r--r-- | plugins/pyoida/arch/processor.c | 314 |
1 files changed, 0 insertions, 314 deletions
diff --git a/plugins/pyoida/arch/processor.c b/plugins/pyoida/arch/processor.c deleted file mode 100644 index 0a3fe95..0000000 --- a/plugins/pyoida/arch/processor.c +++ /dev/null @@ -1,314 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * processor.h - prototypes pour l'équivalent Python du fichier "arch/processor.h" - * - * Copyright (C) 2010 Cyrille Bagard - * - * This file is part of OpenIDA. - * - * 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 "../../../src/arch/processor.h" - - - -/* ------------------------- TYPAGE DES ENUMERATIONS PYTHON ------------------------- */ - - -/* Définit les constantes pour les types de processeur. */ -bool py_arch_processor_type_define_constants(PyObject *); - -/* Ajoute l'objet 'arch.processor.ArchProcessorType' au module. */ -bool add_arch_processor_type_to_python_module(PyObject *); - - - -/* ------------------------- PARTIE STATIQUE DE PROCESSEURS ------------------------- */ - - - - - - - -/* Classe 'analysis.roptions' pour Python */ -typedef struct _py_processor -{ - PyObject_HEAD - -} py_processor; - - - - - - - - - - -/* ---------------------------------------------------------------------------------- */ -/* TYPAGE DES ENUMERATIONS PYTHON */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -* * -* Paramètres : dict = dictionnaire à compléter. * -* * -* Description : Définit les constantes pour les types de processeur. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool py_arch_processor_type_define_constants(PyObject *dict) -{ - int ret; /* Bilan d'un ajout */ - - ret = PyDict_SetItemString(dict, "APT_JVM", PyInt_FromLong(APT_JVM)); - if (ret == -1) return false; - - ret = PyDict_SetItemString(dict, "APT_MIPS", PyInt_FromLong(APT_MIPS)); - if (ret == -1) return false; - - ret = PyDict_SetItemString(dict, "APT_386", PyInt_FromLong(APT_386)); - if (ret == -1) return false; - - ret = PyDict_SetItemString(dict, "APT_COUNT", PyInt_FromLong(APT_COUNT)); - if (ret == -1) return false; - - return true; - -} -PyObject *__test; - -/****************************************************************************** -* * -* Paramètres : module = module dont la définition est à compléter. * -* * -* Description : Ajoute l'objet 'arch.processor.ArchProcessorType' au module. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool add_arch_processor_type_to_python_module(PyObject *module) -{ - int ret; /* Bilan d'un appel */ - - static PyTypeObject py_arch_processor_type_type = { - - PyObject_HEAD_INIT(NULL) - - .tp_name = "pyoida.arch.processor.ArchProcessorType", - - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - - .tp_doc = "PyOIDA version of the ArchProcessorType enumeration", - - }; - - if (PyType_Ready(&py_arch_processor_type_type) < 0) - return false; - - py_arch_processor_type_define_constants(py_arch_processor_type_type.tp_dict); - - Py_INCREF(&py_arch_processor_type_type); - ret = PyModule_AddObject(module, "ArchProcessorType", (PyObject *)&py_arch_processor_type_type); - - __test = &py_arch_processor_type_type; - - return (ret == 0); - -} - - - -/* ---------------------------------------------------------------------------------- */ -/* PARTIE STATIQUE DE PROCESSEURS */ -/* ---------------------------------------------------------------------------------- */ - - - - - - - - - - - - - - - - - - - - - - - - - -/* ---------------------------------------------------------------------------------- */ -/* PARTIE GRAPHIQUE DES [DE]CHARGEMENTS */ -/* ---------------------------------------------------------------------------------- */ - - - - - - - - - -/* Crée un nouvel objet Python de type 'py_processor'. */ -static PyObject *py_processor_new(PyTypeObject *, PyObject *, PyObject *); - - - -/****************************************************************************** -* * -* Paramètres : type = type de l'objet à instancier. * -* args = arguments fournis à l'appel. * -* kwds = arguments de type key=val fournis. * -* * -* Description : Crée un nouvel objet Python de type 'py_processor'. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static PyObject *py_processor_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - py_processor *result; /* Instance à retourner */ - - result = (py_processor *)type->tp_alloc(type, 0); - - return (PyObject *)result; - -} - - - - - - - - - - -static PyObject *util_FromImport(const char *name, const char *from_item) -{ - PyObject *from_list; - PyObject *module; - PyObject *item; - - /* Make the from list. */ - from_list = PyList_New(1); - PyList_SetItem(from_list, 0, PyString_FromString(from_item)); - - /* Attempt the import, with const correctness removed. */ - module = PyImport_ImportModuleEx((char *)name, NULL, NULL, from_list); - Py_DECREF(from_list); - if (!module) - { - return NULL; - } - - /* Get the from_item from the module. */ - item = PyObject_GetAttrString(module, (char *)from_item); - Py_DECREF(module); - - return item; -} - - - - - - -/****************************************************************************** -* * -* Paramètres : module = module dont la définition est à compléter. * -* * -* Description : Ajoute l'objet 'analysis.roptions' au module Python. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool add_arch_processor_to_python_module(PyObject *module) -{ - bool result; /* Bilan à retourner */ - int ret; /* Bilan d'un appel */ - - static PyMethodDef py_processor_methods[] = { - { NULL } - }; - - static PyGetSetDef py_processor_getset[] = { - { NULL } - }; - - static PyTypeObject py_processor_type = { - - PyObject_HEAD_INIT(NULL) - - .tp_name = "pyoida.arch.Processor", - .tp_basicsize = sizeof(py_processor), - - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - - .tp_doc = "PyOIDA processor for a given architecture", - - .tp_methods = py_processor_methods, - .tp_getset = py_processor_getset, - .tp_new = (newfunc)py_processor_new - - }; - - if (PyType_Ready(&py_processor_type) < 0) - return false; - - //printf("ret import = %p\n", PyImport_ImportModule("pyoida.arch.processor.ArchProcessorType")); - - - - Py_INCREF(&py_processor_type); - ret = PyModule_AddObject(module, "Processor", (PyObject *)&py_processor_type); - - result = add_arch_processor_type_to_python_module(module); - - - return (ret == 0); - -} |