diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2014-09-16 20:08:57 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2014-09-16 20:08:57 (GMT) | 
| commit | af083f8bd6da340214ae392451dde5782fb79039 (patch) | |
| tree | ffc45880157f4fdd986b1e16aa6498bef149185a /src/glibext | |
| parent | 74642fbdeefaec21885e5fb6cad432e3e3b47cdb (diff) | |
Used the new vmpa_t type in binary portions.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@405 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/glibext')
| -rw-r--r-- | src/glibext/gbinportion.c | 47 | ||||
| -rw-r--r-- | src/glibext/gbinportion.h | 10 | 
2 files changed, 27 insertions, 30 deletions
| diff --git a/src/glibext/gbinportion.c b/src/glibext/gbinportion.c index 41778ba..76926ca 100644 --- a/src/glibext/gbinportion.c +++ b/src/glibext/gbinportion.c @@ -50,9 +50,8 @@ struct _GBinPortion      char *desc;                             /* Désignation humaine         */ -    off_t offset;                           /* Position physique           */ +    vmpa2t addr;                            /* Emplacement dans le code    */      off_t size;                             /* Taille de la partie         */ -    vmpa_t addr;                            /* Adresse associée            */      PortionAccessRights rights;             /* Droits d'accès              */ @@ -263,9 +262,8 @@ const char *g_binary_portion_get_desc(const GBinPortion *portion)  /******************************************************************************  *                                                                             *  *  Paramètres  : portion = description de partie à mettre à jour.             * -*                offset  = position de la section à conserver.                * +*                addr    = emplacement de la section à conserver.             *  *                size    = taille de la section à conserver.                  * -*                addr    = adresse de la section à conserver.                 *  *                                                                             *  *  Description : Définit les valeurs utiles d'une partie de code.             *  *                                                                             * @@ -275,11 +273,10 @@ const char *g_binary_portion_get_desc(const GBinPortion *portion)  *                                                                             *  ******************************************************************************/ -void g_binary_portion_set_values(GBinPortion *portion, off_t offset, off_t size, vmpa_t addr) +void g_binary_portion_set_values(GBinPortion *portion, const vmpa2t *addr, off_t size)  { -    portion->offset = offset; +    copy_vmpa(&portion->addr, addr);      portion->size = size; -    portion->addr = addr;  } @@ -369,7 +366,7 @@ static bool g_binary_portion_compute_sub_area(GBinPortion *portion, GBinPortion      sub_area->y = area->y;      sub_area->height = area->height; -    sub_area->x = area->x + (sub->offset * area->width) / portion->size; +    sub_area->x = area->x + (get_phy_addr(&sub->addr) * area->width) / portion->size;      sub_area->width = (sub->size * area->width) / portion->size;      return true; @@ -438,7 +435,7 @@ GBinPortion *g_binary_portion_find_at_pos(GBinPortion *portion, gint x, GdkRecta  *                                                                             *  ******************************************************************************/ -GBinPortion *g_binary_portion_find_at_addr(GBinPortion *portion, vmpa_t addr, GdkRectangle *area) +GBinPortion *g_binary_portion_find_at_addr(GBinPortion *portion, const vmpa2t *addr, GdkRectangle *area)  {      GBinPortion *result;                    /* Portion à retourner         */      size_t i;                               /* Boucle de parcours #1       */ @@ -452,11 +449,14 @@ GBinPortion *g_binary_portion_find_at_addr(GBinPortion *portion, vmpa_t addr, Gd      {          sub = portion->sub_portions[i]; +        /* FIXME : cmp ? */ +          /* Portion non allouée en mémoire -> adresse nulle ; on écarte */ -        if (sub->addr == 0) +        if (get_virt_addr(&sub->addr) == 0)              continue; -        if (addr < sub->addr || addr >= (sub->addr + sub->size)) +        if (get_virt_addr(addr) < get_virt_addr(&sub->addr) +            || get_virt_addr(addr) >= (get_virt_addr(&sub->addr) + sub->size))              continue;          if (!g_binary_portion_compute_sub_area(portion, sub, area, &sub_area)) @@ -496,7 +496,7 @@ GBinPortion *g_binary_portion_find_at_addr(GBinPortion *portion, vmpa_t addr, Gd  *                                                                             *  ******************************************************************************/ -bool g_binary_portion_get_addr_from_pos(GBinPortion *portion, gint x, const GdkRectangle *area, vmpa_t *addr) +bool g_binary_portion_get_addr_from_pos(GBinPortion *portion, gint x, const GdkRectangle *area, vmpa2t *addr)  {      GdkRectangle owner_area;                /* Aire de contenance          */      GBinPortion *owner;                     /* Conteneur propriétaire      */ @@ -506,7 +506,9 @@ bool g_binary_portion_get_addr_from_pos(GBinPortion *portion, gint x, const GdkR      owner = g_binary_portion_find_at_pos(portion, x, &owner_area);      if (owner == NULL) return false; -    *addr = owner->addr + (owner->size * (x - owner_area.x)) / owner_area.width; +    copy_vmpa(addr, &owner->addr); + +    advance_vmpa(addr, (owner->size * (x - owner_area.x)) / owner_area.width);      return true; @@ -528,18 +530,18 @@ bool g_binary_portion_get_addr_from_pos(GBinPortion *portion, gint x, const GdkR  *                                                                             *  ******************************************************************************/ -bool g_binary_portion_get_pos_from_addr(GBinPortion *portion, vmpa_t addr, const GdkRectangle *area, gint *x) +bool g_binary_portion_get_pos_from_addr(GBinPortion *portion, const vmpa2t *addr, const GdkRectangle *area, gint *x)  {      GdkRectangle owner_area;                /* Aire de contenance          */      GBinPortion *owner;                     /* Conteneur propriétaire      */ -    vmpa_t diff;                            /* Décallage à appliquer       */ +    off_t diff;                            /* Décallage à appliquer       */      owner_area = *area;      owner = g_binary_portion_find_at_addr(portion, addr, &owner_area);      if (owner == NULL) return false; -    diff = addr - owner->addr; +    diff = compute_vmpa_diff(addr, &owner->addr);      *x = owner_area.x + (diff * owner_area.width) / owner->size; @@ -605,19 +607,21 @@ gboolean g_binary_portion_query_tooltip(GBinPortion *portion, gint x, gint y, co      markup = stradd(markup, "</b>\n");      markup = stradd(markup, _("physical: from ")); -    snprintf(value, 2 * VMPA_MAX_SIZE, OFF_FMT, OFF_CAST(selected->offset)); +    snprintf(value, 2 * VMPA_MAX_SIZE, OFF_FMT, OFF_CAST(get_phy_addr(&selected->addr)));      markup = stradd(markup, value);      markup = stradd(markup, _(" to ")); -    snprintf(value, 2 * VMPA_MAX_SIZE, OFF_FMT, OFF_CAST(selected->offset + selected->size)); +    snprintf(value, 2 * VMPA_MAX_SIZE, OFF_FMT, OFF_CAST(get_phy_addr(&selected->addr) + selected->size));      markup = stradd(markup, value);      markup = stradd(markup, "\n");      markup = stradd(markup, _("memory: from ")); +#if 0      snprintf(value, 2 * VMPA_MAX_SIZE, VMPA_FMT_LONG, VMPA_CAST(selected->addr));      markup = stradd(markup, value);      markup = stradd(markup, _(" to "));      snprintf(value, 2 * VMPA_MAX_SIZE, VMPA_FMT_LONG, VMPA_CAST(selected->addr + selected->size));      markup = stradd(markup, value); +#endif      markup = stradd(markup, "\n\n");      /* Droits d'accès */ @@ -643,13 +647,6 @@ gboolean g_binary_portion_query_tooltip(GBinPortion *portion, gint x, gint y, co  } - - -extern GtkCssProvider *__provider;               /* Fournisseur par défaut      */ - - - -  /******************************************************************************  *                                                                             *  *  Paramètres  : portion = description de partie à consulter.                 * diff --git a/src/glibext/gbinportion.h b/src/glibext/gbinportion.h index fd1336b..fb32496 100644 --- a/src/glibext/gbinportion.h +++ b/src/glibext/gbinportion.h @@ -30,7 +30,7 @@  #include <gtk/gtk.h> -#include "../arch/archbase.h" +#include "../arch/vmpa.h"  #include "../common/fnv1a.h" @@ -85,7 +85,7 @@ void g_binary_portion_set_desc(GBinPortion *, const char *);  const char *g_binary_portion_get_desc(const GBinPortion *);  /* Définit les valeurs utiles d'une partie de code. */ -void g_binary_portion_set_values(GBinPortion *, off_t, off_t, vmpa_t); +void g_binary_portion_set_values(GBinPortion *, const vmpa2t *, off_t);  /* Définit les droits associés à une partie de code. */  void g_binary_portion_set_rights(GBinPortion *, PortionAccessRights); @@ -100,13 +100,13 @@ void g_binary_portion_include(GBinPortion *, GBinPortion *);  GBinPortion *g_binary_portion_find_at_pos(GBinPortion *, gint, GdkRectangle *);  /* Recherche la portion présente à une adresse donnée. */ -GBinPortion *g_binary_portion_find_at_addr(GBinPortion *, vmpa_t, GdkRectangle *); +GBinPortion *g_binary_portion_find_at_addr(GBinPortion *, const vmpa2t *, GdkRectangle *);  /* Fournit la position correspondant à une adresse donnée. */ -bool g_binary_portion_get_addr_from_pos(GBinPortion *, gint, const GdkRectangle *, vmpa_t *); +bool g_binary_portion_get_addr_from_pos(GBinPortion *, gint, const GdkRectangle *, vmpa2t *);  /* Fournit l'adresse correspondant à une position donnée. */ -bool g_binary_portion_get_pos_from_addr(GBinPortion *, vmpa_t, const GdkRectangle *, gint *); +bool g_binary_portion_get_pos_from_addr(GBinPortion *, const vmpa2t *, const GdkRectangle *, gint *);  /* Prépare une astuce concernant une portion pour son affichage. */  gboolean g_binary_portion_query_tooltip(GBinPortion *, gint, gint, const GdkRectangle *, GtkTooltip *); | 
