summaryrefslogtreecommitdiff
path: root/src/gtkext/gtksnippet.h
blob: 41727bd93927f699c13935c0c96e865965bb39aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156

/* OpenIDA - Outil d'analyse de fichiers binaires
 * gtksnippet.h - prototypes pour l'affichage d'un fragment de code d'assemblage
 *
 * Copyright (C) 2008 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 _GTK_SNIPPET_H
#define _GTK_SNIPPET_H


#include <stdint.h>
#include <gtk/gtk.h>
#include <cairo.h>


#include "../analysis/line.h"
#include "../arch/instruction.h"
#include "../arch/processor.h"
#include "../format/exe_format.h"



typedef struct _code_line_info
{
    uint64_t offset;                        /* Position de l'instruction   */
    asm_instr *instr;                       /* Eventuelle instruction      */
    char *comment;                          /* Eventuel commentaire        */

    gboolean bp_set;                        /* Point d'arrêt défini        */

} code_line_info;




/* Crée une ligne de représentation insérable. */
code_line_info *create_code_line_info(uint64_t, asm_instr *, const char *);

/* Supprime une ligne de représentation. */
void delete_code_line_info(code_line_info *);

/* Etablit la comparaison entre deux lignes de représentation. */
int compare_code_line_info(const code_line_info **, const code_line_info **);





G_BEGIN_DECLS


#define GTK_SNIPPET(obj) GTK_CHECK_CAST(obj, gtk_snippet_get_type (), GtkSnippet)
#define GTK_SNIPPET_CLASS(klass) GTK_CHECK_CLASS_CAST(klass, gtk_snippet_get_type(), GtkSnippetClass)
#define GTK_IS_SNIPPET(obj) GTK_CHECK_TYPE(obj, gtk_snippet_get_type())


typedef struct _GtkSnippet GtkSnippet;
typedef struct _GtkSnippetClass GtkSnippetClass;





struct _GtkSnippet {

    GtkWidget widget;                       /* Présence obligatoire en 1er */

    AdressMode mode;                        /* Mode d'affichage            */

    bool show_vaddress;                     /* Affichage des adresses ?    */
    bool show_code;                         /* Affichage du code brut ?    */

    PangoLayout *layout;                    /* Moteur de rendu du code ASM */
    GdkGC *gc;                              /* Contexte graphique du rendu */
    int line_height;                        /* Hauteur maximale des lignes */

    const exe_format *format;               /* Format du contenu bianire   */
    const asm_processor *proc;              /* Architecture utilisée       */
    code_line_info *info;                   /* Contenu à représenter       */
    unsigned int info_count;                /* Quantité d'informations     */

    GRenderingLine *lines;                  /* Contenu à représenter       */


  gint sel;
};

struct _GtkSnippetClass {
  GtkWidgetClass parent_class;
};


GtkType gtk_snippet_get_type(void);
void gtk_snippet_set_sel(GtkSnippet *cpu, gint sel);

GtkWidget * gtk_snippet_new(void);




/* Choisit d'afficher les adresses virtuelles ou non. */
void gtk_snippet_show_vaddress(GtkSnippet *, gboolean);

/* Choisit d'afficher le code brut ou non. */
void gtk_snippet_show_code(GtkSnippet *, gboolean);




/* Définit le format auquel le contenu est lié. */
void gtk_snippet_set_format(GtkSnippet *, const exe_format *);

/* Définit l'architecture à laquelle le contenu est lié. */
void gtk_snippet_set_processor(GtkSnippet *, const asm_processor *);

/* Ajoute une ligne dans le bloc de représentation. */
void gtk_snippet_add_line(GtkSnippet *, const code_line_info *);

/* Définit les lignes du bloc de représentation. */
void gtk_snippet_set_rendering_lines(GtkSnippet *, GRenderingLine *);

/* Définit le contenu visuel à partir des infos enregistrées. */
void gtk_snippet_build_content(GtkSnippet *);



/* Indique la position verticale d'une adresse donnée. */
gboolean gtk_snippet_get_address_vposition(GtkSnippet *, uint64_t, gint *);



G_END_DECLS






#endif  /* _GTK_SNIPPET_H */