diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2009-02-18 00:47:48 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2009-02-18 00:47:48 (GMT) |
commit | c2d9948e1e67b48d1a6c8a711024d8dd3f6ac507 (patch) | |
tree | 0b651a1f7d640ce75414aade589a141d22698bc4 /src/binary.c | |
parent | d7765c0e6d2685b57625f607325f4a80eb28dbe5 (diff) |
Begun to rewrite the way rendering lines are managed.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@49 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/binary.c')
-rw-r--r-- | src/binary.c | 86 |
1 files changed, 85 insertions, 1 deletions
diff --git a/src/binary.c b/src/binary.c index 45dc0e0..16be5ef 100644 --- a/src/binary.c +++ b/src/binary.c @@ -25,6 +25,8 @@ #include <fcntl.h> +#include <malloc.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> @@ -66,6 +68,8 @@ openida_binary *load_binary_file_from_xml(xmlXPathObjectPtr); /* Charge en mémoire le contenu d'un fichier. */ uint8_t *map_binary_file(const char *, size_t *); +/* Construit la description d'introduction du désassemblage. */ +rendering_line *build_binary_prologue(const char *, const uint8_t *, off_t); @@ -342,7 +346,80 @@ uint8_t *map_binary_file(const char *filename, size_t *length) } +/****************************************************************************** +* * +* Paramètres : filename = nom du fichier chargé. * +* data = données en mémoire pour l'empreinte. * +* length = quantité de données à prendre en compte. * +* * +* Description : Construit la description d'introduction du désassemblage. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +rendering_line *build_binary_prologue(const char *filename, const uint8_t *data, off_t length) +{ + rendering_line *result; /* Contenu à renvoyer */ + size_t len; /* Taille du texte */ + char *content; /* Contenu textuel d'une ligne */ + rendering_line *line; /* Représentation à ajouter */ + GChecksum *checksum; /* Calcul de l'empreinte */ + const gchar *hex; /* Valeur hexadécimale du SHA */ + + result = NULL;/* FIXME DL_LIST_HEAD_INIT( **/ + + line = create_prologue_line("Disassembly generated by OpenIDA"); + add_line_to_rendering_lines(&result, line); + + line = create_prologue_line("OpenIDA is free software - © 2008-2009 Cyrille Bagard"); + add_line_to_rendering_lines(&result, line); + + line = create_prologue_line(""); + add_line_to_rendering_lines(&result, line); + + /* Fichier */ + + len = strlen(_("File: ")) + strlen(filename); + content = (char *)calloc(len + 1, sizeof(char)); + + snprintf(content, len + 1, "%s%s", _("File: "), filename); + + line = create_prologue_line(content); + add_line_to_rendering_lines(&result, line); + + free(content); + /* Checksum SHA256 */ + + checksum = g_checksum_new(G_CHECKSUM_SHA256); + + g_checksum_update(checksum, data, length); + hex = g_checksum_get_string(checksum); + + len = strlen(_("Sha256: ")) + strlen(hex); + content = (char *)calloc(len + 1, sizeof(char)); + + snprintf(content, len + 1, "%s%s", _("Sha256: "), hex); + + g_checksum_free(checksum); + + line = create_prologue_line(content); + add_line_to_rendering_lines(&result, line); + + free(content); + + line = create_prologue_line(""); + add_line_to_rendering_lines(&result, line); + + line = create_prologue_line(""); + add_line_to_rendering_lines(&result, line); + + return result; + +} @@ -367,7 +444,7 @@ void fill_snippet(GtkSnippet *snippet, GtkWidget *panel, GtkWidget *panel2) size_t comments_count; code_line_info **comments_list; - + rendering_line *line; code_line_info **list; size_t list_len; @@ -412,6 +489,13 @@ void fill_snippet(GtkSnippet *snippet, GtkWidget *panel, GtkWidget *panel2) //exit(0); + + line = build_binary_prologue("/tmp/hello", bin_data, length); + + + gtk_snippet_set_rendering_lines(snippet, line); + + return; |