diff options
| -rw-r--r-- | ChangeLog | 40 | ||||
| -rw-r--r-- | po/fr.po | 6 | ||||
| -rw-r--r-- | src/analysis/binary.c | 65 | ||||
| -rw-r--r-- | src/analysis/binary.h | 11 | ||||
| -rw-r--r-- | src/editor.c | 71 | ||||
| -rw-r--r-- | src/glibext/gbufferline.c | 9 | ||||
| -rw-r--r-- | src/glibext/gbufferline.h | 5 | ||||
| -rw-r--r-- | src/glibext/gcodebuffer.c | 18 | ||||
| -rw-r--r-- | src/glibext/gcodebuffer.h | 6 | ||||
| -rw-r--r-- | src/gtkext/gtkblockview.c | 10 | ||||
| -rw-r--r-- | src/gtkext/gtkbufferview-int.h | 5 | ||||
| -rw-r--r-- | src/gtkext/gtkbufferview.c | 31 | ||||
| -rw-r--r-- | src/gtkext/gtkbufferview.h | 4 | ||||
| -rw-r--r-- | src/gtkext/gtksourceview.c | 10 | ||||
| -rw-r--r-- | src/gtkext/gtkviewpanel-int.h | 4 | ||||
| -rw-r--r-- | src/gtkext/gtkviewpanel.c | 8 | ||||
| -rw-r--r-- | src/gtkext/gtkviewpanel.h | 4 | ||||
| -rw-r--r-- | src/gui/menus/Makefile.am | 3 | ||||
| -rw-r--r-- | src/gui/menus/menubar.c | 8 | ||||
| -rw-r--r-- | src/gui/menus/view.c | 142 | ||||
| -rw-r--r-- | src/gui/menus/view.h | 38 | ||||
| -rw-r--r-- | src/gui/tb/source.c | 5 | ||||
| -rw-r--r-- | src/project.c | 4 | 
23 files changed, 389 insertions, 118 deletions
| @@ -1,3 +1,43 @@ +12-01-14  Cyrille Bagard <nocbos@gmail.com> + +	* po/fr.po: +	Update translations for the View menu. + +	* src/analysis/binary.c: +	* src/analysis/binary.h: +	Memorize options to render the views. + +	* src/editor.c: +	Delete old code in the old View menu. + +	* src/glibext/gbufferline.c: +	* src/glibext/gbufferline.h: +	* src/glibext/gcodebuffer.c: +	* src/glibext/gcodebuffer.h: +	* src/gtkext/gtkblockview.c: +	* src/gtkext/gtkbufferview.c: +	* src/gtkext/gtkbufferview.h: +	* src/gtkext/gtkbufferview-int.h: +	* src/gtkext/gtksourceview.c: +	* src/gtkext/gtkviewpanel.c: +	* src/gtkext/gtkviewpanel.h: +	* src/gtkext/gtkviewpanel-int.h: +	Update calls to take the binary rendering options into account. + +	* src/gui/menus/Makefile.am: +	Add the view.[ch] files to libguimenus_la_SOURCES. + +	* src/gui/menus/menubar.c: +	Register the new View menu. + +	* src/gui/menus/view.c: +	* src/gui/menus/view.h: +	New entries: create a new View menu in a proper way. + +	* src/gui/tb/source.c: +	* src/project.c: +	Update calls. +  12-01-12  Cyrille Bagard <nocbos@gmail.com>  	* configure.ac: @@ -311,11 +311,11 @@ msgstr ""  #: src/dialogs/add_shellcode.c:812 src/dialogs/export.c:473 src/editor.c:348  msgid "Virtual address" -msgstr "" +msgstr "Adresse virtuelle"  #: src/dialogs/add_shellcode.c:816 src/dialogs/export.c:477 src/editor.c:351  msgid "Binary code" -msgstr "" +msgstr "Code binaire"  #: src/dialogs/add_shellcode.c:820 src/dialogs/export.c:481  msgid "Assembly code" @@ -472,7 +472,7 @@ msgstr ""  #: src/editor.c:319  msgid "_View" -msgstr "" +msgstr "Affichage"  #: src/editor.c:326  msgid "Text view" diff --git a/src/analysis/binary.c b/src/analysis/binary.c index 2e1ecc2..53da917 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -101,6 +101,9 @@ struct _GOpenidaBinary      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           */ @@ -344,6 +347,11 @@ static void g_openida_binary_class_init(GOpenidaBinaryClass *klass)  static void g_openida_binary_init(GOpenidaBinary *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")); @@ -1027,6 +1035,44 @@ GCodeBuffer *g_openida_binary_get_disassembled_buffer(const GOpenidaBinary *bina  /******************************************************************************  *                                                                             *  *  Paramètres  : binary = élément binaire à consulter.                        * +*                                                                             * +*  Description : Indique si les adresses doivent apparaître dans le rendu.    * +*                                                                             * +*  Retour      : Consigne d'affichage. [OUT]                                  * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +bool *g_openida_binary_display_addresses_in_text(const GOpenidaBinary *binary) +{ +    return &binary->text_display[0]; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : binary = élément binaire à consulter.                        * +*                                                                             * +*  Description : Indique si le code doit apparaître dans le rendu.            * +*                                                                             * +*  Retour      : Consigne d'affichage. [OUT]                                  * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +bool *g_openida_binary_display_code_in_text(const GOpenidaBinary *binary) +{ +    return &binary->text_display[1]; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : binary = élément binaire à consulter.                        *  *                index  = indice du fichier à retrouver.                      *  *                                                                             *  *  Description : Fournit le tampon associé au contenu d'un fichier source.    * @@ -1054,6 +1100,25 @@ GCodeBuffer *g_openida_binary_get_decompiled_buffer(const GOpenidaBinary *binary  /******************************************************************************  *                                                                             * +*  Paramètres  : binary = élément binaire à consulter.                        * +*                                                                             * +*  Description : Indique si les lignes doivent apparaître dans le rendu.      * +*                                                                             * +*  Retour      : Consigne d'affichage. [OUT]                                  * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +bool *g_openida_binary_display_decomp_lines(const GOpenidaBinary *binary) +{ +    return &binary->lines_display; + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : filename = nom du fichier à charger.                         *  *                length   = taille des données mises en mémoire. [OUT]        *  *                                                                             * diff --git a/src/analysis/binary.h b/src/analysis/binary.h index 4f9c034..63a9e61 100644 --- a/src/analysis/binary.h +++ b/src/analysis/binary.h @@ -2,7 +2,7 @@  /* OpenIDA - Outil d'analyse de fichiers binaires   * binary.h - prototypes pour le traitement des flots de code binaire   * - * Copyright (C) 2008-2010 Cyrille Bagard + * Copyright (C) 2008-2012 Cyrille Bagard   *   *  This file is part of OpenIDA.   * @@ -112,9 +112,18 @@ GArchInstruction *g_openida_binary_get_instructions(const GOpenidaBinary *);  /* Fournit le tampon associé au contenu assembleur d'un binaire. */  GCodeBuffer *g_openida_binary_get_disassembled_buffer(const GOpenidaBinary *); +/* Indique si les adresses doivent apparaître dans le rendu. */ +bool *g_openida_binary_display_addresses_in_text(const GOpenidaBinary *); + +/* Indique si le code doit apparaître dans le rendu. */ +bool *g_openida_binary_display_code_in_text(const GOpenidaBinary *); +  /* Fournit le tampon associé au contenu d'un fichier source. */  GCodeBuffer *g_openida_binary_get_decompiled_buffer(const GOpenidaBinary *, size_t); +/* Indique si les lignes doivent apparaître dans le rendu. */ +bool *g_openida_binary_display_decomp_lines(const GOpenidaBinary *); +  /* ------------------------------ ELEMENTS DE DEBOGAGE ------------------------------ */ diff --git a/src/editor.c b/src/editor.c index e540e5e..284b16c 100644 --- a/src/editor.c +++ b/src/editor.c @@ -93,13 +93,6 @@ void mcb_open_recent_project(GtkMenuItem *, GObject *);  /* Réagit avec le menu "Affichage -> Vue xxx". */  void mcb_view_change_support(GtkRadioMenuItem *, GObject *); -/* Réagit avec le menu "Affichage -> Adresse virtuelle". */ -void mcb_view_vaddress(GtkCheckMenuItem *, gpointer); - -/* Réagit avec le menu "Affichage -> code binaire". */ -void mcb_view_code(GtkCheckMenuItem *, gpointer); - -  /* Affiche la boîte d'ajout d'un binaire au projet courant. */  void mcb_project_add_binary(GtkMenuItem *, gpointer); @@ -343,12 +336,6 @@ GtkWidget *create_editor(void)      submenuitem = qck_create_menu_separator();      gtk_container_add(GTK_CONTAINER(menubar), submenuitem); -    submenuitem = qck_create_check_menu_item(NULL, NULL, _("Virtual address"), G_CALLBACK(mcb_view_vaddress), result); -    gtk_container_add(GTK_CONTAINER(menubar), submenuitem); - -    submenuitem = qck_create_check_menu_item(NULL, NULL, _("Binary code"), G_CALLBACK(mcb_view_code), result); -    gtk_container_add(GTK_CONTAINER(menubar), submenuitem); -      submenuitem = qck_create_menu_separator();      gtk_container_add(GTK_CONTAINER(menubar), submenuitem); @@ -948,64 +935,6 @@ void mcb_view_change_support(GtkRadioMenuItem *menuitem, GObject *ref)  } -/****************************************************************************** -*                                                                             * -*  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 "Affichage -> Adresse virtuelle".        * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void mcb_view_vaddress(GtkCheckMenuItem *menuitem, gpointer data) -{ -    GtkBinView *binview;                  /* Zone de code principale     */ -    gboolean active;                        /* Etat de sélection du menu   */ - -    /* FIXME : "binview" -> "current_view" */ -    return; - -    binview = GTK_BIN_VIEW(g_object_get_data(G_OBJECT(data), "binview")); -    active = gtk_check_menu_item_get_active(menuitem); - -    gtk_binview_show_vaddress(binview, active); - -} - - -/****************************************************************************** -*                                                                             * -*  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 "Affichage -> code binaire".             * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void mcb_view_code(GtkCheckMenuItem *menuitem, gpointer data) -{ -    GtkBinView *binview;                  /* Zone de code principale     */ -    gboolean active;                        /* Etat de sélection du menu   */ - -    /* FIXME : "binview" -> "current_view" */ -    return; - -    binview = GTK_BIN_VIEW(g_object_get_data(G_OBJECT(data), "binview")); -    active = gtk_check_menu_item_get_active(menuitem); - -    gtk_binview_show_code(binview, active); - -} - - diff --git a/src/glibext/gbufferline.c b/src/glibext/gbufferline.c index 08684d5..cc99ee8 100644 --- a/src/glibext/gbufferline.c +++ b/src/glibext/gbufferline.c @@ -2,7 +2,7 @@  /* OpenIDA - Outil d'analyse de fichiers binaires   * gbufferline.c - représentation de fragments de texte en ligne   * - * Copyright (C) 2010 Cyrille Bagard + * Copyright (C) 2010-2012 Cyrille Bagard   *   *  This file is part of OpenIDA.   * @@ -519,6 +519,8 @@ void g_buffer_line_start_merge_at(GBufferLine *line, BufferLineColumn start)  *                max_widths = largeurs de colonne à respecter.                *  *                x_init     = abscisse du point d'impression de départ.       *  *                y          = ordonnée du point d'impression.                 * +*                addr   = indique si les positions doivent être affichées.    * +*                code   = indique si le code binaire doit être affiché.       *  *                                                                             *  *  Description : Imprime la ligne de texte représentée.                       *  *                                                                             * @@ -528,7 +530,7 @@ void g_buffer_line_start_merge_at(GBufferLine *line, BufferLineColumn start)  *                                                                             *  ******************************************************************************/ -void g_buffer_line_draw(GBufferLine *line, GdkDrawable *drawable, GdkGC *gc, const gint max_widths[BLC_COUNT], gint x_init, gint y) +void g_buffer_line_draw(GBufferLine *line, GdkDrawable *drawable, GdkGC *gc, const gint max_widths[BLC_COUNT], gint x_init, gint y, bool addr, bool code)  {      gint x;                                 /* Point de départ d'impression*/      BufferLineColumn i;                     /* Boucle de parcours          */ @@ -537,7 +539,8 @@ void g_buffer_line_draw(GBufferLine *line, GdkDrawable *drawable, GdkGC *gc, con      for (i = BLC_ADDRESS; i < BLC_COUNT; i++)      { -        /* TODO : skip if... */ +        if (i == BLC_ADDRESS && !addr) continue; +        if (i == BLC_BINARY && !code) continue;          draw_segments_of_column(&line->columns[i], drawable, gc, x, y); diff --git a/src/glibext/gbufferline.h b/src/glibext/gbufferline.h index d4384e3..66ec2b0 100644 --- a/src/glibext/gbufferline.h +++ b/src/glibext/gbufferline.h @@ -2,7 +2,7 @@  /* OpenIDA - Outil d'analyse de fichiers binaires   * gbufferline.h - prototypes pour la représentation de fragments de texte en ligne   * - * Copyright (C) 2010 Cyrille Bagard + * Copyright (C) 2010-2012 Cyrille Bagard   *   *  This file is part of OpenIDA.   * @@ -26,6 +26,7 @@  #include <glib-object.h> +#include <stdbool.h>  #include "gbuffersegment.h" @@ -123,7 +124,7 @@ gint g_buffer_line_get_width(GBufferLine *, BufferLineColumn);  void g_buffer_line_start_merge_at(GBufferLine *, BufferLineColumn);  /* Imprime la ligne de texte représentée. */ -void g_buffer_line_draw(GBufferLine *, GdkDrawable *, GdkGC *, const gint [BLC_COUNT], gint, gint); +void g_buffer_line_draw(GBufferLine *, GdkDrawable *, GdkGC *, const gint [BLC_COUNT], gint, gint, bool, bool); diff --git a/src/glibext/gcodebuffer.c b/src/glibext/gcodebuffer.c index 9f22df7..373f33b 100644 --- a/src/glibext/gcodebuffer.c +++ b/src/glibext/gcodebuffer.c @@ -2,7 +2,7 @@  /* OpenIDA - Outil d'analyse de fichiers binaires   * gcodebuffer.h - prototypes pour l'affichage d'un fragment de code d'assemblage   * - * Copyright (C) 2010 Cyrille Bagard + * Copyright (C) 2010-2012 Cyrille Bagard   *   *  This file is part of OpenIDA.   * @@ -369,6 +369,8 @@ gint g_buffer_view_get_line_height(GBufferView *view)  *  Paramètres  : view   = visualisation à consulter.                          *  *                width  = largeur requise pour une pleine visualisation. [OUT]*  *                height = hauteur requise pour une pleine visualisation. [OUT]* +*                addr   = indique si les positions doivent être affichées.    * +*                code   = indique si le code binaire doit être affiché.       *  *                                                                             *  *  Description : Fournit les dimensions requises par une visualisation.       *  *                                                                             * @@ -378,7 +380,7 @@ gint g_buffer_view_get_line_height(GBufferView *view)  *                                                                             *  ******************************************************************************/ -void g_buffer_view_get_size(GBufferView *view, gint *width, gint *height) +void g_buffer_view_get_size(GBufferView *view, gint *width, gint *height, bool addr, bool code)  {      unsigned int i;                         /* Boucle de parcours          */ @@ -389,8 +391,14 @@ void g_buffer_view_get_size(GBufferView *view, gint *width, gint *height)          g_buffer_view_compute_required_widths(view);      for (i = 0; i < BLC_COUNT; i++) +    { +        if (i == BLC_ADDRESS && !addr) continue; +        if (i == BLC_BINARY && !code) continue; +          *width += view->max_widths[i]; +    } +      *height *= (view->last - view->first);  } @@ -425,6 +433,8 @@ void g_buffer_view_define_extra_drawing(GBufferView *view, buffer_line_draw_fc m  *                gc     = contexte graphique à utiliser pour les pinceaux.    *  *                fake_x = abscisse réelle du point 0 à l'écran.               *  *                fake_y = ordonnée réelle du point 0 à l'écran.               * +*                addr   = indique si les positions doivent être affichées.    * +*                code   = indique si le code binaire doit être affiché.       *  *                                                                             *  *  Description : Imprime la visualisation du tempon de code désassemblé.      *  *                                                                             * @@ -434,7 +444,7 @@ void g_buffer_view_define_extra_drawing(GBufferView *view, buffer_line_draw_fc m  *                                                                             *  ******************************************************************************/ -void g_buffer_view_draw(const GBufferView *view, const GdkEventExpose *event, GdkGC *gc, gint fake_x, gint fake_y) +void g_buffer_view_draw(const GBufferView *view, const GdkEventExpose *event, GdkGC *gc, gint fake_x, gint fake_y, bool addr, bool code)  {      GdkDrawable *drawable;                  /* Surface de dessin           */      gint real_x;                            /* Abscisse réelle pour tampon */ @@ -477,7 +487,7 @@ void g_buffer_view_draw(const GBufferView *view, const GdkEventExpose *event, Gd              if (view->drawing_extra != NULL)                  view->drawing_extra(lines[i], drawable, gc, fake_x, y, view->drawing_data); -            g_buffer_line_draw(lines[i], drawable, gc, view->max_widths, real_x, y); +            g_buffer_line_draw(lines[i], drawable, gc, view->max_widths, real_x, y, addr, code);              y += view->line_height; diff --git a/src/glibext/gcodebuffer.h b/src/glibext/gcodebuffer.h index 49b954d..811a479 100644 --- a/src/glibext/gcodebuffer.h +++ b/src/glibext/gcodebuffer.h @@ -2,7 +2,7 @@  /* OpenIDA - Outil d'analyse de fichiers binaires   * gcodebuffer.h - prototypes pour l'affichage d'un fragment de code d'assemblage   * - * Copyright (C) 2010 Cyrille Bagard + * Copyright (C) 2010-2012 Cyrille Bagard   *   *  This file is part of OpenIDA.   * @@ -89,13 +89,13 @@ GBufferView *g_buffer_view_new(GCodeBuffer *);  gint g_buffer_view_get_line_height(GBufferView *);  /* Fournit les dimensions requises par une visualisation. */ -void g_buffer_view_get_size(GBufferView *, gint *, gint *); +void g_buffer_view_get_size(GBufferView *, gint *, gint *, bool, bool);  /* Définit à une procédure à appeler lors des dessins de ligne. */  void g_buffer_view_define_extra_drawing(GBufferView *, buffer_line_draw_fc, void *);  /* Imprime la visualisation du tempon de code désassemblé. */ -void g_buffer_view_draw(const GBufferView *, const GdkEventExpose *, GdkGC *, gint, gint); +void g_buffer_view_draw(const GBufferView *, const GdkEventExpose *, GdkGC *, gint, gint, bool, bool);  /* Fournit la ligne présente à une ordonnée donnée. */  GBufferLine *g_buffer_view_find_line_at(GBufferView *, gint); diff --git a/src/gtkext/gtkblockview.c b/src/gtkext/gtkblockview.c index 6d828b1..a420194 100644 --- a/src/gtkext/gtkblockview.c +++ b/src/gtkext/gtkblockview.c @@ -2,7 +2,7 @@  /* OpenIDA - Outil d'analyse de fichiers binaires   * gtkblockview.c - affichage d'un fragment de code d'assemblage   * - * Copyright (C) 2008-2010 Cyrille Bagard + * Copyright (C) 2008-2012 Cyrille Bagard   *   *  This file is part of OpenIDA.   * @@ -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 *); +static void gtk_block_view_attach_binary(GtkBlockView *, GOpenidaBinary *, bool *, bool *); @@ -134,6 +134,8 @@ GtkWidget *gtk_block_view_new(void)  *                                                                             *  *  Paramètres  : view   = composant GTK à mettre à jour.                      *  *                binary = binaire associé à intégrer.                         * +*                addr   = indique si les positions doivent être affichées.    * +*                code   = indique si le code binaire doit être affiché.       *  *                                                                             *  *  Description : Prend acte de l'association d'un binaire chargé.             *  *                                                                             * @@ -143,12 +145,12 @@ GtkWidget *gtk_block_view_new(void)  *                                                                             *  ******************************************************************************/ -static void gtk_block_view_attach_binary(GtkBlockView *view, GOpenidaBinary *binary) +static void gtk_block_view_attach_binary(GtkBlockView *view, GOpenidaBinary *binary, bool *addr, bool *code)  {      GCodeBuffer *buffer;                    /* Tampon par défaut           */      buffer = g_openida_binary_get_disassembled_buffer(binary); -    gtk_buffer_view_attach_buffer(GTK_BUFFER_VIEW(view), buffer); +    gtk_buffer_view_attach_buffer(GTK_BUFFER_VIEW(view), buffer, addr, code);  } diff --git a/src/gtkext/gtkbufferview-int.h b/src/gtkext/gtkbufferview-int.h index 936e31d..31b911e 100644 --- a/src/gtkext/gtkbufferview-int.h +++ b/src/gtkext/gtkbufferview-int.h @@ -2,7 +2,7 @@  /* OpenIDA - Outil d'analyse de fichiers binaires   * gtkbufferview.h - prototypes pour l'affichage de tampons de lignes   * - * Copyright (C) 2010 Cyrille Bagard + * Copyright (C) 2010-2012 Cyrille Bagard   *   *  This file is part of OpenIDA.   * @@ -40,6 +40,9 @@ struct _GtkBufferView      GCodeBuffer *buffer;                    /* Code sous forme de texte    */      GBufferView *buffer_view;               /* Affichage de cette forme    */ +    bool *display_addr;                     /* Affichage des adresses ?    */ +    bool *display_code;                     /* Affichage du code binaire ? */ +      gint line_height;                       /* Hauteur maximale des lignes */      gint left_margin;                       /* Marge gauche + espace       */      gint left_text;                         /* Début d'impression du code  */ diff --git a/src/gtkext/gtkbufferview.c b/src/gtkext/gtkbufferview.c index 796a001..6a2e93d 100644 --- a/src/gtkext/gtkbufferview.c +++ b/src/gtkext/gtkbufferview.c @@ -174,9 +174,14 @@ static void gtk_buffer_view_compute_real_coord(GtkBufferView *view, gint *x, gin  static void gtk_buffer_view_size_request(GtkWidget *widget, GtkRequisition *requisition)  { -    if (GTK_BUFFER_VIEW(widget)->buffer_view != NULL) -        g_buffer_view_get_size(GTK_BUFFER_VIEW(widget)->buffer_view, -                               &requisition->width, &requisition->height); +    GtkBufferView *view;                    /* Autre version du composant  */ + +    view = GTK_BUFFER_VIEW(widget); + +    if (view->buffer_view != NULL) +        g_buffer_view_get_size(view->buffer_view, +                               &requisition->width, &requisition->height, +                               *view->display_addr, *view->display_code);  } @@ -197,6 +202,7 @@ static void gtk_buffer_view_size_request(GtkWidget *widget, GtkRequisition *requ  static void gtk_buffer_view_size_allocate(GtkWidget *widget, GtkAllocation *allocation)  {      GtkViewPanel *panel;                    /* Autre version du composant  */ +    GtkBufferView *view;                    /* Encore une autre version    */      gint width;                             /* Largeur de l'objet actuelle */      gint height;                            /* Hauteur de l'objet actuelle */      GtkAllocation valloc;                   /* Surface utilisable          */ @@ -216,7 +222,10 @@ static void gtk_buffer_view_size_allocate(GtkWidget *widget, GtkAllocation *allo      if (panel->hadjustment == NULL || panel->vadjustment == NULL)          return; -    g_buffer_view_get_size(GTK_BUFFER_VIEW(widget)->buffer_view, &width, &height); +    view = GTK_BUFFER_VIEW(widget); + +    g_buffer_view_get_size(view->buffer_view, &width, &height, +                           *view->display_addr, *view->display_code);      gtk_view_panel_compute_allocation(panel, &valloc); @@ -238,7 +247,7 @@ static void gtk_buffer_view_size_allocate(GtkWidget *widget, GtkAllocation *allo      /* Défilement vertical */      panel->vadjustment->page_size = valloc.height; -    panel->vadjustment->step_increment = GTK_BUFFER_VIEW(widget)->line_height; +    panel->vadjustment->step_increment = view->line_height;      panel->vadjustment->page_increment = panel->vadjustment->step_increment * 10.0;      panel->vadjustment->upper = MAX(height, valloc.height); @@ -314,7 +323,8 @@ static gboolean gtk_buffer_view_expose(GtkWidget *widget, GdkEventExpose *event)      /* Impression du désassemblage */      if (view->buffer_view != NULL) -        g_buffer_view_draw(view->buffer_view, event, pview->gc, fake_x, fake_y); +        g_buffer_view_draw(view->buffer_view, event, pview->gc, fake_x, fake_y, +                           *view->display_addr, *view->display_code);      gdk_window_end_paint(drawable); @@ -346,6 +356,8 @@ static void gtk_buffer_view_scroll(GtkBufferView *view)  *                                                                             *  *  Paramètres  : view   = composant GTK à mettre à jour.                      *  *                buffer = tampon de lignes à encadrer.                        * +*                addr   = indique si les positions doivent être affichées.    * +*                code   = indique si le code binaire doit être affiché.       *  *                                                                             *  *  Description : Prend acte de l'association d'un tampon de lignes.           *  *                                                                             * @@ -355,7 +367,7 @@ static void gtk_buffer_view_scroll(GtkBufferView *view)  *                                                                             *  ******************************************************************************/ -void gtk_buffer_view_attach_buffer(GtkBufferView *view, GCodeBuffer *buffer) +void gtk_buffer_view_attach_buffer(GtkBufferView *view, GCodeBuffer *buffer, bool *addr, bool *code)  {      gint width;                             /* Largeur de l'objet actuelle */      gint height;                            /* Hauteur de l'objet actuelle */ @@ -371,6 +383,9 @@ void gtk_buffer_view_attach_buffer(GtkBufferView *view, GCodeBuffer *buffer)      view->buffer_view = g_buffer_view_new(view->buffer); +    view->display_addr = addr; +    view->display_code = code; +      //gdk_threads_enter();      /* Taille des marges */ @@ -381,7 +396,7 @@ void gtk_buffer_view_attach_buffer(GtkBufferView *view, GCodeBuffer *buffer)      /* Validation finale */ -    g_buffer_view_get_size(view->buffer_view, &width, &height); +    g_buffer_view_get_size(view->buffer_view, &width, &height, *addr, *code);      width += -view->left_text + 1;      height += 1; diff --git a/src/gtkext/gtkbufferview.h b/src/gtkext/gtkbufferview.h index ab7a746..da04533 100644 --- a/src/gtkext/gtkbufferview.h +++ b/src/gtkext/gtkbufferview.h @@ -2,7 +2,7 @@  /* OpenIDA - Outil d'analyse de fichiers binaires   * gtkbufferview.h - prototypes pour l'affichage de tampons de lignes   * - * Copyright (C) 2010 Cyrille Bagard + * Copyright (C) 2010-2012 Cyrille Bagard   *   *  This file is part of OpenIDA.   * @@ -52,7 +52,7 @@ typedef struct _GtkBufferViewClass GtkBufferViewClass;  GType gtk_buffer_view_get_type(void);  /* Prend acte de l'association d'un tampon de lignes. */ -void gtk_buffer_view_attach_buffer(GtkBufferView *, GCodeBuffer *); +void gtk_buffer_view_attach_buffer(GtkBufferView *, GCodeBuffer *, bool *, bool *); diff --git a/src/gtkext/gtksourceview.c b/src/gtkext/gtksourceview.c index 026c851..2e5ed48 100644 --- a/src/gtkext/gtksourceview.c +++ b/src/gtkext/gtksourceview.c @@ -2,7 +2,7 @@  /* OpenIDA - Outil d'analyse de fichiers binaires   * gtksourceview.c - affichage de code source   * - * Copyright (C) 2010-2011 Cyrille Bagard + * Copyright (C) 2010-2012 Cyrille Bagard   *   *  This file is part of OpenIDA.   * @@ -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 *); +static void gtk_source_view_attach_binary(GtkSourceView *, GOpenidaBinary *, bool *, bool *); @@ -134,6 +134,8 @@ GtkWidget *gtk_source_view_new(void)  *                                                                             *  *  Paramètres  : view   = composant GTK à mettre à jour.                      *  *                binary = binaire associé à intégrer.                         * +*                addr   = indique si les positions doivent être affichées.    * +*                code   = indique si le code binaire doit être affiché.       *  *                                                                             *  *  Description : Prend acte de l'association d'un binaire chargé.             *  *                                                                             * @@ -143,7 +145,7 @@ GtkWidget *gtk_source_view_new(void)  *                                                                             *  ******************************************************************************/ -static void gtk_source_view_attach_binary(GtkSourceView *view, GOpenidaBinary *binary) +static void gtk_source_view_attach_binary(GtkSourceView *view, GOpenidaBinary *binary, bool *addr, bool *code)  {      GCodeBuffer *buffer;                    /* Tampon par défaut           */ @@ -152,6 +154,6 @@ static void gtk_source_view_attach_binary(GtkSourceView *view, GOpenidaBinary *b      /* FIXME */      if (buffer != NULL) -    gtk_buffer_view_attach_buffer(GTK_BUFFER_VIEW(view), buffer); +    gtk_buffer_view_attach_buffer(GTK_BUFFER_VIEW(view), buffer, addr, code);  } diff --git a/src/gtkext/gtkviewpanel-int.h b/src/gtkext/gtkviewpanel-int.h index 7480807..6ef3567 100644 --- a/src/gtkext/gtkviewpanel-int.h +++ b/src/gtkext/gtkviewpanel-int.h @@ -2,7 +2,7 @@  /* OpenIDA - Outil d'analyse de fichiers binaires   * gtkviewpanel-int.h - définitions internes propre à l'affichage de contenu de binaire   * - * Copyright (C) 2010 Cyrille Bagard + * Copyright (C) 2010-2012 Cyrille Bagard   *   *  This file is part of OpenIDA.   * @@ -34,7 +34,7 @@  /* Prend acte de l'association d'un binaire chargé. */ -typedef void (* attach_binary_fc) (GtkViewPanel *, GOpenidaBinary *); +typedef void (* attach_binary_fc) (GtkViewPanel *, GOpenidaBinary *, bool *, bool *);  /* Réagit à un défilement quelconque. */  typedef void (* scroll_fc) (GtkViewPanel *); diff --git a/src/gtkext/gtkviewpanel.c b/src/gtkext/gtkviewpanel.c index 03279b2..7ffeccc 100644 --- a/src/gtkext/gtkviewpanel.c +++ b/src/gtkext/gtkviewpanel.c @@ -2,7 +2,7 @@  /* OpenIDA - Outil d'analyse de fichiers binaires   * gtkviewpanel.c - affichage de contenu de binaire   * - * Copyright (C) 2010 Cyrille Bagard + * Copyright (C) 2010-2012 Cyrille Bagard   *   *  This file is part of OpenIDA.   * @@ -323,6 +323,8 @@ static gboolean gtk_view_panel_expose(GtkWidget *widget, GdkEventExpose *event)  *                                                                             *  *  Paramètres  : panel  = composant GTK à mettre à jour.                      *  *                binary = binaire associé à intégrer.                         * +*                addr   = indique si les positions doivent être affichées.    * +*                code   = indique si le code binaire doit être affiché.       *  *                                                                             *  *  Description : Associe à un panneau d'affichage un binaire chargé.          *  *                                                                             * @@ -332,12 +334,12 @@ static gboolean gtk_view_panel_expose(GtkWidget *widget, GdkEventExpose *event)  *                                                                             *  ******************************************************************************/ -void gtk_view_panel_attach_binary(GtkViewPanel *panel, GOpenidaBinary *binary) +void gtk_view_panel_attach_binary(GtkViewPanel *panel, GOpenidaBinary *binary, bool *addr, bool *code)  {      g_object_ref(G_OBJECT(binary));      panel->binary = binary; -    panel->attach(panel, binary); +    panel->attach(panel, binary, addr, code);  } diff --git a/src/gtkext/gtkviewpanel.h b/src/gtkext/gtkviewpanel.h index ad6cc46..d2b69af 100644 --- a/src/gtkext/gtkviewpanel.h +++ b/src/gtkext/gtkviewpanel.h @@ -2,7 +2,7 @@  /* OpenIDA - Outil d'analyse de fichiers binaires   * gtkviewpanel.h - prototypes pour l'affichage de contenu de binaire   * - * Copyright (C) 2010 Cyrille Bagard + * Copyright (C) 2010-2012 Cyrille Bagard   *   *  This file is part of OpenIDA.   * @@ -51,7 +51,7 @@ typedef struct _GtkViewPanelClass GtkViewPanelClass;  GType gtk_view_panel_get_type(void);  /* Associe à un panneau d'affichage un binaire chargé. */ -void gtk_view_panel_attach_binary(GtkViewPanel *, GOpenidaBinary *); +void gtk_view_panel_attach_binary(GtkViewPanel *, GOpenidaBinary *, bool *, bool *);  /* Fournit le binaire associé à la représentation. */  GOpenidaBinary *gtk_view_panel_get_binary(const GtkViewPanel *); diff --git a/src/gui/menus/Makefile.am b/src/gui/menus/Makefile.am index 67d65b6..1275394 100644 --- a/src/gui/menus/Makefile.am +++ b/src/gui/menus/Makefile.am @@ -5,7 +5,8 @@ libguimenus_la_SOURCES =				\  	debug.h debug.c						\  	file.h file.c						\  	help.h help.c						\ -	menubar.h menubar.c +	menubar.h menubar.c					\ +	view.h view.c  libguimenus_la_LDFLAGS =  diff --git a/src/gui/menus/menubar.c b/src/gui/menus/menubar.c index e6c9007..62a3cbe 100644 --- a/src/gui/menus/menubar.c +++ b/src/gui/menus/menubar.c @@ -2,7 +2,7 @@  /* OpenIDA - Outil d'analyse de fichiers binaires   * menubar.c - gestion des différents menus de la fenêtre principale   * - * Copyright (C) 2011 Cyrille Bagard + * Copyright (C) 2011-2012 Cyrille Bagard   *   *  This file is part of OpenIDA.   * @@ -28,6 +28,7 @@  #include "debug.h"  #include "file.h"  #include "help.h" +#include "view.h"  #include "../editem-int.h" @@ -137,6 +138,11 @@ GEditorItem *g_menu_bar_new(GObject *ref, GtkAccelGroup *accgroup)      menuitem = build_menu_file(ref, accgroup);      gtk_container_add(GTK_CONTAINER(item->widget), menuitem); +    /* Affichage */ + +    menuitem = build_menu_view(ref, accgroup); +    gtk_container_add(GTK_CONTAINER(item->widget), menuitem); +      /* Débogage */      menuitem = build_menu_debug(ref, accgroup); diff --git a/src/gui/menus/view.c b/src/gui/menus/view.c new file mode 100644 index 0000000..d68ffa4 --- /dev/null +++ b/src/gui/menus/view.c @@ -0,0 +1,142 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * view.c - gestion du menu 'Affichage' + * + * Copyright (C) 2012 Cyrille Bagard + * + *  This view 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 "view.h" + + +#include <i18n.h> + + +#include "../../gtkext/easygtk.h" + + + +/* Réagit avec le menu "Affichage -> Adresse virtuelle". */ +void mcb_view_vaddress(GtkCheckMenuItem *, gpointer); + +/* Réagit avec le menu "Affichage -> code binaire". */ +void mcb_view_code(GtkCheckMenuItem *, gpointer); + + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : ref      = espace de référencement global.                   * +*                accgroup = groupe d'accélérateurs pour les menus.            * +*                                                                             * +*  Description : Construit le menu "Fichier".                                 * +*                                                                             * +*  Retour      : Panneau de menus mis en place.                               * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GtkWidget *build_menu_view(GObject *ref, GtkAccelGroup *accgroup) +{ +    GtkWidget *result;                      /* Support à retourner         */ +    GtkWidget *menubar;                     /* Support pour éléments       */ +    GtkWidget *submenuitem;                 /* Sous-élément de menu        */ + +    result = gtk_menu_item_new_with_mnemonic(_("_View")); +    gtk_widget_show(result); + +    menubar = gtk_menu_new(); +    gtk_menu_item_set_submenu(GTK_MENU_ITEM(result), menubar); + +    submenuitem = qck_create_menu_separator(); +    gtk_container_add(GTK_CONTAINER(menubar), submenuitem); + +    submenuitem = qck_create_check_menu_item(NULL, NULL, _("Virtual address"), G_CALLBACK(mcb_view_vaddress), result); +    gtk_container_add(GTK_CONTAINER(menubar), submenuitem); + +    submenuitem = qck_create_check_menu_item(NULL, NULL, _("Binary code"), G_CALLBACK(mcb_view_code), result); +    gtk_container_add(GTK_CONTAINER(menubar), submenuitem); + +    submenuitem = qck_create_menu_separator(); +    gtk_container_add(GTK_CONTAINER(menubar), submenuitem); + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  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 "Affichage -> Adresse virtuelle".        * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +void mcb_view_vaddress(GtkCheckMenuItem *menuitem, gpointer data) +{ +#if 0 +    GtkBinView *binview;                  /* Zone de code principale     */ +    gboolean active;                        /* Etat de sélection du menu   */ + +    /* FIXME : "binview" -> "current_view" */ +    return; + +    binview = GTK_BIN_VIEW(g_object_get_data(G_OBJECT(data), "binview")); +    active = gtk_check_menu_item_get_active(menuitem); + +    gtk_binview_show_vaddress(binview, active); +#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 "Affichage -> code binaire".             * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +void mcb_view_code(GtkCheckMenuItem *menuitem, gpointer data) +{ +#if 0 +    GtkBinView *binview;                  /* Zone de code principale     */ +    gboolean active;                        /* Etat de sélection du menu   */ + +    /* FIXME : "binview" -> "current_view" */ +    return; + +    binview = GTK_BIN_VIEW(g_object_get_data(G_OBJECT(data), "binview")); +    active = gtk_check_menu_item_get_active(menuitem); + +    gtk_binview_show_code(binview, active); +#endif +} diff --git a/src/gui/menus/view.h b/src/gui/menus/view.h new file mode 100644 index 0000000..4da6a11 --- /dev/null +++ b/src/gui/menus/view.h @@ -0,0 +1,38 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * view.h - prototypes pour la gestion du menu 'Affichage' + * + * 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 this program; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA + */ + + +#ifndef _GUI_MENUS_VIEW_H +#define _GUI_MENUS_VIEW_H + + +#include <gtk/gtk.h> + + + +/* Construit le menu "Fichier". */ +GtkWidget *build_menu_view(GObject *, GtkAccelGroup *); + + + +#endif  /* _GUI_MENUS_VIEW_H */ diff --git a/src/gui/tb/source.c b/src/gui/tb/source.c index 8750608..16f237a 100644 --- a/src/gui/tb/source.c +++ b/src/gui/tb/source.c @@ -2,7 +2,7 @@  /* OpenIDA - Outil d'analyse de fichiers binaires   * source.c - sélection du fichier ciblé lors d'une décompilation   * - * Copyright (C) 2010 Cyrille Bagard + * Copyright (C) 2010-2012 Cyrille Bagard   *   *  This file is part of OpenIDA.   * @@ -222,6 +222,7 @@ static void change_selected_source(GtkComboBox *widget, GObject *ref)      view = GTK_BUFFER_VIEW(g_object_get_data(ref, "current_view"));      if (GTK_IS_BUFFER_VIEW(view)) -        gtk_buffer_view_attach_buffer(view, buffer); +        gtk_buffer_view_attach_buffer(view, buffer, +                                      g_openida_binary_display_decomp_lines(binary), NULL);  } diff --git a/src/project.c b/src/project.c index 652721b..f4f5b1b 100644 --- a/src/project.c +++ b/src/project.c @@ -145,7 +145,9 @@ static loaded_binary *load_openida_binary(GOpenidaBinary *binary)          gdk_flush();          gdk_threads_leave(); -        gtk_view_panel_attach_binary(GTK_VIEW_PANEL(view), binary); +        gtk_view_panel_attach_binary(GTK_VIEW_PANEL(view), binary, +                                     g_openida_binary_display_addresses_in_text(binary), +                                     g_openida_binary_display_code_in_text(binary));          /* Intégration finale */ | 
