summaryrefslogtreecommitdiff
path: root/src/glibext/gbufferline.h
blob: 0da5ffd2ef667f938e3ce61b033015897bddf4c1 (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

/* Chrysalide - Outil d'analyse de fichiers binaires
 * gbufferline.h - prototypes pour la représentation de fragments de texte en ligne
 *
 * Copyright (C) 2010-2014 Cyrille Bagard
 *
 *  This file is part of Chrysalide.
 *
 *  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 _GLIBEXT_GBUFFERLINE_H
#define _GLIBEXT_GBUFFERLINE_H


#include <glib-object.h>
#include <stdbool.h>


#include "gbuffersegment.h"
#include "../analysis/content.h"
#include "../arch/archbase.h"
#include "../arch/vmpa.h"



#define G_TYPE_BUFFER_LINE                  (g_buffer_line_get_type())
#define G_BUFFER_LINE(obj)                  (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_BUFFER_LINE, GBufferLine))
#define G_BUFFER_LINE_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_BUFFER_LINE, GBufferLineClass))
#define G_IS_BUFFER_LINE(obj)               (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_BUFFER_LINE))
#define G_IS_BUFFER_LINE_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_BUFFER_LINE))
#define G_BUFFER_LINE_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_BUFFER_LINE, GBufferLineClass))



/* Représentation de fragments de texte en ligne (instance) */
typedef struct _GBufferLine GBufferLine;

/* Représentation de fragments de texte en ligne (classe) */
typedef struct _GBufferLineClass GBufferLineClass;


/* Désignation des colonnes d'une ligne */
typedef enum _BufferLineColumn
{
    BLC_PHYSICAL,                           /* Position physique           */
    BLC_VIRTUAL,                            /* Adresse virtuelle           */
    BLC_BINARY,                             /* Contenu sous forme binaire  */
    BLC_ASSEMBLY_HEAD,                      /* Instruction pour assembleur */
    BLC_ASSEMBLY,                           /* Code pour assembleur        */
    BLC_COMMENTS,                           /* Commentaires éventuels      */

    BLC_COUNT,

    BLC_LAST_USED,                          /* Dernière colonne utilisée   */
    BLC_INVALID,                            /* Valeur de non-initialisation*/
    BLC_MAIN                                /* Colonne principale (cf. imm)*/

} BufferLineColumn;

/* Première colonne de l'ensemble */
#define BLC_FIRST BLC_PHYSICAL

/* Première colonne toujours affichée */
#define BLC_DISPLAY BLC_ASSEMBLY_HEAD


/* Confort pour l'insertion de texte */
#define SL(str) str, strlen(str)

/* Espace entre les colonnes */
#define COL_MARGIN 23


/* Propriétés particulières supplémentaires */
typedef enum _BufferLineFlags
{
    BLF_NONE        = 0 << 0,               /* Aucune                      */
    BLF_HAS_CODE    = 1 << 0,               /* La ligne contient du code   */
    BLF_ENTRYPOINT  = 1 << 1,               /* Représentation d'une entrée */
    BLF_BOOKMARK    = 1 << 2,               /* Signet associé              */

    BLF_ALL         = ((1 << 3) - 1)

} BufferLineFlags;


/* Détermine le type de la représentation de fragments de texte en ligne. */
GType g_buffer_line_get_type(void);

/* Crée une nouvelle représentation de fragments de texte. */
GBufferLine *g_buffer_line_new(const mrange_t *, BufferLineColumn);

/* Indique la zone mémoire où se situe la ligne. */
const mrange_t *g_buffer_line_get_range(const GBufferLine *);

/* Construit le tronc commun d'une ligne autour de sa position. */
void g_buffer_line_fill_mrange(GBufferLine *, MemoryDataSize, MemoryDataSize);

/* Construit le tronc commun d'une ligne d'instruction. */
void g_buffer_line_fill_for_instr(GBufferLine *, MemoryDataSize, MemoryDataSize, const GBinContent *, bool);

/* Ajoute un fragment de texte à une colonne de ligne. */
void g_buffer_line_add_segment(GBufferLine *, BufferLineColumn, GBufferSegment *) __attribute__ ((deprecated));

/* Donne le segment présent à une abscisse donnée. */
GBufferSegment *g_buffer_line_get_segment_at(const GBufferLine *, const gint [BLC_COUNT], const bool *, gint *, gint *, GdkScrollDirection, bool);

/* Fournit le segment voisin d'un autre segment identifié. */
GBufferSegment *g_buffer_line_find_near_segment(const GBufferLine *, GBufferSegment *, const gint [BLC_COUNT], const bool *, GdkScrollDirection, gint *);

/* Ajoute du texte à formater dans une ligne donnée. */
GBufferSegment *g_buffer_line_insert_text(GBufferLine *, BufferLineColumn, const char *, size_t, RenderingTagType);

/* Donne le texte représenté par une ligne de tampon. */
char *g_buffer_line_get_text(const GBufferLine *, BufferLineColumn, BufferLineColumn, bool);

/* Fournit la largeur requise pour une colonne de ligne donnée. */
gint g_buffer_line_get_column_width(GBufferLine *, BufferLineColumn);

/* Fournit la dernière largeur d'une ligne avec fusion. */
gint g_buffer_line_get_merge_width(GBufferLine *, BufferLineColumn *, const bool *);

/* Définit la colonne à partir de laquelle la fusion opère. */
void g_buffer_line_start_merge_at(GBufferLine *, BufferLineColumn);

/* Ajoute une propriété particulière à une ligne donnée. */
void g_buffer_line_add_flag(GBufferLine *, BufferLineFlags);

/* Renseigne sur les propriétés particulières liées à une ligne. */
BufferLineFlags g_buffer_line_get_flags(const GBufferLine *);

/* Retire une propriété particulière à une ligne donnée. */
void g_buffer_line_remove_flag(GBufferLine *, BufferLineFlags);

/* Imprime la ligne de texte représentée. */
void g_buffer_line_draw(GBufferLine *, cairo_t *, const gint [BLC_COUNT], gint, gint, const bool *, const segcnt_list *);

/* Exporte la ligne de texte représentée. */
void g_buffer_line_export(GBufferLine *, buffer_export_context *, BufferExportType, const bool *);



#endif  /* _GLIBEXT_GBUFFERLINE_H */