diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/extstr.c | 4 | ||||
-rw-r--r-- | src/editor.c | 667 | ||||
-rw-r--r-- | src/gtkext/gtkviewpanel.c | 17 |
3 files changed, 26 insertions, 662 deletions
diff --git a/src/common/extstr.c b/src/common/extstr.c index 87d0b13..8249515 100644 --- a/src/common/extstr.c +++ b/src/common/extstr.c @@ -176,6 +176,8 @@ char *strrpl(char *haystack, const char *needle1, const char *needle2) } + regfree(&preg); + return haystack; } @@ -267,6 +269,8 @@ char *escape_crlf(char *input) } + regfree(&preg); + return input; } diff --git a/src/editor.c b/src/editor.c index 85763bb..c533a64 100644 --- a/src/editor.c +++ b/src/editor.c @@ -28,39 +28,14 @@ #include <i18n.h> -#include "gtkext/support.h" - - - - - -/** exemple GTK **/ -#include <stdio.h> -#include <stdlib.h> -#include <signal.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <unistd.h> -/** exemple GTK **/ - - #include "project.h" - -#include "analysis/binary.h" #include "gtkext/easygtk.h" -#include "gtkext/gtkextstatusbar.h" -#include "gtkext/gtkblockview.h" #include "gtkext/gtkdockstation.h" -#include "gtkext/gtkviewpanel.h" - -#include "debug/debugger.h" -//#include "dialogs/add_shellcode.h" -#include "dialogs/binparts.h" -#include "dialogs/plugins.h" +#include "gtkext/gtkextstatusbar.h" +#include "gtkext/support.h" #include "gui/menus/menubar.h" #include "gui/panels/panel.h" #include "gui/tb/source.h" -#include "panels/panel.h" @@ -79,36 +54,6 @@ static gboolean on_delete_editor(GtkWidget *, GdkEvent *, gpointer); /* Quitte le programme en sortie de la boucle de GTK. */ static void on_destroy_editor(GtkWidget *, gpointer); -/* Charge un projet récent et met à jour la liste. */ -void mcb_open_recent_project(GtkMenuItem *, GObject *); - - - - -/* Réagit avec le menu "Binaire -> Sélectionner les parties...". */ -static void mcb_binary_select_parts(GtkMenuItem *, GObject *); - -/* Réagit avec le menu "Binaire -> Sélectionner les greffons...". */ -static void mcb_binary_select_plugins(GtkMenuItem *, GObject *); - - -/* Réagit avec le menu "Débogage -> Démarrer". */ -void mcb_debug_start(GtkCheckMenuItem *, gpointer); - -/* Réagit avec le menu "Débogage -> Mettre en pause". */ -void mcb_debug_pause(GtkCheckMenuItem *, gpointer); - -/* Réagit avec le menu "Débogage -> Reprendre". */ -void mcb_debug_resume(GtkCheckMenuItem *, gpointer); - -/* Réagit avec le menu "Débogage -> Tuer". */ -void mcb_debug_kill(GtkCheckMenuItem *, gpointer); - -/* Met à jour l'accessibilité aux éléments du menu "Debogage". */ -void update_debug_menu_items(GObject *, gboolean); - - - @@ -122,16 +67,6 @@ static void on_dock_item_switch(GtkDockStation *, GtkWidget *, GObject *); -/* ------------------------- PARTIE DEDIEE AU MODE DEBOGAGE ------------------------- */ - - -/* Prend note d'une pause dans le débogage. */ -static void on_debugger_halted(GBinaryDebugger *, int, vmpa_t, pid_t, GObject *); - - - - - /* ------------------------ INTEGRATION DE LA BARRE D'OUTILS ------------------------ */ @@ -198,44 +133,14 @@ GtkWidget *create_editor(void) GObject *ref; /* Version de référence */ GEditorItem *editem; /* Menus réactifs principaux */ GtkWidget *menuboard; /* Barre de menus principale */ - GtkWidget *menuitem; /* Elément de menu */ - GtkWidget *menubar; /* Support pour éléments */ - GtkWidget *submenuitem; /* Sous-élément de menu */ - GtkWidget *submenubar; /* Support pour sous-éléments */ - GSList *rgroup; /* Groupe des boutons radio */ - - - GtkWidget *ssubmenuitem; /* Sous-élément de menu */ - GtkWidget *toolbar; /* Barre d'outils */ - GtkWidget *vbox1; - GtkWidget *vpaned1; - GtkWidget *hpaned1; - GtkWidget *scrolledwindow2; - GtkWidget *snippet; - GtkWidget *statusbar; - - GtkWidget *view; - - GtkWidget *panel; - - - + GtkWidget *vbox1; + GtkWidget *statusbar; -#if 0 - GtkWidget *vbox; /* Support à divisions vert. */ - GtkWidget *notebook; /* Support à onglets */ - GtkWidget *panel; /* Panneau de configuration */ - GtkWidget *label; /* Etiquette pour onglet */ - GtkWidget *hseparator; /* Barre de séparation */ - GtkWidget *hbuttonbox; /* Support horizontal de btns. */ - GtkWidget *button; /* Btn. de commande inférieur */ -#endif - GtkWidget *button; /* Btn. de commande inférieur */ GtkAccelGroup *accgroup; @@ -250,6 +155,7 @@ GtkWidget *create_editor(void) icons = build_editor_icons_list(); gtk_window_set_icon_list(GTK_WINDOW(result), icons); + g_list_free_full(icons, (GDestroyNotify)g_object_unref); g_signal_connect(G_OBJECT(result), "delete-event", G_CALLBACK(on_delete_editor), NULL); g_signal_connect(G_OBJECT(result), "destroy", G_CALLBACK(on_destroy_editor), NULL); @@ -261,9 +167,9 @@ GtkWidget *create_editor(void) - vbox1 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox1); - gtk_container_add (GTK_CONTAINER (result), vbox1); + vbox1 = gtk_vbox_new(FALSE, 0); + gtk_widget_show(vbox1); + gtk_container_add(GTK_CONTAINER(result), vbox1); /* Intégration des menus */ @@ -277,95 +183,6 @@ GtkWidget *create_editor(void) - menuboard = gtk_menu_bar_new(); - gtk_widget_show(menuboard); - //gtk_box_pack_start(GTK_BOX(vbox1), menuboard, FALSE, FALSE, 0); - - /* Affichage */ - - menuitem = gtk_menu_item_new_with_mnemonic(_("_View")); - gtk_widget_show(menuitem); - gtk_container_add(GTK_CONTAINER(menuboard), menuitem); - - menubar = gtk_menu_new(); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menubar); - - submenuitem = qck_create_menu_separator(); - gtk_container_add(GTK_CONTAINER(menubar), submenuitem); - - submenuitem = qck_create_menu_separator(); - gtk_container_add(GTK_CONTAINER(menubar), submenuitem); - - submenuitem = qck_create_menu_item(NULL, NULL, _("Toolbar"), NULL, NULL); - gtk_container_add(GTK_CONTAINER(menubar), submenuitem); - - submenubar = gtk_menu_new(); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(submenuitem), submenubar); - - ssubmenuitem = qck_create_check_menu_item(NULL, NULL, _("Source file"), G_CALLBACK(NULL), result); - gtk_container_add(GTK_CONTAINER(submenubar), ssubmenuitem); - - - - - - menuitem = gtk_menu_item_new_with_mnemonic(_("_Binary")); - gtk_widget_show(menuitem); - gtk_container_add(GTK_CONTAINER(menuboard), menuitem); - - menubar = gtk_menu_new(); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menubar); - - submenuitem = qck_create_menu_item(NULL, NULL, _("Select parts..."), G_CALLBACK(mcb_binary_select_parts), ref); - gtk_container_add(GTK_CONTAINER(menubar), submenuitem); - - submenuitem = qck_create_menu_item(NULL, NULL, _("Select plugins..."), G_CALLBACK(mcb_binary_select_plugins), ref); - gtk_container_add(GTK_CONTAINER(menubar), submenuitem); - - - menuitem = gtk_menu_item_new_with_mnemonic(_("_Debug")); - gtk_widget_show(menuitem); - gtk_container_add(GTK_CONTAINER(menuboard), menuitem); - - menubar = gtk_menu_new(); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menubar); - - submenuitem = qck_create_menu_item(ref, "mnu_debug_start", _("Start process"), G_CALLBACK(mcb_debug_start), result); - gtk_container_add(GTK_CONTAINER(menubar), submenuitem); - - submenuitem = qck_create_menu_item(ref, "mnu_debug_pause", _("Pause process"), G_CALLBACK(mcb_debug_pause), result); - gtk_container_add(GTK_CONTAINER(menubar), submenuitem); - - submenuitem = qck_create_menu_item(ref, "mnu_debug_resume", _("Resume process"), G_CALLBACK(mcb_debug_resume), result); - gtk_container_add(GTK_CONTAINER(menubar), submenuitem); - - submenuitem = qck_create_menu_item(ref, "mnu_debug_kill", _("Kill process"), G_CALLBACK(mcb_debug_kill), result); - gtk_container_add(GTK_CONTAINER(menubar), submenuitem); - - submenuitem = qck_create_menu_separator(); - gtk_container_add(GTK_CONTAINER(menubar), submenuitem); - - submenuitem = qck_create_menu_item(ref, "mnu_debug_into", _("Step into"), NULL/*G_CALLBACK()*/, result); - gtk_container_add(GTK_CONTAINER(menubar), submenuitem); - - submenuitem = qck_create_menu_item(ref, "mnu_debug_over", _("Step over"), NULL/*G_CALLBACK()*/, result); - gtk_container_add(GTK_CONTAINER(menubar), submenuitem); - - submenuitem = qck_create_menu_item(ref, "mnu_debug_ret", _("Run until ret"), NULL/*G_CALLBACK()*/, result); - gtk_container_add(GTK_CONTAINER(menubar), submenuitem); - - submenuitem = qck_create_menu_separator(); - gtk_container_add(GTK_CONTAINER(menubar), submenuitem); - - - - update_debug_menu_items(ref, FALSE); - - - - - - @@ -389,114 +206,6 @@ GtkWidget *create_editor(void) - -#if 0 - vpaned1 = gtk_vpaned_new (); - gtk_widget_show (vpaned1); - //gtk_box_pack_start (GTK_BOX (vbox1), vpaned1, TRUE, TRUE, 0); - gtk_paned_set_position (GTK_PANED (vpaned1), 400); - - hpaned1 = gtk_hpaned_new (); - gtk_widget_show (hpaned1); - gtk_paned_pack1 (GTK_PANED (vpaned1), hpaned1, FALSE, TRUE); - gtk_paned_set_position (GTK_PANED (hpaned1), 600); - - - init_panels(ref); - - - dpanel = gtk_dock_panel_new(); - g_object_set_data(G_OBJECT(result), "binpanel", dpanel); - gtk_widget_show(dpanel); - - - - g_signal_connect(dpanel, "switch-item", G_CALLBACK(on_dock_item_switch), ref); - - - - gtk_paned_pack1(GTK_PANED(hpaned1), dpanel, TRUE, TRUE); - - - - - - - dpanel = gtk_dock_panel_new(); - gtk_widget_show(dpanel); - - g_signal_connect(dpanel, "switch-item", G_CALLBACK(on_dock_item_switch), ref); - - gtk_paned_pack2(GTK_PANED(hpaned1), dpanel, TRUE, TRUE); - - - place_all_panels_in_editor(dpanel); - - - ditem = g_dock_item_new(_("Registers"), get_panel(PNT_REGISTERS)); - gtk_dock_panel_add_item(dpanel, ditem); - - - - - /* Panneau inférieur */ - - - - dpanel = gtk_dock_panel_new(); - gtk_widget_show(dpanel); - - printf("bottom :: %p\n", dpanel); - - gtk_paned_pack2(GTK_PANED(vpaned1), dpanel, FALSE, FALSE); - - //ditem = g_dock_item_new(_("Messages"), get_panel(PNT_LOG)); - //gtk_dock_panel_add_item(dpanel, ditem); - - ditem = g_dock_item_new(_("Strings"), get_panel(PNT_STRINGS)); - gtk_dock_panel_add_item(dpanel, ditem); - - - - //panel = build_shell_panel(G_OBJECT(result)); - - //ditem = g_dock_item_new(_("Shell"), panel); - //gtk_dock_panel_add_item(dpanel, ditem); - - - - /* - - notebook = qck_create_notebook(NULL, NULL); - gtk_paned_pack2(GTK_PANED(vpaned1), notebook, FALSE, FALSE); - - panel = build_strings_panel(G_OBJECT(result)); - gtk_container_add(GTK_CONTAINER(notebook), panel); - - label = qck_create_label(NULL, NULL, _("Strings")); - gtk_notebook_set_tab_label(GTK_NOTEBOOK(notebook), gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), 0), label); - - */ - - - - - /* - - scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_show (scrolledwindow1); - gtk_paned_pack2 (GTK_PANED (vpaned1), scrolledwindow1, TRUE, TRUE); - - textview1 = gtk_text_view_new (); - gtk_widget_show (textview1); - gtk_container_add (GTK_CONTAINER (scrolledwindow1), textview1); - - - */ - - -#endif - statusbar = gtk_extended_status_bar_new(); g_object_set_data(ref, "statusbar", statusbar); @@ -542,7 +251,7 @@ static gboolean on_delete_editor(GtkWidget *widget, GdkEvent *event, gpointer da if (g_study_project_get_filename(project) == NULL) { - dialog = gtk_message_dialog_new(widget, + dialog = gtk_message_dialog_new(GTK_WINDOW(widget), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, @@ -606,334 +315,15 @@ static void on_destroy_editor(GtkWidget *widget, gpointer data) -/****************************************************************************** -* * -* Paramètres : menuitem = élément de menu sélectionné. * -* ref = adresse de l'espace de référencement global. * -* * -* Description : Charge un projet récent et met à jour la liste. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void mcb_open_recent_project(GtkMenuItem *menuitem, GObject *ref) -{ -#if 0 - const gchar *caption; /* Etiquette du menu */ - openida_project *project; /* Nouveau projet chargé */ - - caption = gtk_label_get_text(GTK_LABEL(gtk_bin_get_child(GTK_BIN(menuitem)))); - - project = g_openida_project_new_from_xml(ref, caption); - - if (project != NULL) - { - push_openida_project_into_recent_list(project); - load_recent_openida_projects_list(ref, G_CALLBACK(mcb_open_recent_project)); - - set_current_project(project); - - /* TODO ... */ - - } -#endif -} - - - - - - - - - - - - - - - - - - -/****************************************************************************** -* * -* Paramètres : menuitem = élément de menu sélectionné. * -* ref = adresse de l'espace de référencement global. * -* * -* Description : Réagit avec le menu "Binaire -> Sélectionner les parties...".* -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void mcb_binary_select_parts(GtkMenuItem *menuitem, GObject *ref) -{ - GLoadedBinary *binary; /* Binaire courant à l'écran */ - GtkWidget *dialog; /* Boîte de dialogue à montrer */ - - binary = G_LOADED_BINARY(g_object_get_data(ref, "current_binary")); - - dialog = create_sections_dialog(binary, GTK_WINDOW(ref)); - gtk_widget_show(dialog); - -} - - -/****************************************************************************** -* * -* Paramètres : menuitem = élément de menu sélectionné. * -* ref = adresse de l'espace de référencement global. * -* * -* Description : Réagit avec le menu "Binaire -> Sélectionner les greffons..."* -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void mcb_binary_select_plugins(GtkMenuItem *menuitem, GObject *ref) -{ - GLoadedBinary *binary; /* Binaire courant à l'écran */ - GtkWidget *dialog; /* Boîte de dialogue à montrer */ - - binary = G_LOADED_BINARY(g_object_get_data(ref, "current_binary")); - - dialog = create_plugins_selection_dialog(binary, GTK_WINDOW(ref)); - gtk_widget_show(dialog); - -} - - - - - -void debugger_stopped_cb(GBinaryDebugger *debugger, uint64_t last, uint64_t cur, gpointer data) -{ -#if 0 - GObject *ref; - - GLoadedBinary *binary; - GRenderingLine *line; - - - GtkWidget *submenuitem; /* Menu à rendre accessible */ - - register_value *values; - size_t count; - - - ref = G_OBJECT(data); - - - binary = g_object_get_data(ref, "current_binary"); - - - if (last != cur) - { - 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); - - } - - - printf("bp at 0x%016llx\n", 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); - else - printf("no line at address !\n"); - - - values = g_binary_debugger_get_registers(debugger, &count); - - - - - - /* Mises à jour */ - - update_debug_menu_items(ref, TRUE); - - - - - - - - refresh_registers_panel_with_registers(get_panel(PNT_REGISTERS), values, count); - -#endif - -} - - -/****************************************************************************** -* * -* Paramètres : menuitem = élément de menu ayant basculé. * -* data = adresse de l'espace de référencement global. * -* * -* Description : Réagit avec le menu "Débogage -> Démarrer". * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void mcb_debug_start(GtkCheckMenuItem *menuitem, gpointer data) -{ - GLoadedBinary *binary; /* Binaire à analyser */ - GBinaryDebugger *debugger; /* Débogueur offrant l'analyse */ - - - binary = g_object_get_data(G_OBJECT(data), "current_binary"); - - - - debugger = g_new_binary_debugger(DGT_JDWP, binary); - g_object_set_data(G_OBJECT(data), "current_debugger", debugger); - - // - g_binary_debugger_attach(debugger); - - g_signal_connect(debugger, "debugger-stopped", G_CALLBACK(debugger_stopped_cb), data); - - g_signal_connect(debugger, "halted", G_CALLBACK(on_debugger_halted), data); - - // g_binary_debugger_run(debugger); - - -} - - -/****************************************************************************** -* * -* Paramètres : menuitem = élément de menu ayant basculé. * -* data = adresse de l'espace de référencement global. * -* * -* Description : Réagit avec le menu "Débogage -> Mettre en pause". * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void mcb_debug_pause(GtkCheckMenuItem *menuitem, gpointer data) -{ - GBinaryDebugger *debugger; /* Débogueur offrant l'analyse */ - - - debugger = g_object_get_data(G_OBJECT(data), "current_debugger"); - - - - //g_binary_debugger_resume(debugger); - - - -} - - -/****************************************************************************** -* * -* Paramètres : menuitem = élément de menu ayant basculé. * -* data = adresse de l'espace de référencement global. * -* * -* Description : Réagit avec le menu "Débogage -> Reprendre". * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void mcb_debug_resume(GtkCheckMenuItem *menuitem, gpointer data) -{ - GBinaryDebugger *debugger; /* Débogueur offrant l'analyse */ - - - debugger = g_object_get_data(G_OBJECT(data), "current_debugger"); - - - - g_binary_debugger_resume(debugger); - - - -} - - -/****************************************************************************** -* * -* Paramètres : menuitem = élément de menu ayant basculé. * -* data = adresse de l'espace de référencement global. * -* * -* Description : Réagit avec le menu "Débogage -> Tuer". * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void mcb_debug_kill(GtkCheckMenuItem *menuitem, gpointer data) -{ - GBinaryDebugger *debugger; /* Débogueur offrant l'analyse */ - - debugger = g_object_get_data(G_OBJECT(data), "current_debugger"); - - g_binary_debugger_kill(debugger); - - /* TODO : retirer l'association binary <-> debugger */ - -} -/****************************************************************************** -* * -* Paramètres : ref = adresse de l'espace de référencement global. * -* stopped = indique l'état d'accessibilité des menus. * -* * -* Description : Met à jour l'accessibilité aux éléments du menu "Debogage". * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ -void update_debug_menu_items(GObject *ref, gboolean stopped) -{ - GtkWidget *submenuitem; /* Menu à rendre accessible */ - submenuitem = GTK_WIDGET(g_object_get_data(ref, "mnu_debug_pause")); - gtk_widget_set_sensitive(submenuitem, stopped); - submenuitem = GTK_WIDGET(g_object_get_data(ref, "mnu_debug_resume")); - gtk_widget_set_sensitive(submenuitem, stopped); - submenuitem = GTK_WIDGET(g_object_get_data(ref, "mnu_debug_into")); - gtk_widget_set_sensitive(submenuitem, stopped); - submenuitem = GTK_WIDGET(g_object_get_data(ref, "mnu_debug_over")); - gtk_widget_set_sensitive(submenuitem, stopped); - submenuitem = GTK_WIDGET(g_object_get_data(ref, "mnu_debug_ret")); - gtk_widget_set_sensitive(submenuitem, stopped); -} @@ -998,45 +388,6 @@ static void on_dock_item_switch(GtkDockStation *station, GtkWidget *widget, GObj -/* ---------------------------------------------------------------------------------- */ -/* PARTIE DEDIEE AU MODE DEBOGAGE */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -* * -* Paramètres : debugger = débogueur intervenant dans l'action. * -* sig = identifiant du signal source (nul si indéterminé).* -* addr = adresse de l'instruction courante. * -* thread = identifiant du thread concerné. * -* ref = espace de référencement global. * -* * -* Description : Prend note d'une pause dans le débogage. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void on_debugger_halted(GBinaryDebugger *debugger, int sig, vmpa_t addr, pid_t thread, GObject *ref) -{ - - printf("HALT (sig=%d) at 0x%016llx\n", sig, addr); - - - - -} - - - - - - - - - /* ---------------------------------------------------------------------------------- */ diff --git a/src/gtkext/gtkviewpanel.c b/src/gtkext/gtkviewpanel.c index 3c9ef6b..a3bf747 100644 --- a/src/gtkext/gtkviewpanel.c +++ b/src/gtkext/gtkviewpanel.c @@ -125,14 +125,23 @@ static void gtk_view_panel_init(GtkViewPanel *panel) static void gtk_view_panel_set_scroll_adjustments(GtkViewPanel *panel, GtkAdjustment *hadjustment, GtkAdjustment *vadjustment) { + /* TODO : déconnecter les anciens ? */ + panel->hadjustment = hadjustment; panel->vadjustment = vadjustment; - g_signal_connect(hadjustment, "value_changed", - G_CALLBACK(gtk_view_panel_adj_value_changed), panel); + /** + * On vérifie que le support n'est pas en train de nous libérer, + * avant de se connecter... + */ + + if (hadjustment != NULL) + g_signal_connect(hadjustment, "value_changed", + G_CALLBACK(gtk_view_panel_adj_value_changed), panel); - g_signal_connect(vadjustment, "value_changed", - G_CALLBACK(gtk_view_panel_adj_value_changed), panel); + if (vadjustment != NULL) + g_signal_connect(vadjustment, "value_changed", + G_CALLBACK(gtk_view_panel_adj_value_changed), panel); } |