summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide')
-rw-r--r--plugins/pychrysalide/core/Makefile.am1
-rw-r--r--plugins/pychrysalide/core/formats.c201
-rw-r--r--plugins/pychrysalide/core/formats.h42
-rw-r--r--plugins/pychrysalide/core/module.c2
-rw-r--r--plugins/pychrysalide/plugin.c138
5 files changed, 0 insertions, 384 deletions
diff --git a/plugins/pychrysalide/core/Makefile.am b/plugins/pychrysalide/core/Makefile.am
index 9e467ff..b431dcc 100644
--- a/plugins/pychrysalide/core/Makefile.am
+++ b/plugins/pychrysalide/core/Makefile.am
@@ -3,7 +3,6 @@ noinst_LTLIBRARIES = libpychrysacore.la
libpychrysacore_la_SOURCES = \
demanglers.h demanglers.c \
- formats.h formats.c \
global.h global.c \
logs.h logs.c \
module.h module.c \
diff --git a/plugins/pychrysalide/core/formats.c b/plugins/pychrysalide/core/formats.c
deleted file mode 100644
index f11bb46..0000000
--- a/plugins/pychrysalide/core/formats.c
+++ /dev/null
@@ -1,201 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * formats.c - équivalent Python du fichier "core/formats.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 "formats.h"
-
-
-#include <pygobject.h>
-
-
-#include <core/formats.h>
-
-
-#include "../access.h"
-#include "../helpers.h"
-
-
-
-/* Fournit le nom humain du format binaire visé. */
-static PyObject *py_formats_get_binary_format_name(PyObject *, PyObject *);
-
-/* Définit les constantes pour les paramètres. */
-static bool py_formats_define_constants(PyTypeObject *);
-
-
-
-/******************************************************************************
-* *
-* Paramètres : self = NULL car méthode statique. *
-* args = non utilisé ici. *
-* *
-* Description : Fournit le nom humain du format binaire visé. *
-* *
-* Retour : Désignation humaine trouvée ou None. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static PyObject *py_formats_get_binary_format_name(PyObject *self, PyObject *args)
-{
- PyObject *result; /* Désignation à retourner */
- const char *key; /* Nom court du format */
- int ret; /* Bilan de lecture des args. */
- const char *name; /* Désignation humaine */
-
- ret = PyArg_ParseTuple(args, "s", &key);
- if (!ret) return NULL;
-
- name = get_binary_format_name(key);
-
- if (name != NULL)
- result = PyUnicode_FromString(name);
-
- else
- {
- result = Py_None;
- Py_INCREF(result);
- }
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : - *
-* *
-* Description : Fournit un accès à une définition de type à diffuser. *
-* *
-* Retour : Définition d'objet pour Python. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-PyTypeObject *get_python_formats_type(void)
-{
- static PyMethodDef py_formats_methods[] = {
-
- { "get_binary_format_name", py_formats_get_binary_format_name,
- METH_VARARGS | METH_STATIC,
- "get_binary_format_name(key, /)\n--\n\nGive access to the main configuration of Chrysalide."
- },
- { NULL }
-
- };
-
- static PyTypeObject py_formats_type = {
-
- PyVarObject_HEAD_INIT(NULL, 0)
-
- .tp_name = "pychrysalide.core.formats",
- .tp_basicsize = sizeof(PyObject),
-
- .tp_flags = Py_TPFLAGS_DEFAULT,
-
- .tp_doc = "Access to the code formats",
-
- .tp_methods = py_formats_methods
-
- };
-
- return &py_formats_type;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : obj_type = type dont le dictionnaire est à compléter. *
-* *
-* Description : Définit les constantes pour les paramètres. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool py_formats_define_constants(PyTypeObject *obj_type)
-{
- bool result; /* Bilan à retourner */
-
- result = true;
-
- result &= PyDict_AddIntMacro(obj_type, FMS_MATCHED);
- result &= PyDict_AddIntMacro(obj_type, FMS_FORWARDED);
- result &= PyDict_AddIntMacro(obj_type, FMS_UNKNOWN);
-
- result &= PyDict_AddIntMacro(obj_type, FMS_COUNT);
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : module = module dont la définition est à compléter. *
-* *
-* Description : Prend en charge l'objet 'pychrysalide.core.formats'. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-bool ensure_python_formats_is_registered(void)
-{
- PyTypeObject *type; /* Type Python pour 'formats' */
- PyObject *module; /* Module à recompléter */
- int ret; /* Bilan d'un appel */
-
- type = get_python_formats_type();
-
- if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
- {
- type->tp_new = PyType_GenericNew;
-
- if (PyType_Ready(type) != 0)
- return false;
-
- if (!py_formats_define_constants(type))
- return false;
-
- module = get_access_to_python_module("pychrysalide.core");
-
- Py_INCREF(type);
- ret = PyModule_AddObject(module, "formats", (PyObject *)type);
-
- if (ret != 0)
- return false;
-
- }
-
- return true;
-
-}
diff --git a/plugins/pychrysalide/core/formats.h b/plugins/pychrysalide/core/formats.h
deleted file mode 100644
index 55d948a..0000000
--- a/plugins/pychrysalide/core/formats.h
+++ /dev/null
@@ -1,42 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * formats.h - prototypes pour l'équivalent Python du fichier "core/formats.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_PYCHRYSALIDE_CORE_FORMATS_H
-#define _PLUGINS_PYCHRYSALIDE_CORE_FORMATS_H
-
-
-#include <Python.h>
-#include <stdbool.h>
-
-
-
-/* Fournit un accès à une définition de type à diffuser. */
-PyTypeObject *get_python_formats_type(void);
-
-/* Prend en charge l'objet 'pychrysalide.core.formats'. */
-bool ensure_python_formats_is_registered(void);
-
-
-
-#endif /* _PLUGINS_PYCHRYSALIDE_CORE_FORMATS_H */
diff --git a/plugins/pychrysalide/core/module.c b/plugins/pychrysalide/core/module.c
index 6171e18..71fa508 100644
--- a/plugins/pychrysalide/core/module.c
+++ b/plugins/pychrysalide/core/module.c
@@ -29,7 +29,6 @@
#include "demanglers.h"
-#include "formats.h"
#include "global.h"
#include "logs.h"
#include "params.h"
@@ -93,7 +92,6 @@ bool populate_core_module(void)
result = true;
if (result) result = ensure_python_demanglers_is_registered();
- if (result) result = ensure_python_formats_is_registered();
if (result) result = ensure_python_global_is_registered();
if (result) result = ensure_python_logs_is_registered();
if (result) result = ensure_python_params_is_registered();
diff --git a/plugins/pychrysalide/plugin.c b/plugins/pychrysalide/plugin.c
index b957eff..321fda9 100644
--- a/plugins/pychrysalide/plugin.c
+++ b/plugins/pychrysalide/plugin.c
@@ -32,8 +32,6 @@
#include <common/extstr.h>
-#include "../../src/core/formats.h"
-//#include <core/formats.h>
#include <plugins/plugin-int.h>
@@ -88,9 +86,6 @@ static bool g_python_plugin_do_exit(GPythonPlugin *);
/* Procède à une opération liée à un contenu binaire. */
static void g_python_plugin_handle_binary_content(const GPythonPlugin *, PluginAction, GBinContent *, wgroup_id_t, GtkStatusStack *);
-/* Indique si le format peut être pris en charge ici. */
-FormatMatchStatus python_plugin_is_matching(GBinContent *, GExeFormat *, GPythonPlugin *, char **);
-
/* Exécute une action pendant un désassemblage de binaire. */
static void g_python_plugin_process_disass(const GPythonPlugin *, PluginAction, GLoadedBinary *, GtkStatusStack *, GProcContext *);
@@ -387,22 +382,6 @@ GPluginModule *g_python_plugin_new(const char *modname, const char *filename)
switch (action)
{
- case PGA_FORMAT_MATCHER:
-
- if (!has_python_method(instance, "is_format_matching"))
- {
- log_variadic_message(LMT_ERROR,
- _("No '%s' entry in plugin candidate '%s'"),
- "is_format_matching",
- G_PLUGIN_MODULE(result)->filename);
- goto gppn_bad_plugin;
- }
-
- if (!register_format_matcher((format_match_fc)python_plugin_is_matching, result))
- goto gppn_bad_plugin;
-
- break;
-
case PGA_FORMAT_LOADER_LAST:
/* TODO */
break;
@@ -683,122 +662,6 @@ static void g_python_plugin_handle_binary_content(const GPythonPlugin *plugin, P
/******************************************************************************
* *
-* Paramètres : content = contenu binaire à parcourir. *
-* parent = éventuel format exécutable déjà chargé. *
-* plugin = grefon C interne représentant le grefon Python. *
-* key = identifiant de format trouvé ou NULL. [OUT] *
-* *
-* Description : Indique si le format peut être pris en charge ici. *
-* *
-* Retour : Conclusion de haut niveau sur la reconnaissance effectuée. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-FormatMatchStatus python_plugin_is_matching(GBinContent *content, GExeFormat *parent, GPythonPlugin *plugin, char **key)
-{
- FormatMatchStatus result; /* Bilan à renvoyer */
- PyObject *args; /* Arguments pour l'appel */
- PyObject *value; /* Valeur obtenue */
- PyObject *arg; /* Argument en élément de tuple*/
-
- result = FMS_UNKNOWN;
-
- args = PyTuple_New(2);
- PyTuple_SetItem(args, 0, pygobject_new(G_OBJECT(content)));
- PyTuple_SetItem(args, 1, pygobject_new(G_OBJECT(parent)));
-
- value = run_python_method(plugin->instance, "is_format_matching", args);
-
- if (PyTuple_Check(value))
- {
- if (PyTuple_Size(value) > 0)
- {
- arg = PyTuple_GetItem(value, 0);
-
- if (PyLong_Check(arg))
- {
- result = PyLong_AsLong(arg);
-
- switch (result)
- {
- case FMS_MATCHED:
-
- if (PyTuple_Size(value) != 2)
- {
- g_plugin_module_log_variadic_message(G_PLUGIN_MODULE(plugin), LMT_ERROR,
- _("Expecting only a tuple [ status, key ] " \
- "as result for format matching."));
- result = FMS_UNKNOWN;
- break;
- }
-
- arg = PyTuple_GetItem(value, 1);
-
- if (PyUnicode_Check(arg))
- *key = strdup(PyUnicode_AsUTF8(arg));
-
- else
- {
- g_plugin_module_log_variadic_message(G_PLUGIN_MODULE(plugin), LMT_ERROR,
- _("Expecting a key string for format matching."));
- result = FMS_UNKNOWN;
- }
-
- break;
-
- case FMS_FORWARDED:
- case FMS_UNKNOWN:
- if (PyTuple_Size(value) != 1)
- {
- g_plugin_module_log_variadic_message(G_PLUGIN_MODULE(plugin), LMT_WARNING,
- _("Unused second item for format matching."));
- }
- break;
-
- default:
- g_plugin_module_log_variadic_message(G_PLUGIN_MODULE(plugin), LMT_ERROR,
- _("Unexpected result for format matching."));
- result = FMS_UNKNOWN;
- break;
-
- }
-
- }
-
- else
- {
- g_plugin_module_log_variadic_message(G_PLUGIN_MODULE(plugin), LMT_ERROR,
- _("Unexpected result status for format matching."));
- result = FMS_UNKNOWN;
- }
-
- }
- else
- g_plugin_module_log_variadic_message(G_PLUGIN_MODULE(plugin), LMT_WARNING,
- _("Interpreting a empty tuple as FMS_UNKNOWN " \
- "for format matching."));
-
- }
- else
- g_plugin_module_log_variadic_message(G_PLUGIN_MODULE(plugin), LMT_ERROR,
- _("Expected a tuple containing [ status, key ] as result " \
- "for format matching."));
-
- Py_XDECREF(value);
- Py_DECREF(args);
-
- return result;
-
-
-
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : plugin = greffon à manipuler. *
* action = type d'action attendue. *
* binary = binaire dont le contenu est en cours de traitement.*
@@ -862,7 +725,6 @@ static bool py_plugin_module_define_constants(PyTypeObject *obj_type)
result &= PyDict_AddIntMacro(obj_type, PGA_PLUGIN_EXIT);
result &= PyDict_AddIntMacro(obj_type, PGA_CONTENT_EXPLORER);
result &= PyDict_AddIntMacro(obj_type, PGA_CONTENT_RESOLVER);
- result &= PyDict_AddIntMacro(obj_type, PGA_FORMAT_MATCHER);
result &= PyDict_AddIntMacro(obj_type, PGA_FORMAT_LOADER_LAST);
result &= PyDict_AddIntMacro(obj_type, PGA_DISASSEMBLY_STARTED);
result &= PyDict_AddIntMacro(obj_type, PGA_DISASSEMBLY_RAW);