diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2015-12-28 23:27:12 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2015-12-28 23:27:12 (GMT) | 
| commit | b57e8ef5522dcbe126157fc2c50fcf879aa7d743 (patch) | |
| tree | 1ecfd9de39073fee3a2c1a4afa9ce5da574b26df /src/gtkext | |
| parent | 276b75e6e9ff99a930bd36045e55b1117bb29579 (diff) | |
Defined layers to register all kinds of binary portions.
Diffstat (limited to 'src/gtkext')
| -rw-r--r-- | src/gtkext/gtkbinarystrip.c | 39 | ||||
| -rw-r--r-- | src/gtkext/gtkstatusstack.c | 8 | 
2 files changed, 27 insertions, 20 deletions
| diff --git a/src/gtkext/gtkbinarystrip.c b/src/gtkext/gtkbinarystrip.c index e0016d2..0ad0763 100644 --- a/src/gtkext/gtkbinarystrip.c +++ b/src/gtkext/gtkbinarystrip.c @@ -211,7 +211,7 @@ static void gtk_binary_strip_size_allocate(GtkWidget *widget, GtkAllocation *all  {      GtkBinaryStrip *strip;                  /* Autre version du composant  */      GExeFormat *format;                     /* Format du binaire           */ -    GBinPortion *portions;                  /* Portions binaires à dessiner*/ +    GPortionLayer *layer;                   /* Couche première de portions */      GdkRectangle area;                      /* Surface du composant        */      GTK_WIDGET_CLASS(gtk_binary_strip_parent_class)->size_allocate(widget, allocation); @@ -222,16 +222,18 @@ static void gtk_binary_strip_size_allocate(GtkWidget *widget, GtkAllocation *all          return;      format = g_loaded_binary_get_format(strip->binary); -    portions = g_exe_format_get_portions(format); +    layer = g_exe_format_get_main_layer(format);      area.x = 0;      area.y = 0;      area.width = allocation->width;      area.height = allocation->height; -    if (!g_binary_portion_get_pos_from_addr(portions, &strip->cursor_addr, &area, &strip->cursor_pos)) +    if (!g_portion_layer_get_pos_from_addr(layer, &strip->cursor_addr, &area, &strip->cursor_pos))          strip->cursor_pos = 0; +    g_object_unref(G_OBJECT(layer)); +  } @@ -254,7 +256,7 @@ static gboolean gtk_binary_strip_button_release(GtkWidget *widget, GdkEventButto      gint height;                            /* Hauteur du composant        */      GtkBinaryStrip *strip;                  /* Autre version du composant  */      GExeFormat *format;                     /* Format du binaire           */ -    GBinPortion *portions;                  /* Portions binaires à dessiner*/ +    GPortionLayer *layer;                   /* Couche première de portions */      GdkRectangle area;                      /* Surface du composant        */      vmpa2t addr;                            /* Adresse à sélectionner      */ @@ -269,27 +271,26 @@ static gboolean gtk_binary_strip_button_release(GtkWidget *widget, GdkEventButto      strip = GTK_BINARY_STRIP(widget);      format = g_loaded_binary_get_format(strip->binary); -    portions = g_exe_format_get_portions(format); +    layer = g_exe_format_get_main_layer(format);      area.x = 0;      area.y = 0;      area.width = width;      area.height = height; -    if (g_binary_portion_get_addr_from_pos(portions, event->x, &area, &addr)) +    if (g_portion_layer_get_addr_from_pos(layer, event->x, &area, &addr))      {          copy_vmpa(&strip->cursor_addr, &addr);          strip->cursor_pos = event->x;          gtk_widget_queue_draw(GTK_WIDGET(strip)); -        printf("got :: %p\n", &addr); -        printf("  -> 0x%x 0x%x\n", (unsigned int)get_phy_addr(&addr), (unsigned int)get_virt_addr(&addr)); -          g_signal_emit_by_name(strip, "select-address");      } +    g_object_unref(G_OBJECT(layer)); +      return FALSE;  } @@ -312,7 +313,7 @@ static gboolean gtk_binary_strip_draw(GtkWidget *widget, cairo_t *cr)  {      GtkBinaryStrip *strip;                  /* Autre vision du composant   */      GExeFormat *format;                     /* Format du binaire           */ -    GBinPortion *portions;                  /* Portions binaires à dessiner*/ +    GPortionLayer *layer;                   /* Couche première de portions */      GdkRectangle full;                      /* Taille totale de la surface */      GtkStyleContext *context;               /* Contexte du thème actuel    */      GdkRGBA *color;                         /* Couleur du curseur          */ @@ -322,11 +323,11 @@ static gboolean gtk_binary_strip_draw(GtkWidget *widget, cairo_t *cr)      if (strip->binary == NULL)          return FALSE; -    format = g_loaded_binary_get_format(strip->binary); -    portions = g_exe_format_get_portions(format); -      /* Dessin des portions de binaire */ +    format = g_loaded_binary_get_format(strip->binary); +    layer = g_exe_format_get_main_layer(format); +      full.x = 0;      full.y = 1;      full.width = gtk_widget_get_allocated_width(widget); @@ -334,7 +335,9 @@ static gboolean gtk_binary_strip_draw(GtkWidget *widget, cairo_t *cr)      context = gtk_widget_get_style_context(widget); -    g_binary_portion_draw(portions, context, cr, &full); +    g_portion_layer_draw(layer, context, cr, &full); + +    g_object_unref(G_OBJECT(layer));      /* Dessin de la position */ @@ -389,7 +392,7 @@ static gboolean gtk_binary_strip_query_tooltip(GtkWidget *widget, gint x, gint y      gboolean result;                        /* Bilan à retourner           */      GtkBinaryStrip *strip;                  /* Autre version du composant  */      GExeFormat *format;                     /* Format du binaire           */ -    GBinPortion *portions;                  /* Portions binaires à dessiner*/ +    GPortionLayer *layer;                   /* Couches binaires à consulter*/      GdkRectangle area;                      /* Surface du composant        */      if (keyboard) return FALSE; @@ -399,14 +402,16 @@ static gboolean gtk_binary_strip_query_tooltip(GtkWidget *widget, gint x, gint y      if (strip->binary != NULL)      {          format = g_loaded_binary_get_format(strip->binary); -        portions = g_exe_format_get_portions(format); +        layer = g_exe_format_get_main_layer(format);          area.x = 0;          area.y = 0;          area.width = gtk_widget_get_allocated_width(widget);          area.height = gtk_widget_get_allocated_height(widget); -        result = g_binary_portion_query_tooltip(portions, x, y, &area, tooltip); +        result = g_portion_layer_query_tooltip(layer, x, y, &area, tooltip); + +        g_object_unref(G_OBJECT(layer));      }      else result = FALSE; diff --git a/src/gtkext/gtkstatusstack.c b/src/gtkext/gtkstatusstack.c index e9a61d8..148dd03 100644 --- a/src/gtkext/gtkstatusstack.c +++ b/src/gtkext/gtkstatusstack.c @@ -462,7 +462,7 @@ void gtk_status_stack_update_current_instruction(GtkStatusStack *stack, const GL      GExeFormat *format;                     /* Format de binaire à traiter */      const mrange_t *range;                  /* Emplacement d'instruction   */      const vmpa2t *addr;                     /* Localisation de départ      */ -    GBinPortion *portions;                  /* Portions binaires existantes*/ +    GPortionLayer *layer;                   /* Couche première de portions */      GBinPortion *portion;                   /* Zone mémoire d'appartenance */      const char *text;                       /* Texte au contenu à copier   */      GBinSymbol *symbol;                     /* Symbole présent à l'adresse */ @@ -491,9 +491,9 @@ void gtk_status_stack_update_current_instruction(GtkStatusStack *stack, const GL      /* Zone d'appartenance */ -    portions = g_exe_format_get_portions(format); +    layer = g_exe_format_get_main_layer(format); -    portion = g_binary_portion_find_at_addr(portions, addr, (GdkRectangle []) { }); +    portion = g_portion_layer_find_portion_at_addr(layer, addr, (GdkRectangle []) { });      text = g_binary_portion_get_desc(portion); @@ -502,6 +502,8 @@ void gtk_status_stack_update_current_instruction(GtkStatusStack *stack, const GL      else          info->segment = strdup(_("Binary")); +    g_object_unref(G_OBJECT(layer)); +      /* Adresses de base */      vmpa2_phys_to_string(addr, MDS_UNDEFINED, info->phys, NULL); | 
