From 9cfe738c2e9bb49eb2872e92bc4422c548edb517 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Sun, 12 Aug 2012 23:32:21 +0000 Subject: Cleaned the code and handled file binaries properly. git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@259 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a --- ChangeLog | 97 +++++ configure.ac | 1 + plugins/dexresolver/context.c | 12 +- plugins/dexresolver/context.h | 2 +- plugins/dexresolver/plugin.c | 2 +- plugins/dexresolver/plugin.h | 2 +- plugins/pychrysa/analysis/binary.c | 27 +- plugins/pychrysa/analysis/binary.h | 2 +- plugins/pychrysa/analysis/py_binary.c | 6 +- plugins/pychrysa/analysis/py_binary.h | 2 +- plugins/pychrysa/plugin.c | 4 +- plugins/stackvars/stackvars.c | 6 +- plugins/stackvars/stackvars.h | 2 +- plugins/theseus/theseus.c | 42 +- plugins/theseus/theseus.h | 2 +- src/analysis/Makefile.am | 3 +- src/analysis/binaries/Makefile.am | 18 + src/analysis/binaries/file.c | 328 +++++++++++++++ src/analysis/binaries/file.h | 61 +++ src/analysis/binary-int.h | 84 ++++ src/analysis/binary.c | 728 ++++++++-------------------------- src/analysis/binary.h | 74 +--- src/analysis/decomp/decompiler.c | 10 +- src/analysis/decomp/decompiler.h | 2 +- src/analysis/disass/disassembler.c | 14 +- src/analysis/disass/disassembler.h | 2 +- src/analysis/disass/fetch.c | 6 +- src/analysis/disass/fetch.h | 2 +- src/debug/debugger-int.h | 2 +- src/debug/debugger.c | 2 +- src/debug/debugger.h | 2 +- src/debug/jdwp/debugger.c | 2 +- src/debug/jdwp/debugger.h | 2 +- src/debug/remgdb/gdb.c | 2 +- src/debug/remgdb/gdb.h | 2 +- src/dialogs/add_shellcode.c | 16 +- src/dialogs/binparts.c | 28 +- src/dialogs/binparts.h | 2 +- src/dialogs/export.c | 14 +- src/dialogs/export.h | 2 +- src/dialogs/plugins.c | 8 +- src/dialogs/plugins.h | 2 +- src/editor.c | 30 +- src/graph/layout.c | 4 +- src/gtkext/easygtk.c | 6 +- src/gtkext/gtkbinview-int.h | 2 +- src/gtkext/gtkbinview.c | 10 +- src/gtkext/gtkbinview.h | 2 +- src/gtkext/gtkblockview.c | 6 +- src/gtkext/gtkdockpanel.c | 4 +- src/gtkext/gtkdockstation.c | 4 +- src/gtkext/gtkgraphview.c | 20 +- src/gtkext/gtksourceview.c | 6 +- src/gtkext/gtkviewpanel-int.h | 4 +- src/gtkext/gtkviewpanel.c | 6 +- src/gtkext/gtkviewpanel.h | 4 +- src/gui/editem-int.h | 2 +- src/gui/editem.c | 4 +- src/gui/editem.h | 4 +- src/gui/menus/binary.c | 2 +- src/gui/menus/debug.c | 4 +- src/gui/menus/project.c | 15 +- src/gui/menus/view.c | 2 +- src/gui/panels/symbols.c | 10 +- src/gui/tb/source.c | 14 +- src/panels/breaks.c | 15 +- src/panels/panel-int.h | 2 +- src/panels/panel.c | 4 +- src/panels/panel.h | 4 +- src/plugins/plugin-int.h | 2 +- src/plugins/plugin.c | 2 +- src/plugins/plugin.h | 2 +- src/project.c | 33 +- src/project.h | 10 +- 74 files changed, 1006 insertions(+), 860 deletions(-) create mode 100755 src/analysis/binaries/Makefile.am create mode 100644 src/analysis/binaries/file.c create mode 100644 src/analysis/binaries/file.h create mode 100644 src/analysis/binary-int.h diff --git a/ChangeLog b/ChangeLog index d1bd7b4..96c7ce1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,100 @@ +12-08-13 Cyrille Bagard + + * configure.ac: + Add the new Makefile from the 'src/analysis/binaries directory + to AC_CONFIG_FILES. + + * plugins/dexresolver/context.c: + * plugins/dexresolver/context.h: + * plugins/dexresolver/plugin.c: + * plugins/dexresolver/plugin.h: + * plugins/pychrysa/analysis/binary.c: + * plugins/pychrysa/analysis/binary.h: + * plugins/pychrysa/analysis/py_binary.c: + * plugins/pychrysa/analysis/py_binary.h: + * plugins/pychrysa/plugin.c: + * plugins/stackvars/stackvars.c: + * plugins/stackvars/stackvars.h: + * plugins/theseus/theseus.c: + * plugins/theseus/theseus.h: + Update code. + + * src/analysis/binaries/file.c: + * src/analysis/binaries/file.h: + * src/analysis/binaries/Makefile.am: + New entries: handle file binaries properly. + + * src/analysis/binary.c: + * src/analysis/binary.h: + Clean and update the code. + + * src/analysis/binary-int.h: + New entry: store the code shared by binaries here. + + * src/analysis/decomp/decompiler.c: + * src/analysis/decomp/decompiler.h: + * src/analysis/disass/disassembler.c: + * src/analysis/disass/disassembler.h: + * src/analysis/disass/fetch.c: + * src/analysis/disass/fetch.h: + Update code. + + * src/analysis/Makefile.am: + Add the binaries/libanalysisbinaries.la file to libanalysis_la_LIBADD + and binaries to SUBDIRS. + + * src/debug/debugger.c: + * src/debug/debugger.h: + * src/debug/debugger-int.h: + * src/debug/jdwp/debugger.c: + * src/debug/jdwp/debugger.h: + * src/debug/remgdb/gdb.c: + * src/debug/remgdb/gdb.h: + * src/dialogs/add_shellcode.c: + * src/dialogs/binparts.c: + * src/dialogs/binparts.h: + * src/dialogs/export.c: + * src/dialogs/export.h: + * src/dialogs/plugins.c: + * src/dialogs/plugins.h: + * src/editor.c: + * src/graph/layout.c: + Update code. + + * src/gtkext/easygtk.c: + * src/gtkext/gtkbinview.c: + * src/gtkext/gtkbinview.h: + * src/gtkext/gtkbinview-int.h: + * src/gtkext/gtkblockview.c: + * src/gtkext/gtkdockpanel.c: + * src/gtkext/gtkdockstation.c: + * src/gtkext/gtkgraphview.c: + * src/gtkext/gtksourceview.c: + * src/gtkext/gtkviewpanel.c: + * src/gtkext/gtkviewpanel.h: + * src/gtkext/gtkviewpanel-int.h: + Update code and make it compile with the lastest versions of GTK. + + * src/gui/editem.c: + * src/gui/editem.h: + * src/gui/editem-int.h: + * src/gui/menus/binary.c: + * src/gui/menus/debug.c: + * src/gui/menus/project.c: + * src/gui/menus/view.c: + * src/gui/panels/symbols.c: + * src/gui/tb/source.c: + * src/panels/breaks.c: + * src/panels/panel.c: + * src/panels/panel.h: + * src/panels/panel-int.h: + * src/plugins/plugin.c: + * src/plugins/plugin.h: + * src/plugins/plugin-int.h: + * src/project.c: + * src/project.h: + Update code. + 12-08-06 Cyrille Bagard * configure.ac: diff --git a/configure.ac b/configure.ac index ae07522..9f369da 100644 --- a/configure.ac +++ b/configure.ac @@ -250,6 +250,7 @@ AC_CONFIG_FILES([Makefile plugins/theseus/Makefile src/Makefile src/analysis/Makefile + src/analysis/binaries/Makefile src/analysis/decomp/Makefile src/analysis/disass/Makefile src/arch/Makefile diff --git a/plugins/dexresolver/context.c b/plugins/dexresolver/context.c index 19be9c0..b63ccf3 100644 --- a/plugins/dexresolver/context.c +++ b/plugins/dexresolver/context.c @@ -51,7 +51,7 @@ typedef struct _GDexResolverWork { GDelayedWork parent; /* A laisser en premier */ - GOpenidaBinary *binary; /* Destinataire final */ + GLoadedBinary *binary; /* Destinataire final */ } GDexResolverWork; @@ -74,7 +74,7 @@ static void g_dex_resolver_work_class_init(GDexResolverWorkClass *); static void g_dex_resolver_work_init(GDexResolverWork *); /* Crée une tâche de résolution d'opérandes différée. */ -static GDexResolverWork *g_dex_resolver_work_new(GOpenidaBinary *); +static GDexResolverWork *g_dex_resolver_work_new(GLoadedBinary *); /* Assure la résolution d'opérandes en différé. */ static void g_dex_resolver_work_process(GDexResolverWork *, GtkExtStatusBar *); @@ -172,7 +172,7 @@ static void g_dex_resolver_work_init(GDexResolverWork *disass) * * ******************************************************************************/ -static GDexResolverWork *g_dex_resolver_work_new(GOpenidaBinary *binary) +static GDexResolverWork *g_dex_resolver_work_new(GLoadedBinary *binary) { GDexResolverWork *result; /* Tâche à retourner */ @@ -209,9 +209,9 @@ static void g_dex_resolver_work_process(GDexResolverWork *work, GtkExtStatusBar const GArchOperand *op; /* Opérande à analyser */ GArchOperand *new; /* Nouvel opérande à afficher */ - format = G_DEX_FORMAT(g_openida_binary_get_format(work->binary)); + format = G_DEX_FORMAT(g_loaded_binary_get_format(work->binary)); - lines = g_openida_binary_get_lines(work->binary); + lines = g_loaded_binary_get_lines(work->binary); for (iter = lines; iter != NULL; @@ -303,7 +303,7 @@ static void g_dex_resolver_context_init(GDexResolverContext *context) * * ******************************************************************************/ -GPluginContext *g_dex_resolver_context_new(GOpenidaBinary *binary) +GPluginContext *g_dex_resolver_context_new(GLoadedBinary *binary) { GPluginContext *result; /* Bilan d'exécution à renvoyer*/ GDexResolverWork *work; /* Tâche de parcours de lignes */ diff --git a/plugins/dexresolver/context.h b/plugins/dexresolver/context.h index 79e4204..bcc4f19 100644 --- a/plugins/dexresolver/context.h +++ b/plugins/dexresolver/context.h @@ -50,7 +50,7 @@ typedef struct _GDexResolverContextClass GDexResolverContextClass; GType g_dex_resolver_context_get_type(void); /* Lance l'exécution d'une action du greffon. */ -GPluginContext *g_dex_resolver_context_new(GOpenidaBinary *); +GPluginContext *g_dex_resolver_context_new(GLoadedBinary *); diff --git a/plugins/dexresolver/plugin.c b/plugins/dexresolver/plugin.c index 356f7cf..7a2fe77 100644 --- a/plugins/dexresolver/plugin.c +++ b/plugins/dexresolver/plugin.c @@ -98,7 +98,7 @@ G_MODULE_EXPORT PluginAction get_plugin_action(void) * * ******************************************************************************/ -G_MODULE_EXPORT bool execute_action_on_binary(GOpenidaBinary *binary, PluginAction action) +G_MODULE_EXPORT bool execute_action_on_binary(GLoadedBinary *binary, PluginAction action) { bool result; /* Bilan à retourner */ diff --git a/plugins/dexresolver/plugin.h b/plugins/dexresolver/plugin.h index 85da278..c5a1a97 100644 --- a/plugins/dexresolver/plugin.h +++ b/plugins/dexresolver/plugin.h @@ -42,7 +42,7 @@ G_MODULE_EXPORT PluginType get_plugin_type(void); G_MODULE_EXPORT PluginAction get_plugin_action(void); /* Exécute une action définie sur un binaire chargé. */ -G_MODULE_EXPORT bool execute_action_on_binary(GOpenidaBinary *, PluginAction); +G_MODULE_EXPORT bool execute_action_on_binary(GLoadedBinary *, PluginAction); diff --git a/plugins/pychrysa/analysis/binary.c b/plugins/pychrysa/analysis/binary.c index 44721b5..93db685 100644 --- a/plugins/pychrysa/analysis/binary.c +++ b/plugins/pychrysa/analysis/binary.c @@ -28,6 +28,9 @@ #include +#include /* REMME ! */ + + #include "../quirks.h" #include "../arch/instruction.h" #include "../glibext/codebuffer.h" @@ -70,12 +73,12 @@ static PyObject *py_loaded_binary_new(PyTypeObject *type, PyObject *args, PyObje PyObject *result; /* Instance à retourner */ char *filename; /* Nom du fichier à charger */ int ret; /* Bilan de lecture des args. */ - GOpenidaBinary *binary; /* Version GLib du format */ + GLoadedBinary *binary; /* Version GLib du format */ ret = PyArg_ParseTuple(args, "s", &filename); if (!ret) return Py_None; - binary = g_openida_binary_new_from_file(filename); + binary = g_file_binary_new_from_file(filename); result = py_loaded_binary_from_c(binary); g_object_unref(binary); @@ -97,7 +100,7 @@ static PyObject *py_loaded_binary_new(PyTypeObject *type, PyObject *args, PyObje * * ******************************************************************************/ -PyObject *py_loaded_binary_from_c(GOpenidaBinary *binary) +PyObject *py_loaded_binary_from_c(GLoadedBinary *binary) { PyObject *module; /* Module d'appartenance */ PyTypeObject *type; /* Type Python correspondant */ @@ -129,12 +132,12 @@ PyObject *py_loaded_binary_from_c(GOpenidaBinary *binary) static PyObject *py_loaded_binary_get_filename(PyObject *self, PyObject *args) { PyObject *result; /* Trouvailles à retourner */ - GOpenidaBinary *binary; /* Version native */ + GLoadedBinary *binary; /* Version native */ const char *filename; /* Fichier associé au binaire */ - binary = G_OPENIDA_BINARY(pygobject_get(self)); + binary = G_LOADED_BINARY(pygobject_get(self)); - filename = g_openida_binary_get_filename(binary); + filename = g_loaded_binary_get_filename(binary, true); result = PyString_FromString(filename); @@ -159,12 +162,12 @@ static PyObject *py_loaded_binary_get_filename(PyObject *self, PyObject *args) static PyObject *py_loaded_binary_get_instructions(PyObject *self, PyObject *args) { PyObject *result; /* Trouvailles à retourner */ - GOpenidaBinary *binary; /* Version native */ + GLoadedBinary *binary; /* Version native */ GArchInstruction *instr; /* Première instruction */ - binary = G_OPENIDA_BINARY(pygobject_get(self)); + binary = G_LOADED_BINARY(pygobject_get(self)); - instr = g_openida_binary_get_instructions(binary); + instr = g_loaded_binary_get_instructions(binary); result = py_arch_instruction_from_c(instr); @@ -192,11 +195,11 @@ static PyObject *py_loaded_binary_get_instructions(PyObject *self, PyObject *arg static PyObject *py_loaded_binary_get_disassembled_buffer(PyObject *self, void *closure) { PyObject *result; /* Trouvailles à retourner */ - GOpenidaBinary *binary; /* Version native */ + GLoadedBinary *binary; /* Version native */ GCodeBuffer *buffer; /* Tampon à récupérer */ - binary = G_OPENIDA_BINARY(pygobject_get(self)); - buffer = g_openida_binary_get_disassembled_buffer(binary); + binary = G_LOADED_BINARY(pygobject_get(self)); + buffer = g_loaded_binary_get_disassembled_buffer(binary); result = py_code_buffer_from_c(buffer); diff --git a/plugins/pychrysa/analysis/binary.h b/plugins/pychrysa/analysis/binary.h index 89e5e59..33ead7e 100644 --- a/plugins/pychrysa/analysis/binary.h +++ b/plugins/pychrysa/analysis/binary.h @@ -34,7 +34,7 @@ /* Crée un nouvel objet Python de type 'LoadedBinary'. */ -PyObject *py_loaded_binary_from_c(GOpenidaBinary *); +PyObject *py_loaded_binary_from_c(GLoadedBinary *); /* Prend en charge l'objet 'pychrysalide.analysis.LoadedBinary'. */ bool register_python_loaded_binary(PyObject *); diff --git a/plugins/pychrysa/analysis/py_binary.c b/plugins/pychrysa/analysis/py_binary.c index 04d4881..7c1653d 100644 --- a/plugins/pychrysa/analysis/py_binary.c +++ b/plugins/pychrysa/analysis/py_binary.c @@ -35,7 +35,7 @@ typedef struct { PyObject_HEAD - GOpenidaBinary *binary; /* Instance réelle rattachée */ + GLoadedBinary *binary; /* Instance réelle rattachée */ } pybinary; @@ -126,7 +126,7 @@ pybinary_new(PyTypeObject *type, PyObject *args, PyObject *kwds) * * ******************************************************************************/ -PyObject *pybinary_new_from_existing(GOpenidaBinary *binary) +PyObject *pybinary_new_from_existing(GLoadedBinary *binary) { pybinary *result; /* Nouvelle instance à renvoyer*/ PyTypeObject *type; /* Type d'objet à créer */ @@ -216,7 +216,7 @@ static PyObject *pybinary_get_lines(pybinary *self) PyObject *result; /* Liste à retourner */ GRenderingLine *lines; /* Liste récupérée à convertir */ - lines = g_openida_binary_get_lines(self->binary); + lines = g_loaded_binary_get_lines(self->binary); result = pyline_new_from_existing(lines, lines); diff --git a/plugins/pychrysa/analysis/py_binary.h b/plugins/pychrysa/analysis/py_binary.h index f87d2a5..92c37eb 100644 --- a/plugins/pychrysa/analysis/py_binary.h +++ b/plugins/pychrysa/analysis/py_binary.h @@ -35,7 +35,7 @@ /* Initialise le greffon permettant l'usage de Python. */ -PyObject *pybinary_new_from_existing(GOpenidaBinary *); +PyObject *pybinary_new_from_existing(GLoadedBinary *); /* Ajoute l'objet 'binary' au module Python. */ bool add_binary_to_python_module(PyObject *); diff --git a/plugins/pychrysa/plugin.c b/plugins/pychrysa/plugin.c index 6d8a494..70ca26e 100644 --- a/plugins/pychrysa/plugin.c +++ b/plugins/pychrysa/plugin.c @@ -72,7 +72,7 @@ static PluginAction g_python_plugin_get_action(const GPythonPlugin *); static MatchingFormatAction g_python_plugin_is_matching(const GPythonPlugin *, char **, bin_t **, off_t *); /* Exécute une action définie sur un binaire chargé. */ -static bool g_python_plugin_execute_on_binary(GPythonPlugin *, GOpenidaBinary *, PluginAction); +static bool g_python_plugin_execute_on_binary(GPythonPlugin *, GLoadedBinary *, PluginAction); /* Exécute une action relative à un débogueur. */ @@ -496,7 +496,7 @@ static MatchingFormatAction g_python_plugin_is_matching(const GPythonPlugin *plu * * ******************************************************************************/ -static bool g_python_plugin_execute_on_binary(GPythonPlugin *plugin, GOpenidaBinary *binary, PluginAction action) +static bool g_python_plugin_execute_on_binary(GPythonPlugin *plugin, GLoadedBinary *binary, PluginAction action) { bool result; /* Bilan à remonter */ PyObject *args; /* Arguments pour l'appel */ diff --git a/plugins/stackvars/stackvars.c b/plugins/stackvars/stackvars.c index 35f8016..1e18f28 100644 --- a/plugins/stackvars/stackvars.c +++ b/plugins/stackvars/stackvars.c @@ -97,7 +97,7 @@ G_MODULE_EXPORT PluginAction get_plugin_action(void) * * ******************************************************************************/ -G_MODULE_EXPORT bool execute_action_on_binary(GOpenidaBinary *binary, PluginAction action) +G_MODULE_EXPORT bool execute_action_on_binary(GLoadedBinary *binary, PluginAction action) { bool result; /* Bilan à retourner */ GRenderingLine *lines; /* Lignes de rendu */ @@ -108,9 +108,9 @@ G_MODULE_EXPORT bool execute_action_on_binary(GOpenidaBinary *binary, PluginActi result = false; - lines = g_openida_binary_get_lines(binary); + lines = g_loaded_binary_get_lines(binary); - format = g_openida_binary_get_format(binary); + format = g_loaded_binary_get_format(binary); routines = g_binary_format_get_routines(G_BIN_FORMAT(format), &routines_count); for (i = 0; i < routines_count; i++) diff --git a/plugins/stackvars/stackvars.h b/plugins/stackvars/stackvars.h index fdd48b5..bf3e42e 100644 --- a/plugins/stackvars/stackvars.h +++ b/plugins/stackvars/stackvars.h @@ -42,7 +42,7 @@ G_MODULE_EXPORT bool init_plugin(GObject *); G_MODULE_EXPORT PluginAction get_plugin_action(void); /* Exécute une action définie sur un binaire chargé. */ -G_MODULE_EXPORT bool execute_action_on_binary(GOpenidaBinary *, PluginAction); +G_MODULE_EXPORT bool execute_action_on_binary(GLoadedBinary *, PluginAction); diff --git a/plugins/theseus/theseus.c b/plugins/theseus/theseus.c index 5cc2d98..ea119ef 100644 --- a/plugins/theseus/theseus.c +++ b/plugins/theseus/theseus.c @@ -30,7 +30,7 @@ /* Traite en premier lieu les adresses marquées "impératives". */ -static bool register_white_list(GOpenidaBinary *); +static bool register_white_list(GLoadedBinary *); /* Indique si une ligne peut faire l'objet d'un nouveau suivi. */ static bool can_line_be_followed(const GRenderingLine *); @@ -42,13 +42,13 @@ static bool can_line_be_processed(const GRenderingLine *); static void mark_line_as_done(GRenderingLine *, bool); /* Suit le flot d'exécution à partir d'un point donné. */ -static bool follow_flow_from_line(GOpenidaBinary *, vmpa_t); +static bool follow_flow_from_line(GLoadedBinary *, vmpa_t); /* Désassemble une nouvelle instruction à partir d'une adresse. */ -static GRenderingLine *disassemble_target_address(GOpenidaBinary *, GRenderingLine *, vmpa_t); +static GRenderingLine *disassemble_target_address(GLoadedBinary *, GRenderingLine *, vmpa_t); /* Insère dans le flux existant les nouvelles lignes crées. */ -static bool insert_new_lines_into_flow(GOpenidaBinary *, GRenderingLine *, GRenderingLine *); +static bool insert_new_lines_into_flow(GLoadedBinary *, GRenderingLine *, GRenderingLine *); @@ -140,7 +140,7 @@ G_MODULE_EXPORT PluginAction get_plugin_action(void) * * ******************************************************************************/ -G_MODULE_EXPORT bool execute_action_on_binary(GOpenidaBinary *binary, PluginAction action) +G_MODULE_EXPORT bool execute_action_on_binary(GLoadedBinary *binary, PluginAction action) { bool result; /* Bilan à retourner */ GRenderingLine *lines; /* Lignes désassemblées */ @@ -153,12 +153,12 @@ G_MODULE_EXPORT bool execute_action_on_binary(GOpenidaBinary *binary, PluginActi GRenderingLine *iter; - lines = g_openida_binary_get_lines(binary); + lines = g_loaded_binary_get_lines(binary); - format = g_openida_binary_get_format(binary); + format = g_loaded_binary_get_format(binary); start = g_exe_format_get_entry_point(format); @@ -173,7 +173,7 @@ G_MODULE_EXPORT bool execute_action_on_binary(GOpenidaBinary *binary, PluginActi - options = g_openida_binary_get_options(binary); + options = g_loaded_binary_get_options(binary); for (iter = lines; iter != NULL; iter = g_rendering_line_get_next_iter(lines, iter, NULL)) { @@ -212,7 +212,7 @@ G_MODULE_EXPORT bool execute_action_on_binary(GOpenidaBinary *binary, PluginActi * * ******************************************************************************/ -static bool register_white_list(GOpenidaBinary *binary) +static bool register_white_list(GLoadedBinary *binary) { bool result; /* Bilan à retourner */ GRenderingLine *lines; /* Lignes désassemblées */ @@ -223,7 +223,7 @@ static bool register_white_list(GOpenidaBinary *binary) result = true; - lines = g_openida_binary_get_lines(binary); + lines = g_loaded_binary_get_lines(binary); for (i = 0; i < _white_list_count && result; i++) { @@ -327,7 +327,7 @@ static void mark_line_as_done(GRenderingLine *line, bool white) * * ******************************************************************************/ -static bool follow_flow_from_line(GOpenidaBinary *binary, vmpa_t start) +static bool follow_flow_from_line(GLoadedBinary *binary, vmpa_t start) { bool result; /* Bilan de opérations */ GRenderingLine *lines; /* Lignes désassemblées */ @@ -339,7 +339,7 @@ static bool follow_flow_from_line(GOpenidaBinary *binary, vmpa_t start) InstructionLinkType type; /* Type de référence */ GRenderingLine *target; /* Ligne visée par la référence*/ - lines = g_openida_binary_get_lines(binary); + lines = g_loaded_binary_get_lines(binary); first = g_rendering_line_find_by_address(lines, NULL, start); first = g_rendering_line_loop_for_code(first, NULL); @@ -466,7 +466,7 @@ static bool follow_flow_from_line(GOpenidaBinary *binary, vmpa_t start) * * ******************************************************************************/ -static GRenderingLine *disassemble_target_address(GOpenidaBinary *binary, GRenderingLine *old, vmpa_t target) +static GRenderingLine *disassemble_target_address(GLoadedBinary *binary, GRenderingLine *old, vmpa_t target) { GRenderingLine *result; /* Lignes en place à renvoyer */ GExeFormat *format; /* Format du binaire fourni */ @@ -482,11 +482,11 @@ static GRenderingLine *disassemble_target_address(GOpenidaBinary *binary, GRende result = NULL; - format = g_openida_binary_get_format(binary); + format = g_loaded_binary_get_format(binary); proc = get_arch_processor_from_format(format); - options = g_openida_binary_get_options(binary); + options = g_loaded_binary_get_options(binary); - data = g_openida_binary_get_data(binary, &length); + data = g_loaded_binary_get_data(binary, &length); old_addr = get_rendering_line_address(old); if (!g_exe_format_translate_address_into_offset(format, old_addr, &offset)) @@ -532,7 +532,7 @@ static GRenderingLine *disassemble_target_address(GOpenidaBinary *binary, GRende * * ******************************************************************************/ -static bool insert_new_lines_into_flow(GOpenidaBinary *binary, GRenderingLine *old, GRenderingLine *new) +static bool insert_new_lines_into_flow(GLoadedBinary *binary, GRenderingLine *old, GRenderingLine *new) { bool result; /* Bilan de opérations */ GExeFormat *format; /* Format du binaire fourni */ @@ -551,11 +551,11 @@ static bool insert_new_lines_into_flow(GOpenidaBinary *binary, GRenderingLine *o GRenderingLine *line; /* Nouvelle ligne de rendu */ GRenderingLine *last; /* Dernière ligne à vérifier */ - format = g_openida_binary_get_format(binary); + format = g_loaded_binary_get_format(binary); proc = get_arch_processor_from_format(format); - options = g_openida_binary_get_options(binary); + options = g_loaded_binary_get_options(binary); - data = g_openida_binary_get_data(binary, &length); + data = g_loaded_binary_get_data(binary, &length); /* Etendue du bloc de remplacement */ @@ -568,7 +568,7 @@ static bool insert_new_lines_into_flow(GOpenidaBinary *binary, GRenderingLine *o /* Bourrage nécessaire ? */ - root = g_openida_binary_get_lines_root(binary); + root = g_loaded_binary_get_lines_root(binary); iter = g_rendering_line_find_by_address(*root, NULL, end); diff --git a/plugins/theseus/theseus.h b/plugins/theseus/theseus.h index 2fa4ac1..e1a6f36 100644 --- a/plugins/theseus/theseus.h +++ b/plugins/theseus/theseus.h @@ -42,7 +42,7 @@ G_MODULE_EXPORT bool init_plugin(GObject *); G_MODULE_EXPORT PluginAction get_plugin_action(void); /* Exécute une action définie sur un binaire chargé. */ -G_MODULE_EXPORT bool execute_action_on_binary(GOpenidaBinary *, PluginAction); +G_MODULE_EXPORT bool execute_action_on_binary(GLoadedBinary *, PluginAction); diff --git a/src/analysis/Makefile.am b/src/analysis/Makefile.am index e59b648..b5b345f 100755 --- a/src/analysis/Makefile.am +++ b/src/analysis/Makefile.am @@ -16,6 +16,7 @@ libanalysis_la_SOURCES = \ variable.h variable.c libanalysis_la_LIBADD = \ + binaries/libanalysisbinaries.la \ decomp/libanalysisdecomp.la \ disass/libanalysisdisass.la @@ -28,4 +29,4 @@ AM_CPPFLAGS = AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) -SUBDIRS = decomp disass +SUBDIRS = binaries decomp disass diff --git a/src/analysis/binaries/Makefile.am b/src/analysis/binaries/Makefile.am new file mode 100755 index 0000000..f065070 --- /dev/null +++ b/src/analysis/binaries/Makefile.am @@ -0,0 +1,18 @@ + +noinst_LTLIBRARIES = libanalysisbinaries.la + +libanalysisbinaries_la_SOURCES = \ + file.h file.c + +libanalysisbinaries_la_LIBADD = + +libanalysisbinaries_la_LDFLAGS = + + +INCLUDES = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) + +AM_CPPFLAGS = + +AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) + +SUBDIRS = diff --git a/src/analysis/binaries/file.c b/src/analysis/binaries/file.c new file mode 100644 index 0000000..0be1fd7 --- /dev/null +++ b/src/analysis/binaries/file.c @@ -0,0 +1,328 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * file.h - prototypes pour la prise en charge des binaires sous forme de fichier + * + * Copyright (C) 2012 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 Foobar. If not, see . + */ + + +#include "file.h" + + +#include + + +#include "../binary-int.h" +#include "../../common/extstr.h" +#include "../../gui/panels/log.h" + + + +/* Description de fichier binaire (instance) */ +struct _GFileBinary +{ + GLoadedBinary parent; /* A laisser en premier */ + + char *filename; /* Fichier chargé en mémoire */ + +}; + +/* Description de fichier binaire (classe) */ +struct _GFileBinaryClass +{ + GLoadedBinaryClass parent; /* A laisser en premier */ + +}; + + +/* Initialise la classe des descriptions de fichier binaire. */ +static void g_file_binary_class_init(GFileBinaryClass *); + +/* Initialise une description de fichier binaire. */ +static void g_file_binary_init(GFileBinary *); + +/* Procède à la libération totale de la mémoire. */ +static void g_file_binary_finalize(GFileBinary *); + +/* Ecrit une sauvegarde du binaire dans un fichier XML. */ +static bool g_file_binary_save(const GFileBinary *, xmlDocPtr, xmlXPathContextPtr, const char *); + +/* Fournit le fichier correspondant à l'élément binaire. */ +static const char *g_file_binary_get_filename(const GFileBinary *, bool); + + + +/* Indique le type défini pour une description de fichier binaire. */ +G_DEFINE_TYPE(GFileBinary, g_file_binary, G_TYPE_LOADED_BINARY); + + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des descriptions de fichier binaire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_file_binary_class_init(GFileBinaryClass *klass) +{ + GObjectClass *object; /* Autre version de la classe */ + + object = G_OBJECT_CLASS(klass); + + object->finalize = (GObjectFinalizeFunc)g_file_binary_finalize; + +} + + +/****************************************************************************** +* * +* Paramètres : binary = instance à initialiser. * +* * +* Description : Initialise une description de fichier binaire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_file_binary_init(GFileBinary *binary) +{ + GLoadedBinary *loaded; /* Version parente */ + + loaded = G_LOADED_BINARY(binary); + + loaded->save = (save_binary_fc)g_file_binary_save; + loaded->get_filename = (get_binary_filename_fc)g_file_binary_get_filename; + +} + + +/****************************************************************************** +* * +* Paramètres : binary = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_file_binary_finalize(GFileBinary *binary) +{ + gpointer obj_class; /* Classe parente */ + + free(binary->filename); + + /* On passe le relai */ + + obj_class = g_type_class_peek_parent(G_FILE_BINARY_GET_CLASS(binary)); + + G_OBJECT_CLASS(obj_class)->finalize(G_OBJECT(binary)); + +} + + +/****************************************************************************** +* * +* Paramètres : filename = nom du fichier à charger. * +* * +* Description : Charge en mémoire le contenu d'un fichier. * +* * +* Retour : Adresse de la représentation ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GLoadedBinary *g_file_binary_new_from_file(const char *filename) +{ + GFileBinary *result; /* Adresse à retourner */ + GLoadedBinary *loaded; /* Version parente */ + char *tmp; /* Nom de fichier modifiable */ + + result = g_object_new(G_TYPE_FILE_BINARY, NULL); + loaded = G_LOADED_BINARY(result); + + log_variadic_message(LMT_PROCESS, _("Opening '%s' file..."), filename); + + result->filename = strdup(filename); + + tmp = strdup(filename); + loaded->format = G_EXE_FORMAT(load_new_format(FMT_EXEC, tmp, + &loaded->bin_data, &loaded->bin_length)); + free(tmp); + + if (loaded->format == NULL) + { + log_simple_message(LMT_INFO, _("Unknown binary format")); + goto lbf_error; + } + + switch (g_exe_format_get_target_machine(loaded->format)) + { + case FTM_ARM: + log_simple_message(LMT_INFO, _("Detected architecture: ARM")); + break; + case FTM_DALVIK: + log_simple_message(LMT_INFO, _("Detected architecture: Dalvik Virtual Machine")); + break; + case FTM_JVM: + log_simple_message(LMT_INFO, _("Detected architecture: Java Virtual Machine")); + break; + case FTM_MIPS: + log_simple_message(LMT_INFO, _("Detected architecture: Microprocessor without Interlocked Pipeline Stages")); + break; + case FTM_386: + log_simple_message(LMT_INFO, _("Detected architecture: i386")); + break; + default: + log_simple_message(LMT_INFO, _("Unknown architecture")); + goto lbf_error; + break; + } + + loaded->proc = get_arch_processor_from_format(loaded->format); + + return G_LOADED_BINARY(result); + + lbf_error: + + g_object_unref(G_OBJECT(result)); + + return NULL; + +} + + +/****************************************************************************** +* * +* Paramètres : context = contexte pour les recherches XPath. * +* path = chemin d'accès au noeud XML à lire. * +* * +* Description : Charge en mémoire le contenu d'un fichier à partir d'XML. * +* * +* Retour : Adresse de la représentation ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GLoadedBinary *g_file_binary_new_from_xml(xmlXPathContextPtr context, const char *path) +{ + GLoadedBinary *result; /* Adresse à retourner */ + char *access; /* Chemin pour une sous-config.*/ + char *filename; /* Chemin du binaire à charger */ + + result = NULL; + + /* Chemin du fichier à retrouver */ + + access = strdup(path); + access = stradd(access, "/Filename"); + + filename = get_node_text_value(context, access); + + free(access); + + /* Chargement */ + + if (filename != NULL) + { + result = g_file_binary_new_from_file(filename); + free(filename); + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : binary = élément binaire à traiter. * +* xdoc = structure XML en cours d'édition. * +* context = contexte à utiliser pour les recherches. * +* path = chemin d'accès réservé au binaire. * +* * +* Description : Ecrit une sauvegarde du binaire dans un fichier XML. * +* * +* Retour : true si l'opération a bien tourné, false sinon. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_file_binary_save(const GFileBinary *binary, xmlDocPtr xdoc, xmlXPathContextPtr context, const char *path) +{ + bool result; /* Bilan à faire remonter */ + char *access; /* Chemin d'accès à un élément */ + + result = true; + + /* Type */ + + result &= add_string_attribute_to_node(xdoc, context, path, "type", "file"); + + /* Nom du fichier associé */ + + access = strdup(path); + access = stradd(access, "/Filename"); + + result &= add_content_to_node(xdoc, context, access, binary->filename); + + free(access); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : binary = élément binaire à consulter. * +* full = précise s'il s'agit d'une version longue ou non. * +* * +* Description : Fournit le fichier correspondant à l'élément binaire. * +* * +* Retour : Nom de fichier avec chemin absolu. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static const char *g_file_binary_get_filename(const GFileBinary *binary, bool full) +{ + const char *result; /* Description à retourner */ + + if (full) + result = binary->filename; + else + result = strrchr(binary->filename, G_DIR_SEPARATOR) + 1; + + return result; + +} diff --git a/src/analysis/binaries/file.h b/src/analysis/binaries/file.h new file mode 100644 index 0000000..3bff0a2 --- /dev/null +++ b/src/analysis/binaries/file.h @@ -0,0 +1,61 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * file.h - prototypes pour la prise en charge des binaires sous forme de fichier + * + * Copyright (C) 2012 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 Foobar. If not, see . + */ + + +#ifndef _ANALYSIS_BINARIES_FILE_H +#define _ANALYSIS_BINARIES_FILE_H + + +#include + + +#include "../binary.h" +#include "../../common/xml.h" + + + +#define G_TYPE_FILE_BINARY g_file_binary_get_type() +#define G_FILE_BINARY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_file_binary_get_type(), GFileBinary)) +#define G_IS_FILE_BINARY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_file_binary_get_type())) +#define G_FILE_BINARY_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_file_binary_get_type(), GFileBinaryIface)) +#define G_FILE_BINARY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_FILE_BINARY, GFileBinaryClass)) + + +/* Description de fichier binaire (instance) */ +typedef struct _GFileBinary GFileBinary; + +/* Description de fichier binaire (classe) */ +typedef struct _GFileBinaryClass GFileBinaryClass; + + +/* Indique le type défini pour une description de fichier binaire. */ +GType g_file_binary_get_type(void); + +/* Charge en mémoire le contenu d'un fichier. */ +GLoadedBinary *g_file_binary_new_from_file(const char *); + +/* Charge en mémoire le contenu d'un fichier à partir d'XML. */ +GLoadedBinary *g_file_binary_new_from_xml(xmlXPathContextPtr, const char *); + + + +#endif /* _ANALYSIS_BINARIES_FILE_H */ diff --git a/src/analysis/binary-int.h b/src/analysis/binary-int.h new file mode 100644 index 0000000..c9be0bf --- /dev/null +++ b/src/analysis/binary-int.h @@ -0,0 +1,84 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * binary-int.h - prototypes pour la définition interne des binaires + * + * Copyright (C) 2012 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 Foobar. If not, see . + */ + + +#ifndef _ANALYSIS_BINARY_INT_H +#define _ANALYSIS_BINARY_INT_H + + +#include "binary.h" + + +#include "../format/format.h" + + + +/* Ecrit une sauvegarde du binaire dans un fichier XML. */ +typedef bool (* save_binary_fc) (const GLoadedBinary *, xmlDocPtr, xmlXPathContextPtr, const char *); + +/* Fournit le fichier correspondant à l'élément binaire. */ +typedef const char * (* get_binary_filename_fc) (const GLoadedBinary *, bool); + + +/* Description de fichier binaire (instance) */ +struct _GLoadedBinary +{ + GObject parent; /* A laisser en premier */ + + save_binary_fc save; /* Sauvegarde au format XML */ + get_binary_filename_fc get_filename; /* Obtention d'une description */ + + off_t bin_length; /* Taille des données brutes */ + bin_t *bin_data; /* Données binaires brutes */ + + GExeFormat *format; /* Format du binaire */ + GArchProcessor *proc; /* Architecture du binaire */ + + BinaryPartModel model; /* Modèle de sélection */ + GBinPart **parts[BPM_COUNT]; /* Parties binaires à analyser */ + size_t parts_count[BPM_COUNT]; /* Quantité de ces parties */ + + GArchInstruction *instrs; /* Instructions d'assemblage */ + GCodeBuffer *disass_buffer; /* Instructions lisibles */ + GCodeBuffer **dec_buffers; /* Sources sous forme de texte */ + size_t decbuf_count; /* Taille des tableaux */ + size_t defsrc; /* Fichier source principal */ + + bool text_display[2]; /* Position et code binaire #1 */ + bool lines_display; /* Affichage des lignes */ + +}; + +/* Description de fichier binaire (classe) */ +struct _GLoadedBinaryClass +{ + GObjectClass parent; /* A laisser en premier */ + + /* Signaux */ + + void (* disassembly_done) (GLoadedBinary *); + +}; + + + +#endif /* _ANALYSIS_BINARY_INT_H */ diff --git a/src/analysis/binary.c b/src/analysis/binary.c index 73070b1..fe8188b 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -24,118 +24,56 @@ #include "binary.h" -#include #include #include #include #include -#include -#include -#include #include #include -#include "line_code.h" /* TODO : supprimer ? */ -#include "line_comment.h" /* TODO : supprimer ? */ -#include "line_prologue.h" +#include "binary-int.h" #include "routine.h" +#include "binaries/file.h" #include "decomp/decompiler.h" #include "disass/disassembler.h" -#include "../common/cpp.h" #include "../common/extstr.h" -#include "../debug/break.h" -#include "../format/format.h" -#include "../gui/panels/log.h" -#include "../plugins/pglist.h" /* TODO : supprimer ? */ - - -#include "../format/dbg_format.h" - - /* ------------------------ DESASSEMBLAGE DE BINAIRE DIFFERE ------------------------ */ -/* Description de fichier binaire (instance) */ -struct _GOpenidaBinary -{ - GObject parent; /* A laisser en premier */ - - char *filename; /* Fichier chargé en mémoire */ - - off_t bin_length; /* Taille des données brutes */ - bin_t *bin_data; /* Données binaires brutes */ - - GExeFormat *format; /* Format du binaire */ - GArchProcessor *proc; /* Architecture du binaire */ - - BinaryPartModel model; /* Modèle de sélection */ - GBinPart **parts[BPM_COUNT]; /* Parties binaires à analyser */ - size_t parts_count[BPM_COUNT]; /* Quantité de ces parties */ - - GRenderingLine *lines; /* Lignes de rendu en place */ - GRenderingOptions *options; /* Options de désassemblage */ - - GArchInstruction *instrs; /* Instructions d'assemblage */ - GCodeBuffer *disass_buffer; /* Instructions lisibles */ - GCodeBuffer **dec_buffers; /* Sources sous forme de texte */ - size_t decbuf_count; /* Taille des tableaux */ - size_t defsrc; /* Fichier source principal */ - - bool text_display[2]; /* Position et code binaire #1 */ - bool lines_display; /* Affichage des lignes */ - - GBreakGroup **brk_groups; /* Groupes de points d'arrêt */ - size_t brk_count; /* Taille de cette liste */ - GBreakGroup *brk_default; /* Groupe par défaut */ - -}; - -/* Description de fichier binaire (classe) */ -struct _GOpenidaBinaryClass -{ - GObjectClass parent; /* A laisser en premier */ - - /* Signaux */ - - void (* disassembly_done) (GOpenidaBinary *); - -}; - /* Initialise la classe des descriptions de fichier binaire. */ -static void g_openida_binary_class_init(GOpenidaBinaryClass *); +static void g_loaded_binary_class_init(GLoadedBinaryClass *); /* Initialise une description de fichier binaire. */ -static void g_openida_binary_init(GOpenidaBinary *); - -/* Charge en mémoire le contenu d'un fichier. */ -bin_t *map_binary_file(const char *, off_t *); - -/* Acquitte la fin d'un désasemblage différé et complet. */ -void ack_completed_disassembly(void/*GDelayedDisassembly*/ *, GOpenidaBinary *); +static void g_loaded_binary_init(GLoadedBinary *); +/* Supprime toutes les références externes. */ +static void g_loaded_binary_dispose(GLoadedBinary *); +/* Procède à la libération totale de la mémoire. */ +static void g_loaded_binary_finalize(GLoadedBinary *); +/* Charge les parties intéressantes du binaire à partir d'XML. */ +static bool g_loaded_binary_load_parts_from_xml(GLoadedBinary *, xmlXPathContextPtr, const char *); +/* Ecrit les parties de valeur du binaire dans un fichier XML. */ +static bool g_loaded_binary_save_parts(const GLoadedBinary *, xmlDocPtr, xmlXPathContextPtr, const char *); -/* ------------------------------ ELEMENTS DE DEBOGAGE ------------------------------ */ +/* Acquitte la fin d'un désasemblage différé et complet. */ +void ack_completed_disassembly(void/*GDelayedDisassembly*/ *, GLoadedBinary *); -/* Réagit à une nouvelle création de point d'arrêt. */ -static void g_openida_binary_breakpoint_added(GBreakGroup *, GBreakPoint *, GOpenidaBinary *); -/* Réagit à une suppression de point d'arrêt. */ -static void g_openida_binary_breakpoint_removed(GBreakGroup *, GBreakPoint *, GOpenidaBinary *); /* Indique le type défini pour une description de fichier binaire. */ -G_DEFINE_TYPE(GOpenidaBinary, g_openida_binary, G_TYPE_OBJECT); +G_DEFINE_TYPE(GLoadedBinary, g_loaded_binary, G_TYPE_OBJECT); /****************************************************************************** @@ -150,12 +88,19 @@ G_DEFINE_TYPE(GOpenidaBinary, g_openida_binary, G_TYPE_OBJECT); * * ******************************************************************************/ -static void g_openida_binary_class_init(GOpenidaBinaryClass *klass) +static void g_loaded_binary_class_init(GLoadedBinaryClass *klass) { + GObjectClass *object; /* Autre version de la classe */ + + object = G_OBJECT_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_loaded_binary_dispose; + object->finalize = (GObjectFinalizeFunc)g_loaded_binary_finalize; + g_signal_new("disassembly-done", - G_TYPE_OPENIDA_BINARY, + G_TYPE_LOADED_BINARY, G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(GOpenidaBinaryClass, disassembly_done), + G_STRUCT_OFFSET(GLoadedBinaryClass, disassembly_done), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); @@ -175,133 +120,143 @@ static void g_openida_binary_class_init(GOpenidaBinaryClass *klass) * * ******************************************************************************/ -static void g_openida_binary_init(GOpenidaBinary *binary) +static void g_loaded_binary_init(GLoadedBinary *binary) { binary->text_display[0] = true; binary->text_display[1] = true; binary->lines_display = true; - /* FIXME : à replacer ailleurs */ - g_openida_binary_add_break_group(binary, _("default")); - } /****************************************************************************** * * -* Paramètres : filename = nom du fichier à charger. * +* Paramètres : binary = instance d'objet GLib à traiter. * * * -* Description : Charge en mémoire le contenu d'un fichier. * +* Description : Supprime toutes les références externes. * * * -* Retour : Adresse de la représentation ou NULL en cas d'échec. * +* Retour : - * * * * Remarques : - * * * ******************************************************************************/ -GOpenidaBinary *g_openida_binary_new_from_file(const char *filename) +static void g_loaded_binary_dispose(GLoadedBinary *binary) { - GOpenidaBinary *result; /* Adresse à retourner */ - GPluginModule **pglist; /* Liste de greffons */ - size_t pgcount; /* Taille de cette liste */ - size_t i; /* Boucle de parcours */ - + gpointer obj_class; /* Classe parente */ - char *file = strdup(filename); + g_object_unref(G_OBJECT(binary->format)); + g_object_unref(G_OBJECT(binary->proc)); - result = g_object_new(G_TYPE_OPENIDA_BINARY, NULL); + /* TODO... */ + /* On passe le relai */ + obj_class = g_type_class_peek_parent(G_FILE_BINARY_GET_CLASS(binary)); + G_OBJECT_CLASS(obj_class)->dispose(G_OBJECT(binary)); - printf("%s\n", filename); +} +/****************************************************************************** +* * +* Paramètres : binary = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ - pglist = get_all_plugins_for_action(PGA_FORMAT_MATCHER, &pgcount); +static void g_loaded_binary_finalize(GLoadedBinary *binary) +{ + gpointer obj_class; /* Classe parente */ - if (pgcount > 0) - { - printf("===>>>> FOUND :: %d\n", pgcount); + /* TODO */ + /* On passe le relai */ - /* - for (i = 0; i < pgcount; i++) - g_plugin_module_execute_action_on_binary(pglist[i], binary, PGA_CODE_PROCESS); - */ - free(pglist); + obj_class = g_type_class_peek_parent(G_FILE_BINARY_GET_CLASS(binary)); - } + G_OBJECT_CLASS(obj_class)->finalize(G_OBJECT(binary)); +} +/****************************************************************************** +* * +* Paramètres : context = contexte pour les recherches XPath. * +* path = chemin d'accès au noeud XML à lire. * +* * +* Description : Charge en mémoire le contenu d'un fichier à partir d'XML. * +* * +* Retour : Adresse de la représentation ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ +GLoadedBinary *g_loaded_binary_new_from_xml(xmlXPathContextPtr context, const char *path) +{ + GLoadedBinary *result; /* Adresse à retourner */ + char *type; /* Tupe de binaire à charger */ + result = NULL; + type = get_node_prop_value(context, path, "type"); + if (strcmp(type, "file") == 0) + result = g_loaded_binary_new_from_xml(context, path); + free(type); - log_variadic_message(LMT_PROCESS, _("Opening '%s' file..."), filename); + if (result == NULL) + return NULL; - result->filename = strdup(filename); + if (!g_loaded_binary_load_parts_from_xml(result, context, path)) + goto glbnfx_error; - /* - result->bin_data = map_binary_file(filename, &result->bin_length); - if (result->bin_data == NULL) goto lbf_error; - */ + return result; - result->format = G_EXE_FORMAT(load_new_format(FMT_EXEC, file, - &result->bin_data, &result->bin_length)); - if (result->format == NULL) - { - log_simple_message(LMT_INFO, _("Unknown binary format")); - goto lbf_error; - } + glbnfx_error: - /* FIXME : à déplacer dans arch/... */ - switch (g_exe_format_get_target_machine(result->format)) - { - case FTM_ARM: - log_simple_message(LMT_INFO, _("Detected architecture: ARM")); - break; - case FTM_DALVIK: - log_simple_message(LMT_INFO, _("Detected architecture: Dalvik Virtual Machine")); - break; - case FTM_JVM: - log_simple_message(LMT_INFO, _("Detected architecture: Java Virtual Machine")); - break; - case FTM_MIPS: - log_simple_message(LMT_INFO, _("Detected architecture: Microprocessor without Interlocked Pipeline Stages")); - break; - case FTM_386: - log_simple_message(LMT_INFO, _("Detected architecture: i386")); - break; - default: - log_simple_message(LMT_INFO, _("Unknown architecture")); - goto lbf_error; - break; - } + g_object_unref(G_OBJECT(result)); - result->lines = NULL; + return NULL; - result->proc = get_arch_processor_from_format(result->format); +} - result->options = g_rendering_options_new(result->format); - g_rendering_options_show_address(result->options, MRD_BLOCK, true); - g_rendering_options_show_code(result->options, MRD_BLOCK, true); +/****************************************************************************** +* * +* Paramètres : binary = élément binaire à traiter. * +* xdoc = structure XML en cours d'édition. * +* context = contexte à utiliser pour les recherches. * +* path = chemin d'accès réservé au binaire. * +* * +* Description : Ecrit une sauvegarde du binaire dans un fichier XML. * +* * +* Retour : true si l'opération a bien tourné, false sinon. * +* * +* Remarques : - * +* * +******************************************************************************/ - g_rendering_options_show_address(result->options, MRD_GRAPH, true); - g_rendering_options_show_code(result->options, MRD_GRAPH, false); +bool g_loaded_binary_save(const GLoadedBinary *binary, xmlDocPtr xdoc, xmlXPathContextPtr context, const char *path) +{ + bool result; /* Bilan à faire remonter */ - return result; + result = binary->save(binary, xdoc, context, path); - lbf_error: + /* Parties à désassembler */ - //unload_binary_file(result); + result = g_loaded_binary_save_parts(binary, xdoc, context, path); - return NULL; + return result; } @@ -311,21 +266,18 @@ GOpenidaBinary *g_openida_binary_new_from_file(const char *filename) * Paramètres : context = contexte pour les recherches XPath. * * path = chemin d'accès au noeud XML à lire. * * * -* Description : Charge en mémoire le contenu d'un fichier à partir d'XML. * +* Description : Charge les parties intéressantes du binaire à partir d'XML. * * * -* Retour : Adresse de la représentation ou NULL en cas d'échec. * +* Retour : Bilan de l'opération. * * * * Remarques : - * * * ******************************************************************************/ -GOpenidaBinary *g_openida_binary_new_from_xml(xmlXPathContextPtr context, const char *path) +static bool g_loaded_binary_load_parts_from_xml(GLoadedBinary *binary, xmlXPathContextPtr context, const char *path) { - GOpenidaBinary *result; /* Adresse à retourner */ - char *type; /* Tupe de binaire à charger */ - size_t access_len; /* Taille d'un chemin interne */ + bool result; /* Bilan à retourner */ char *access; /* Chemin pour une sous-config.*/ - char *filename; /* Chemin du binaire à charger */ xmlXPathObjectPtr xobjects; /* Cible d'une recherche */ int i; /* Boucle de parcours */ GBinPart *part; /* Partie binaire à traiter */ @@ -334,33 +286,6 @@ GOpenidaBinary *g_openida_binary_new_from_xml(xmlXPathContextPtr context, const result = NULL; - /* Type */ - - type = get_node_prop_value(context, path, "type"); - - printf("###type### %s\n", type); - - free(type); - - /* Chemin du fichier à retrouver */ - - access = strdup(path); - access = stradd(access, "/Filename"); - - filename = get_node_text_value(context, access); - - free(access); - - /* Chargement */ - - if (filename != NULL) - { - result = g_openida_binary_new_from_file(filename); - free(filename); - } - - if (result == NULL) return NULL; - /* Parties à désassembler : default */ access = strdup(path); @@ -376,29 +301,29 @@ GOpenidaBinary *g_openida_binary_new_from_xml(xmlXPathContextPtr context, const { g_binary_part_get_values(part, &offset, NULL, NULL); - if (!g_exe_format_translate_offset_into_address(G_EXE_FORMAT(result->format), offset, &addr)) + if (!g_exe_format_translate_offset_into_address(G_EXE_FORMAT(binary->format), offset, &addr)) { g_object_unref(G_OBJECT(part)); continue; } - result->parts_count[BPM_DEFAULT]++; - result->parts[BPM_DEFAULT] = (GBinPart **)realloc(result->parts[BPM_DEFAULT], - result->parts_count[BPM_DEFAULT] * sizeof(GBinPart *)); + binary->parts_count[BPM_DEFAULT]++; + binary->parts[BPM_DEFAULT] = (GBinPart **)realloc(binary->parts[BPM_DEFAULT], + binary->parts_count[BPM_DEFAULT] * sizeof(GBinPart *)); - result->parts[BPM_DEFAULT][result->parts_count[BPM_DEFAULT] - 1] = part; + binary->parts[BPM_DEFAULT][binary->parts_count[BPM_DEFAULT] - 1] = part; } } - if(xobjects != NULL) /* FIXME */ + if(xobjects != NULL) xmlXPathFreeObject(xobjects); free(access); - qsort(result->parts[BPM_DEFAULT], result->parts_count[BPM_DEFAULT], - sizeof(GBinPart *), g_binary_part_compare); + qsort(binary->parts[BPM_DEFAULT], binary->parts_count[BPM_DEFAULT], + sizeof(GBinPart *), (__compar_fn_t)g_binary_part_compare); /* Parties à désassembler : routines */ @@ -415,30 +340,30 @@ GOpenidaBinary *g_openida_binary_new_from_xml(xmlXPathContextPtr context, const { g_binary_part_get_values(part, &offset, NULL, NULL); - if (!g_exe_format_translate_offset_into_address(G_EXE_FORMAT(result->format), offset, &addr)) + if (!g_exe_format_translate_offset_into_address(G_EXE_FORMAT(binary->format), offset, &addr)) { g_object_unref(G_OBJECT(part)); continue; } else g_binary_part_set_address(part, addr); - result->parts_count[BPM_ROUTINES]++; - result->parts[BPM_ROUTINES] = (GBinPart **)realloc(result->parts[BPM_ROUTINES], - result->parts_count[BPM_ROUTINES] * sizeof(GBinPart *)); + binary->parts_count[BPM_ROUTINES]++; + binary->parts[BPM_ROUTINES] = (GBinPart **)realloc(binary->parts[BPM_ROUTINES], + binary->parts_count[BPM_ROUTINES] * sizeof(GBinPart *)); - result->parts[BPM_ROUTINES][result->parts_count[BPM_ROUTINES] - 1] = part; + binary->parts[BPM_ROUTINES][binary->parts_count[BPM_ROUTINES] - 1] = part; } } - if(xobjects != NULL) /* FIXME */ + if(xobjects != NULL) xmlXPathFreeObject(xobjects); free(access); - qsort(result->parts[BPM_ROUTINES], result->parts_count[BPM_ROUTINES], - sizeof(GBinPart *), g_binary_part_compare); + qsort(binary->parts[BPM_ROUTINES], binary->parts_count[BPM_ROUTINES], + sizeof(GBinPart *), (__compar_fn_t)g_binary_part_compare); /* Parties à désassembler : utilisateur */ @@ -455,34 +380,29 @@ GOpenidaBinary *g_openida_binary_new_from_xml(xmlXPathContextPtr context, const { g_binary_part_get_values(part, &offset, NULL, NULL); - if (!g_exe_format_translate_offset_into_address(G_EXE_FORMAT(result->format), offset, &addr)) + if (!g_exe_format_translate_offset_into_address(G_EXE_FORMAT(binary->format), offset, &addr)) { g_object_unref(G_OBJECT(part)); continue; } - result->parts_count[BPM_USER]++; - result->parts[BPM_USER] = (GBinPart **)realloc(result->parts[BPM_USER], - result->parts_count[BPM_USER] * sizeof(GBinPart *)); + binary->parts_count[BPM_USER]++; + binary->parts[BPM_USER] = (GBinPart **)realloc(binary->parts[BPM_USER], + binary->parts_count[BPM_USER] * sizeof(GBinPart *)); - result->parts[BPM_USER][result->parts_count[BPM_USER] - 1] = part; + binary->parts[BPM_USER][binary->parts_count[BPM_USER] - 1] = part; } } - if(xobjects != NULL) /* FIXME */ + if(xobjects != NULL) xmlXPathFreeObject(xobjects); free(access); - qsort(result->parts[BPM_USER], result->parts_count[BPM_USER], - sizeof(GBinPart *), g_binary_part_compare); - - - - - + qsort(binary->parts[BPM_USER], binary->parts_count[BPM_USER], + sizeof(GBinPart *), (__compar_fn_t)g_binary_part_compare); return result; @@ -496,7 +416,7 @@ GOpenidaBinary *g_openida_binary_new_from_xml(xmlXPathContextPtr context, const * context = contexte à utiliser pour les recherches. * * path = chemin d'accès réservé au binaire. * * * -* Description : Ecrit une sauvegarde du binaire dans un fichier XML. * +* Description : Ecrit les parties de valeur du binaire dans un fichier XML. * * * * Retour : true si l'opération a bien tourné, false sinon. * * * @@ -504,7 +424,7 @@ GOpenidaBinary *g_openida_binary_new_from_xml(xmlXPathContextPtr context, const * * ******************************************************************************/ -bool g_openida_binary_save(const GOpenidaBinary *binary, xmlDocPtr xdoc, xmlXPathContextPtr context, const char *path) +static bool g_loaded_binary_save_parts(const GLoadedBinary *binary, xmlDocPtr xdoc, xmlXPathContextPtr context, const char *path) { bool result; /* Bilan à faire remonter */ char *access; /* Chemin d'accès à un élément */ @@ -513,21 +433,6 @@ bool g_openida_binary_save(const GOpenidaBinary *binary, xmlDocPtr xdoc, xmlXPat result = true; - /* Type */ - - result &= add_string_attribute_to_node(xdoc, context, path, "type", "file"); - - /* Nom du fichier associé */ - - access = strdup(path); - access = stradd(access, "/Filename"); - - result &= add_content_to_node(xdoc, context, access, binary->filename); - - free(access); - - /* Parties à désassembler */ - if (binary->parts_count[BPM_DEFAULT] > 0) { access = strdup(path); @@ -590,9 +495,9 @@ bool g_openida_binary_save(const GOpenidaBinary *binary, xmlDocPtr xdoc, xmlXPat * * ******************************************************************************/ -void g_openida_binary_set_parts(GOpenidaBinary *binary, BinaryPartModel model, GBinPart **parts, size_t count) +void g_loaded_binary_set_parts(GLoadedBinary *binary, BinaryPartModel model, GBinPart **parts, size_t count) { - qsort(parts, count, sizeof(GBinPart *), g_binary_part_compare); + qsort(parts, count, sizeof(GBinPart *), (__compar_fn_t)g_binary_part_compare); binary->parts[model] = parts; binary->parts_count[model] = count; @@ -614,7 +519,7 @@ void g_openida_binary_set_parts(GOpenidaBinary *binary, BinaryPartModel model, G * * ******************************************************************************/ -GBinPart ***g_openida_binary_get_parts(const GOpenidaBinary *binary, BinaryPartModel *model, size_t **count) +GBinPart ***g_loaded_binary_get_parts(const GLoadedBinary *binary, BinaryPartModel *model, size_t **count) { *model = binary->model; *count = binary->parts_count; @@ -636,7 +541,7 @@ GBinPart ***g_openida_binary_get_parts(const GOpenidaBinary *binary, BinaryPartM * * ******************************************************************************/ -void g_openida_binary_analyse(GOpenidaBinary *binary) +void g_loaded_binary_analyse(GLoadedBinary *binary) { GBinPart **parts; /* Parties d'élément binaire */ size_t parts_count; /* Nombre de ces parties */ @@ -660,7 +565,7 @@ void g_openida_binary_analyse(GOpenidaBinary *binary) else { parts = g_exe_format_get_parts(binary->format, &parts_count); - qsort(parts, parts_count, sizeof(GBinPart *), g_binary_part_compare); + qsort(parts, parts_count, sizeof(GBinPart *), (__compar_fn_t)g_binary_part_compare); } } @@ -676,25 +581,7 @@ void g_openida_binary_analyse(GOpenidaBinary *binary) /****************************************************************************** * * * Paramètres : binary = élément binaire à consulter. * -* * -* Description : Fournit une description humaine d'un élément binaire. * -* * -* Retour : Chaîne de caractères humainenement lisible de représentation.* -* * -* Remarques : - * -* * -******************************************************************************/ - -const char *g_openida_binary_to_string(const GOpenidaBinary *binary) -{ - return binary->filename; - -} - - -/****************************************************************************** -* * -* Paramètres : binary = élément binaire à consulter. * +* full = précise s'il s'agit d'une version longue ou non. * * * * Description : Fournit le fichier correspondant à l'élément binaire. * * * @@ -704,9 +591,9 @@ const char *g_openida_binary_to_string(const GOpenidaBinary *binary) * * ******************************************************************************/ -const char *g_openida_binary_get_filename(const GOpenidaBinary *binary) +const char *g_loaded_binary_get_filename(const GLoadedBinary *binary, bool full) { - return binary->filename; + return binary->get_filename(binary, full); } @@ -724,7 +611,7 @@ const char *g_openida_binary_get_filename(const GOpenidaBinary *binary) * * ******************************************************************************/ -bin_t *g_openida_binary_get_data(const GOpenidaBinary *binary, off_t *length) +bin_t *g_loaded_binary_get_data(const GLoadedBinary *binary, off_t *length) { if (length != NULL) *length = binary->bin_length; @@ -746,7 +633,7 @@ bin_t *g_openida_binary_get_data(const GOpenidaBinary *binary, off_t *length) * * ******************************************************************************/ -GExeFormat *g_openida_binary_get_format(const GOpenidaBinary *binary) +GExeFormat *g_loaded_binary_get_format(const GLoadedBinary *binary) { return binary->format; @@ -757,63 +644,6 @@ GExeFormat *g_openida_binary_get_format(const GOpenidaBinary *binary) * * * Paramètres : binary = élément binaire à consulter. * * * -* Description : Fournit les options d'affichage définies pour le binaire. * -* * -* Retour : Adresse des options d'affichage. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GRenderingOptions *g_openida_binary_get_options(const GOpenidaBinary *binary) -{ - return binary->options; - -} - - -/****************************************************************************** -* * -* Paramètres : binary = élément binaire à consulter. * -* * -* Description : Donne la racine des lignes de rendu issues du désassemblage. * -* * -* Retour : Lieu d'enregistrement des lignes issues du désassemblage. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GRenderingLine **g_openida_binary_get_lines_root(const GOpenidaBinary *binary) -{ - return &binary->lines; - -} - - -/****************************************************************************** -* * -* Paramètres : binary = élément binaire à consulter. * -* * -* Description : Fournit les lignes de rendu issues du désassemblage. * -* * -* Retour : Lignes issues du désassemblage. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GRenderingLine *g_openida_binary_get_lines(const GOpenidaBinary *binary) -{ - return binary->lines; - -} - - -/****************************************************************************** -* * -* Paramètres : binary = élément binaire à consulter. * -* * * Description : Fournit les instructions issues du désassemblage. * * * * Retour : Instructions issues du désassemblage. * @@ -822,7 +652,7 @@ GRenderingLine *g_openida_binary_get_lines(const GOpenidaBinary *binary) * * ******************************************************************************/ -GArchInstruction *g_openida_binary_get_instructions(const GOpenidaBinary *binary) +GArchInstruction *g_loaded_binary_get_instructions(const GLoadedBinary *binary) { return binary->instrs; @@ -841,7 +671,7 @@ GArchInstruction *g_openida_binary_get_instructions(const GOpenidaBinary *binary * * ******************************************************************************/ -GCodeBuffer *g_openida_binary_get_disassembled_buffer(const GOpenidaBinary *binary) +GCodeBuffer *g_loaded_binary_get_disassembled_buffer(const GLoadedBinary *binary) { return binary->disass_buffer; @@ -860,7 +690,7 @@ GCodeBuffer *g_openida_binary_get_disassembled_buffer(const GOpenidaBinary *bina * * ******************************************************************************/ -bool *g_openida_binary_display_addresses_in_text(const GOpenidaBinary *binary) +bool *g_loaded_binary_display_addresses_in_text(GLoadedBinary *binary) { return &binary->text_display[0]; @@ -879,7 +709,7 @@ bool *g_openida_binary_display_addresses_in_text(const GOpenidaBinary *binary) * * ******************************************************************************/ -bool *g_openida_binary_display_code_in_text(const GOpenidaBinary *binary) +bool *g_loaded_binary_display_code_in_text(GLoadedBinary *binary) { return &binary->text_display[1]; @@ -899,7 +729,7 @@ bool *g_openida_binary_display_code_in_text(const GOpenidaBinary *binary) * * ******************************************************************************/ -GCodeBuffer *g_openida_binary_get_decompiled_buffer(const GOpenidaBinary *binary, size_t index) +GCodeBuffer *g_loaded_binary_get_decompiled_buffer(const GLoadedBinary *binary, size_t index) { GCodeBuffer *result; /* Tampon à retourner */ @@ -926,7 +756,7 @@ GCodeBuffer *g_openida_binary_get_decompiled_buffer(const GOpenidaBinary *binary * * ******************************************************************************/ -bool *g_openida_binary_display_decomp_lines(const GOpenidaBinary *binary) +bool *g_loaded_binary_display_decomp_lines(GLoadedBinary *binary) { return &binary->lines_display; @@ -935,59 +765,6 @@ bool *g_openida_binary_display_decomp_lines(const GOpenidaBinary *binary) /****************************************************************************** * * -* Paramètres : filename = nom du fichier à charger. * -* length = taille des données mises en mémoire. [OUT] * -* * -* Description : Charge en mémoire le contenu d'un fichier. * -* * -* Retour : Adresse du contenu binaire ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bin_t *map_binary_file(const char *filename, off_t *length) -{ - uint8_t *result; /* Données à retourner */ - int fd; /* Fichier ouvert en lecture */ - struct stat info; /* Informations sur le fichier */ - int ret; /* Bilan d'un appel */ - - fd = open(filename, 0, O_RDONLY); - if (fd == -1) - { - perror("open()"); - return NULL; - } - - ret = fstat(fd, &info); - if (ret == -1) - { - perror("fstat()"); - close(fd); - return NULL; - } - - *length = info.st_size; - - result = (uint8_t *)mmap(NULL, *length, PROT_READ, MAP_PRIVATE, fd, 0); - if (result == MAP_FAILED) - { - perror("mmap()"); - result = NULL; - } - - ret = close(fd); - if (ret == -1) - perror("close()"); - - return result; - -} - - -/****************************************************************************** -* * * Paramètres : disass = travail de désassemblage mené à bien. * * binary = représentation de binaire à l'origine de l'opérat°. * * * @@ -999,9 +776,9 @@ bin_t *map_binary_file(const char *filename, off_t *length) * * ******************************************************************************/ -void ack_completed_disassembly(void/*GDelayedDisassembly*/ *disass, GOpenidaBinary *binary) +void ack_completed_disassembly(void/*GDelayedDisassembly*/ *disass, GLoadedBinary *binary) { - GRenderingLine *line; /* "Première" ligne de rendu */ + //GRenderingLine *line; /* "Première" ligne de rendu */ size_t i; /* Boucle de parcours */ @@ -1040,196 +817,3 @@ void ack_completed_disassembly(void/*GDelayedDisassembly*/ *disass, GOpenidaBina g_signal_emit_by_name(binary, "disassembly-done"); } - - - -/* ---------------------------------------------------------------------------------- */ -/* ELEMENTS DE DEBOGAGE */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -* * -* Paramètres : binary = représentation de binaire à modifier. * -* name = éventuel nom à associer au groupe. * -* * -* Description : Ajoute un nouveau groupe de points d'arrêt au binaire. * -* * -* Retour : true si l'opération s'est bien effectuée, false sinon. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool g_openida_binary_add_break_group(GOpenidaBinary *binary, const char *name) -{ - bool result; /* Bilan à faire remonter */ - const char *used; /* Désignation à utiliser */ - size_t tmp_len; /* Longeur maximale à gérer */ - char *tmp; /* Construction temporaire */ - size_t i; /* Boucle de parcours */ - const char *test; /* Nom existant à tester */ - - result = true; - - /* Préparation du nom de scène */ - - if (name != NULL) used = name; - else - { - tmp_len = strlen(_("Group")) + 1 + SIZE_T_MAXLEN + 1; - tmp = (char *)calloc(tmp_len, sizeof(char)); - - snprintf(tmp, tmp_len, "%s %lu", _("Group"), binary->brk_count); - - used = tmp; - - } - - /* Vérification d'unicité */ - - for (i = 0; i < binary->brk_count && result; i++) - { - test = g_break_group_get_name(binary->brk_groups[i]); - - if (test != NULL) - result = (strcmp(used, test) != 0); - - } - - /* Mise en place finale */ - - if (result) - { - binary->brk_count++; - binary->brk_groups = (GBreakGroup **)realloc(binary->brk_groups, - binary->brk_count * sizeof(GBreakGroup *)); - - binary->brk_groups[i] = g_break_group_new(); - - g_break_group_set_name(binary->brk_groups[i], used); - - if (binary->brk_default == NULL) - binary->brk_default = binary->brk_groups[i]; - - g_signal_connect(binary->brk_groups[i], "added", - G_CALLBACK(g_openida_binary_breakpoint_added), binary); - - g_signal_connect(binary->brk_groups[i], "removed", - G_CALLBACK(g_openida_binary_breakpoint_removed), binary); - - } - - if (name == NULL) free(tmp); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : group = ensemble de points d'arrêt intervenant. * -* point = point d'arrêt à l'origine de la procédure. * -* binary = représentation de binaire à modifier. * -* * -* Description : Réagit à une nouvelle création de point d'arrêt. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_openida_binary_breakpoint_added(GBreakGroup *group, GBreakPoint *point, GOpenidaBinary *binary) -{ - GRenderingLine *line; /* Ligne à retrouver */ - - line = g_rendering_line_find_by_address(binary->lines, NULL, - g_break_point_get_address(point)); - - if (line != NULL) - g_rendering_line_toggle_flag(line, RLF_BREAK_POINT); - -} - - -/****************************************************************************** -* * -* Paramètres : group = ensemble de points d'arrêt intervenant. * -* point = point d'arrêt à l'origine de la procédure. * -* binary = représentation de binaire à modifier. * -* * -* Description : Réagit à une suppression de point d'arrêt. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_openida_binary_breakpoint_removed(GBreakGroup *group, GBreakPoint *point, GOpenidaBinary *binary) -{ - GRenderingLine *line; /* Ligne à retrouver */ - - line = g_rendering_line_find_by_address(binary->lines, NULL, - g_break_point_get_address(point)); - - if (line != NULL) - g_rendering_line_toggle_flag(line, RLF_BREAK_POINT); - -} - - -/****************************************************************************** -* * -* Paramètres : binary = représentation de binaire à mettre à jour. * -* addr = adresse mémoire à faire basculer. * -* * -* Description : Ajoute ou supprime un point d'arrêt dans un binaire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_openida_binary_toggle_breakpoint(GOpenidaBinary *binary, vmpa_t addr) -{ - size_t i; /* Boucle de parcours */ - - for (i = 0; i < binary->brk_count; i++) - if (g_break_group_has_address(binary->brk_groups[i], addr)) - { - g_break_group_toggle_breakpoint(binary->brk_groups[i], addr); - break; - } - - if (i == binary->brk_count) - g_break_group_toggle_breakpoint(binary->brk_default, addr); - -} - - -/****************************************************************************** -* * -* Paramètres : binary = représentation de binaire à parcourir. * -* func = fonction à appeler à chaque point trouvé. * -* data = éventuelle donnée de l'utilisateur à joindre. * -* * -* Description : Parcourt l'ensemble des groupes de points d'arrêt du binaire.* -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_openida_binary_for_each_bp_group(GOpenidaBinary *binary, GExtFunc func, gpointer data) -{ - size_t i; /* Boucle de parcours */ - - for (i = 0; i < binary->brk_count; i++) - func(binary, binary->brk_groups[i], data); - -} diff --git a/src/analysis/binary.h b/src/analysis/binary.h index 63a9e61..7ff9080 100644 --- a/src/analysis/binary.h +++ b/src/analysis/binary.h @@ -32,24 +32,23 @@ #include "line.h" #include "../arch/processor.h" #include "../common/xml.h" -#include "../debug/break.h" #include "../format/executable.h" #include "../glibext/gcodebuffer.h" -#define G_TYPE_OPENIDA_BINARY g_openida_binary_get_type() -#define G_OPENIDA_BINARY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_openida_binary_get_type(), GOpenidaBinary)) -#define G_IS_OPENIDA_BINARY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_openida_binary_get_type())) -#define G_OPENIDA_BINARY_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_openida_binary_get_type(), GOpenidaBinaryIface)) -#define G_OPENIDA_BINARY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_OPENIDA_BINARY, GOpenidaBinaryClass)) +#define G_TYPE_LOADED_BINARY g_loaded_binary_get_type() +#define G_LOADED_BINARY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_loaded_binary_get_type(), GLoadedBinary)) +#define G_IS_LOADED_BINARY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_loaded_binary_get_type())) +#define G_LOADED_BINARY_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_loaded_binary_get_type(), GLoadedBinaryIface)) +#define G_LOADED_BINARY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_LOADED_BINARY, GLoadedBinaryClass)) /* Description de fichier binaire (instance) */ -typedef struct _GOpenidaBinary GOpenidaBinary; +typedef struct _GLoadedBinary GLoadedBinary; /* Description de fichier binaire (classe) */ -typedef struct _GOpenidaBinaryClass GOpenidaBinaryClass; +typedef struct _GLoadedBinaryClass GLoadedBinaryClass; /* Modèle de sélection des parties */ @@ -65,78 +64,49 @@ typedef enum _BinaryPartModel /* Indique le type défini pour une description de fichier binaire. */ -GType g_openida_binary_get_type(void); - -/* Charge en mémoire le contenu d'un fichier. */ -GOpenidaBinary *g_openida_binary_new_from_file(const char *); +GType g_loaded_binary_get_type(void); /* Charge en mémoire le contenu d'un fichier à partir d'XML. */ -GOpenidaBinary *g_openida_binary_new_from_xml(xmlXPathContextPtr, const char *); +GLoadedBinary *g_loaded_binary_new_from_xml(xmlXPathContextPtr, const char *); /* Ecrit une sauvegarde du binaire dans un fichier XML. */ -bool g_openida_binary_save(const GOpenidaBinary *, xmlDocPtr, xmlXPathContextPtr, const char *); +bool g_loaded_binary_save(const GLoadedBinary *, xmlDocPtr, xmlXPathContextPtr, const char *); /* Définit les parties de binaire à analyser. */ -void g_openida_binary_set_parts(GOpenidaBinary *, BinaryPartModel, GBinPart **, size_t); +void g_loaded_binary_set_parts(GLoadedBinary *, BinaryPartModel, GBinPart **, size_t); /* Fournit les parties de binaire analysées. */ -GBinPart ***g_openida_binary_get_parts(const GOpenidaBinary *, BinaryPartModel *, size_t **); +GBinPart ***g_loaded_binary_get_parts(const GLoadedBinary *, BinaryPartModel *, size_t **); /* Lance l'analyse d'un élément binaire chargé. */ -void g_openida_binary_analyse(GOpenidaBinary *); - -/* Fournit une description humaine d'un élément binaire. */ -const char *g_openida_binary_to_string(const GOpenidaBinary *); +void g_loaded_binary_analyse(GLoadedBinary *); /* Fournit le fichier correspondant à l'élément binaire. */ -const char *g_openida_binary_get_filename(const GOpenidaBinary *); +const char *g_loaded_binary_get_filename(const GLoadedBinary *, bool); /* Fournit les détails du contenu binaire chargé en mémoire. */ -bin_t *g_openida_binary_get_data(const GOpenidaBinary *, off_t *); +bin_t *g_loaded_binary_get_data(const GLoadedBinary *, off_t *); /* Fournit le format de fichier reconnu dans le contenu binaire. */ -GExeFormat *g_openida_binary_get_format(const GOpenidaBinary *); - -/* Fournit les options d'affichage définies pour le binaire. */ -GRenderingOptions *g_openida_binary_get_options(const GOpenidaBinary *); - -/* Donne la racine des lignes de rendu issues du désassemblage. */ -GRenderingLine **g_openida_binary_get_lines_root(const GOpenidaBinary *); - -/* Fournit les lignes de rendu issues du désassemblage. */ -GRenderingLine *g_openida_binary_get_lines(const GOpenidaBinary *); +GExeFormat *g_loaded_binary_get_format(const GLoadedBinary *); /* Fournit les instructions issues du désassemblage. */ -GArchInstruction *g_openida_binary_get_instructions(const GOpenidaBinary *); +GArchInstruction *g_loaded_binary_get_instructions(const GLoadedBinary *); /* Fournit le tampon associé au contenu assembleur d'un binaire. */ -GCodeBuffer *g_openida_binary_get_disassembled_buffer(const GOpenidaBinary *); +GCodeBuffer *g_loaded_binary_get_disassembled_buffer(const GLoadedBinary *); /* Indique si les adresses doivent apparaître dans le rendu. */ -bool *g_openida_binary_display_addresses_in_text(const GOpenidaBinary *); +bool *g_loaded_binary_display_addresses_in_text(GLoadedBinary *); /* Indique si le code doit apparaître dans le rendu. */ -bool *g_openida_binary_display_code_in_text(const GOpenidaBinary *); +bool *g_loaded_binary_display_code_in_text(GLoadedBinary *); /* Fournit le tampon associé au contenu d'un fichier source. */ -GCodeBuffer *g_openida_binary_get_decompiled_buffer(const GOpenidaBinary *, size_t); +GCodeBuffer *g_loaded_binary_get_decompiled_buffer(const GLoadedBinary *, size_t); /* Indique si les lignes doivent apparaître dans le rendu. */ -bool *g_openida_binary_display_decomp_lines(const GOpenidaBinary *); - - - -/* ------------------------------ ELEMENTS DE DEBOGAGE ------------------------------ */ - - -/* Ajoute un nouveau groupe de points d'arrêt au binaire. */ -bool g_openida_binary_add_break_group(GOpenidaBinary *, const char *); - -/* Ajoute ou supprime un point d'arrêt dans un binaire. */ -void g_openida_binary_toggle_breakpoint(GOpenidaBinary *, vmpa_t); - -/* Parcourt l'ensemble des groupes de points d'arrêt du binaire. */ -void g_openida_binary_for_each_bp_group(GOpenidaBinary *, GExtFunc, gpointer); +bool *g_loaded_binary_display_decomp_lines(GLoadedBinary *); diff --git a/src/analysis/decomp/decompiler.c b/src/analysis/decomp/decompiler.c index 42dc1ff..8e574c0 100644 --- a/src/analysis/decomp/decompiler.c +++ b/src/analysis/decomp/decompiler.c @@ -42,7 +42,7 @@ static void build_decomp_prologue(GCodeBuffer *, const char *); /* S'assure de la transcription de routines en expressions. */ -static void prepare_all_routines_for_decomp(const GOpenidaBinary *, const char *); +static void prepare_all_routines_for_decomp(const GLoadedBinary *, const char *); @@ -127,7 +127,7 @@ static void build_decomp_prologue(GCodeBuffer *buffer, const char *filename) * * ******************************************************************************/ -static void prepare_all_routines_for_decomp(const GOpenidaBinary *binary, const char *filename) +static void prepare_all_routines_for_decomp(const GLoadedBinary *binary, const char *filename) { GExeFormat *format; /* Format du binaire fourni */ GArchProcessor *proc; /* Architecture du binaire */ @@ -140,7 +140,7 @@ static void prepare_all_routines_for_decomp(const GOpenidaBinary *binary, const GDecContext *context; /* Contexte pour la décompil. */ GDecInstruction *instr; - format = g_openida_binary_get_format(binary); + format = g_loaded_binary_get_format(binary); proc = get_arch_processor_from_format(G_EXE_FORMAT(format)); @@ -179,7 +179,7 @@ static void prepare_all_routines_for_decomp(const GOpenidaBinary *binary, const * * ******************************************************************************/ -GCodeBuffer *decompile_all_from_file(const GOpenidaBinary *binary, const char *filename) +GCodeBuffer *decompile_all_from_file(const GLoadedBinary *binary, const char *filename) { GCodeBuffer *result; /* Tampon constitué à renvoyer */ GExeFormat *format; /* Format du binaire fourni */ @@ -195,7 +195,7 @@ GCodeBuffer *decompile_all_from_file(const GOpenidaBinary *binary, const char *f - format = g_openida_binary_get_format(binary); + format = g_loaded_binary_get_format(binary); g_binary_format_decompile(G_BIN_FORMAT(format), result, filename); return result; diff --git a/src/analysis/decomp/decompiler.h b/src/analysis/decomp/decompiler.h index 363ad27..5233b74 100644 --- a/src/analysis/decomp/decompiler.h +++ b/src/analysis/decomp/decompiler.h @@ -30,7 +30,7 @@ /* Procède à la décompilation des routines d'un fichier donné. */ -GCodeBuffer *decompile_all_from_file(const GOpenidaBinary *, const char *); +GCodeBuffer *decompile_all_from_file(const GLoadedBinary *, const char *); diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c index 872dc09..73d75cf 100644 --- a/src/analysis/disass/disassembler.c +++ b/src/analysis/disass/disassembler.c @@ -60,7 +60,7 @@ typedef struct _GDelayedDisassembly { GDelayedWork parent; /* A laisser en premier */ - const GOpenidaBinary *binary; /* Destinataire final */ + const GLoadedBinary *binary; /* Destinataire final */ const GExeFormat *format; /* Format du binaire représenté*/ GBinPart **parts; /* Parties binaires à traiter */ @@ -89,7 +89,7 @@ static void g_delayed_disassembly_class_init(GDelayedDisassemblyClass *); static void g_delayed_disassembly_init(GDelayedDisassembly *); /* Crée une tâche de désassemblage différé. */ -static GDelayedDisassembly *g_delayed_disassembly_new(const GOpenidaBinary *, GBinPart **, size_t, GCodeBuffer *); +static GDelayedDisassembly *g_delayed_disassembly_new(const GLoadedBinary *, GBinPart **, size_t, GCodeBuffer *); /* Assure le désassemblage en différé. */ static void g_delayed_disassembly_process(GDelayedDisassembly *, GtkExtStatusBar *); @@ -165,14 +165,14 @@ static void g_delayed_disassembly_init(GDelayedDisassembly *disass) * * ******************************************************************************/ -static GDelayedDisassembly *g_delayed_disassembly_new(const GOpenidaBinary *binary, GBinPart **parts, size_t count, GCodeBuffer *buffer) +static GDelayedDisassembly *g_delayed_disassembly_new(const GLoadedBinary *binary, GBinPart **parts, size_t count, GCodeBuffer *buffer) { GDelayedDisassembly *result; /* Tâche à retourner */ result = g_object_new(G_TYPE_DELAYED_DISASSEMBLY, NULL); result->binary = binary; - result->format = g_openida_binary_get_format(binary); + result->format = g_loaded_binary_get_format(binary); result->parts = parts; result->count = count; @@ -381,7 +381,7 @@ static void build_disass_prologue(GCodeBuffer *buffer, const char *filename, con * * ******************************************************************************/ -void disassemble_binary(GOpenidaBinary *binary, GBinPart **parts, size_t parts_count, GArchInstruction **instrs, GCodeBuffer **buffer) +void disassemble_binary(GLoadedBinary *binary, GBinPart **parts, size_t parts_count, GArchInstruction **instrs, GCodeBuffer **buffer) { const uint8_t *data; /* Données binaires brutes */ off_t length; /* Quantité de ces données */ @@ -395,8 +395,8 @@ void disassemble_binary(GOpenidaBinary *binary, GBinPart **parts, size_t parts_c *buffer = g_code_buffer_new(); - data = g_openida_binary_get_data(binary, &length); - build_disass_prologue(*buffer, g_openida_binary_get_filename(binary), data, length); + data = g_loaded_binary_get_data(binary, &length); + build_disass_prologue(*buffer, g_loaded_binary_get_filename(binary, true), data, length); disass = g_delayed_disassembly_new(binary, parts, parts_count, *buffer); diff --git a/src/analysis/disass/disassembler.h b/src/analysis/disass/disassembler.h index 2c5adef..8cca194 100644 --- a/src/analysis/disass/disassembler.h +++ b/src/analysis/disass/disassembler.h @@ -31,7 +31,7 @@ /* Procède à la décompilation des routines d'un fichier donné. */ -void disassemble_binary(GOpenidaBinary *, GBinPart **parts, size_t parts_count, GArchInstruction **, GCodeBuffer **); +void disassemble_binary(GLoadedBinary *, GBinPart **parts, size_t parts_count, GArchInstruction **, GCodeBuffer **); diff --git a/src/analysis/disass/fetch.c b/src/analysis/disass/fetch.c index 6bd9795..a1df5e3 100644 --- a/src/analysis/disass/fetch.c +++ b/src/analysis/disass/fetch.c @@ -45,7 +45,7 @@ * * ******************************************************************************/ -GArchInstruction *disassemble_binary_parts(const GOpenidaBinary *binary, GBinPart **parts, size_t count, GtkExtStatusBar *statusbar, guint id) +GArchInstruction *disassemble_binary_parts(const GLoadedBinary *binary, GBinPart **parts, size_t count, GtkExtStatusBar *statusbar, guint id) { GArchInstruction *result; /* Liste d'instr. à renvoyer */ GBinFormat *format; /* Format du fichier binaire */ @@ -69,9 +69,9 @@ GArchInstruction *disassemble_binary_parts(const GOpenidaBinary *binary, GBinPar result = NULL; - format = G_BIN_FORMAT(g_openida_binary_get_format(binary)); + format = G_BIN_FORMAT(g_loaded_binary_get_format(binary)); proc = get_arch_processor_from_format(G_EXE_FORMAT(format)); - bin_data = g_openida_binary_get_data(binary, &bin_length); + bin_data = g_loaded_binary_get_data(binary, &bin_length); /* Préparation du suivi de la progression */ diff --git a/src/analysis/disass/fetch.h b/src/analysis/disass/fetch.h index 09bb584..89c3226 100644 --- a/src/analysis/disass/fetch.h +++ b/src/analysis/disass/fetch.h @@ -31,7 +31,7 @@ /* Procède au désassemblage basique d'un contenu binaire. */ -GArchInstruction *disassemble_binary_parts(const GOpenidaBinary *, GBinPart **, size_t, GtkExtStatusBar *, guint); +GArchInstruction *disassemble_binary_parts(const GLoadedBinary *, GBinPart **, size_t, GtkExtStatusBar *, guint); diff --git a/src/debug/debugger-int.h b/src/debug/debugger-int.h index f6f51ad..c978731 100644 --- a/src/debug/debugger-int.h +++ b/src/debug/debugger-int.h @@ -56,7 +56,7 @@ struct _GBinaryDebugger { GObject parent; /* A laisser en premier */ - GOpenidaBinary *binary; /* Cible à traiter */ + GLoadedBinary *binary; /* Cible à traiter */ attach_debugger_fc attach; /* Démarre le débogueur */ diff --git a/src/debug/debugger.c b/src/debug/debugger.c index 73b8719..19f4f65 100644 --- a/src/debug/debugger.c +++ b/src/debug/debugger.c @@ -108,7 +108,7 @@ static void g_binary_debugger_init(GBinaryDebugger *debugger) * * ******************************************************************************/ -GBinaryDebugger *g_new_binary_debugger(DebuggerType type, GOpenidaBinary *binary) +GBinaryDebugger *g_new_binary_debugger(DebuggerType type, GLoadedBinary *binary) { GBinaryDebugger *result; diff --git a/src/debug/debugger.h b/src/debug/debugger.h index 7a6459b..e4c9458 100644 --- a/src/debug/debugger.h +++ b/src/debug/debugger.h @@ -85,7 +85,7 @@ typedef struct _GBinaryDebuggerClass GBinaryDebuggerClass; GType g_binary_debugger_get_type(void); /* Crée un nouveau débogueur. */ -GBinaryDebugger *g_new_binary_debugger(DebuggerType, GOpenidaBinary *); +GBinaryDebugger *g_new_binary_debugger(DebuggerType, GLoadedBinary *); /* Démarre une procédure de débogage. */ bool g_binary_debugger_attach(GBinaryDebugger *); diff --git a/src/debug/jdwp/debugger.c b/src/debug/jdwp/debugger.c index b416840..d63c068 100644 --- a/src/debug/jdwp/debugger.c +++ b/src/debug/jdwp/debugger.c @@ -147,7 +147,7 @@ static void g_java_debugger_init(GJavaDebugger *debugger) * * ******************************************************************************/ -GBinaryDebugger *g_java_debugger_new(GOpenidaBinary *binary, void *options) +GBinaryDebugger *g_java_debugger_new(GLoadedBinary *binary, void *options) { GBinaryDebugger *result; /* Débogueur à retourner */ diff --git a/src/debug/jdwp/debugger.h b/src/debug/jdwp/debugger.h index c19a415..69a1545 100644 --- a/src/debug/jdwp/debugger.h +++ b/src/debug/jdwp/debugger.h @@ -51,7 +51,7 @@ typedef struct _GJavaDebuggerClass GJavaDebuggerClass; GType g_java_debugger_get_type(void); /* Crée un débogueur utilisant un serveur Java distant. */ -GBinaryDebugger *g_java_debugger_new(GOpenidaBinary *, void *); +GBinaryDebugger *g_java_debugger_new(GLoadedBinary *, void *); void test_java(void); diff --git a/src/debug/remgdb/gdb.c b/src/debug/remgdb/gdb.c index caff762..681ff00 100644 --- a/src/debug/remgdb/gdb.c +++ b/src/debug/remgdb/gdb.c @@ -149,7 +149,7 @@ static void g_gdb_debugger_init(GGdbDebugger *debugger) * * ******************************************************************************/ -GBinaryDebugger *g_gdb_debugger_new(GOpenidaBinary *binary, void *options) +GBinaryDebugger *g_gdb_debugger_new(GLoadedBinary *binary, void *options) { GBinaryDebugger *result; /* Débogueur à retourner */ diff --git a/src/debug/remgdb/gdb.h b/src/debug/remgdb/gdb.h index 6cda59e..30ee2f0 100644 --- a/src/debug/remgdb/gdb.h +++ b/src/debug/remgdb/gdb.h @@ -51,7 +51,7 @@ typedef struct _GGdbDebuggerClass GGdbDebuggerClass; GType g_gdb_debugger_get_type(void); /* Crée un débogueur utilisant un serveur GDB distant. */ -GBinaryDebugger *g_gdb_debugger_new(GOpenidaBinary *, void *); +GBinaryDebugger *g_gdb_debugger_new(GLoadedBinary *, void *); void test_gdb(void); diff --git a/src/dialogs/add_shellcode.c b/src/dialogs/add_shellcode.c index 78bfb9d..65e081b 100644 --- a/src/dialogs/add_shellcode.c +++ b/src/dialogs/add_shellcode.c @@ -184,7 +184,7 @@ static void export_assistant_cancel(GtkAssistant *assistant, gpointer data) static void export_assistant_close(GtkAssistant *assistant, GObject *ref) { - GOpenidaBinary *binary; /* Binaire chargé à parcourir */ + GLoadedBinary *binary; /* Binaire chargé à parcourir */ GExeFormat *format; /* Format du binaire */ GRenderingOptions *options; /* Options d'exportation */ GtkToggleButton *checkbutton; /* Coche à retrouver */ @@ -192,9 +192,9 @@ static void export_assistant_close(GtkAssistant *assistant, GObject *ref) GtkEntry *entry; /* Zone de saisie */ const gchar *filename; /* Chemin d'accès du fichier */ - //binary = G_OPENIDA_BINARY(g_object_get_data(ref, "binary")); + //binary = G_LOADED_BINARY(g_object_get_data(ref, "binary")); - format = g_openida_binary_get_format(binary); + format = g_loaded_binary_get_format(binary); options = g_rendering_options_new(format); /* Eléments à afficher */ @@ -285,8 +285,8 @@ static void register_bincode_panel(GtkAssistant *assistant) /* Choix par défaut */ /* - binary = G_OPENIDA_BINARY(g_object_get_data(G_OBJECT(assistant), "binary")); - filename = g_openida_binary_get_filename(binary); + binary = G_LOADED_BINARY(g_object_get_data(G_OBJECT(assistant), "binary")); + filename = g_loaded_binary_get_filename(binary); gtk_entry_set_text(GTK_ENTRY(entry), filename); gtk_entry_append_text(GTK_ENTRY(entry), ".txt"); @@ -611,7 +611,7 @@ static void register_output_panel(GtkAssistant *assistant) GtkWidget *combobox; /* Sélection du format */ GtkWidget *entry; /* Zone de saisie de texte */ GtkWidget *button; /* Sélection de fichier */ - GOpenidaBinary *binary; /* Binaire chargé à parcourir */ + GLoadedBinary *binary; /* Binaire chargé à parcourir */ const char *filename; /* Chemin d'accès par défaut */ alignment = qck_create_padded_alignment(8, 8, 8, 8); @@ -661,8 +661,8 @@ static void register_output_panel(GtkAssistant *assistant) /* Choix par défaut */ /* - binary = G_OPENIDA_BINARY(g_object_get_data(G_OBJECT(assistant), "binary")); - filename = g_openida_binary_get_filename(binary); + binary = G_LOADED_BINARY(g_object_get_data(G_OBJECT(assistant), "binary")); + filename = g_loaded_binary_get_filename(binary); gtk_entry_set_text(GTK_ENTRY(entry), filename); gtk_entry_append_text(GTK_ENTRY(entry), ".txt"); diff --git a/src/dialogs/binparts.c b/src/dialogs/binparts.c index 054c7bf..14e1422 100644 --- a/src/dialogs/binparts.c +++ b/src/dialogs/binparts.c @@ -68,7 +68,7 @@ static void save_current_selection(GtkButton *, GObject *); static void close_editor(GtkButton *, GtkWidget *); /* Charge les parties courantes d'un binaire donné. */ -static void load_binary_current_parts(GOpenidaBinary *binary, GObject *ref); +static void load_binary_current_parts(GLoadedBinary *binary, GObject *ref); /* Affiche les parties désassemblées par défaut. */ static void load_default_parts(GObject *); @@ -99,7 +99,7 @@ static void on_part_selection_toggle(GtkCellRendererToggle *, gchar *, GObject * * * ******************************************************************************/ -GtkWidget *create_sections_dialog(GOpenidaBinary *binary, GtkWindow *parent) +GtkWidget *create_sections_dialog(GLoadedBinary *binary, GtkWindow *parent) { GtkWidget *result; /* Fenêtre à renvoyer */ GObject *ref; /* Espace de référencements */ @@ -345,7 +345,7 @@ static void save_current_selection(GtkButton *button, GObject *ref) - GOpenidaBinary *binary; /* Binaire à traiter */ + GLoadedBinary *binary; /* Binaire à traiter */ GExeFormat *format; /* Format associé au binaire */ GArchProcessor *proc; /* Architecture utilisée */ @@ -363,9 +363,9 @@ static void save_current_selection(GtkButton *button, GObject *ref) off_t offset; /* Position dans le binaire */ - binary = G_OPENIDA_BINARY(g_object_get_data(ref, "binary")); + binary = G_LOADED_BINARY(g_object_get_data(ref, "binary")); - format = g_openida_binary_get_format(binary); + format = g_loaded_binary_get_format(binary); proc = get_arch_processor_from_format(format); @@ -402,7 +402,7 @@ static void save_current_selection(GtkButton *button, GObject *ref) } - g_openida_binary_set_parts(binary, BPM_ROUTINES, parts, parts_count); + g_loaded_binary_set_parts(binary, BPM_ROUTINES, parts, parts_count); @@ -451,7 +451,7 @@ static void close_editor(GtkButton *button, GtkWidget *widget) * * ******************************************************************************/ -static void load_binary_current_parts(GOpenidaBinary *binary, GObject *ref) +static void load_binary_current_parts(GLoadedBinary *binary, GObject *ref) { GtkTreeModel *store; /* Modèle de représentation */ GBinPart ***list; /* Tableau de parties choisies */ @@ -472,7 +472,7 @@ static void load_binary_current_parts(GOpenidaBinary *binary, GObject *ref) store = GTK_TREE_MODEL(g_object_get_data(ref, "store")); - list = g_openida_binary_get_parts(binary, &model, &count); + list = g_loaded_binary_get_parts(binary, &model, &count); for (i = 0; i < (BPM_COUNT - 1 /* TODO*/); i++) { @@ -535,7 +535,7 @@ static void load_binary_current_parts(GOpenidaBinary *binary, GObject *ref) static void load_default_parts(GObject *ref) { - GOpenidaBinary *binary; /* Binaire à traiter */ + GLoadedBinary *binary; /* Binaire à traiter */ GtkTreeStore *store; /* Modèle de gestion */ GExeFormat *format; /* Format associé au binaire */ GArchProcessor *proc; /* Architecture utilisée */ @@ -550,10 +550,10 @@ static void load_default_parts(GObject *ref) char end[VMPA_MAX_SIZE]; /* Version humainement lisible */ GtkTreeIter iter; /* Point d'insertion */ - binary = G_OPENIDA_BINARY(g_object_get_data(ref, "binary")); + binary = G_LOADED_BINARY(g_object_get_data(ref, "binary")); store = GTK_TREE_STORE(g_object_get_data(ref, "store")); - format = g_openida_binary_get_format(binary); + format = g_loaded_binary_get_format(binary); proc = get_arch_processor_from_format(format); parts = g_exe_format_get_parts(format, &parts_count); @@ -609,7 +609,7 @@ static void load_default_parts(GObject *ref) static void load_routines_parts(GObject *ref) { - GOpenidaBinary *binary; /* Binaire à traiter */ + GLoadedBinary *binary; /* Binaire à traiter */ GtkTreeStore *store; /* Modèle de gestion */ GExeFormat *format; /* Format associé au binaire */ GArchProcessor *proc; /* Architecture utilisée */ @@ -623,10 +623,10 @@ static void load_routines_parts(GObject *ref) char end[VMPA_MAX_SIZE]; /* Version humainement lisible */ GtkTreeIter iter; /* Point d'insertion */ - binary = G_OPENIDA_BINARY(g_object_get_data(ref, "binary")); + binary = G_LOADED_BINARY(g_object_get_data(ref, "binary")); store = GTK_TREE_STORE(g_object_get_data(ref, "store")); - format = g_openida_binary_get_format(binary); + format = g_loaded_binary_get_format(binary); proc = get_arch_processor_from_format(format); routines = g_binary_format_get_routines(G_BIN_FORMAT(format), &routines_count); diff --git a/src/dialogs/binparts.h b/src/dialogs/binparts.h index 0880f85..e21d990 100644 --- a/src/dialogs/binparts.h +++ b/src/dialogs/binparts.h @@ -33,7 +33,7 @@ /* Construit la fenêtre de sélection des sections. */ -GtkWidget *create_sections_dialog(GOpenidaBinary *, GtkWindow *); +GtkWidget *create_sections_dialog(GLoadedBinary *, GtkWindow *); diff --git a/src/dialogs/export.c b/src/dialogs/export.c index e514511..317ada4 100644 --- a/src/dialogs/export.c +++ b/src/dialogs/export.c @@ -103,7 +103,7 @@ static void register_content_panel(GtkAssistant *); * * ******************************************************************************/ -void run_export_assistant(GOpenidaBinary *binary, GtkWindow *parent) +void run_export_assistant(GLoadedBinary *binary, GtkWindow *parent) { GtkWidget *assistant; /* Fenêtre à afficher */ GObject *ref; /* Espace de référencement */ @@ -170,7 +170,7 @@ static void export_assistant_close(GtkAssistant *assistant, GObject *ref) int fd; /* Descripteur de la sortie */ struct _export_data *export; /* Informations à faire suivre */ GtkToggleButton *checkbutton; /* Coche à retrouver */ - GOpenidaBinary *binary; /* Binaire chargé à parcourir */ + GLoadedBinary *binary; /* Binaire chargé à parcourir */ GCodeBuffer *buffer; /* Tampon de code à traiter */ /* Fichier de sortie */ @@ -206,9 +206,9 @@ static void export_assistant_close(GtkAssistant *assistant, GObject *ref) /* Programmation de la tâche */ - binary = G_OPENIDA_BINARY(g_object_get_data(ref, "binary")); + binary = G_LOADED_BINARY(g_object_get_data(ref, "binary")); - buffer = g_openida_binary_get_disassembled_buffer(binary); + buffer = g_loaded_binary_get_disassembled_buffer(binary); g_buffer_code_scan(buffer, 0, VMPA_MAX, _("Exporting binary lines..."), (process_line_fc)export_buffer_line, export); @@ -277,7 +277,7 @@ static void register_output_panel(GtkAssistant *assistant) GtkWidget *combobox; /* Sélection du format */ GtkWidget *entry; /* Zone de saisie de texte */ GtkWidget *button; /* Sélection de fichier */ - GOpenidaBinary *binary; /* Binaire chargé à parcourir */ + GLoadedBinary *binary; /* Binaire chargé à parcourir */ const char *filename; /* Chemin d'accès par défaut */ alignment = qck_create_padded_alignment(8, 8, 8, 8); @@ -327,8 +327,8 @@ static void register_output_panel(GtkAssistant *assistant) /* Choix par défaut */ - binary = G_OPENIDA_BINARY(g_object_get_data(G_OBJECT(assistant), "binary")); - filename = g_openida_binary_get_filename(binary); + binary = G_LOADED_BINARY(g_object_get_data(G_OBJECT(assistant), "binary")); + filename = g_loaded_binary_get_filename(binary, true); gtk_entry_set_text(GTK_ENTRY(entry), filename); gtk_editable_insert_text(GTK_EDITABLE(entry), ".txt", -1, (gint []) { strlen(filename) }); diff --git a/src/dialogs/export.h b/src/dialogs/export.h index c14d05d..3274b12 100644 --- a/src/dialogs/export.h +++ b/src/dialogs/export.h @@ -30,7 +30,7 @@ /* Crée et affiche un assistant d'aide à l'exportation. */ -void run_export_assistant(GOpenidaBinary *, GtkWindow *); +void run_export_assistant(GLoadedBinary *, GtkWindow *); diff --git a/src/dialogs/plugins.c b/src/dialogs/plugins.c index b5e045b..e74296e 100644 --- a/src/dialogs/plugins.c +++ b/src/dialogs/plugins.c @@ -47,7 +47,7 @@ * * ******************************************************************************/ -GtkWidget *create_plugins_selection_dialog(GOpenidaBinary *binary, GtkWindow *parent) +GtkWidget *create_plugins_selection_dialog(GLoadedBinary *binary, GtkWindow *parent) { GtkWidget *result; /* Fenêtre à renvoyer */ GObject *ref; /* Espace de référencements */ @@ -146,7 +146,6 @@ GtkWidget *create_plugins_selection_dialog(GOpenidaBinary *binary, GtkWindow *pa button7 = gtk_button_new(); gtk_widget_show(button7); gtk_container_add(GTK_CONTAINER(vbuttonbox1), button7); - GTK_WIDGET_SET_FLAGS(button7, GTK_CAN_DEFAULT); image3 = gtk_image_new_from_stock("gtk-add", GTK_ICON_SIZE_BUTTON); gtk_widget_show(image3); @@ -155,7 +154,6 @@ GtkWidget *create_plugins_selection_dialog(GOpenidaBinary *binary, GtkWindow *pa button8 = gtk_button_new(); gtk_widget_show(button8); gtk_container_add(GTK_CONTAINER(vbuttonbox1), button8); - GTK_WIDGET_SET_FLAGS(button8, GTK_CAN_DEFAULT); image4 = gtk_image_new_from_stock("gtk-remove", GTK_ICON_SIZE_BUTTON); gtk_widget_show(image4); @@ -174,7 +172,6 @@ GtkWidget *create_plugins_selection_dialog(GOpenidaBinary *binary, GtkWindow *pa button9 = gtk_button_new(); gtk_widget_show(button9); gtk_container_add(GTK_CONTAINER(vbuttonbox2), button9); - GTK_WIDGET_SET_FLAGS(button9, GTK_CAN_DEFAULT); image5 = gtk_image_new_from_stock("gtk-go-up", GTK_ICON_SIZE_BUTTON); gtk_widget_show(image5); @@ -183,7 +180,6 @@ GtkWidget *create_plugins_selection_dialog(GOpenidaBinary *binary, GtkWindow *pa button10 = gtk_button_new(); gtk_widget_show(button10); gtk_container_add(GTK_CONTAINER(vbuttonbox2), button10); - GTK_WIDGET_SET_FLAGS(button10, GTK_CAN_DEFAULT); image6 = gtk_image_new_from_stock("gtk-go-down", GTK_ICON_SIZE_BUTTON); gtk_widget_show(image6); @@ -276,7 +272,6 @@ GtkWidget *create_plugins_selection_dialog(GOpenidaBinary *binary, GtkWindow *pa button1 = gtk_button_new(); gtk_widget_show(button1); gtk_container_add(GTK_CONTAINER(hbuttonbox1), button1); - GTK_WIDGET_SET_FLAGS(button1, GTK_CAN_DEFAULT); alignment1 = gtk_alignment_new(0.5, 0.5, 0, 0); gtk_widget_show(alignment1); @@ -297,7 +292,6 @@ GtkWidget *create_plugins_selection_dialog(GOpenidaBinary *binary, GtkWindow *pa button2 = gtk_button_new(); gtk_widget_show(button2); gtk_container_add(GTK_CONTAINER(hbuttonbox1), button2); - GTK_WIDGET_SET_FLAGS(button2, GTK_CAN_DEFAULT); alignment2 = gtk_alignment_new(0.5, 0.5, 0, 0); gtk_widget_show(alignment2); diff --git a/src/dialogs/plugins.h b/src/dialogs/plugins.h index f0ea164..32901fb 100644 --- a/src/dialogs/plugins.h +++ b/src/dialogs/plugins.h @@ -33,7 +33,7 @@ /* Construit la fenêtre de sélection des sections. */ -GtkWidget *create_plugins_selection_dialog(GOpenidaBinary *, GtkWindow *); +GtkWidget *create_plugins_selection_dialog(GLoadedBinary *, GtkWindow *); diff --git a/src/editor.c b/src/editor.c index 54149ff..3c861d1 100644 --- a/src/editor.c +++ b/src/editor.c @@ -119,7 +119,7 @@ void update_debug_menu_items(GObject *, gboolean); static void on_dock_item_switch(GtkDockPanel *, GtkWidget *, GObject *); /* Met en concordance les menus avec l'édition courante. */ -static void refresh_editor_menus(GObject *, GOpenidaBinary *, GtkBinView *); +static void refresh_editor_menus(GObject *, GLoadedBinary *, GtkBinView *); @@ -681,10 +681,10 @@ void mcb_open_recent_project(GtkMenuItem *menuitem, GObject *ref) static void mcb_binary_select_parts(GtkMenuItem *menuitem, GObject *ref) { - GOpenidaBinary *binary; /* Binaire courant à l'écran */ + GLoadedBinary *binary; /* Binaire courant à l'écran */ GtkWidget *dialog; /* Boîte de dialogue à montrer */ - binary = G_OPENIDA_BINARY(g_object_get_data(ref, "current_binary")); + binary = G_LOADED_BINARY(g_object_get_data(ref, "current_binary")); dialog = create_sections_dialog(binary, GTK_WINDOW(ref)); gtk_widget_show(dialog); @@ -707,10 +707,10 @@ static void mcb_binary_select_parts(GtkMenuItem *menuitem, GObject *ref) static void mcb_binary_select_plugins(GtkMenuItem *menuitem, GObject *ref) { - GOpenidaBinary *binary; /* Binaire courant à l'écran */ + GLoadedBinary *binary; /* Binaire courant à l'écran */ GtkWidget *dialog; /* Boîte de dialogue à montrer */ - binary = G_OPENIDA_BINARY(g_object_get_data(ref, "current_binary")); + binary = G_LOADED_BINARY(g_object_get_data(ref, "current_binary")); dialog = create_plugins_selection_dialog(binary, GTK_WINDOW(ref)); gtk_widget_show(dialog); @@ -723,10 +723,10 @@ static void mcb_binary_select_plugins(GtkMenuItem *menuitem, GObject *ref) void debugger_stopped_cb(GBinaryDebugger *debugger, uint64_t last, uint64_t cur, gpointer data) { - +#if 0 GObject *ref; - GOpenidaBinary *binary; + GLoadedBinary *binary; GRenderingLine *line; @@ -744,7 +744,7 @@ void debugger_stopped_cb(GBinaryDebugger *debugger, uint64_t last, uint64_t cur, if (last != cur) { - line = g_rendering_line_find_by_address(g_openida_binary_get_lines(binary), NULL/* FIXME */, last); + line = g_rendering_line_find_by_address(g_loaded_binary_get_lines(binary), NULL/* FIXME */, last); if (line != NULL) g_rendering_line_remove_flag(line, RLF_RUNNING_BP); @@ -754,7 +754,7 @@ void debugger_stopped_cb(GBinaryDebugger *debugger, uint64_t last, uint64_t cur, printf("bp at 0x%016llx\n", cur); - line = g_rendering_line_find_by_address(g_openida_binary_get_lines(binary), NULL/* FIXME */, cur); + line = g_rendering_line_find_by_address(g_loaded_binary_get_lines(binary), NULL/* FIXME */, cur); if (line != NULL) g_rendering_line_add_flag(line, RLF_RUNNING_BP); @@ -780,7 +780,7 @@ void debugger_stopped_cb(GBinaryDebugger *debugger, uint64_t last, uint64_t cur, refresh_registers_panel_with_registers(get_panel(PNT_REGISTERS), values, count); - +#endif } @@ -800,7 +800,7 @@ void debugger_stopped_cb(GBinaryDebugger *debugger, uint64_t last, uint64_t cur, void mcb_debug_start(GtkCheckMenuItem *menuitem, gpointer data) { - GOpenidaBinary *binary; /* Binaire à analyser */ + GLoadedBinary *binary; /* Binaire à analyser */ GBinaryDebugger *debugger; /* Débogueur offrant l'analyse */ @@ -968,8 +968,8 @@ void update_debug_menu_items(GObject *ref, gboolean stopped) static void on_dock_item_switch(GtkDockPanel *panel, GtkWidget *widget, GObject *ref) { - GOpenidaBinary *old_binary; /* Ancien binaire édité */ - GOpenidaBinary *binary; /* Binaire en cours d'édition */ + GLoadedBinary *old_binary; /* Ancien binaire édité */ + GLoadedBinary *binary; /* Binaire en cours d'édition */ if (GTK_IS_SCROLLED_WINDOW(widget)) widget = gtk_bin_get_child(GTK_BIN(widget)); @@ -981,7 +981,7 @@ static void on_dock_item_switch(GtkDockPanel *panel, GtkWidget *widget, GObject { /* Changement de binaire ? */ - old_binary = G_OPENIDA_BINARY(g_object_get_data(ref, "current_binary")); + old_binary = G_LOADED_BINARY(g_object_get_data(ref, "current_binary")); binary = gtk_view_panel_get_binary(GTK_VIEW_PANEL(widget)); if (old_binary != binary) @@ -1015,7 +1015,7 @@ static void on_dock_item_switch(GtkDockPanel *panel, GtkWidget *widget, GObject * * ******************************************************************************/ -static void refresh_editor_menus(GObject *ref, GOpenidaBinary *binary, GtkBinView *view) +static void refresh_editor_menus(GObject *ref, GLoadedBinary *binary, GtkBinView *view) { #if 0 GtkCheckMenuItem *menuitem; /* Menu à coche à traiter */ diff --git a/src/graph/layout.c b/src/graph/layout.c index 21f7454..f8afad6 100644 --- a/src/graph/layout.c +++ b/src/graph/layout.c @@ -124,7 +124,7 @@ bool build_graph_view(GtkGraphView *view, GtkViewPanel **views, size_t count) static char *complete_graph_links(const GtkGraphView *view, GtkViewPanel **views, size_t count, char *desc) { - GOpenidaBinary *binary; /* Binaire rattaché aux vues */ + GLoadedBinary *binary; /* Binaire rattaché aux vues */ GArchInstruction *instrs; /* Instructions pour assembleur*/ GBufferView *buffer; /* Tampon d'une partie de code */ vmpa_t end; /* Adresse finale du tampon */ @@ -143,7 +143,7 @@ static char *complete_graph_links(const GtkGraphView *view, GtkViewPanel **views return desc; binary = gtk_view_panel_get_binary(views[0]); - instrs = g_openida_binary_get_instructions(binary); + instrs = g_loaded_binary_get_instructions(binary); for (i = 0; i < count; i++) { diff --git a/src/gtkext/easygtk.c b/src/gtkext/easygtk.c index 5218381..510c74f 100644 --- a/src/gtkext/easygtk.c +++ b/src/gtkext/easygtk.c @@ -334,7 +334,7 @@ GtkWidget *qck_create_button(GObject *object, const char *name, const char *capt GtkWidget *result; /* Résultat à renvoyer */ result = gtk_button_new_with_label(caption); - GTK_WIDGET_SET_FLAGS(result, GTK_CAN_DEFAULT); + gtk_widget_set_can_default(result, TRUE); if (G_IS_OBJECT(object) && name != NULL) { @@ -373,7 +373,7 @@ GtkWidget *qck_create_button_from_stock(GObject *object, const char *name, const GtkWidget *result; /* Résultat à renvoyer */ result = gtk_button_new_from_stock(stock); - GTK_WIDGET_SET_FLAGS(result, GTK_CAN_DEFAULT); + gtk_widget_set_can_default(result, TRUE); if (G_IS_OBJECT(object) && name != NULL) { @@ -413,7 +413,7 @@ GtkWidget *qck_create_button_with_img(GObject *object, const char *name, const c GtkWidget *render; /* Image à ajouter au bouton */ result = gtk_button_new(); - GTK_WIDGET_SET_FLAGS(result, GTK_CAN_DEFAULT); + gtk_widget_set_can_default(result, TRUE); render = gtk_image_new_from_stock(image, GTK_ICON_SIZE_BUTTON); gtk_widget_show(render); diff --git a/src/gtkext/gtkbinview-int.h b/src/gtkext/gtkbinview-int.h index 94d406f..7091e15 100644 --- a/src/gtkext/gtkbinview-int.h +++ b/src/gtkext/gtkbinview-int.h @@ -48,7 +48,7 @@ struct _GtkBinView { GtkViewPanel parent; /* A laisser en premier */ - GOpenidaBinary *binary; /* Contenu binaire affiché */ + GLoadedBinary *binary; /* Contenu binaire affiché */ GRenderingLine *lines; /* Contenu à représenter */ GRenderingLine *last; /* Dernière ligne associée */ diff --git a/src/gtkext/gtkbinview.c b/src/gtkext/gtkbinview.c index a1657b3..2fe88ad 100644 --- a/src/gtkext/gtkbinview.c +++ b/src/gtkext/gtkbinview.c @@ -39,7 +39,7 @@ typedef struct _bv_loading_ack /* Prend acte de l'association d'un binaire chargé. */ -static void gtk_bin_view_attach_binary(GtkBinView *, GOpenidaBinary *); +static void gtk_bin_view_attach_binary(GtkBinView *, GLoadedBinary *); /* Prend note de la fin d'une construction d'une visualisation. */ static void ack_loaded_lines_for_bin_view(GtkBinView *, bv_loading_ack *); @@ -137,7 +137,7 @@ GtkWidget* gtk_binview_new(void) * * ******************************************************************************/ -static void gtk_bin_view_attach_binary(GtkBinView *view, GOpenidaBinary *binary) +static void gtk_bin_view_attach_binary(GtkBinView *view, GLoadedBinary *binary) { bv_loading_ack ack; /* Informations d'acquitement */ @@ -147,8 +147,10 @@ static void gtk_bin_view_attach_binary(GtkBinView *view, GOpenidaBinary *binary) g_signal_connect(view, "lines-set", G_CALLBACK(ack_loaded_lines_for_bin_view), &ack); + /* gtk_bin_view_set_rendering_lines(view, binary, - g_openida_binary_get_lines(binary), NULL); + g_loaded_binary_get_lines(binary), NULL); + */ /* Attente de la fin de construction */ g_mutex_lock(ack.mutex); @@ -233,7 +235,7 @@ void gtk_bin_view_show_border(GtkBinView *view, bool show) * * ******************************************************************************/ -void gtk_bin_view_set_rendering_lines(GtkBinView *view, GOpenidaBinary *binary, GRenderingLine *lines, GRenderingLine *last) +void gtk_bin_view_set_rendering_lines(GtkBinView *view, GLoadedBinary *binary, GRenderingLine *lines, GRenderingLine *last) { view->binary = binary; diff --git a/src/gtkext/gtkbinview.h b/src/gtkext/gtkbinview.h index b6027a6..165f423 100644 --- a/src/gtkext/gtkbinview.h +++ b/src/gtkext/gtkbinview.h @@ -57,7 +57,7 @@ void gtk_bin_view_show_border(GtkBinView *, bool); /* Définit les lignes à associer à la représentation. */ -void gtk_bin_view_set_rendering_lines(GtkBinView *, GOpenidaBinary *, GRenderingLine *, GRenderingLine *); +void gtk_bin_view_set_rendering_lines(GtkBinView *, GLoadedBinary *, GRenderingLine *, GRenderingLine *); /* Fournit la liste des lignes associées à la représentation. */ GRenderingLine *gtk_bin_view_get_lines(const GtkBinView *); diff --git a/src/gtkext/gtkblockview.c b/src/gtkext/gtkblockview.c index cd2d99d..398856f 100644 --- a/src/gtkext/gtkblockview.c +++ b/src/gtkext/gtkblockview.c @@ -53,7 +53,7 @@ static void gtk_block_view_class_init(GtkBlockViewClass *); static void gtk_block_view_init(GtkBlockView *); /* Prend acte de l'association d'un binaire chargé. */ -static void gtk_block_view_attach_binary(GtkBlockView *, GOpenidaBinary *, bool *, bool *); +static void gtk_block_view_attach_binary(GtkBlockView *, GLoadedBinary *, bool *, bool *); @@ -145,11 +145,11 @@ GtkWidget *gtk_block_view_new(void) * * ******************************************************************************/ -static void gtk_block_view_attach_binary(GtkBlockView *view, GOpenidaBinary *binary, bool *addr, bool *code) +static void gtk_block_view_attach_binary(GtkBlockView *view, GLoadedBinary *binary, bool *addr, bool *code) { GCodeBuffer *buffer; /* Tampon par défaut */ - buffer = g_openida_binary_get_disassembled_buffer(binary); + buffer = g_loaded_binary_get_disassembled_buffer(binary); gtk_buffer_view_attach_buffer(GTK_BUFFER_VIEW(view), g_buffer_view_new(buffer), addr, code); diff --git a/src/gtkext/gtkdockpanel.c b/src/gtkext/gtkdockpanel.c index 24e99eb..79a4a0e 100644 --- a/src/gtkext/gtkdockpanel.c +++ b/src/gtkext/gtkdockpanel.c @@ -67,7 +67,7 @@ static void on_dock_item_content_changed(GDockItem *, GtkWidget *, GtkWidget *, static void _gtk_dock_panel_remove_item(GtkDockPanel *, GDockItem *, GtkWidget *); /* Met à jour le titre du support de panneaux dockables. */ -static gboolean gtk_dock_panel_update_title(GtkNotebook *, GtkNotebookPage *, guint, gpointer); +static gboolean gtk_dock_panel_update_title(GtkNotebook *, gpointer *, guint, gpointer); @@ -742,7 +742,7 @@ static void _gtk_dock_panel_remove_item(GtkDockPanel *dpanel, GDockItem *ditem, * * ******************************************************************************/ -static gboolean gtk_dock_panel_update_title(GtkNotebook *notebook, GtkNotebookPage *page, guint index, gpointer data) +static gboolean gtk_dock_panel_update_title(GtkNotebook *notebook, gpointer *page, guint index, gpointer data) { GDockItem *ditem; /* Elément nouvellement actif */ const gchar *desc; /* Description à afficher */ diff --git a/src/gtkext/gtkdockstation.c b/src/gtkext/gtkdockstation.c index a91998e..ba17788 100644 --- a/src/gtkext/gtkdockstation.c +++ b/src/gtkext/gtkdockstation.c @@ -40,7 +40,7 @@ static void gtk_dock_station_class_init(GtkDockStationClass *); static void gtk_dock_station_init(GtkDockStation *); /* Met à jour le titre du support de panneaux concentrés. */ -static gboolean gtk_dock_station_switch_panel(GtkNotebook *, GtkNotebookPage *, guint, gpointer); +static gboolean gtk_dock_station_switch_panel(GtkNotebook *, gpointer *, guint, gpointer); @@ -173,7 +173,7 @@ GtkWidget *gtk_dock_station_new(void) * * ******************************************************************************/ -static gboolean gtk_dock_station_switch_panel(GtkNotebook *notebook, GtkNotebookPage *page, guint index, gpointer data) +static gboolean gtk_dock_station_switch_panel(GtkNotebook *notebook, gpointer *page, guint index, gpointer data) { GtkWidget *widget; /* Panneau concerné */ char *caption; /* Texte à redonner */ diff --git a/src/gtkext/gtkgraphview.c b/src/gtkext/gtkgraphview.c index 8366c1f..6ce6060 100644 --- a/src/gtkext/gtkgraphview.c +++ b/src/gtkext/gtkgraphview.c @@ -87,7 +87,7 @@ static void gtk_graph_view_scroll(GtkGraphView *); static void gtk_graph_view_reset(GtkGraphView *); /* Liste d'éléments du graphique à placer. */ -static GtkViewPanel **gtk_graph_view_load_nodes(GtkGraphView *, GOpenidaBinary *, vmpa_t, vmpa_t); +static GtkViewPanel **gtk_graph_view_load_nodes(GtkGraphView *, GLoadedBinary *, vmpa_t, vmpa_t); @@ -319,7 +319,7 @@ static void gtk_graph_view_define_main_address(GtkGraphView *view, vmpa_t addr) { gtk_graph_view_reset(view); - format = g_openida_binary_get_format(GTK_VIEW_PANEL(view)->binary); + format = g_loaded_binary_get_format(GTK_VIEW_PANEL(view)->binary); routines = g_binary_format_get_routines(G_BIN_FORMAT(format), &routines_count); for (i = 0; i < routines_count; i++) @@ -533,7 +533,7 @@ static void gtk_graph_view_reset(GtkGraphView *view) * * ******************************************************************************/ -static GtkViewPanel **gtk_graph_view_load_nodes(GtkGraphView *view, GOpenidaBinary *binary, vmpa_t start, vmpa_t end) +static GtkViewPanel **gtk_graph_view_load_nodes(GtkGraphView *view, GLoadedBinary *binary, vmpa_t start, vmpa_t end) { GtkViewPanel **result; /* Liste à retourner */ size_t *count; /* Nombre d'éléments créés. */ @@ -551,11 +551,11 @@ static GtkViewPanel **gtk_graph_view_load_nodes(GtkGraphView *view, GOpenidaBina count = &view->childs_count; *count = 0; - list = g_openida_binary_get_instructions(binary); - buffer = g_openida_binary_get_disassembled_buffer(binary); + list = g_loaded_binary_get_instructions(binary); + buffer = g_loaded_binary_get_disassembled_buffer(binary); - addr = g_openida_binary_display_addresses_in_text(binary); - code = g_openida_binary_display_code_in_text(binary); + addr = g_loaded_binary_display_addresses_in_text(binary); + code = g_loaded_binary_display_code_in_text(binary); first = start; last = first; @@ -718,7 +718,7 @@ static void gtk_graph_view_define_main_address(GtkGraphView *, vmpa_t); static bool gtk_graph_view_get_address_coordinates(const GtkGraphView *, vmpa_t, gint *, gint *); /* Définit la liste complète des éléments du futur graphique. */ -static GtkBinView **gtk_graph_view_load_nodes(GtkGraphView *, GOpenidaBinary *, GRenderingLine *, GRenderingLine *); +static GtkBinView **gtk_graph_view_load_nodes(GtkGraphView *, GLoadedBinary *, GRenderingLine *, GRenderingLine *); /* Prend note de la fin d'une construction d'une visualisation. */ static void notify_graph_view(GtkBinView *, GtkGraphView *); @@ -870,7 +870,7 @@ static void gtk_graph_view_define_main_address(GtkGraphView *view, vmpa_t addr) { gtk_graph_view_reset(view); - format = g_openida_binary_get_format(GTK_BIN_VIEW(view)->binary); + format = g_loaded_binary_get_format(GTK_BIN_VIEW(view)->binary); routines = g_binary_format_get_routines(G_BIN_FORMAT(format), &routines_count); for (i = 0; i < routines_count; i++) @@ -954,7 +954,7 @@ static bool gtk_graph_view_get_address_coordinates(const GtkGraphView *view, vmp * * ******************************************************************************/ -static GtkBinView **gtk_graph_view_load_nodes(GtkGraphView *view, GOpenidaBinary *binary, GRenderingLine *first, GRenderingLine *last) +static GtkBinView **gtk_graph_view_load_nodes(GtkGraphView *view, GLoadedBinary *binary, GRenderingLine *first, GRenderingLine *last) { #if 0 GtkBinView **result; /* Liste à retourner */ diff --git a/src/gtkext/gtksourceview.c b/src/gtkext/gtksourceview.c index 1244bb8..5faed7b 100644 --- a/src/gtkext/gtksourceview.c +++ b/src/gtkext/gtksourceview.c @@ -53,7 +53,7 @@ static void gtk_source_view_class_init(GtkSourceViewClass *); static void gtk_source_view_init(GtkSourceView *); /* Prend acte de l'association d'un binaire chargé. */ -static void gtk_source_view_attach_binary(GtkSourceView *, GOpenidaBinary *, bool *, bool *); +static void gtk_source_view_attach_binary(GtkSourceView *, GLoadedBinary *, bool *, bool *); @@ -145,11 +145,11 @@ GtkWidget *gtk_source_view_new(void) * * ******************************************************************************/ -static void gtk_source_view_attach_binary(GtkSourceView *view, GOpenidaBinary *binary, bool *addr, bool *code) +static void gtk_source_view_attach_binary(GtkSourceView *view, GLoadedBinary *binary, bool *addr, bool *code) { GCodeBuffer *buffer; /* Tampon par défaut */ - buffer = g_openida_binary_get_decompiled_buffer(binary, -1); + buffer = g_loaded_binary_get_decompiled_buffer(binary, -1); /* FIXME */ if (buffer != NULL) diff --git a/src/gtkext/gtkviewpanel-int.h b/src/gtkext/gtkviewpanel-int.h index a4edd06..6e6cbaf 100644 --- a/src/gtkext/gtkviewpanel-int.h +++ b/src/gtkext/gtkviewpanel-int.h @@ -34,7 +34,7 @@ /* Prend acte de l'association d'un binaire chargé. */ -typedef void (* attach_binary_fc) (GtkViewPanel *, GOpenidaBinary *, bool *, bool *); +typedef void (* attach_binary_fc) (GtkViewPanel *, GLoadedBinary *, bool *, bool *); /* Réagit à la sélection externe d'une adresse. */ typedef void (* define_address_fc) (GtkViewPanel *, vmpa_t); @@ -57,7 +57,7 @@ struct _GtkViewPanel GdkGC *gc; /* Contexte graphique du rendu */ bool show_border; /* Affichage d'une bordure ? */ - GOpenidaBinary *binary; /* Binaire à visualiser */ + GLoadedBinary *binary; /* Binaire à visualiser */ attach_binary_fc attach; /* Association avec un binaire */ define_address_fc define; /* Centrage sur une partie */ diff --git a/src/gtkext/gtkviewpanel.c b/src/gtkext/gtkviewpanel.c index 326e4d8..2935458 100644 --- a/src/gtkext/gtkviewpanel.c +++ b/src/gtkext/gtkviewpanel.c @@ -246,7 +246,7 @@ static void gtk_view_panel_realize(GtkWidget *widget) guint attributes_mask; /* Masque de prise en compte */ GdkColor white; /* Couleur de fond normale */ - GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED); + gtk_widget_set_realized(widget, TRUE); attributes.window_type = GDK_WINDOW_CHILD; attributes.x = widget->allocation.x; @@ -356,7 +356,7 @@ void gtk_view_panel_show_border(GtkViewPanel *panel, bool show) * * ******************************************************************************/ -void gtk_view_panel_attach_binary(GtkViewPanel *panel, GOpenidaBinary *binary, bool *addr, bool *code) +void gtk_view_panel_attach_binary(GtkViewPanel *panel, GLoadedBinary *binary, bool *addr, bool *code) { g_object_ref(G_OBJECT(binary)); panel->binary = binary; @@ -468,7 +468,7 @@ void gtk_view_panel_set_code_display(const GtkViewPanel *panel, bool state) * * ******************************************************************************/ -GOpenidaBinary *gtk_view_panel_get_binary(const GtkViewPanel *panel) +GLoadedBinary *gtk_view_panel_get_binary(const GtkViewPanel *panel) { return panel->binary; diff --git a/src/gtkext/gtkviewpanel.h b/src/gtkext/gtkviewpanel.h index 12b0e44..f1dd2b7 100644 --- a/src/gtkext/gtkviewpanel.h +++ b/src/gtkext/gtkviewpanel.h @@ -54,7 +54,7 @@ GType gtk_view_panel_get_type(void); void gtk_view_panel_show_border(GtkViewPanel *, bool); /* Associe à un panneau d'affichage un binaire chargé. */ -void gtk_view_panel_attach_binary(GtkViewPanel *, GOpenidaBinary *, bool *, bool *); +void gtk_view_panel_attach_binary(GtkViewPanel *, GLoadedBinary *, bool *, bool *); /* Indique si les adresses doivent apparaître dans le rendu. */ bool gtk_view_panel_get_addresses_display(const GtkViewPanel *); @@ -69,7 +69,7 @@ bool gtk_view_panel_get_code_display(const GtkViewPanel *); void gtk_view_panel_set_code_display(const GtkViewPanel *, bool); /* Fournit le binaire associé à la représentation. */ -GOpenidaBinary *gtk_view_panel_get_binary(const GtkViewPanel *); +GLoadedBinary *gtk_view_panel_get_binary(const GtkViewPanel *); /* Indique si la vue contient une addrese donnée. */ bool gtk_view_panel_contain_address(const GtkViewPanel *, vmpa_t); diff --git a/src/gui/editem-int.h b/src/gui/editem-int.h index 0f25147..8ab0c43 100644 --- a/src/gui/editem-int.h +++ b/src/gui/editem-int.h @@ -37,7 +37,7 @@ /* Réagit à un changement du binaire courant. */ -typedef void (* update_item_binary_fc) (GEditorItem *, GOpenidaBinary *); +typedef void (* update_item_binary_fc) (GEditorItem *, GLoadedBinary *); /* Réagit à un changement d'affichage principal de contenu. */ typedef void (* update_item_view_fc) (GEditorItem *, GtkViewPanel *); diff --git a/src/gui/editem.c b/src/gui/editem.c index 18102f4..1d542a3 100644 --- a/src/gui/editem.c +++ b/src/gui/editem.c @@ -125,7 +125,7 @@ GtkWidget *g_editor_item_get_widget(const GEditorItem *item) * * ******************************************************************************/ -GOpenidaBinary *g_editor_item_get_current_binary(const GEditorItem *item) +GLoadedBinary *g_editor_item_get_current_binary(const GEditorItem *item) { return g_object_get_data(item->ref, "current_binary"); @@ -189,7 +189,7 @@ void register_editor_item(GEditorItem *item) * * ******************************************************************************/ -void change_editor_items_current_binary(GObject *ref, GOpenidaBinary *binary) +void change_editor_items_current_binary(GObject *ref, GLoadedBinary *binary) { GEditorItem *iter; /* Boucle de parcours */ diff --git a/src/gui/editem.h b/src/gui/editem.h index 0b9989e..4bb1cd3 100644 --- a/src/gui/editem.h +++ b/src/gui/editem.h @@ -60,7 +60,7 @@ GType g_editor_item_get_type(void); GtkWidget *g_editor_item_get_widget(const GEditorItem *); /* Fournit le gestionnaire du binaire courant. */ -GOpenidaBinary *g_editor_item_get_current_binary(const GEditorItem *); +GLoadedBinary *g_editor_item_get_current_binary(const GEditorItem *); /* Fournit l'affichage de binaire courant. */ GtkViewPanel *g_editor_item_get_current_view(const GEditorItem *); @@ -74,7 +74,7 @@ GtkViewPanel *g_editor_item_get_current_view(const GEditorItem *); void register_editor_item(GEditorItem *); /* Lance une actualisation du fait d'un changement de binaire. */ -void change_editor_items_current_binary(GObject *, GOpenidaBinary *); +void change_editor_items_current_binary(GObject *, GLoadedBinary *); /* Lance une actualisation du fait d'un changement de vue. */ void change_editor_items_current_view(GObject *, GtkViewPanel *); diff --git a/src/gui/menus/binary.c b/src/gui/menus/binary.c index ac59444..8699c02 100644 --- a/src/gui/menus/binary.c +++ b/src/gui/menus/binary.c @@ -89,7 +89,7 @@ GtkWidget *build_menu_binary(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *ba static void mcb_binary_export(GtkMenuItem *menuitem, GMenuBar *bar) { - GOpenidaBinary *binary; /* Edition courante */ + GLoadedBinary *binary; /* Edition courante */ binary = g_editor_item_get_current_binary(G_EDITOR_ITEM(bar)); diff --git a/src/gui/menus/debug.c b/src/gui/menus/debug.c index 963c095..666a605 100644 --- a/src/gui/menus/debug.c +++ b/src/gui/menus/debug.c @@ -93,10 +93,10 @@ GtkWidget *build_menu_debug(GObject *ref, GtkAccelGroup *accgroup) static void mcb_debug_start_stop(GtkMenuItem *menuitem, GObject *ref) { - GOpenidaBinary *binary; /* Edition courante */ + GLoadedBinary *binary; /* Edition courante */ GBinaryDebugger *debugger; /* Module prêt à emploi */ - binary = (GOpenidaBinary *)g_object_get_data(ref, "current_binary"); + binary = (GLoadedBinary *)g_object_get_data(ref, "current_binary"); debugger = NULL;//get_main_debugger_for_binary(get_current_openida_project(), binary); if (debugger == NULL) diff --git a/src/gui/menus/project.c b/src/gui/menus/project.c index 96b411b..dbf61bc 100644 --- a/src/gui/menus/project.c +++ b/src/gui/menus/project.c @@ -32,6 +32,7 @@ #include "../editem-int.h" +#include "../../analysis/binaries/file.h" #include "../../gtkext/easygtk.h" @@ -115,7 +116,7 @@ void update_menu_project_for_project(GtkWidget *widget, GStudyProject *project, GList *list; /* Liste des éléments en place */ GList *iter; /* Boucle de parcours #1 */ size_t count; /* Nombre de binaires attachés */ - GOpenidaBinary **binaries; /* Liste de ces binaires */ + GLoadedBinary **binaries; /* Liste de ces binaires */ size_t i; /* Boucle de parcours #2 */ const char *desc; /* Description à afficher */ GtkWidget *submenuitem; /* Sous-menu à ajouter */ @@ -138,7 +139,7 @@ void update_menu_project_for_project(GtkWidget *widget, GStudyProject *project, for (i = 0; i < count; i++) { - desc = g_openida_binary_to_string(binaries[i]); + desc = g_loaded_binary_get_filename(binaries[i], true); submenuitem = qck_create_menu_item(NULL, NULL, desc, G_CALLBACK(mcb_project_remove_binary), project); @@ -175,7 +176,7 @@ static void mcb_project_add_binary_file(GtkMenuItem *menuitem, GMenuBar *bar) GtkWidget *dialog; /* Boîte à afficher */ char *dir; /* Répertoire courant */ gchar *filename; /* Nom du fichier à intégrer */ - GOpenidaBinary *binary; /* Représentation chargée */ + GLoadedBinary *binary; /* Représentation chargée */ dialog = gtk_file_chooser_dialog_new(_("Open a binary file"), GTK_WINDOW(G_EDITOR_ITEM(bar)->ref), @@ -204,13 +205,13 @@ static void mcb_project_add_binary_file(GtkMenuItem *menuitem, GMenuBar *bar) { filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); - binary = g_openida_binary_new_from_file(filename); + binary = g_file_binary_new_from_file(filename); if (binary != NULL) { g_signal_connect(binary, "disassembly-done", G_CALLBACK(g_study_project_add_loaded_binary), get_current_project()); - g_openida_binary_analyse(binary); + g_loaded_binary_analyse(binary); } g_free(filename); @@ -237,9 +238,9 @@ static void mcb_project_add_binary_file(GtkMenuItem *menuitem, GMenuBar *bar) static void mcb_project_remove_binary(GtkMenuItem *menuitem, GStudyProject *project) { - GOpenidaBinary *binary; /* Binaire à retirer */ + GLoadedBinary *binary; /* Binaire à retirer */ - binary = G_OPENIDA_BINARY(g_object_get_data(G_OBJECT(menuitem), "binary")); + binary = G_LOADED_BINARY(g_object_get_data(G_OBJECT(menuitem), "binary")); g_study_project_detach_binary(project, binary); g_object_unref(G_OBJECT(binary)); diff --git a/src/gui/menus/view.c b/src/gui/menus/view.c index e0e7cc4..748df9f 100644 --- a/src/gui/menus/view.c +++ b/src/gui/menus/view.c @@ -178,7 +178,7 @@ static void mcb_view_change_support(GtkRadioMenuItem *menuitem, GMenuBar *bar) BinaryView view; /* Nouvelle vue à présenter */ GtkViewPanel *vpanel; /* Afficheur effectif de code */ GtkWidget *station; /* Base du remplacement */ - GOpenidaBinary *binary; /* Edition courante */ + GLoadedBinary *binary; /* Edition courante */ GtkWidget *scroll; /* Nouveau support à utiliser */ /* On ne traite qu'une seule fois ! */ diff --git a/src/gui/panels/symbols.c b/src/gui/panels/symbols.c index aea90fe..6cc391f 100644 --- a/src/gui/panels/symbols.c +++ b/src/gui/panels/symbols.c @@ -46,7 +46,7 @@ struct _GSymbolsPanel GtkTreeView *treeview; /* Composant d'affichage */ GtkTreeStore *store; /* Modèle de gestion */ - GOpenidaBinary *binary; /* Binaire à prendre en compte */ + GLoadedBinary *binary; /* Binaire à prendre en compte */ }; @@ -84,7 +84,7 @@ static void g_symbols_panel_init(GSymbolsPanel *); static void on_symbols_selection_change(GtkTreeSelection *, GSymbolsPanel *); /* Réagit à un changement d'affichage principal de contenu. */ -void change_symbols_panel_current_binary(GSymbolsPanel *, GOpenidaBinary *); +void change_symbols_panel_current_binary(GSymbolsPanel *, GLoadedBinary *); @@ -383,7 +383,7 @@ static void on_symbols_selection_change(GtkTreeSelection *selection, GSymbolsPan * * ******************************************************************************/ -void change_symbols_panel_current_binary(GSymbolsPanel *panel, GOpenidaBinary *binary) +void change_symbols_panel_current_binary(GSymbolsPanel *panel, GLoadedBinary *binary) { GtkToggleToolButton *button; /* Mode de représentation */ @@ -437,7 +437,7 @@ static void reload_symbols_for_new_list_view(GSymbolsPanel *panel) char tmp[VMPA_MAX_SIZE]; /* Version humainement lisible */ GtkTreeIter iter; /* Point d'insertion */ - format = g_openida_binary_get_format(panel->binary); + format = g_loaded_binary_get_format(panel->binary); routines = g_binary_format_get_routines(G_BIN_FORMAT(format), &routines_count); qsort(routines, routines_count, sizeof(GBinRoutine *), (__compar_fn_t)g_binary_routine_rcompare); @@ -590,7 +590,7 @@ static void reload_symbols_for_new_tree_view(GSymbolsPanel *panel) GtkTreeIter iter; /* Point d'insertion */ GdkPixbuf *pixbuf; /* Icone pour l'élément inséré */ - format = g_openida_binary_get_format(panel->binary); + format = g_loaded_binary_get_format(panel->binary); routines = g_binary_format_get_routines(G_BIN_FORMAT(format), &routines_count); qsort(routines, routines_count, sizeof(GBinRoutine *), (__compar_fn_t)g_binary_routine_rcompare); diff --git a/src/gui/tb/source.c b/src/gui/tb/source.c index 2a1a532..109cbfa 100644 --- a/src/gui/tb/source.c +++ b/src/gui/tb/source.c @@ -41,7 +41,7 @@ static GtkWidget *build_source_tb_widget(GObject *); /* Réagit à un changement du binaire courant. */ -static void update_source_item_binary(GEditorItem *, GOpenidaBinary *); +static void update_source_item_binary(GEditorItem *, GLoadedBinary *); /* Réagit à un changement de panneau d'affichage courant. */ static void update_source_item_view(GEditorItem *, GtkViewPanel *); @@ -136,7 +136,7 @@ GEditorItem *create_source_tb_item(GObject *ref) * * ******************************************************************************/ -static void update_source_item_binary(GEditorItem *item, GOpenidaBinary *binary) +static void update_source_item_binary(GEditorItem *item, GLoadedBinary *binary) { GtkComboBox *combo; /* Liste de sélection */ GtkTreeModel *model; /* Gestionnaire d'éléments */ @@ -160,7 +160,7 @@ static void update_source_item_binary(GEditorItem *item, GOpenidaBinary *binary) /* Inscriptions */ - format = g_openida_binary_get_format(binary); + format = g_loaded_binary_get_format(binary); files = g_binary_format_get_source_files(G_BIN_FORMAT(format), &count, &defsrc); for (i = 0; i < count; i++) @@ -211,18 +211,18 @@ static void update_source_item_view(GEditorItem *item, GtkViewPanel *view) static void change_selected_source(GtkComboBox *widget, GObject *ref) { gint index; /* Nouvelle source ciblée */ - GOpenidaBinary *binary; /* Binaire chargé courant */ + GLoadedBinary *binary; /* Binaire chargé courant */ GCodeBuffer *buffer; /* Nouveau tampon à présenter */ GtkBufferView *view; /* Afficheur de tampons */ index = gtk_combo_box_get_active(widget); - binary = G_OPENIDA_BINARY(g_object_get_data(ref, "current_binary")); - buffer = g_openida_binary_get_decompiled_buffer(binary, index); + binary = G_LOADED_BINARY(g_object_get_data(ref, "current_binary")); + buffer = g_loaded_binary_get_decompiled_buffer(binary, index); view = GTK_BUFFER_VIEW(g_object_get_data(ref, "current_view")); if (GTK_IS_BUFFER_VIEW(view)) gtk_buffer_view_attach_buffer(view, buffer, - g_openida_binary_display_decomp_lines(binary), NULL); + g_loaded_binary_display_decomp_lines(binary), NULL); } diff --git a/src/panels/breaks.c b/src/panels/breaks.c index 31e2217..958d6fb 100644 --- a/src/panels/breaks.c +++ b/src/panels/breaks.c @@ -26,6 +26,7 @@ #include "panel-int.h" +#include "../debug/break.h" #include "../gtkext/easygtk.h" #include "../gtkext/support.h" @@ -42,7 +43,7 @@ struct _GBreaksPanel GtkTreeView *treeview; /* Composant d'affichage */ GtkTreeStore *store; /* Modèle de gestion */ - GOpenidaBinary *binary; /* Binaire en cours d'étude */ + GLoadedBinary *binary; /* Binaire en cours d'étude */ }; @@ -75,13 +76,13 @@ static void g_breaks_panel_class_init(GBreaksPanelClass *); static void g_breaks_panel_init(GBreaksPanel *); /* Réagit à un changement du binaire courant. */ -static void reload_breaks_for_new_binary(GBreaksPanel *, GOpenidaBinary *); +static void reload_breaks_for_new_binary(GBreaksPanel *, GLoadedBinary *); /* Intègre à l'affichage un groupe de points d'arrêt. */ -static void add_bp_group_to_breaks_panel(GOpenidaBinary *, GBreakGroup *, GBreaksPanel *); +static void add_bp_group_to_breaks_panel(GLoadedBinary *, GBreakGroup *, GBreaksPanel *); /* Réagit à une nouvelle création de point d'arrêt. */ static void refresh_breaks_panel_on_bp_added(GBreakGroup *, GBreakPoint *, GBreaksPanel *); @@ -250,14 +251,14 @@ GEditorPanel *g_breaks_panel_new(void) * * ******************************************************************************/ -static void reload_breaks_for_new_binary(GBreaksPanel *panel, GOpenidaBinary *binary) +static void reload_breaks_for_new_binary(GBreaksPanel *panel, GLoadedBinary *binary) { printf("CHNAGE BINARY !\n"); panel->binary = binary; - g_openida_binary_for_each_bp_group(binary, (GExtFunc)add_bp_group_to_breaks_panel, panel); + //g_loaded_binary_for_each_bp_group(binary, (GExtFunc)add_bp_group_to_breaks_panel, panel); } @@ -289,7 +290,7 @@ static void reload_breaks_for_new_binary(GBreaksPanel *panel, GOpenidaBinary *bi * * ******************************************************************************/ -static void add_bp_group_to_breaks_panel(GOpenidaBinary *binary, GBreakGroup *group, GBreaksPanel *panel) +static void add_bp_group_to_breaks_panel(GLoadedBinary *binary, GBreakGroup *group, GBreaksPanel *panel) { /* FIXME : bloquer toute émission de signal tant que les ajouts ne sont pas terminés. */ @@ -325,7 +326,7 @@ static void refresh_breaks_panel_on_bp_added(GBreakGroup *group, GBreakPoint *po char address[VMPA_MAX_SIZE]; /* Conversion de l'adresse */ GtkTreeIter iter; /* Point d'insertion */ - format = g_openida_binary_get_format(panel->binary); + format = g_loaded_binary_get_format(panel->binary); proc = get_arch_processor_from_format(format); vmpa_to_string(g_break_point_get_address(point), diff --git a/src/panels/panel-int.h b/src/panels/panel-int.h index 543c33c..7579eae 100644 --- a/src/panels/panel-int.h +++ b/src/panels/panel-int.h @@ -35,7 +35,7 @@ /* Réagit à un changement du binaire courant. */ -typedef void (* reload_for_new_binary_fc) (GEditorPanel *, GOpenidaBinary *); +typedef void (* reload_for_new_binary_fc) (GEditorPanel *, GLoadedBinary *); /* Réagit à un changement d'affichage principal de contenu. */ typedef void (* reload_for_new_view_fc) (GEditorPanel *, GtkViewPanel *, bool); diff --git a/src/panels/panel.c b/src/panels/panel.c index 5922fe5..4d08b7f 100644 --- a/src/panels/panel.c +++ b/src/panels/panel.c @@ -106,7 +106,7 @@ static void g_editor_panel_init(GEditorPanel *panel) * * ******************************************************************************/ -void change_current_binary_in_panels(GObject *ref, GOpenidaBinary *binary) +void change_current_binary_in_panels(GObject *ref, GLoadedBinary *binary) { @@ -193,7 +193,7 @@ void place_all_panels_in_editor(GtkWidget *top) * * ******************************************************************************/ -void notify_panels_of_binary_change(GOpenidaBinary *binary) +void notify_panels_of_binary_change(GLoadedBinary *binary) { GEditorPanel *iter; /* Boucle de parcours */ diff --git a/src/panels/panel.h b/src/panels/panel.h index b946222..60ce657 100644 --- a/src/panels/panel.h +++ b/src/panels/panel.h @@ -64,7 +64,7 @@ GType g_editor_panel_get_type(void); /* Répercute sur les panneaux un nouveau binaire actif. */ -void change_current_binary_in_panels(GObject *, GOpenidaBinary *); +void change_current_binary_in_panels(GObject *, GLoadedBinary *); @@ -77,7 +77,7 @@ void init_internal_panels(void); void place_all_panels_in_editor(GtkWidget *); /* Lance une actualisation du fait d'un changement de binaire. */ -void notify_panels_of_binary_change(GOpenidaBinary *); +void notify_panels_of_binary_change(GLoadedBinary *); /* Lance une actualisation du fait d'un changement de vue. */ void notify_panels_of_view_change(GtkViewPanel *, bool); diff --git a/src/plugins/plugin-int.h b/src/plugins/plugin-int.h index 56753e0..9a5c37c 100644 --- a/src/plugins/plugin-int.h +++ b/src/plugins/plugin-int.h @@ -47,7 +47,7 @@ typedef PluginAction (* get_plugin_action_fc) (const GPluginModule *); typedef MatchingFormatAction (* is_matching_fc) (const GPluginModule *, char **, bin_t **, off_t *); /* Exécute une action définie sur un binaire chargé. */ -typedef bool (* execute_action_on_binary_fc) (const GPluginModule *, GOpenidaBinary *, PluginAction); +typedef bool (* execute_action_on_binary_fc) (const GPluginModule *, GLoadedBinary *, PluginAction); /* Exécute une action relative à un débogueur. */ typedef bool (* execute_on_debugger_fc) (const GPluginModule *, GBinaryDebugger *, PluginAction); diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index e769df6..0cdcb04 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -387,7 +387,7 @@ MatchingFormatAction g_plugin_module_is_matching(const GPluginModule *plugin, ch * * ******************************************************************************/ -bool g_plugin_module_execute_action_on_binary(const GPluginModule *plugin, GOpenidaBinary *binary, PluginAction action) +bool g_plugin_module_execute_action_on_binary(const GPluginModule *plugin, GLoadedBinary *binary, PluginAction action) { return plugin->exec_on_bin(plugin, binary, action); diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h index aa90ee1..6fbba4d 100644 --- a/src/plugins/plugin.h +++ b/src/plugins/plugin.h @@ -64,7 +64,7 @@ PluginAction g_plugin_module_get_action(const GPluginModule *); MatchingFormatAction g_plugin_module_is_matching(const GPluginModule *, char **, bin_t **, off_t *); /* Exécute une action définie sur un binaire chargé. */ -bool g_plugin_module_execute_action_on_binary(const GPluginModule *, GOpenidaBinary *, PluginAction); +bool g_plugin_module_execute_action_on_binary(const GPluginModule *, GLoadedBinary *, PluginAction); /* Exécute une action relative à un débogueur. */ bool g_plugin_module_handle_debugger(const GPluginModule *, GBinaryDebugger *, PluginAction); diff --git a/src/project.c b/src/project.c index 91fe36c..c3c1844 100644 --- a/src/project.c +++ b/src/project.c @@ -31,6 +31,7 @@ #include "params.h" #include "common/xml.h" +#include "analysis/binaries/file.h" #include "gtkext/easygtk.h" #include "gtkext/gtkblockview.h" #include "gtkext/gtkdockpanel.h" @@ -46,7 +47,7 @@ /* Conservation d'un binaire chargé */ typedef struct _loaded_binary { - GOpenidaBinary *binary; /* Binaire en question */ + GLoadedBinary *binary; /* Binaire en question */ GtkViewPanel *views[BVW_COUNT]; /* Composants pour l'affichage */ GtkWidget *scrollwindows[BVW_COUNT]; /* Supports pour l'affichage */ @@ -179,7 +180,7 @@ GStudyProject *g_study_project_open(const char *filename) unsigned int i; /* Boucle de parcours */ size_t access_len; /* Taille d'un chemin interne */ char *access; /* Chemin pour une sous-config.*/ - GOpenidaBinary *binary; /* Représentation à intégrer */ + GLoadedBinary *binary; /* Représentation à intégrer */ if (!open_xml_file(filename, &xdoc, &context)) return NULL; @@ -199,7 +200,7 @@ GStudyProject *g_study_project_open(const char *filename) access = calloc(access_len, sizeof(char)); snprintf(access, access_len, "/OpenIDAProject/Binaries/Binary[position()=%u]", i + 1); - binary = g_openida_binary_new_from_xml(context, access); + binary = g_file_binary_new_from_xml(context, access); free(access); @@ -207,7 +208,7 @@ GStudyProject *g_study_project_open(const char *filename) { g_signal_connect(binary, "disassembly-done", G_CALLBACK(g_study_project_add_loaded_binary), result); - g_openida_binary_analyse(binary); + g_loaded_binary_analyse(binary); } } @@ -260,7 +261,7 @@ bool g_study_project_save(GStudyProject *project, const char *filename) access = calloc(access_len, sizeof(char)); snprintf(access, access_len, "/OpenIDAProject/Binaries/Binary[position()=%zu]", i + 1); - result = g_openida_binary_save(project->binaries[i]->binary, xdoc, context, access); + result = g_loaded_binary_save(project->binaries[i]->binary, xdoc, context, access); free(access); @@ -316,7 +317,7 @@ const char *g_study_project_get_filename(const GStudyProject *project) * * ******************************************************************************/ -void g_study_project_add_loaded_binary(GOpenidaBinary *binary, GStudyProject *project) +void g_study_project_add_loaded_binary(GLoadedBinary *binary, GStudyProject *project) { size_t index; /* Indice du nouveau binaire */ @@ -343,7 +344,7 @@ void g_study_project_add_loaded_binary(GOpenidaBinary *binary, GStudyProject *pr * * ******************************************************************************/ -size_t g_study_project_attach_binary(GStudyProject *project, GOpenidaBinary *binary) +size_t g_study_project_attach_binary(GStudyProject *project, GLoadedBinary *binary) { size_t result; /* Indice à retourner */ loaded_binary *loaded; /* Structure à renvoyer */ @@ -385,8 +386,8 @@ size_t g_study_project_attach_binary(GStudyProject *project, GOpenidaBinary *bin loaded->views[i] = GTK_VIEW_PANEL(view); gtk_view_panel_attach_binary(loaded->views[i], binary, - g_openida_binary_display_addresses_in_text(binary), - g_openida_binary_display_code_in_text(binary)); + g_loaded_binary_display_addresses_in_text(binary), + g_loaded_binary_display_code_in_text(binary)); /* Intégration finale dans un support défilant */ @@ -402,9 +403,9 @@ size_t g_study_project_attach_binary(GStudyProject *project, GOpenidaBinary *bin /* Support graphique final */ scroll = loaded->scrollwindows[BVW_BLOCK]; - title = g_openida_binary_to_string(binary); + title = g_loaded_binary_get_filename(binary, false); - loaded->item = g_panel_item_new(strrchr(title, G_DIR_SEPARATOR) + 1, title, scroll, "M"); + loaded->item = g_panel_item_new(title, title, scroll, "M"); /* Enregistrement dans le projet */ @@ -439,7 +440,7 @@ size_t g_study_project_attach_binary(GStudyProject *project, GOpenidaBinary *bin * * ******************************************************************************/ -void g_study_project_detach_binary(GStudyProject *project, GOpenidaBinary *binary) +void g_study_project_detach_binary(GStudyProject *project, GLoadedBinary *binary) { //GtkDockPanel *dpanel; /* Support de panneaux */ //GDockItem *ditem; /* Support d'affichage utilisé */ @@ -479,7 +480,7 @@ void g_study_project_detach_binary(GStudyProject *project, GOpenidaBinary *binar * * ******************************************************************************/ -GtkWidget *g_study_project_get_view_for_binary(const GStudyProject *project, const GOpenidaBinary *binary, BinaryView kind, GtkViewPanel **view) +GtkWidget *g_study_project_get_view_for_binary(const GStudyProject *project, const GLoadedBinary *binary, BinaryView kind, GtkViewPanel **view) { GtkWidget *result; /* Composant GTK à retourner */ size_t i; /* Boucle de parcours */ @@ -557,13 +558,13 @@ static void g_study_project_hide(const GStudyProject *project) * * ******************************************************************************/ -GOpenidaBinary **g_study_project_get_binaries(const GStudyProject *project, size_t *count) +GLoadedBinary **g_study_project_get_binaries(const GStudyProject *project, size_t *count) { - GOpenidaBinary **result; /* Tableau à retourner */ + GLoadedBinary **result; /* Tableau à retourner */ size_t i; /* Boucle de parcours */ *count = project->binaries_count; - result = (GOpenidaBinary **)calloc(*count, sizeof(GOpenidaBinary *)); + result = (GLoadedBinary **)calloc(*count, sizeof(GLoadedBinary *)); for (i = 0; i < *count; i++) { diff --git a/src/project.h b/src/project.h index 3fd3dab..de5badb 100644 --- a/src/project.h +++ b/src/project.h @@ -79,22 +79,22 @@ bool g_study_project_save(GStudyProject *, const char *); const char *g_study_project_get_filename(const GStudyProject *); /* Assure l'intégration d'un élément binaire dans un projet. */ -void g_study_project_add_loaded_binary(GOpenidaBinary *, GStudyProject *); +void g_study_project_add_loaded_binary(GLoadedBinary *, GStudyProject *); /* Attache un fichier donné à un projet donné. */ -size_t g_study_project_attach_binary(GStudyProject *, GOpenidaBinary *); +size_t g_study_project_attach_binary(GStudyProject *, GLoadedBinary *); /* Détache un fichier donné à un projet donné. */ -void g_study_project_detach_binary(GStudyProject *, GOpenidaBinary *); +void g_study_project_detach_binary(GStudyProject *, GLoadedBinary *); /* Fournit un support d'affichage donné pour un binaire chargé. */ -GtkWidget *g_study_project_get_view_for_binary(const GStudyProject *, const GOpenidaBinary *, BinaryView, GtkViewPanel **); +GtkWidget *g_study_project_get_view_for_binary(const GStudyProject *, const GLoadedBinary *, BinaryView, GtkViewPanel **); /* Met en place un projet à l'écran. */ void g_study_project_display(const GStudyProject *); /* Fournit l'ensemble des binaires associés à un projet. */ -GOpenidaBinary **g_study_project_get_binaries(const GStudyProject *, size_t *); +GLoadedBinary **g_study_project_get_binaries(const GStudyProject *, size_t *); -- cgit v0.11.2-87-g4458