summaryrefslogtreecommitdiff
path: root/tools/d2c/rules.h
blob: af2cac5dc6a545c4ad059ce4abe4d064d2f25793 (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

/* Chrysalide - Outil d'analyse de fichiers binaires
 * rules.h - prototypes pour les variations de décodage selon certaines conditions
 *
 * Copyright (C) 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 _TOOLS_RULES_H
#define _TOOLS_RULES_H


#include "bits.h"



/* -------------------------- CONDITIONS DE DECLENCHEMENTS -------------------------- */


/* Types de comparaison */
typedef enum _CondCompType
{
    CCT_EQUAL,                              /* Egalité '=='                */
    CCT_DIFF                                /* Différence '!='             */

} CondCompType;

/* Types de combinaison d'expressions */
typedef enum _CondOpType
{
    COT_AND,                                /* Combinaison ET ('&&')       */
    COT_OR                                  /* Combinaison OU ('||')       */

} CondOpType;

/* Expression d'une condition */
typedef struct _cond_expr cond_expr;


/* Crée une expression conditionnelle simple. */
cond_expr *build_simple_cond_expression(char *, CondCompType, char *);

/* Crée une expression conditionnelle composée. */
cond_expr *build_composed_cond_expression(cond_expr *, CondOpType, cond_expr *);



/* ------------------------- REGLES ET ACTIONS CONSEQUENTES ------------------------- */


/* Conséquence en cas de condition remplie */
typedef enum _CondActionType
{
    CAT_SEE,                                /* Renvoi vers une instruction */
    CAT_UNPREDICTABLE                       /* Cas de figure improbable    */

} CondActionType;

/* Règles de décodage supplémentaires */
typedef struct _decoding_rules decoding_rules;


/* Crée un nouveau rassemblement de règles de décodage. */
decoding_rules *create_decoding_rules(void);

/* Supprime de la mémoire un ensemble de règles supplémentaires. */
void delete_decoding_rules(decoding_rules *);

/* Ajoute une règle complète à la définition d'un codage. */
void register_conditional_rule(decoding_rules *, cond_expr *, CondActionType, const char *);

/* Traduit en code les éventuelles règles présentes. */
bool write_decoding_rules(decoding_rules *, int, const char *, const char *, const coding_bits *, bool *);



#endif  /* _TOOLS_RULES_H */