diff options
Diffstat (limited to 'src')
| -rwxr-xr-x | src/analysis/Makefile.am | 1 | ||||
| -rw-r--r-- | src/analysis/binary.c | 20 | ||||
| -rw-r--r-- | src/analysis/binary.h | 2 | ||||
| -rw-r--r-- | src/analysis/line-int.h | 6 | ||||
| -rw-r--r-- | src/analysis/line.c | 61 | ||||
| -rw-r--r-- | src/analysis/line.h | 35 | ||||
| -rw-r--r-- | src/analysis/line_code.c | 41 | ||||
| -rw-r--r-- | src/analysis/line_code.h | 2 | ||||
| -rw-r--r-- | src/analysis/line_comment.c | 35 | ||||
| -rw-r--r-- | src/analysis/line_comment.h | 2 | ||||
| -rw-r--r-- | src/analysis/line_prologue.c | 10 | ||||
| -rw-r--r-- | src/analysis/roptions.c | 239 | ||||
| -rw-r--r-- | src/analysis/roptions.h | 88 | ||||
| -rw-r--r-- | src/gtkext/gtkblockview.c | 14 | ||||
| -rw-r--r-- | src/gtkext/gtkblockview.h | 2 | ||||
| -rw-r--r-- | src/gtkext/gtkgraphview.c | 10 | ||||
| -rw-r--r-- | src/gtkext/gtklinkrenderer.c | 141 | ||||
| -rw-r--r-- | src/gtkext/gtklinkrenderer.h | 59 | ||||
| -rw-r--r-- | src/project.c | 2 | 
19 files changed, 644 insertions, 126 deletions
| diff --git a/src/analysis/Makefile.am b/src/analysis/Makefile.am index f763f53..5f6beed 100755 --- a/src/analysis/Makefile.am +++ b/src/analysis/Makefile.am @@ -9,6 +9,7 @@ libanalysis_la_SOURCES =				\  	line_comment.h line_comment.c		\  	line_prologue.h line_prologue.c		\  	prototype.h prototype.c				\ +	roptions.h roptions.c				\  	variable.h variable.c  libanalysis_la_LDFLAGS =  diff --git a/src/analysis/binary.c b/src/analysis/binary.c index e74680e..d7d050b 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -70,7 +70,7 @@ struct _openida_binary      GArchProcessor *proc;                   /* Architecture du binaire     */      GRenderingLine *lines;                  /* Lignes de rendu en place    */ -    disass_options options;                 /* Options de désassemblage    */ +    GRenderingOptions *options;             /* Options de désassemblage    */  }; @@ -137,11 +137,13 @@ openida_binary *load_binary_file(const char *filename)      result->proc = get_arch_processor_from_format(result->format); -    result->options.show_address = true; -    result->options.show_code = true; +    result->options = g_rendering_options_new(result->format, result->proc); -    result->options.format = result->format; -    result->options.proc = result->proc; +    g_rendering_options_show_address(result->options, MRD_BLOCK, true); +    g_rendering_options_show_code(result->options, MRD_BLOCK, true); + +    g_rendering_options_show_address(result->options, MRD_GRAPH, true); +    g_rendering_options_show_code(result->options, MRD_GRAPH, false);      disassemble_openida_binary(result); @@ -300,9 +302,9 @@ exe_format *get_openida_binary_format(const openida_binary *binary)  *                                                                             *  ******************************************************************************/ -disass_options *get_openida_binary_options(const openida_binary *binary) +GRenderingOptions *get_openida_binary_options(const openida_binary *binary)  { -    return &binary->options; +    return binary->options;  } @@ -642,7 +644,7 @@ void disassemble_openida_binary(openida_binary *binary)                  instr = g_arch_processor_decode_instruction(binary->proc, &binary->bin_data[start], &pos, len, start, addr); -                line = g_code_line_new(addr, instr, &binary->options); +                line = g_code_line_new(addr, instr, binary->options);                  g_rendering_line_add_to_lines(&binary->lines, line);              } @@ -657,7 +659,7 @@ void disassemble_openida_binary(openida_binary *binary)                  routine_desc = g_binary_routine_to_string(routines[k]); -                line = g_comment_line_new(routine_offset, routine_desc, &binary->options); +                line = g_comment_line_new(routine_offset, routine_desc, binary->options);                  g_rendering_line_insert_into_lines(&binary->lines, line, true);                  free(routine_desc); diff --git a/src/analysis/binary.h b/src/analysis/binary.h index 94f4514..0c63738 100644 --- a/src/analysis/binary.h +++ b/src/analysis/binary.h @@ -58,7 +58,7 @@ uint8_t *get_openida_binary_data(const openida_binary *, off_t *);  exe_format *get_openida_binary_format(const openida_binary *);  /* Fournit les options d'affichage définies pour le binaire. */ -disass_options *get_openida_binary_options(const openida_binary *); +GRenderingOptions *get_openida_binary_options(const openida_binary *);  /* Fournit les lignes de rendu issues du désassemblage. */  GRenderingLine *get_openida_binary_lines(const openida_binary *); diff --git a/src/analysis/line-int.h b/src/analysis/line-int.h index ea8bce0..cf70695 100644 --- a/src/analysis/line-int.h +++ b/src/analysis/line-int.h @@ -36,7 +36,7 @@  typedef void (* get_bin_len_fc) (GRenderingLine *, off_t *);  /* Méthode de mise à jour d'une ligne de représentation. */ -typedef void (* refresh_markup_fc) (GRenderingLine *, LinesMainOwner); +typedef void (* refresh_markup_fc) (GRenderingLine *, MainRendering);  /* Ligne de représentation générique (instance) */ @@ -57,10 +57,10 @@ struct _GRenderingLine      GRenderingLine *to;                     /* Eventuelle ligne visée      */      InstructionLinkType link_type;          /* Type de visée               */ -    PangoLayout *layout[LMO_COUNT];         /* Moteur de rendu du code/txt */ +    PangoLayout *layout[MRD_COUNT];         /* Moteur de rendu du code/txt */      get_bin_len_fc get_bin_len;             /* Nbre d'octets représentés   */ -    off_t max_bin_len[LMO_COUNT];           /* Nombre global maximal       */ +    off_t max_bin_len[MRD_COUNT];           /* Nombre global maximal       */      refresh_markup_fc refresh_markup;       /* Reconstruit la représentat° */ diff --git a/src/analysis/line.c b/src/analysis/line.c index 332e88d..42b034a 100644 --- a/src/analysis/line.c +++ b/src/analysis/line.c @@ -38,8 +38,7 @@ - - +/* ------------------------ TRAITEMENT INDIVIDUEL DES LIGNES ------------------------ */  /* Initialise la classe des lignes de représentation. */ @@ -56,11 +55,15 @@ static GdkPixbuf *g_rendering_line_render_icon(const GRenderingLine *, const cha +/* ---------------------------------------------------------------------------------- */ +/*                          TRAITEMENT INDIVIDUEL DES LIGNES                          */ +/* ---------------------------------------------------------------------------------- */ + +  /* Indique le type définit pour une ligne de représentation. */  G_DEFINE_TYPE(GRenderingLine, g_rendering_line, G_TYPE_OBJECT); -  /******************************************************************************  *                                                                             *  *  Paramètres  : klass = classe à initialiser.                                * @@ -104,7 +107,7 @@ static void g_rendering_line_init(GRenderingLine *line)  {      GdkScreen *screen;                      /* Ecran d'application         */      PangoFontDescription *desc;             /* Description de la police    */ -    LinesMainOwner i;                       /* Boucle de parcours          */ +    MainRendering i;                        /* Boucle de parcours          */      static PangoContext *context = NULL;    /* Contexte graphique Pango    */ @@ -120,7 +123,7 @@ static void g_rendering_line_init(GRenderingLine *line)      } -    for (i = 0; i < LMO_COUNT; i++) +    for (i = 0; i < MRD_COUNT; i++)          line->layout[i] = pango_layout_new(context);      line->get_bin_len = NULL; @@ -397,14 +400,14 @@ static GdkPixbuf *g_rendering_line_render_icon(const GRenderingLine *line, const  /******************************************************************************  *                                                                             * -*  Paramètres  : line     = adresse de la structure à représenter.            * -*                drawable = support de rendu pour le dessin.                  * -*                gc       = contexte graphique à utiliser.                    * -*                x0       = abscisse de la zone de rendu (marge).             * -*                x1       = abscisse de la zone de rendu (texte).             * -*                y        = ordonnée de la zone de rendu.                     * -*                h        = hauteur réservée pour la ligne.                   * -*                owner    = support effectif final des lignes de code.        * +*  Paramètres  : line      = adresse de la structure à représenter.           * +*                drawable  = support de rendu pour le dessin.                 * +*                gc        = contexte graphique à utiliser.                   * +*                x0        = abscisse de la zone de rendu (marge).            * +*                x1        = abscisse de la zone de rendu (texte).            * +*                y         = ordonnée de la zone de rendu.                    * +*                h         = hauteur réservée pour la ligne.                  * +*                rendering = support effectif final des lignes de code.       *  *                                                                             *  *  Description : Procède à l'initialisation des bases d'une représentation.   *  *                                                                             * @@ -414,11 +417,11 @@ static GdkPixbuf *g_rendering_line_render_icon(const GRenderingLine *line, const  *                                                                             *  ******************************************************************************/ -void g_rendering_line_draw(GRenderingLine *line, GdkDrawable *drawable, GdkGC *gc, gint x0, gint x1, gint y, gint h, LinesMainOwner owner) +void g_rendering_line_draw(GRenderingLine *line, GdkDrawable *drawable, GdkGC *gc, gint x0, gint x1, gint y, gint h, MainRendering rendering)  {      GdkPixbuf *pixbuf;                      /* Données utiles au dessin    */ -    gdk_draw_layout(drawable, gc, x1, y, line->layout[owner]); +    gdk_draw_layout(drawable, gc, x1, y, line->layout[rendering]);      if (line->to != NULL)          pixbuf = g_rendering_line_render_icon(line, "gtk-bold", GTK_ICON_SIZE_MENU); @@ -561,9 +564,9 @@ GRenderingLine *g_rendering_line_get_next_iter(GRenderingLine *lines, const GRen  /******************************************************************************  *                                                                             * -*  Paramètres  : lines = liste de lignes de représentation à actualiser.      * -*                last  = dernière élément imposé du parcours ou NULL.         * -*                owner = support effectif des lignes pour l'appelant.         * +*  Paramètres  : lines     = liste de lignes de représentation à actualiser.  * +*                last      = dernière élément imposé du parcours ou NULL.     * +*                rendering = support effectif des lignes pour l'appelant.     *  *                                                                             *  *  Description : Met à jour le nombre d'octets maximal par instruction.       *  *                                                                             * @@ -573,7 +576,7 @@ GRenderingLine *g_rendering_line_get_next_iter(GRenderingLine *lines, const GRen  *                                                                             *  ******************************************************************************/ -void g_rendering_line_update_bin_len(GRenderingLine *lines, GRenderingLine *last, LinesMainOwner owner) +void g_rendering_line_update_bin_len(GRenderingLine *lines, GRenderingLine *last, MainRendering rendering)  {      GRenderingLine *iter;                   /* Boucle de parcours          */      off_t bin_len;                          /* Taille d'instruction        */ @@ -591,8 +594,8 @@ void g_rendering_line_update_bin_len(GRenderingLine *lines, GRenderingLine *last      lines_list_for_each(iter, lines)      { -        iter->max_bin_len[owner] = (bin_len > 0 ? bin_len * 2 + (bin_len - 1) : 0); -        iter->refresh_markup(iter, owner); +        iter->max_bin_len[rendering] = (bin_len > 0 ? bin_len * 2 + (bin_len - 1) : 0); +        iter->refresh_markup(iter, rendering);          if (iter == last) break; @@ -603,12 +606,12 @@ void g_rendering_line_update_bin_len(GRenderingLine *lines, GRenderingLine *last  /******************************************************************************  *                                                                             * -*  Paramètres  : lines  = liste de lignes de représentation à actualiser.     * -*                last   = dernière élément imposé du parcours ou NULL.        * -*                owner  = support effectif final des lignes de code.          * -*                width  = largeur maximale des lignes. [OUT]                  * -*                height = hauteur maximale des lignes. [OUT]                  * -*                alone  = hauteur d'une seule ligne. [OUT]                    * +*  Paramètres  : lines     = liste de lignes de représentation à actualiser.  * +*                last      = dernière élément imposé du parcours ou NULL.     * +*                rendering = support effectif final des lignes de code.       * +*                width     = largeur maximale des lignes. [OUT]               * +*                height    = hauteur maximale des lignes. [OUT]               * +*                alone     = hauteur d'une seule ligne. [OUT]                 *  *                                                                             *  *  Description : Fournit les dimensions de lignes de représentation.          *  *                                                                             * @@ -618,7 +621,7 @@ void g_rendering_line_update_bin_len(GRenderingLine *lines, GRenderingLine *last  *                                                                             *  ******************************************************************************/ -void g_rendering_line_get_size(GRenderingLine *lines, const GRenderingLine *last, LinesMainOwner owner, int *width, int *height, int *alone) +void g_rendering_line_get_size(GRenderingLine *lines, const GRenderingLine *last, MainRendering rendering, int *width, int *height, int *alone)  {      GRenderingLine *iter;                   /* Boucle de parcours          */      int w;                                  /* Largeur de l'objet actuelle */ @@ -630,7 +633,7 @@ void g_rendering_line_get_size(GRenderingLine *lines, const GRenderingLine *last      lines_list_for_each(iter, lines)      { -        pango_layout_get_pixel_size(iter->layout[owner], &w, &h); +        pango_layout_get_pixel_size(iter->layout[rendering], &w, &h);          *width = MAX(*width, w);          *height += h; diff --git a/src/analysis/line.h b/src/analysis/line.h index 981cf90..4a293cf 100644 --- a/src/analysis/line.h +++ b/src/analysis/line.h @@ -25,27 +25,14 @@  #define _ANALYSIS_LINE_H -#include <stdbool.h>  #include <gtk/gtk.h> -#include "../arch/processor.h" -#include "../format/exe_format.h" - - - -/* Support principal de lignes */ -typedef enum _LinesMainOwner -{ -    LMO_BLOCK,                              /* Unique bloc de code         */ -    LMO_GRAPH,                              /* Graphique de blocs de code  */ - -    LMO_COUNT - -} LinesMainOwner; +#include "roptions.h" +/* ------------------------ TRAITEMENT INDIVIDUEL DES LIGNES ------------------------ */  /* Définitions des types de ligne */ @@ -67,18 +54,6 @@ typedef enum _RenderingLineFlag  } RenderingLineFlag; -/* Passage de paramètres compact */ -typedef struct _disass_options -{ -    bool show_address;                      /* Affichage de l'adresse ?    */ -    bool show_code;                         /* Affichage du code brut ?    */ - -    exe_format *format;                     /* Format du contenu bianire   */ -    GArchProcessor *proc;                   /* Architecture utilisée       */ - -} disass_options; - -  #define G_TYPE_RENDERING_LINE               g_rendering_line_get_type()  #define G_RENDERING_LINE(obj)               (G_TYPE_CHECK_INSTANCE_CAST((obj), g_rendering_line_get_type(), GRenderingLine)) @@ -128,7 +103,7 @@ bool g_rendering_line_has_destination(const GRenderingLine *);  GRenderingLine *g_rendering_line_get_destination(const GRenderingLine *, InstructionLinkType *);  /* Procède à l'initialisation des bases d'une représentation. */ -void g_rendering_line_draw(GRenderingLine *, GdkDrawable *, GdkGC *, gint, gint, gint, gint, LinesMainOwner); +void g_rendering_line_draw(GRenderingLine *, GdkDrawable *, GdkGC *, gint, gint, gint, gint, MainRendering); @@ -145,10 +120,10 @@ void g_rendering_line_insert_into_lines(GRenderingLine **, GRenderingLine *, boo  GRenderingLine *g_rendering_line_get_next_iter(GRenderingLine *, const GRenderingLine *, const GRenderingLine *);  /* Met à jour le nombre d'octets maximal par instruction. */ -void g_rendering_line_update_bin_len(GRenderingLine *, GRenderingLine *, LinesMainOwner); +void g_rendering_line_update_bin_len(GRenderingLine *, GRenderingLine *, MainRendering);  /* Fournit les dimensions de lignes de représentation. */ -void g_rendering_line_get_size(GRenderingLine *, const GRenderingLine *, LinesMainOwner, int *, int *, int *); +void g_rendering_line_get_size(GRenderingLine *, const GRenderingLine *, MainRendering, int *, int *, int *);  /* Recherche une ligne d'après sa position à l'écran. */  GRenderingLine *g_rendering_line_find_by_y(GRenderingLine *, const GRenderingLine *, gdouble *); diff --git a/src/analysis/line_code.c b/src/analysis/line_code.c index 84ab36c..c44899e 100644 --- a/src/analysis/line_code.c +++ b/src/analysis/line_code.c @@ -38,7 +38,7 @@ struct _GCodeLine      GRenderingLine parent;                  /* Instance parente            */      GArchInstruction *instr;                /* Instruction représentée     */ -    const disass_options *options;          /* Options de représentation   */ +    const GRenderingOptions *options;       /* Options de représentation   */  }; @@ -61,7 +61,7 @@ static void g_code_line_init(GCodeLine *);  void g_code_line_get_binary_len(GCodeLine *, off_t *);  /* Met à jour la ligne de représentation de code. */ -void g_code_line_refresh_markup(GCodeLine *, LinesMainOwner); +void g_code_line_refresh_markup(GCodeLine *, MainRendering); @@ -140,8 +140,8 @@ void g_code_line_get_binary_len(GCodeLine *line, off_t *blen)  /******************************************************************************  *                                                                             * -*  Paramètres  : line  = ligne de représentation à actualiser.                * -*                owner = support effectif final des lignes de code.           * +*  Paramètres  : line      = ligne de représentation à actualiser.            * +*                rendering = support effectif final des lignes de code.       *  *                                                                             *  *  Description : Met à jour la ligne de représentation de code.               *  *                                                                             * @@ -151,8 +151,10 @@ void g_code_line_get_binary_len(GCodeLine *line, off_t *blen)  *                                                                             *  ******************************************************************************/ -void g_code_line_refresh_markup(GCodeLine *line, LinesMainOwner owner) +void g_code_line_refresh_markup(GCodeLine *line, MainRendering rendering)  { +    bool show_address;                      /* Affichage de l'adresse ?    */ +    bool show_code;                         /* Affichage du code brut ?    */      size_t len;                             /* Taille du contenu           */      char *content;                          /* Contenu réellement imprimé  */      off_t bin_offset;                       /* Début de l'instruction      */ @@ -165,18 +167,21 @@ void g_code_line_refresh_markup(GCodeLine *line, LinesMainOwner owner)      off_t k;                                /* Boucle de parcours #2       */      off_t j;                                /* Boucle de parcours #1       */ +    show_address = g_rendering_options_has_to_show_address(line->options, rendering); +    show_code = g_rendering_options_has_to_show_code(line->options, rendering); +      len = strlen("<tt>") + 1;      content = (char *)calloc(len, sizeof(char));      strcpy(content, "<tt>"); -    if (line->options->show_code) +    if (show_code)          g_arch_instruction_get_location(line->instr, &bin_offset, &bin_len, NULL);      /* Eventuelle adresse virtuelle */ -    if (line->options->show_address) +    if (show_address)      { -        switch (g_arch_processor_get_memory_size(line->options->proc)) +        switch (g_arch_processor_get_memory_size(g_rendering_options_get_processor(line->options)))          {              case MDS_8_BITS:                  snprintf(buffer, CODE_BUFFER_LEN, @@ -213,10 +218,10 @@ void g_code_line_refresh_markup(GCodeLine *line, LinesMainOwner owner)      /* Eventuel code brut */ -    if (line->options->show_code) +    if (show_code)      { -        exe_content = get_exe_content(line->options->format, NULL); -        max_bin_len = &G_RENDERING_LINE(line)->max_bin_len[owner]; +        exe_content = get_exe_content(g_rendering_options_get_format(line->options), NULL); +        max_bin_len = &G_RENDERING_LINE(line)->max_bin_len[rendering];          bin_code = (char *)calloc(*max_bin_len + 1, sizeof(char)); @@ -233,10 +238,10 @@ void g_code_line_refresh_markup(GCodeLine *line, LinesMainOwner owner)          for (; k < *max_bin_len; k++)              snprintf(&bin_code[k], 2, " "); -        if (line->options->show_address) len += strlen("\t"); +        if (show_address) len += strlen("\t");          len += strlen(bin_code);          content = (char *)realloc(content, len * sizeof(char)); -        if (line->options->show_address) strcat(content, "\t"); +        if (show_address) strcat(content, "\t");          strcat(content, bin_code);          free(bin_code); @@ -245,13 +250,13 @@ void g_code_line_refresh_markup(GCodeLine *line, LinesMainOwner owner)      /* Instruction proprement dite */ -    buffer2 = g_arch_instruction_get_text(line->instr, line->options->format, ASX_INTEL/*FIXME*/); +    buffer2 = g_arch_instruction_get_text(line->instr, g_rendering_options_get_format(line->options), ASX_INTEL/*FIXME*/); -    if (line->options->show_address || line->options->show_code) len += strlen("\t"); +    if (show_address || show_code) len += strlen("\t");      len += strlen(buffer2);      content = (char *)realloc(content, len * sizeof(char)); -    if (line->options->show_address || line->options->show_code) strcat(content, "\t"); +    if (show_address || show_code) strcat(content, "\t");      strcat(content, buffer2);      free(buffer2); @@ -262,7 +267,7 @@ void g_code_line_refresh_markup(GCodeLine *line, LinesMainOwner owner)      content = (char *)realloc(content, len * sizeof(char));      strcat(content, "</tt>"); -    pango_layout_set_markup(G_RENDERING_LINE(line)->layout[owner], content, len - 1); +    pango_layout_set_markup(G_RENDERING_LINE(line)->layout[rendering], content, len - 1);      free(content); @@ -283,7 +288,7 @@ void g_code_line_refresh_markup(GCodeLine *line, LinesMainOwner owner)  *                                                                             *  ******************************************************************************/ -GRenderingLine *g_code_line_new(uint64_t offset, GArchInstruction *instr, const disass_options *options) +GRenderingLine *g_code_line_new(uint64_t offset, GArchInstruction *instr, const GRenderingOptions *options)  {      GCodeLine *result;                      /* Structure à retourner       */ diff --git a/src/analysis/line_code.h b/src/analysis/line_code.h index 9c9d8e9..42ac2ff 100644 --- a/src/analysis/line_code.h +++ b/src/analysis/line_code.h @@ -52,7 +52,7 @@ typedef struct _GCodeLineClass GCodeLineClass;  GType g_code_line_get_type(void);  /* Crée une ligne de code binaire. */ -GRenderingLine *g_code_line_new(uint64_t, GArchInstruction *, const disass_options *); +GRenderingLine *g_code_line_new(uint64_t, GArchInstruction *, const GRenderingOptions *);  /* Fournit l'instruction associée à la ligne de code binaire. */  GArchInstruction *g_code_line_get_instruction(const GCodeLine *); diff --git a/src/analysis/line_comment.c b/src/analysis/line_comment.c index 331bd19..a39cb11 100644 --- a/src/analysis/line_comment.c +++ b/src/analysis/line_comment.c @@ -38,7 +38,7 @@ struct _GCommentLine      GRenderingLine parent;                  /* Instance parente            */      char *comment;                          /* Texte à afficher            */ -    const disass_options *options;          /* Options de représentation   */ +    const GRenderingOptions *options;       /* Options de représentation   */  }; @@ -58,7 +58,7 @@ static void g_comment_line_class_init(GCommentLineClass *);  static void g_comment_line_init(GCommentLine *);  /* Met à jour la ligne de représentation de commentaires. */ -void g_comment_line_refresh_markup(GCommentLine *, LinesMainOwner); +void g_comment_line_refresh_markup(GCommentLine *, MainRendering); @@ -112,8 +112,8 @@ static void g_comment_line_init(GCommentLine *line)  /******************************************************************************  *                                                                             * -*  Paramètres  : line  = ligne de représentation à actualiser.                * -*                owner = support effectif final des lignes de code.           * +*  Paramètres  : line      = ligne de représentation à actualiser.            * +*                rendering = support effectif final des lignes de code.       *  *                                                                             *  *  Description : Met à jour la ligne de représentation de commentaires.       *  *                                                                             * @@ -123,23 +123,28 @@ static void g_comment_line_init(GCommentLine *line)  *                                                                             *  ******************************************************************************/ -void g_comment_line_refresh_markup(GCommentLine *line, LinesMainOwner owner) +void g_comment_line_refresh_markup(GCommentLine *line, MainRendering rendering)  { +    bool show_address;                      /* Affichage de l'adresse ?    */ +    bool show_code;                         /* Affichage du code brut ?    */      size_t len;                             /* Taille du contenu           */      char *content;                          /* Contenu réellement imprimé  */      char buffer[CODE_BUFFER_LEN];           /* Zone tampon à utiliser      */      const off_t *max_bin_len;               /* Taille de ligne max/globale */      size_t clen;                            /* Taille du commentaire       */ +    show_address = g_rendering_options_has_to_show_address(line->options, rendering); +    show_code = g_rendering_options_has_to_show_code(line->options, rendering); +      len = strlen("<tt>") + 1;      content = (char *)calloc(len, sizeof(char));      strcpy(content, "<tt>");      /* Eventuelle adresse virtuelle */ -    if (line->options->show_address) +    if (show_address)      { -        switch (g_arch_processor_get_memory_size(line->options->proc)) +        switch (g_arch_processor_get_memory_size(g_rendering_options_get_processor(line->options)))          {              case MDS_8_BITS:                  snprintf(buffer, CODE_BUFFER_LEN, @@ -176,16 +181,16 @@ void g_comment_line_refresh_markup(GCommentLine *line, LinesMainOwner owner)      /* Eventuel code brut (sauté) */ -    if (line->options->show_code) +    if (show_code)      { -        max_bin_len = &G_RENDERING_LINE(line)->max_bin_len[owner]; +        max_bin_len = &G_RENDERING_LINE(line)->max_bin_len[rendering]; -        clen = (line->options->show_address ? strlen("\t") : 0); +        clen = (show_address ? strlen("\t") : 0);          clen += *max_bin_len;          content = (char *)realloc(content, (len + clen) * sizeof(char)); -        if (line->options->show_address) +        if (show_address)          {              strcat(content, "\t");              len += strlen("\t"); @@ -201,14 +206,14 @@ void g_comment_line_refresh_markup(GCommentLine *line, LinesMainOwner owner)      /* Commentaire proprement dit */ -    clen = (line->options->show_address || line->options->show_code ? strlen("\t") : 0); +    clen = (show_address || show_code ? strlen("\t") : 0);      clen += strlen("<b><span foreground='#003300'>");      clen += strlen("; ") + strlen(line->comment);      clen += strlen("</span></b>");      content = (char *)realloc(content, (len + clen) * sizeof(char)); -    if (line->options->show_address || line->options->show_code) +    if (show_address || show_code)      {          strcat(content, "\t");          len += strlen("\t"); @@ -225,7 +230,7 @@ void g_comment_line_refresh_markup(GCommentLine *line, LinesMainOwner owner)      content = (char *)realloc(content, len * sizeof(char));      strcat(content, "</tt>"); -    pango_layout_set_markup(G_RENDERING_LINE(line)->layout[owner], content, len - 1); +    pango_layout_set_markup(G_RENDERING_LINE(line)->layout[rendering], content, len - 1);      free(content); @@ -246,7 +251,7 @@ void g_comment_line_refresh_markup(GCommentLine *line, LinesMainOwner owner)  *                                                                             *  ******************************************************************************/ -GRenderingLine *g_comment_line_new(uint64_t offset, const char *comment, const disass_options *options) +GRenderingLine *g_comment_line_new(uint64_t offset, const char *comment, const GRenderingOptions *options)  {      GCommentLine *result;                   /* Structure à retourner       */ diff --git a/src/analysis/line_comment.h b/src/analysis/line_comment.h index 7d103f4..09657cb 100644 --- a/src/analysis/line_comment.h +++ b/src/analysis/line_comment.h @@ -51,7 +51,7 @@ typedef struct _GCommentLineClass GCommentLineClass;  GType g_comment_line_get_type(void);  /* Crée une ligne de commentaires entière. */ -GRenderingLine *g_comment_line_new(uint64_t, const char *, const disass_options *); +GRenderingLine *g_comment_line_new(uint64_t, const char *, const GRenderingOptions *); diff --git a/src/analysis/line_prologue.c b/src/analysis/line_prologue.c index 16876af..4b83b68 100644 --- a/src/analysis/line_prologue.c +++ b/src/analysis/line_prologue.c @@ -57,7 +57,7 @@ static void g_prologue_line_class_init(GPrologueLineClass *);  static void g_prologue_line_init(GPrologueLine *);  /* Met à jour la ligne de représentation de prologue. */ -void g_prologue_line_refresh_markup(GPrologueLine *, LinesMainOwner); +void g_prologue_line_refresh_markup(GPrologueLine *, MainRendering); @@ -113,8 +113,8 @@ static void g_prologue_line_init(GPrologueLine *line)  /******************************************************************************  *                                                                             * -*  Paramètres  : line  = ligne de représentation à actualiser.                * -*                owner = support effectif final des lignes de code.           * +*  Paramètres  : line      = ligne de représentation à actualiser.            * +*                rendering = support effectif final des lignes de code.       *  *                                                                             *  *  Description : Met à jour la ligne de représentation de prologue.           *  *                                                                             * @@ -124,7 +124,7 @@ static void g_prologue_line_init(GPrologueLine *line)  *                                                                             *  ******************************************************************************/ -void g_prologue_line_refresh_markup(GPrologueLine *line, LinesMainOwner owner) +void g_prologue_line_refresh_markup(GPrologueLine *line, MainRendering rendering)  {      size_t len;                             /* Taille du contenu           */      char *content;                          /* Contenu réellement imprimé  */ @@ -137,7 +137,7 @@ void g_prologue_line_refresh_markup(GPrologueLine *line, LinesMainOwner owner)      snprintf(content, len + 1, "<b><span foreground='#003300'>; %s</span></b>", line->comment); -    pango_layout_set_markup(G_RENDERING_LINE(line)->layout[owner], content, len); +    pango_layout_set_markup(G_RENDERING_LINE(line)->layout[rendering], content, len);      free(content); diff --git a/src/analysis/roptions.c b/src/analysis/roptions.c new file mode 100644 index 0000000..aab8ef7 --- /dev/null +++ b/src/analysis/roptions.c @@ -0,0 +1,239 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * roptions.c - options de rendus des lignes de code + * + * Copyright (C) 2009 Cyrille Bagard + * + *  This file is part of OpenIDA. + * + *  OpenIDA is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 3 of the License, or + *  (at your option) any later version. + * + *  OpenIDA is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "roptions.h" + + + +/* Options de représentation (instance) */ +struct _GRenderingOptions +{ +    exe_format *format;                     /* Format du contenu bianire   */ +    GArchProcessor *proc;                   /* Architecture utilisée       */ + +    bool show_address[MRD_COUNT];           /* Affichage de l'adresse ?    */ +    bool show_code[MRD_COUNT];              /* Affichage du code brut ?    */ + +}; + +/* Options de représentation (classe) */ +struct _GRenderingOptionsClass +{ +    GObjectClass parent;                    /* A laisser en premier        */ + +}; + + +/* Initialise la classe des options pour le rendu des lignes. */ +static void g_rendering_options_class_init(GRenderingOptionsClass *); + +/* Initialise une instance d'options pour le rendu des lignes. */ +static void g_rendering_options_init(GRenderingOptions *); + + + +/* Indique le type définit pour une ligne de représentation. */ +G_DEFINE_TYPE(GRenderingOptions, g_rendering_options, G_TYPE_OBJECT); + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : klass = classe à initialiser.                                * +*                                                                             * +*  Description : Initialise la classe des options pour le rendu des lignes.   * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void g_rendering_options_class_init(GRenderingOptionsClass *klass) +{ + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : options = instance à initialiser.                            * +*                                                                             * +*  Description : Initialise une instance d'options pour le rendu des lignes.  * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void g_rendering_options_init(GRenderingOptions *options) +{ + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : format = format du contenu binaire.                          * +*                proc   = architecture utilisée par le binaire.               * +*                                                                             * +*  Description : Crée un un groupe d'options pour le rendu des lignes.        * +*                                                                             * +*  Retour      : Adresse de la structure mise en place.                       * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GRenderingOptions *g_rendering_options_new(exe_format *format, GArchProcessor *proc) +{ +    GRenderingOptions *result;              /* Structure à retourner       */ + +    result = g_object_new(G_TYPE_RENDERING_OPTIONS, NULL); + +    result->format = format; +    result->proc = proc; + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : options = options à consulter.                               * +*                                                                             * +*  Description : Fournit le format du contenu binaire représenté.             * +*                                                                             * +*  Retour      : Format du contenu binaire.                                   * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +exe_format *g_rendering_options_get_format(const GRenderingOptions *options) +{ +    return options->format; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : options = options à consulter.                               * +*                                                                             * +*  Description : Fournit l'architecture du contenu binaire représenté.        * +*                                                                             * +*  Retour      : Architecture utilisée par le binaire.                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GArchProcessor *g_rendering_options_get_processor(const GRenderingOptions *options) +{ +    return options->proc; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : options   = options à mettre à jour.                         * +*                rendering = type de rendu impliqué.                          * +*                state     = nouvel état de l'option visée.                   * +*                                                                             * +*  Description : Affiche (ou non) les adresses des instructions.              * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +void g_rendering_options_show_address(GRenderingOptions *options, MainRendering rendering, bool state) +{ +    options->show_address[rendering] = state; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : options   = options à consulter.                             * +*                rendering = type de rendu impliqué.                          * +*                                                                             * +*  Description : Indique si les adresses des instructions sont à afficher.    * +*                                                                             * +*  Retour      : Etat courant de l'option visée.                              * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +bool g_rendering_options_has_to_show_address(const GRenderingOptions *options, MainRendering rendering) +{ +    return options->show_address[rendering]; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : options   = options à mettre à jour.                         * +*                rendering = type de rendu impliqué.                          * +*                state     = nouvel état de l'option visée.                   * +*                                                                             * +*  Description : Affiche (ou non) le code des instructions.                   * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +void g_rendering_options_show_code(GRenderingOptions *options, MainRendering rendering, bool state) +{ +    options->show_code[rendering] = state; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : options   = options à consulter.                             * +*                rendering = type de rendu impliqué.                          * +*                                                                             * +*  Description : Indique si le code des instructions est à afficher.          * +*                                                                             * +*  Retour      : Etat courant de l'option visée.                              * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +bool g_rendering_options_has_to_show_code(const GRenderingOptions *options, MainRendering rendering) +{ +    return options->show_code[rendering]; + +} diff --git a/src/analysis/roptions.h b/src/analysis/roptions.h new file mode 100644 index 0000000..184f59a --- /dev/null +++ b/src/analysis/roptions.h @@ -0,0 +1,88 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * roptions.h - prototypes pour les options de rendus des lignes de code + * + * Copyright (C) 2009 Cyrille Bagard + * + *  This file is part of OpenIDA. + * + *  OpenIDA is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 3 of the License, or + *  (at your option) any later version. + * + *  OpenIDA is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>. + */ + + +#ifndef _ANALYSIS_ROPTIONS_H +#define _ANALYSIS_ROPTIONS_H + + +#include <glib-object.h> +#include <stdbool.h> + + +#include "../arch/processor.h" +#include "../format/exe_format.h" + + + +/* Support principal de rendu */ +typedef enum _MainRendering +{ +    MRD_BLOCK,                              /* Unique bloc de code         */ +    MRD_GRAPH,                              /* Graphique de blocs de code  */ + +    MRD_COUNT + +} MainRendering; + + +#define G_TYPE_RENDERING_OPTIONS               g_rendering_options_get_type() +#define G_RENDERING_OPTIONS(obj)               (G_TYPE_CHECK_INSTANCE_CAST((obj), g_rendering_options_get_type(), GRenderingOptions)) +#define G_IS_RENDERING_OPTIONS(obj)            (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_rendering_options_get_type())) +#define G_RENDERING_OPTIONS_GET_IFACE(inst)    (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_rendering_options_get_type(), GRenderingOptionsIface)) +#define G_RENDERING_OPTIONS_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_RENDERING_OPTIONS, GRenderingOptionsClass)) + + +/* Options de représentation (instance) */ +typedef struct _GRenderingOptions GRenderingOptions; + +/* Options de représentation (classe) */ +typedef struct _GRenderingOptionsClass GRenderingOptionsClass; + + +/* Indique le type défini pour des options de représentation. */ +GType g_rendering_options_get_type(void); + +/* Crée un un groupe d'options pour le rendu des lignes. */ +GRenderingOptions *g_rendering_options_new(exe_format *, GArchProcessor *); + +/* Fournit le format du contenu binaire représenté. */ +exe_format *g_rendering_options_get_format(const GRenderingOptions *); + +/* Fournit l'architecture du contenu binaire représenté. */ +GArchProcessor *g_rendering_options_get_processor(const GRenderingOptions *); + +/* Affiche (ou non) les adresses des instructions. */ +void g_rendering_options_show_address(GRenderingOptions *, MainRendering, bool); + +/* Indique si les adresses des instructions sont à afficher. */ +bool g_rendering_options_has_to_show_address(const GRenderingOptions *, MainRendering); + +/* Affiche (ou non) le code des instructions. */ +void g_rendering_options_show_code(GRenderingOptions *, MainRendering, bool); + +/* Indique si le code des instructions est à afficher. */ +bool g_rendering_options_has_to_show_code(const GRenderingOptions *, MainRendering); + + + +#endif  /* _ANALYSIS_ROPTIONS_H */ diff --git a/src/gtkext/gtkblockview.c b/src/gtkext/gtkblockview.c index f0ee0dd..19510cb 100644 --- a/src/gtkext/gtkblockview.c +++ b/src/gtkext/gtkblockview.c @@ -41,7 +41,7 @@ struct _GtkBlockView  {      GtkBinView parent;                      /* A laisser en premier        */ -    LinesMainOwner owner;                   /* Support final des lignes    */ +    MainRendering rendering;                /* Support final des lignes    */      bool show_vaddress;                     /* Affichage des adresses ?    */      bool show_code;                         /* Affichage du code brut ?    */ @@ -122,7 +122,7 @@ G_DEFINE_TYPE(GtkBlockView, gtk_block_view, GTK_TYPE_BIN_VIEW)  /******************************************************************************  *                                                                             * -*  Paramètres  : owner = support effectif des lignes au final.                * +*  Paramètres  : rendering = support effectif des lignes au final.            *  *                                                                             *  *  Description : Crée un nouveau composant pour l'affichage en block.         *  *                                                                             * @@ -132,13 +132,13 @@ G_DEFINE_TYPE(GtkBlockView, gtk_block_view, GTK_TYPE_BIN_VIEW)  *                                                                             *  ******************************************************************************/ -GtkWidget * gtk_block_view_new(LinesMainOwner owner) +GtkWidget * gtk_block_view_new(MainRendering rendering)  {      GtkBlockView *result;      result = gtk_type_new(gtk_block_view_get_type()); -    result->owner = owner; +    result->rendering = rendering;      return GTK_WIDGET(result); @@ -402,7 +402,7 @@ gtk_block_view_paint(GtkBlockView *view)      {          g_rendering_line_draw(iter, GDK_DRAWABLE(widget->window), GTK_BIN_VIEW(view)->gc,                                MARGIN_SPACE, 2 * MARGIN_SPACE + view->line_height, -                              y, view->line_height, view->owner); +                              y, view->line_height, view->rendering);          y += view->line_height; @@ -529,7 +529,7 @@ static void gtk_block_view_set_rendering_lines(GtkBlockView *view, GRenderingLin      }      g_rendering_line_update_bin_len(GTK_BIN_VIEW(view)->lines, -                                    GTK_BIN_VIEW(view)->last, view->owner); +                                    GTK_BIN_VIEW(view)->last, view->rendering);      gtk_block_view_recompute_size_request(view); @@ -558,7 +558,7 @@ void gtk_block_view_recompute_size_request(GtkBlockView *view)      g_rendering_line_get_size(GTK_BIN_VIEW(view)->lines,                                GTK_BIN_VIEW(view)->last, -                              view->owner, +                              view->rendering,                                &width, &height, &view->line_height);      gtk_widget_set_size_request(GTK_WIDGET(view), diff --git a/src/gtkext/gtkblockview.h b/src/gtkext/gtkblockview.h index 43561b1..ed958d0 100644 --- a/src/gtkext/gtkblockview.h +++ b/src/gtkext/gtkblockview.h @@ -55,7 +55,7 @@ typedef struct _GtkBlockViewClass GtkBlockViewClass;  GType gtk_block_view_get_type(void);  /* Crée un nouveau composant pour l'affichage en block. */ -GtkWidget *gtk_block_view_new(LinesMainOwner); +GtkWidget *gtk_block_view_new(MainRendering); diff --git a/src/gtkext/gtkgraphview.c b/src/gtkext/gtkgraphview.c index 03693d5..14cd5b2 100644 --- a/src/gtkext/gtkgraphview.c +++ b/src/gtkext/gtkgraphview.c @@ -241,7 +241,7 @@ static void gtk_graph_view_set_rendering_lines(GtkGraphView *view, GRenderingLin      view->childs = (GtkBinView **)calloc(2, sizeof(GtkBinView *));      view->childs_count = 2; -    view->childs[0] = GTK_BIN_VIEW(gtk_block_view_new(LMO_GRAPH)); +    view->childs[0] = GTK_BIN_VIEW(gtk_block_view_new(MRD_GRAPH));      gtk_widget_show(GTK_WIDGET(view->childs[0]));      gtk_fixed_put(GTK_FIXED(view), GTK_WIDGET(view->childs[0]), 50, 50); @@ -256,7 +256,7 @@ static void gtk_graph_view_set_rendering_lines(GtkGraphView *view, GRenderingLin      printf("mainl : %p\n", mainl); -    view->childs[1] = GTK_BIN_VIEW(gtk_block_view_new(LMO_GRAPH)); +    view->childs[1] = GTK_BIN_VIEW(gtk_block_view_new(MRD_GRAPH));      gtk_widget_show(GTK_WIDGET(view->childs[1]));      gtk_fixed_put(GTK_FIXED(view), GTK_WIDGET(view->childs[1]), 100, 450); @@ -405,7 +405,7 @@ static GtkBinView **gtk_graph_view_load_nodes(openida_binary *binary, GRendering          {              result = (GtkBinView **)realloc(result, ++(*count) * sizeof(GtkBinView *)); -            result[*count - 1] = GTK_BIN_VIEW(gtk_block_view_new(LMO_GRAPH)); +            result[*count - 1] = GTK_BIN_VIEW(gtk_block_view_new(MRD_GRAPH));              gtk_widget_show(GTK_WIDGET(result[*count - 1]));              gtk_bin_view_show_border(result[*count - 1], true); @@ -422,7 +422,7 @@ static GtkBinView **gtk_graph_view_load_nodes(openida_binary *binary, GRendering          {              result = (GtkBinView **)realloc(result, ++(*count) * sizeof(GtkBinView *)); -            result[*count - 1] = GTK_BIN_VIEW(gtk_block_view_new(LMO_GRAPH)); +            result[*count - 1] = GTK_BIN_VIEW(gtk_block_view_new(MRD_GRAPH));              gtk_widget_show(GTK_WIDGET(result[*count - 1]));              gtk_bin_view_show_border(result[*count - 1], true); @@ -438,7 +438,7 @@ static GtkBinView **gtk_graph_view_load_nodes(openida_binary *binary, GRendering      {          result = (GtkBinView **)realloc(result, ++(*count) * sizeof(GtkBinView *)); -        result[*count - 1] = GTK_BIN_VIEW(gtk_block_view_new(LMO_GRAPH)); +        result[*count - 1] = GTK_BIN_VIEW(gtk_block_view_new(MRD_GRAPH));          gtk_widget_show(GTK_WIDGET(result[*count - 1]));          gtk_bin_view_show_border(result[*count - 1], true); diff --git a/src/gtkext/gtklinkrenderer.c b/src/gtkext/gtklinkrenderer.c new file mode 100644 index 0000000..9332860 --- /dev/null +++ b/src/gtkext/gtklinkrenderer.c @@ -0,0 +1,141 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * gtklinkrenderer.c - liens graphiques entre différents morceaux de code + * + * Copyright (C) 2009 Cyrille Bagard + * + *  This file is part of OpenIDA. + * + *  OpenIDA is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 3 of the License, or + *  (at your option) any later version. + * + *  OpenIDA is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "gtklinkrenderer.h" + + + +/* Lien entre morceaux de code (instance) */ +struct _GtkLinkRenderer +{ +    GtkObject parent;                       /* A laisser en premier        */ + +    GdkPoint *points;                       /* Points de la ligne dessinée */ +    size_t count;                           /* Quantité de ces points      */ + +}; + + +/* Lien entre morceaux de code (classe) */ +struct _GtkLinkRendererClass +{ +    GtkObjectClass parent;                  /* A laisser en premier        */ + +}; + + +/* Initialise la classe générique des liens graphiques. */ +static void gtk_link_renderer_class_init(GtkLinkRendererClass *); + +/* Initialise une instance de lien graphique entre codes. */ +static void gtk_link_renderer_init(GtkLinkRenderer *); + + + + +/* Détermine le type du moteur de rendu pour les liens graphiques. */ +G_DEFINE_TYPE(GtkLinkRenderer, gtk_link_renderer, GTK_TYPE_OBJECT) + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : class = classe GTK à initialiser.                            * +*                                                                             * +*  Description : Initialise la classe générique des liens graphiques.         * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void gtk_link_renderer_class_init(GtkLinkRendererClass *class) +{ + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : view = instance GTK à initialiser.                           * +*                                                                             * +*  Description : Initialise une instance de lien graphique entre codes.       * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void gtk_link_renderer_init(GtkLinkRenderer *view) +{ + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : points = points consituant la ligne à représenter.           * +*                count  = nombre de ces points.                               * +*                                                                             * +*  Description : Crée un nouveau moteur de rendu pour les liens graphiques.   * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GtkObject *gtk_link_renderer_new(GdkPoint *points, size_t count) +{ +    GtkLinkRenderer *result;                /* Moteur de rendu à retourner */ + +    result = g_object_new(GTK_TYPE_LINK_RENDERER, NULL); + +    result->points = points; +    result->count = count; + +    return GTK_OBJECT(result); + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : renderer = moteur de rendu à manipuler.                      * +*                drawable = surface de rendu à utiliser.                      * +*                gc       = contexte graphique du dessin.                     * +*                                                                             * +*  Description : Dessine les liens graphiques enregistrés dans le moteur.     * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +void gtk_link_renderer_draw(const GtkLinkRenderer *renderer, GdkDrawable *drawable, GdkGC *gc) +{ +    gdk_draw_lines(drawable, gc, renderer->points, renderer->count); + +} diff --git a/src/gtkext/gtklinkrenderer.h b/src/gtkext/gtklinkrenderer.h new file mode 100644 index 0000000..d662454 --- /dev/null +++ b/src/gtkext/gtklinkrenderer.h @@ -0,0 +1,59 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * gtklinkrenderer.h - prototypes pour les liens graphiques entre différents morceaux de code + * + * Copyright (C) 2009 Cyrille Bagard + * + *  This file is part of OpenIDA. + * + *  OpenIDA is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 3 of the License, or + *  (at your option) any later version. + * + *  OpenIDA is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>. + */ + + +#ifndef _GTKEXT_GTKLINKRENDERER_H +#define _GTKEXT_GTKLINKRENDERER_H + + +#include <gdk/gdk.h> +#include <gtk/gtkobject.h> + + + +#define GTK_TYPE_LINK_RENDERER                  (gtk_link_renderer_get_type()) +#define GTK_LINK_RENDERER(obj)                  (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_LINK_RENDERER, GtkLinkRenderer)) +#define GTK_LINK_RENDERER_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_LINK_RENDERER, GtkLinkRendererClass)) +#define GTK_IS_LINK_RENDERER(obj)               (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_LINK_RENDERER)) +#define GTK_IS_LINK_RENDERER_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_LINK_RENDERER)) +#define GTK_LINK_RENDERER_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_LINK_RENDERER, GtkLinkRendererClass)) + + +/* Lien entre morceaux de code (instance) */ +typedef struct _GtkLinkRenderer GtkLinkRenderer; + +/* Lien entre morceaux de code (classe) */ +typedef struct _GtkLinkRendererClass GtkLinkRendererClass; + + +/* Détermine le type du moteur de rendu pour les liens graphiques. */ +GType gtk_link_renderer_get_type(void); + +/* Crée un nouveau moteur de rendu pour les liens graphiques. */ +GtkObject *gtk_link_renderer_new(GdkPoint *, size_t); + +/* Dessine les liens graphiques enregistrés dans le moteur. */ +void gtk_link_renderer_draw(const GtkLinkRenderer *, GdkDrawable *, GdkGC *); + + + +#endif  /* _GTKEXT_GTKLINKRENDERER_H */ diff --git a/src/project.c b/src/project.c index d1b7225..9f880a2 100644 --- a/src/project.c +++ b/src/project.c @@ -108,7 +108,7 @@ loaded_binary *load_openida_binary(openida_binary *binary)          {              default: /* GCC ! */              case BVW_BLOCK: -                view = gtk_block_view_new(LMO_BLOCK); +                view = gtk_block_view_new(MRD_BLOCK);                  break;              case BVW_GRAPH:                  view = gtk_graph_view_new(); | 
