diff options
Diffstat (limited to 'plugins/pychrysalide/plugin.c')
-rw-r--r-- | plugins/pychrysalide/plugin.c | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/plugins/pychrysalide/plugin.c b/plugins/pychrysalide/plugin.c index fad0084..4689d0c 100644 --- a/plugins/pychrysalide/plugin.c +++ b/plugins/pychrysalide/plugin.c @@ -76,6 +76,9 @@ static bool g_python_plugin_do_init(GPythonPlugin *); /* Procède à l'extinction du greffon. */ static bool g_python_plugin_do_exit(GPythonPlugin *, GObject *); +/* Procède à une opération liée à un contenu binaire. */ +static void g_python_plugin_handle_binary_content(const GPythonPlugin *, PluginAction, GBinContent *, gid_t, GtkStatusStack *); + /* Indique si le format peut être pris en charge ici. */ FormatMatchStatus python_plugin_is_matching(GBinContent *, GExeFormat *, GPythonPlugin *, char **); @@ -285,6 +288,27 @@ GPluginModule *g_python_plugin_new(const char *modname, const char *filename) switch (sub) { + case DPS_CONTENT: + + switch (action) + { + case PGA_CONTENT_EXPLORER: + case PGA_CONTENT_RESOLVER: + if (!register_python_binding(instance, handle_content, \ + (pg_handle_content)g_python_plugin_handle_binary_content)) + goto gppn_bad_plugin; + break; + + default: + log_variadic_message(LMT_WARNING, + _("Unknown action '0x%02x' in plugin '%s'..."), + action, filename); + break; + + } + + break; + case DPS_FORMAT: switch (action) @@ -439,7 +463,7 @@ static bool g_python_plugin_read_interface(GPythonPlugin *plugin) { action = PyList_GET_ITEM(tuple, i); - interface.actions[i] = PyLong_AsLong(action); + interface.actions[i] = PyLong_AsUnsignedLong(action); } @@ -543,6 +567,42 @@ static bool g_python_plugin_do_exit(GPythonPlugin *plugin, GObject *ref) /****************************************************************************** * * +* Paramètres : plugin = greffon à manipuler. * +* action = type d'action attendue. * +* content = contenu binaire à traiter. * +* gid = identifiant du groupe de traitement. * +* status = barre de statut à tenir informée. * +* * +* Description : Procède à une opération liée à un contenu binaire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_python_plugin_handle_binary_content(const GPythonPlugin *plugin, PluginAction action, GBinContent *content, gid_t gid, GtkStatusStack *status) +{ + PyObject *args; /* Arguments pour l'appel */ + PyObject *value; /* Valeurs obtenues */ + + args = PyTuple_New(4); + + PyTuple_SetItem(args, 0, PyLong_FromUnsignedLong(action)); + PyTuple_SetItem(args, 1, pygobject_new(G_OBJECT(content))); + PyTuple_SetItem(args, 2, PyLong_FromUnsignedLong(gid)); + PyTuple_SetItem(args, 3, pygobject_new(G_OBJECT(status))); + + value = run_python_method(plugin->instance, "handle_binary_content", args); + + Py_XDECREF(value); + Py_DECREF(args); + +} + + +/****************************************************************************** +* * * Paramètres : content = contenu binaire à parcourir. * * parent = éventuel format exécutable déjà chargé. * * plugin = grefon C interne représentant le grefon Python. * @@ -678,7 +738,7 @@ static void g_python_plugin_process_disass(const GPythonPlugin *plugin, PluginAc args = PyTuple_New(2); - PyTuple_SetItem(args, 0, PyLong_FromLong(action)); + PyTuple_SetItem(args, 0, PyLong_FromUnsignedLong(action)); PyTuple_SetItem(args, 1, pygobject_new(G_OBJECT(binary))); value = run_python_method(plugin->instance, "process_binary_disassembly", args); @@ -716,6 +776,8 @@ static bool py_plugin_module_define_constants(PyTypeObject *obj_type) result &= PyDict_AddIntMacro(obj_type, PGA_BASIC_NONE); result &= PyDict_AddIntMacro(obj_type, PGA_PLUGIN_INIT); 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); |