summaryrefslogtreecommitdiff
path: root/src/glibext/gbinportion.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/glibext/gbinportion.c')
-rw-r--r--src/glibext/gbinportion.c113
1 files changed, 109 insertions, 4 deletions
diff --git a/src/glibext/gbinportion.c b/src/glibext/gbinportion.c
index 884c31d..12e12fb 100644
--- a/src/glibext/gbinportion.c
+++ b/src/glibext/gbinportion.c
@@ -38,9 +38,9 @@
#include "../analysis/human/asm/lang.h"
#include "../common/extstr.h"
#include "../common/sort.h"
+#include "../core/columns.h"
#include "../glibext/gbinarycursor.h"
#include "../glibext/linegen-int.h"
-#include "../gtkext/gtkblockdisplay.h"
@@ -62,9 +62,13 @@ static void g_binary_portion_dispose(GBinPortion *);
/* Procède à la libération totale de la mémoire. */
static void g_binary_portion_finalize(GBinPortion *);
+#ifdef INCLUDE_GTK_SUPPORT
+
/* Détermine l'aire d'une sous-portion. */
static bool g_binary_portion_compute_sub_area(const GBinPortion *, phys_t, const GdkRectangle *, GdkRectangle *);
+#endif
+
/* ------------------------ OFFRE DE CAPACITES DE GENERATION ------------------------ */
@@ -73,12 +77,16 @@ static bool g_binary_portion_compute_sub_area(const GBinPortion *, phys_t, const
/* Indique le nombre de ligne prêtes à être générées. */
static size_t g_binary_portion_count_lines(const GBinPortion *);
+#ifdef INCLUDE_GTK_SUPPORT
+
/* Retrouve l'emplacement correspondant à une position donnée. */
static void g_binary_portion_compute_cursor(const GBinPortion *, gint, size_t, size_t, GLineCursor **);
/* Détermine si le conteneur s'inscrit dans une plage donnée. */
static int g_binary_portion_contain_cursor(const GBinPortion *, size_t, size_t, const GLineCursor *);
+#endif
+
/* Renseigne sur les propriétés liées à un générateur. */
static BufferLineFlags g_binary_portion_get_flags(const GBinPortion *, size_t, size_t);
@@ -93,12 +101,19 @@ static void g_binary_portion_print(GBinPortion *, GBufferLine *, size_t, size_t,
/* Détermine si une portion contient une adresse donnée. */
static bool g_binary_portion_contains_vmpa(const GBinPortion *, const vmpa2t *);
+#ifdef INCLUDE_GTK_SUPPORT
+
+/* Recherche la portion présente à une adresse donnée. */
+static GBinPortion *g_binary_portion_find_with_area_at_addr(GBinPortion *, const vmpa2t *, GdkRectangle *);
+
/* Détermine si une portion contient une position donnée. */
static bool g_binary_portion_contains_physical(const GBinPortion *, phys_t);
/* Détermine si une portion contient une adresse donnée. */
static bool g_binary_portion_contains_virtual(const GBinPortion *, virt_t);
+#endif
+
/* ---------------------------------------------------------------------------------- */
@@ -154,6 +169,10 @@ static void g_binary_portion_init(GBinPortion *portion)
portion->code = NULL;
+#ifdef INCLUDE_GTK_SUPPORT
+ portion->icon = NULL;
+#endif
+
portion->desc = NULL;
portion->text = NULL;
portion->lcount = 0;
@@ -181,8 +200,10 @@ static void g_binary_portion_init(GBinPortion *portion)
static void g_binary_portion_interface_init(GLineGeneratorInterface *iface)
{
iface->count = (linegen_count_lines_fc)g_binary_portion_count_lines;
+#ifdef INCLUDE_GTK_SUPPORT
iface->compute = (linegen_compute_fc)g_binary_portion_compute_cursor;
iface->contain = (linegen_contain_fc)g_binary_portion_contain_cursor;
+#endif
iface->get_flags = (linegen_get_flags_fc)g_binary_portion_get_flags;
iface->print = (linegen_print_fc)g_binary_portion_print;
@@ -232,8 +253,10 @@ static void g_binary_portion_finalize(GBinPortion *portion)
if (portion->code != NULL)
free(portion->code);
+#ifdef INCLUDE_GTK_SUPPORT
if (portion->icon != NULL)
cairo_surface_destroy(portion->icon);
+#endif
if (portion->desc != NULL)
free(portion->desc);
@@ -310,6 +333,9 @@ int g_binary_portion_compare(const GBinPortion **a, const GBinPortion **b)
}
+#ifdef INCLUDE_GTK_SUPPORT
+
+
/******************************************************************************
* *
* Paramètres : portion = description de partie à mettre à jour. *
@@ -360,6 +386,9 @@ cairo_surface_t *g_binary_portion_get_icon(const GBinPortion *portion)
}
+#endif
+
+
/******************************************************************************
* *
* Paramètres : portion = description de partie à mettre à jour. *
@@ -588,6 +617,9 @@ PortionAccessRights g_binary_portion_get_rights(const GBinPortion *portion)
}
+#ifdef INCLUDE_GTK_SUPPORT
+
+
/******************************************************************************
* *
* Paramètres : portion = description de partie à mettre à jour. *
@@ -669,6 +701,9 @@ void g_binary_portion_query_tooltip(GBinPortion *portion, GtkTooltip *tooltip)
}
+#ifdef INCLUDE_GTK_SUPPORT
+
+
/******************************************************************************
* *
* Paramètres : portion = portion mère à consulter. *
@@ -707,6 +742,9 @@ static bool g_binary_portion_compute_sub_area(const GBinPortion *portion, phys_t
}
+#endif
+
+
/******************************************************************************
* *
* Paramètres : portion = description de partie à consulter. *
@@ -762,6 +800,9 @@ void g_binary_portion_draw(const GBinPortion *portion, GtkStyleContext *context,
}
+#endif
+
+
/******************************************************************************
* *
* Paramètres : portion = portion principale à compléter. *
@@ -1025,6 +1066,9 @@ static size_t g_binary_portion_count_lines(const GBinPortion *portion)
}
+#ifdef INCLUDE_GTK_SUPPORT
+
+
/******************************************************************************
* *
* Paramètres : portion = générateur à consulter. *
@@ -1081,6 +1125,9 @@ static int g_binary_portion_contain_cursor(const GBinPortion *portion, size_t in
}
+#endif
+
+
/******************************************************************************
* *
* Paramètres : portion = générateur à consulter. *
@@ -1143,6 +1190,9 @@ static void g_binary_portion_print(GBinPortion *portion, GBufferLine *line, size
/* ---------------------------------------------------------------------------------- */
+#ifdef INCLUDE_GTK_SUPPORT
+
+
/******************************************************************************
* *
* Paramètres : portion = couche de portions à parcourir pour les recherches.*
@@ -1237,6 +1287,9 @@ GBinPortion *g_binary_portion_find_at_pos(GBinPortion *portion, gint x, GdkRecta
}
+#endif
+
+
/******************************************************************************
* *
* Paramètres : portion = portion mère à consulter. *
@@ -1276,6 +1329,55 @@ static bool g_binary_portion_contains_vmpa(const GBinPortion *portion, const vmp
* *
* Paramètres : portion = couche de portions à parcourir pour les recherches.*
* addr = adresse du point de recherche. *
+* *
+* Description : Recherche la portion présente à une adresse donnée. *
+* *
+* Retour : Portion trouvée à l'endroit indiqué. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GBinPortion *g_binary_portion_find_at_addr(GBinPortion *portion, const vmpa2t *addr)
+{
+ GBinPortion *result; /* Portion à retourner */
+ phys_t full; /* Espace total représenté */
+ size_t i; /* Boucle de parcours #1 */
+ GBinPortion *sub; /* Portion incluse à traiter */
+
+ result = NULL;
+
+ full = get_mrange_length(&portion->range);
+
+ for (i = 0; i < portion->count && result == NULL; i++)
+ {
+ sub = portion->subs[i];
+
+ if (!g_binary_portion_contains_vmpa(sub, addr))
+ continue;
+
+ result = g_binary_portion_find_at_addr(sub, addr);
+
+ }
+
+ if (result == NULL)
+ {
+ result = portion;
+ g_object_ref(G_OBJECT(result));
+ }
+
+ return result;
+
+}
+
+
+#ifdef INCLUDE_GTK_SUPPORT
+
+
+/******************************************************************************
+* *
+* Paramètres : portion = couche de portions à parcourir pour les recherches.*
+* addr = adresse du point de recherche. *
* area = étendue de portion mère, puis celle trouvée. [OUT] *
* *
* Description : Recherche la portion présente à une adresse donnée. *
@@ -1286,7 +1388,7 @@ static bool g_binary_portion_contains_vmpa(const GBinPortion *portion, const vmp
* *
******************************************************************************/
-GBinPortion *g_binary_portion_find_at_addr(GBinPortion *portion, const vmpa2t *addr, GdkRectangle *area)
+static GBinPortion *g_binary_portion_find_with_area_at_addr(GBinPortion *portion, const vmpa2t *addr, GdkRectangle *area)
{
GBinPortion *result; /* Portion à retourner */
phys_t full; /* Espace total représenté */
@@ -1308,7 +1410,7 @@ GBinPortion *g_binary_portion_find_at_addr(GBinPortion *portion, const vmpa2t *a
if (!g_binary_portion_compute_sub_area(sub, full, area, &sub_area))
continue;
- result = g_binary_portion_find_at_addr(sub, addr, &sub_area);
+ result = g_binary_portion_find_with_area_at_addr(sub, addr, &sub_area);
if (result != NULL)
*area = sub_area;
@@ -1385,7 +1487,7 @@ bool get_binary_portion_pos_from_addr(GBinPortion *root, const vmpa2t *addr, con
owner_area = *area;
- owner = g_binary_portion_find_at_addr(root, addr, &owner_area);
+ owner = g_binary_portion_find_with_area_at_addr(root, addr, &owner_area);
if (owner == NULL) return false;
diff = compute_vmpa_diff(addr, get_mrange_addr(&owner->range));
@@ -1431,6 +1533,9 @@ gboolean query_tooltip_for_binary_portion(GBinPortion *root, gint x, gint y, con
}
+#endif
+
+
/******************************************************************************
* *
* Paramètres : portion = portion mère à consulter. *