summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis')
-rw-r--r--src/analysis/binary.c8
-rw-r--r--src/analysis/exporter.c50
-rw-r--r--src/analysis/line-int.h1
-rw-r--r--src/analysis/line.c20
-rw-r--r--src/analysis/line.h3
-rw-r--r--src/analysis/line_comment.c47
-rw-r--r--src/analysis/line_prologue.c35
7 files changed, 160 insertions, 4 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index c35118e..d518328 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -736,6 +736,8 @@ GOpenidaBinary *g_openida_binary_new_from_file(const char *filename)
break;
}
+ result->lines = build_binary_prologue(filename, result->bin_data, result->bin_length);
+
result->proc = get_arch_processor_from_format(result->format);
result->options = g_rendering_options_new(result->format);
@@ -1344,7 +1346,7 @@ GRenderingLine *build_binary_prologue(const char *filename, const uint8_t *data,
line = g_prologue_line_new("Disassembly generated by OpenIDA");
g_rendering_line_add_to_lines(&result, line);
- line = g_prologue_line_new("OpenIDA is free software - © 2008-2009 Cyrille Bagard");
+ line = g_prologue_line_new("OpenIDA is free software - © 2008-2010 Cyrille Bagard");
g_rendering_line_add_to_lines(&result, line);
line = g_prologue_line_new("");
@@ -1413,9 +1415,7 @@ void ack_completed_disassembly(GDelayedDisassembly *disass, GOpenidaBinary *bina
size_t i; /* Boucle de parcours */
- binary->lines = disass->lines;
-
-
+ g_rendering_line_merge(&binary->lines, &disass->lines);
diff --git a/src/analysis/exporter.c b/src/analysis/exporter.c
index b6d773a..9de5fbc 100644
--- a/src/analysis/exporter.c
+++ b/src/analysis/exporter.c
@@ -48,6 +48,7 @@ static void g_content_exporter_class_init(GContentExporterClass *klass)
{
GdkScreen *screen; /* Ecran pour GDK */
PangoFontDescription *font_desc; /* Police de caractère */
+ PangoAttribute *attrib; /* Propriété de rendu */
/* Exportation vers un tampon de code */
@@ -61,22 +62,71 @@ static void g_content_exporter_class_init(GContentExporterClass *klass)
pango_context_set_base_dir(klass->context, PANGO_DIRECTION_LTR);
pango_context_set_language(klass->context, gtk_get_default_language());
+ /* RTT_RAW */
+
klass->attribs[RTT_RAW] = pango_attr_list_new();
+ attrib = pango_attr_foreground_new(0, 0, 0);
+ pango_attr_list_insert(klass->attribs[RTT_RAW], attrib);
+
+ /* RTT_COMMENT */
+
klass->attribs[RTT_COMMENT] = pango_attr_list_new();
+ attrib = pango_attr_foreground_new(14335, 45311, 23551);
+ pango_attr_list_insert(klass->attribs[RTT_COMMENT], attrib);
+
+ /* RTT_RAW_CODE */
+
klass->attribs[RTT_RAW_CODE] = pango_attr_list_new();
+ attrib = pango_attr_foreground_new(48895, 48895, 48895);
+ pango_attr_list_insert(klass->attribs[RTT_RAW_CODE], attrib);
+
+ /* RTT_INSTRUCTION */
+
klass->attribs[RTT_INSTRUCTION] = pango_attr_list_new();
+ attrib = pango_attr_foreground_new(0, 0, 0);
+ pango_attr_list_insert(klass->attribs[RTT_INSTRUCTION], attrib);
+
+ /* RTT_IMMEDIATE */
+
klass->attribs[RTT_IMMEDIATE] = pango_attr_list_new();
+ attrib = pango_attr_foreground_new(41215, 8447, 61695);
+ pango_attr_list_insert(klass->attribs[RTT_IMMEDIATE], attrib);
+
+ /* RTT_REGISTER */
+
klass->attribs[RTT_REGISTER] = pango_attr_list_new();
+ //attrib = pango_attr_foreground_new(23551, 23551, 51455);
+ attrib = pango_attr_foreground_new(16895, 16895, 53759);
+ pango_attr_list_insert(klass->attribs[RTT_REGISTER], attrib);
+
+ /* RTT_HOOK */
+
klass->attribs[RTT_HOOK] = pango_attr_list_new();
+ attrib = pango_attr_foreground_new(0, 0, 0);
+ pango_attr_list_insert(klass->attribs[RTT_HOOK], attrib);
+
+ attrib = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
+ pango_attr_list_insert(klass->attribs[RTT_HOOK], attrib);
+
+ /* RTT_SIGNS */
+
klass->attribs[RTT_SIGNS] = pango_attr_list_new();
+ attrib = pango_attr_foreground_new(0, 0, 0);
+ pango_attr_list_insert(klass->attribs[RTT_SIGNS], attrib);
+
+ attrib = pango_attr_weight_new(PANGO_WEIGHT_SEMIBOLD);
+ pango_attr_list_insert(klass->attribs[RTT_SIGNS], attrib);
+
+ /* RTT_LTGT */
+
klass->attribs[RTT_LTGT] = pango_attr_list_new();
klass->attribs[RTT_SEGMENT] = pango_attr_list_new();
diff --git a/src/analysis/line-int.h b/src/analysis/line-int.h
index 38efeda..795adcc 100644
--- a/src/analysis/line-int.h
+++ b/src/analysis/line-int.h
@@ -63,6 +63,7 @@ struct _GRenderingLine
#define lines_list_add_before(new, head, pos) dl_list_add_before(new, head, pos, link)
#define lines_list_add_tail(new, head) dl_list_add_tail(new, head, GRenderingLine, link)
#define lines_list_del(item, head) dl_list_del(item, head, GRenderingLine, link)
+#define lines_list_merge(head1, head2) dl_list_merge(head1, head2, GRenderingLine, link)
#define lines_list_for_each(pos, head) dl_list_for_each(pos, head, GRenderingLine, link)
#define lines_list_for_each_safe(pos, head, next) dl_list_for_each_safe(pos, head, next, GRenderingLine, link)
diff --git a/src/analysis/line.c b/src/analysis/line.c
index bb4188a..a964b2a 100644
--- a/src/analysis/line.c
+++ b/src/analysis/line.c
@@ -540,6 +540,26 @@ void g_rendering_line_remove_range(GRenderingLine **lines, vmpa_t start, vmpa_t
/******************************************************************************
* *
+* Paramètres : lines1 = première liste à fusionner. *
+* lines2 = seconde liste à intégrer à la première. *
+* *
+* Description : Fusionne deux listes de lignes de rendu. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_rendering_line_merge(GRenderingLine **lines1, GRenderingLine **lines2)
+{
+ lines_list_merge(lines1, lines2);
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : lines = liste de lignes de représentation à actualiser. *
* : iter = position actuelle dans la liste. *
* last = dernière élément imposé du parcours ou NULL. *
diff --git a/src/analysis/line.h b/src/analysis/line.h
index fbc560f..b7565f6 100644
--- a/src/analysis/line.h
+++ b/src/analysis/line.h
@@ -128,6 +128,9 @@ void g_rendering_line_insert_lines(GRenderingLine **, GRenderingLine **);
/* Supprime une série de lignes comprises dans un intervalle. */
void g_rendering_line_remove_range(GRenderingLine **, vmpa_t, vmpa_t);
+/* Fusionne deux listes de lignes de rendu. */
+void g_rendering_line_merge(GRenderingLine **, GRenderingLine **);
+
/* Fournit l'élement suivant un autre pour un parcours. */
GRenderingLine *g_rendering_line_get_next_iter(GRenderingLine *, const GRenderingLine *, const GRenderingLine *);
diff --git a/src/analysis/line_comment.c b/src/analysis/line_comment.c
index 5bdf29a..7d2758d 100644
--- a/src/analysis/line_comment.c
+++ b/src/analysis/line_comment.c
@@ -60,6 +60,8 @@ static void g_comment_line_init(GCommentLine *);
/* Ajoute du texte simple à un fichier ouvert en écriture. */
static void g_comment_line_add_text(GCommentLine *, GRenderingOptions *, MainRendering, FILE *);
+/* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */
+static void g_comment_line_to_buffer(GCommentLine *, GBufferLine *, GRenderingOptions *);
/* Indique le type définit par la GLib pour la ligne. */
@@ -105,6 +107,7 @@ static void g_comment_line_init(GCommentLine *line)
exporter_parent = G_CONTENT_EXPORTER(line);
exporter_parent->add_text = (add_text_fc)g_comment_line_add_text;
+ exporter_parent->export_buffer = (export_buffer_fc)g_comment_line_to_buffer;
line_parent = G_RENDERING_LINE(line);
@@ -173,6 +176,50 @@ static void g_comment_line_add_text(GCommentLine *line, GRenderingOptions *optio
/******************************************************************************
* *
+* Paramètres : line = ligne de représentation à représenter. *
+* buffer = espace où placer ledit contenu. *
+* options = options de rendu. *
+* *
+* Description : Ajoute à un tampon GLib le contenu de l'instance spécifiée. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_comment_line_to_buffer(GCommentLine *line, GBufferLine *buffer, GRenderingOptions *options)
+{
+ GContentExporter *exporter; /* Autre vision de la ligne */
+ MemoryDataSize msize; /* Taille du bus d'adresses */
+ char address[VMPA_MAX_SIZE]; /* Adresse au format texte */
+ size_t len; /* Taille de l'élément inséré */
+
+ exporter = G_CONTENT_EXPORTER(line);
+
+ g_buffer_line_start_merge_at(buffer, BLC_ASSEMBLY_HEAD);
+
+ /* Eventuelle adresse virtuelle ou physique */
+
+ msize = g_arch_processor_get_memory_size(g_rendering_options_get_processor(line->options));
+
+ len = vmpa_to_string(G_RENDERING_LINE(line)->offset, msize, address);
+
+ g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ADDRESS, address, len, RTT_RAW);
+
+ /* Commentaire ? */
+
+ len = strlen(line->comment);
+
+ g_content_exporter_insert_into_buffer(exporter, buffer, BLC_COMMENTS, "; ", 2, RTT_COMMENT);
+ g_content_exporter_insert_into_buffer(exporter, buffer, BLC_COMMENTS,
+ line->comment, len, RTT_COMMENT);
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : offset = emplacement physique ou en mémoire. *
* comment = texte à afficher au final. *
* options = paramétrage du rendu. *
diff --git a/src/analysis/line_prologue.c b/src/analysis/line_prologue.c
index d530a44..70c8e79 100644
--- a/src/analysis/line_prologue.c
+++ b/src/analysis/line_prologue.c
@@ -59,6 +59,8 @@ static void g_prologue_line_init(GPrologueLine *);
/* Ajoute du texte simple à un fichier ouvert en écriture. */
static void g_prologue_line_add_text(GPrologueLine *, GRenderingOptions *, MainRendering, FILE *);
+/* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */
+static void g_prologue_line_to_buffer(GPrologueLine *, GBufferLine *, GRenderingOptions *);
/* Indique le type définit par la GLib pour la ligne. */
@@ -104,6 +106,7 @@ static void g_prologue_line_init(GPrologueLine *line)
exporter_parent = G_CONTENT_EXPORTER(line);
exporter_parent->add_text = (add_text_fc)g_prologue_line_add_text;
+ exporter_parent->export_buffer = (export_buffer_fc)g_prologue_line_to_buffer;
line_parent = G_RENDERING_LINE(line);
@@ -144,6 +147,38 @@ static void g_prologue_line_add_text(GPrologueLine *line, GRenderingOptions *opt
/******************************************************************************
* *
+* Paramètres : line = ligne de représentation à représenter. *
+* buffer = espace où placer ledit contenu. *
+* options = options de rendu. *
+* *
+* Description : Ajoute à un tampon GLib le contenu de l'instance spécifiée. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_prologue_line_to_buffer(GPrologueLine *line, GBufferLine *buffer, GRenderingOptions *options)
+{
+ GContentExporter *exporter; /* Autre vision de la ligne */
+ size_t len; /* Taille de l'élément inséré */
+
+ exporter = G_CONTENT_EXPORTER(line);
+
+ g_buffer_line_start_merge_at(buffer, BLC_ADDRESS);
+
+ len = strlen(line->comment);
+
+ g_content_exporter_insert_into_buffer(exporter, buffer, BLC_COMMENTS, "; ", 2, RTT_COMMENT);
+ g_content_exporter_insert_into_buffer(exporter, buffer, BLC_COMMENTS,
+ line->comment, len, RTT_COMMENT);
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : comment = texte à afficher au final. *
* *
* Description : Crée une des lignes de descriptions initiales. *