summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/analysis/routine.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-01-16 19:02:56 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-01-16 19:02:56 (GMT)
commit9da8f8b37e3edebc917b4e223dd2447cd7cbc818 (patch)
tree3f330b13e7ca2a0a163882be3043ca9571f25211 /plugins/pychrysa/analysis/routine.c
parenteb9b7fd76451db5c9f07a800c0394480e4b88c9c (diff)
Changed the Python bindings source directory and updated code.
Diffstat (limited to 'plugins/pychrysa/analysis/routine.c')
-rw-r--r--plugins/pychrysa/analysis/routine.c295
1 files changed, 0 insertions, 295 deletions
diff --git a/plugins/pychrysa/analysis/routine.c b/plugins/pychrysa/analysis/routine.c
deleted file mode 100644
index 37f36a7..0000000
--- a/plugins/pychrysa/analysis/routine.c
+++ /dev/null
@@ -1,295 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * routine.c - équivalent Python du fichier "analysis/routine.c"
- *
- * Copyright (C) 2013-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 "routine.h"
-
-
-#include <string.h>
-#include <pygobject.h>
-
-
-#include <i18n.h>
-
-
-#include <analysis/block.h>
-#include <analysis/routine.h>
-
-
-#include "block.h"
-#include "../helpers.h"
-#include "../format/symbol.h"
-
-
-
-/* Crée un nouvel objet Python de type 'BinRoutine'. */
-static PyObject *py_binary_routine_new(PyTypeObject *, PyObject *, PyObject *);
-
-/* Fournit le nom humain d'une routine. */
-static PyObject *py_binary_routine_get_name(PyObject *, void *);
-
-/* Définit le nom humain d'une routine. */
-static int py_binary_routine_set_name(PyObject *, PyObject *, void *);
-
-/* Fournit les blocs basiques de la routine. */
-static PyObject *py_binary_routine_get_basic_blocks(PyObject *, void *);
-
-
-
-/******************************************************************************
-* *
-* 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 'BinaryRoutine'. *
-* *
-* Retour : Instance Python mise en place. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static PyObject *py_binary_routine_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- PyObject *result; /* Création à retourner */
-
- result = pygobject_new(G_OBJECT(g_binary_routine_new()));
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : self = objet Python concerné par l'appel. *
-* closure = non utilisé ici. *
-* *
-* Description : Fournit le nom humain d'une routine. *
-* *
-* Retour : Désignation humainement lisible ou None si non définie. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static PyObject *py_binary_routine_get_name(PyObject *self, void *closure)
-{
- PyObject *result; /* Valeur à retourner */
- GBinRoutine *routine; /* Elément à consulter */
- const char *name; /* Désignation courante */
-
- routine = G_BIN_ROUTINE(pygobject_get(self));
- name = g_binary_routine_get_name(routine);
-
- if (name != NULL)
- result = PyUnicode_FromString(name);
- else
- {
- result = Py_None;
- Py_INCREF(result);
- }
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : self = objet Python concerné par l'appel. *
-* value = valeur fournie à intégrer ou prendre en compte. *
-* closure = non utilisé ici. *
-* *
-* Description : Définit le nom humain d'une routine. *
-* *
-* Retour : Bilan de l'opération pour Python. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static int py_binary_routine_set_name(PyObject *self, PyObject *value, void *closure)
-{
- GBinRoutine *routine; /* Elément à consulter */
-
- if (!PyUnicode_Check(value) && value != Py_None)
- {
- PyErr_SetString(PyExc_TypeError, _("The attribute value must be a string."));
- return -1;
- }
-
- routine = G_BIN_ROUTINE(pygobject_get(self));
-
- if (!PyUnicode_Check(value))
- g_binary_routine_set_name(routine, strdup(PyUnicode_DATA(value)));
- else
- g_binary_routine_set_name(routine, NULL);
-
- return 0;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : self = classe représentant une routine binaire. *
-* closure = adresse non utilisée ici. *
-* *
-* Description : Fournit les blocs basiques de la routine. *
-* *
-* Retour : Ensemble de blocs déterminés via les instructions. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static PyObject *py_binary_routine_get_basic_blocks(PyObject *self, void *closure)
-{
- PyObject *result; /* Eléments à retourner */
- GBinRoutine *routine; /* Version native */
- GBlockList *blocks; /* Blocs basiques de routine */
-
- routine = G_BIN_ROUTINE(pygobject_get(self));
- blocks = g_binary_routine_get_basic_blocks(routine);
-
- result = pygobject_new(G_OBJECT(blocks));
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : self = objet Python concerné par l'appel. *
-* value = valeur fournie à intégrer ou prendre en compte. *
-* closure = non utilisé ici. *
-* *
-* Description : Définit les blocs basiques de la routine. *
-* *
-* Retour : Bilan de l'opération pour Python. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static int py_binary_routine_set_basic_blocks(PyObject *self, PyObject *value, void *closure)
-{
- GBinRoutine *routine; /* Elément à consulter */
- int ret; /* Bilan de lecture des args. */
- GBlockList *blocks; /* Blocs basiques à intégrer */
-
- ret = PyObject_IsInstance(value, (PyObject *)get_python_instr_block_type());
- if (!ret) return -1;
-
- routine = G_BIN_ROUTINE(pygobject_get(self));
- blocks = G_BLOCK_LIST(pygobject_get(value));
-
- g_binary_routine_set_basic_blocks(routine, blocks);
-
- return 0;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : - *
-* *
-* Description : Fournit un accès à une définition de type à diffuser. *
-* *
-* Retour : Définition d'objet pour Python. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-PyTypeObject *get_python_binary_routine_type(void)
-{
- static PyMethodDef py_binary_routine_methods[] = {
- { NULL }
- };
-
- static PyGetSetDef py_binary_routine_getseters[] = {
- {
- "name", py_binary_routine_get_name, py_binary_routine_set_name,
- "Name of the current routine.", NULL
- },
- {
- "basic_blocks", py_binary_routine_get_basic_blocks, py_binary_routine_set_basic_blocks,
- "Basic blocks of the binary routine.", NULL
- },
- { NULL }
- };
-
- static PyTypeObject py_binary_routine_type = {
-
- PyVarObject_HEAD_INIT(NULL, 0)
-
- .tp_name = "pychrysalide.analysis.BinRoutine",
-
- .tp_flags = Py_TPFLAGS_DEFAULT,
-
- .tp_doc = "PyChrysalide binary routine",
-
- .tp_methods = py_binary_routine_methods,
- .tp_getset = py_binary_routine_getseters,
- .tp_new = (newfunc)py_binary_routine_new
-
- };
-
- return &py_binary_routine_type;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : module = module dont la définition est à compléter. *
-* *
-* Description : Prend en charge l'objet 'pychrysalide.analysis.BinRoutine'. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-bool register_python_binary_routine(PyObject *module)
-{
- PyTypeObject *py_binary_routine_type; /* Type Python 'BinRoutine' */
- PyObject *dict; /* Dictionnaire du module */
-
- py_binary_routine_type = get_python_binary_routine_type();
-
- dict = PyModule_GetDict(module);
-
- if (!register_class_for_pygobject(dict, G_TYPE_BIN_ROUTINE,
- py_binary_routine_type, get_python_binary_symbol_type()))
- return false;
-
- return true;
-
-}