summaryrefslogtreecommitdiff
path: root/src/panel
diff options
context:
space:
mode:
Diffstat (limited to 'src/panel')
-rwxr-xr-xsrc/panel/Makefile.am3
-rw-r--r--src/panel/log.c7
-rw-r--r--src/panel/panels.c8
-rw-r--r--src/panel/panels.h3
-rw-r--r--src/panel/symbols.c217
-rw-r--r--src/panel/symbols.h45
6 files changed, 277 insertions, 6 deletions
diff --git a/src/panel/Makefile.am b/src/panel/Makefile.am
index f53a841..48f0958 100755
--- a/src/panel/Makefile.am
+++ b/src/panel/Makefile.am
@@ -4,7 +4,8 @@ noinst_LTLIBRARIES = libpanel.la
libpanel_la_SOURCES = \
log.h log.c \
panels.h panels.c \
- registers.h registers.c
+ registers.h registers.c \
+ symbols.h symbols.c
libpanel_la_LDFLAGS =
diff --git a/src/panel/log.c b/src/panel/log.c
index 812d470..e8ac952 100644
--- a/src/panel/log.c
+++ b/src/panel/log.c
@@ -67,7 +67,6 @@ GtkWidget *build_log_panel(void)
GtkWidget *treeview; /* Affichage de la liste */
GtkCellRenderer *renderer; /* Moteur de rendu de colonne */
GtkTreeViewColumn *column; /* Colonne de la liste */
- GtkTreeSelection *select; /* Sélection dans la liste */
result = gtk_scrolled_window_new(NULL, NULL);
gtk_widget_show(result);
@@ -154,6 +153,12 @@ void log_simple_message(LogMessageType type, const char *msg)
-1);
break;
+ default:
+ gtk_tree_store_set(store, &iter,
+ LGC_STRING, msg,
+ -1);
+ break;
+
}
}
diff --git a/src/panel/panels.c b/src/panel/panels.c
index eae6ba3..39adc10 100644
--- a/src/panel/panels.c
+++ b/src/panel/panels.c
@@ -27,6 +27,7 @@
#include "log.h"
#include "registers.h"
+#include "symbols.h"
@@ -36,7 +37,7 @@ static GtkWidget *panel_list[PNT_COUNT];
/******************************************************************************
* *
-* Paramètres : - *
+* Paramètres : ref = espace de référencements global. *
* *
* Description : Procède au chargement de tous les panneaux. *
* *
@@ -46,10 +47,11 @@ static GtkWidget *panel_list[PNT_COUNT];
* *
******************************************************************************/
-void init_panels(void)
+void init_panels(GObject *ref)
{
panel_list[PNT_LOG] = build_log_panel();
panel_list[PNT_REGISTERS] = build_registers_panel();
+ panel_list[PNT_SYMBOLS] = build_symbols_panel(ref);
}
@@ -68,6 +70,6 @@ void init_panels(void)
GtkWidget *get_panel(PanelType id)
{
- return panel_list[id];
+ return (id < PNT_COUNT ? panel_list[id] : NULL);
}
diff --git a/src/panel/panels.h b/src/panel/panels.h
index e38f196..feaa908 100644
--- a/src/panel/panels.h
+++ b/src/panel/panels.h
@@ -35,6 +35,7 @@ typedef enum _PanelType
{
PNT_LOG, /* Messages système */
PNT_REGISTERS, /* Registres d'architecture */
+ PNT_SYMBOLS, /* Symboles d'exécutable */
PNT_COUNT
@@ -42,7 +43,7 @@ typedef enum _PanelType
/* Procède au chargement de tous les panneaux. */
-void init_panels(void);
+void init_panels(GObject *);
/* Fournit la référence d'un panneau donné. */
GtkWidget *get_panel(PanelType);
diff --git a/src/panel/symbols.c b/src/panel/symbols.c
new file mode 100644
index 0000000..3937849
--- /dev/null
+++ b/src/panel/symbols.c
@@ -0,0 +1,217 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * symbols.c - panneau d'affichage des symboles
+ *
+ * Copyright (C) 2006-2007 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "symbols.h"
+
+
+#include <malloc.h>
+#include <stdlib.h>
+
+
+#include "../arch/processor.h"
+#include "../gtkext/gtkbinview.h"
+
+
+
+/* Colonnes de la liste des symboles */
+typedef enum _SymbolsColumn
+{
+ SBC_ADDRESS, /* Adresse mémoire du symbole */
+ SBC_NAME, /* Désignation humaine */
+
+ SBC_COUNT /* Nombre de colonnes */
+
+} SymbolsColumn;
+
+
+/* Réagit au changement de sélection des symboles. */
+void change_symbols_selection(GtkTreeSelection *, gpointer);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : ref = adresse de l'espace de référencements. *
+* *
+* Description : Construit le panneau d'affichage des symboles. *
+* *
+* Retour : Adresse du panneau mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GtkWidget *build_symbols_panel(GObject *ref)
+{
+ GtkWidget *result; /* Panneau à retourner */
+ GtkTreeStore *store; /* Modèle de gestion */
+ GtkWidget *treeview; /* Affichage de la liste */
+ GtkCellRenderer *renderer; /* Moteur de rendu de colonne */
+ GtkTreeViewColumn *column; /* Colonne de la liste */
+ GtkTreeSelection *select; /* Sélection dans la liste */
+
+ result = gtk_scrolled_window_new(NULL, NULL);
+ gtk_widget_show(result);
+
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(result), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(result), GTK_SHADOW_IN);
+
+ store = gtk_tree_store_new(SBC_COUNT, G_TYPE_STRING, G_TYPE_STRING);
+ g_object_set_data(G_OBJECT(result), "store", store);
+
+ treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
+ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE);
+ gtk_widget_show(treeview);
+ gtk_container_add(GTK_CONTAINER(result), treeview);
+
+ g_object_unref(G_OBJECT(store));
+
+ column = gtk_tree_view_column_new();
+ gtk_tree_view_column_set_visible(column, FALSE);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+ gtk_tree_view_set_expander_column(GTK_TREE_VIEW(treeview), column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes("Address", renderer, "text", SBC_ADDRESS, NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes("Name", renderer, "text", SBC_NAME, NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+
+ select = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
+ gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
+ g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK(change_symbols_selection), ref);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : selection = sélection modifiée. *
+* data = adresse de l'espace de référencements. *
+* *
+* Description : Réagit au changement de sélection des symboles. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void change_symbols_selection(GtkTreeSelection *selection, gpointer data)
+{
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ gchar *string; /* Chaîne sélectionnée */
+ vmpa_t address; /* Adresse à rejoindre */
+ GtkBinview *binview; /* Affichage à faire défiler */
+
+ if (gtk_tree_selection_get_selected(selection, &model, &iter))
+ {
+ gtk_tree_model_get(model, &iter, SBC_ADDRESS, &string, -1);
+ address = strtoll(string, NULL, 16); /* FIXME */
+ g_free(string);
+
+ binview = GTK_BIN_VIEW(g_object_get_data(G_OBJECT(data), "binview"));
+
+ gtk_binview_scroll_to_address(binview, address);
+
+ }
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : panel = panneau à mettre à jour. *
+* format = données sur l'exécutable à représenter. *
+* *
+* Description : Affiche la liste des symboles présents dans un exécutable. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void reload_symbols_panel_content(GtkWidget *panel, const exe_format *format)
+{
+ GBinRoutine **routines; /* Routines trouvées */
+ size_t count; /* Nombre de ces routines */
+ GtkTreeStore *store; /* Modèle de gestion */
+ GArchProcessor *proc; /* Architecture utilisée */
+ size_t i; /* Boucle de parcours */
+ vmpa_t address; /* Adresse associée au symbole */
+ char tmp[19]; /* Version humainement lisible */
+ GtkTreeIter iter; /* Point d'insertion */
+
+ routines = get_all_exe_routines(format, &count);
+
+ if (routines != NULL)
+ {
+ store = g_object_get_data(G_OBJECT(panel), "store");
+
+ proc = get_arch_processor_from_format(format);
+
+ for (i = 0; i < count; i++)
+ {
+ address = g_binary_routine_get_address(routines[i]);
+
+ switch (g_arch_processor_get_memory_size(proc))
+ {
+ case MDS_8_BITS:
+ snprintf(tmp, 19, "0x%02llx", address);
+ break;
+
+ case MDS_16_BITS:
+ snprintf(tmp, 19, "0x%04llx", address);
+ break;
+
+ case MDS_32_BITS:
+ snprintf(tmp, 19, "0x%08llx", address);
+ break;
+
+ default:
+ case MDS_64_BITS:
+ snprintf(tmp, 19, "0x%16llx", address);
+ break;
+
+ }
+
+ gtk_tree_store_append(store, &iter, NULL);
+ gtk_tree_store_set(store, &iter,
+ SBC_ADDRESS, tmp,
+ SBC_NAME, g_binary_routine_get_name(routines[i]),
+ -1);
+
+ }
+
+ free(routines);
+
+ }
+
+}
diff --git a/src/panel/symbols.h b/src/panel/symbols.h
new file mode 100644
index 0000000..195bcf2
--- /dev/null
+++ b/src/panel/symbols.h
@@ -0,0 +1,45 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * pan_symbols.h - prototypes pour le panneau d'affichage des symboles
+ *
+ * Copyright (C) 2006-2007 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _PAN_SYMBOLS_H
+#define _PAN_SYMBOLS_H
+
+
+#include <gtk/gtk.h>
+
+
+#include "../format/exe_format.h"
+
+
+
+/* Construit le panneau d'affichage des symboles. */
+GtkWidget *build_symbols_panel(GObject *);
+
+
+/* Affiche la liste des symboles présents dans un exécutable. */
+void reload_symbols_panel_content(GtkWidget *, const exe_format *);
+
+
+
+#endif /* _PAN_SYMBOLS_H */