summaryrefslogtreecommitdiff
path: root/src/analysis/roptions.c
blob: 8da348f7d791e44e31c1bc88b2ae3bec7f686ad3 (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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259

/* Chrysalide - Outil d'analyse de fichiers binaires
 * roptions.c - options de rendus des lignes de code
 *
 * Copyright (C) 2009-2012 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/>.
 */


#include "roptions.h"



/* Options de représentation (instance) */
struct _GRenderingOptions
{
    GExeFormat *format;                     /* Format du contenu bianire   */
    GArchProcessor *proc;                   /* Architecture utilisée       */

    AsmSyntax syntax;                       /* Style de rendu ASM          */

    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.                          *
*                                                                             *
*  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(GExeFormat *format)
{
    GRenderingOptions *result;              /* Structure à retourner       */

    result = g_object_new(G_TYPE_RENDERING_OPTIONS, NULL);

    result->format = format;
    result->proc = NULL;//get_arch_processor_from_format(format);

    return result;

}


/******************************************************************************
*                                                                             *
*  Paramètres  : options = options à consulter.                               *
*                                                                             *
*  Description : Fournit le format du contenu binaire représenté.             *
*                                                                             *
*  Retour      : Format du contenu binaire.                                   *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

GExeFormat *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 à consulter.                               *
*                                                                             *
*  Description : Fournit le style de rendu pour le contenu ASM.               *
*                                                                             *
*  Retour      : Style de rendu pour le langage d'assemblage.                 *
*                                                                             *
*  Remarques   : -                                                            *
*                                                                             *
******************************************************************************/

AsmSyntax g_rendering_options_get_syntax(const GRenderingOptions *options)
{
    return options->syntax;

}


/******************************************************************************
*                                                                             *
*  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];

}