diff options
Diffstat (limited to 'tools/conv.h')
-rw-r--r-- | tools/conv.h | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/tools/conv.h b/tools/conv.h new file mode 100644 index 0000000..acf007b --- /dev/null +++ b/tools/conv.h @@ -0,0 +1,160 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * conv.h - prototypes pour les substitutions de valeurs depuis un contenu binaire + * + * 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_CONV_H +#define _TOOLS_CONV_H + + +#include "bits.h" +#include "pproc.h" + + + + +/* Liste des fonctions de conversions présentes */ +typedef struct _conv_list conv_list; + + + + + + + +/* Types d'opérations unaires */ +typedef enum _ConvUnaryOperation +{ + CUO_NOT, /* NOT (booléen) */ + + CUO_COUNT + +} ConvUnaryOperation; + + + +/* Types d'opérations binaires */ +typedef enum _ConvBinaryOperation +{ + CBO_EOR, /* Ou exclusif (booléen) */ + + CBO_COUNT + +} ConvBinaryOperation; + + +/* Représentation d'une expression de conversion */ +typedef struct _conv_expr_t conv_expr_t; + + + +/* Référence une variable en tant qu'expression de conversion. */ +conv_expr_t *build_conv_expr_from_name(char *); + +/* Conserve une valeur en tant qu'expression de conversion. */ +conv_expr_t *build_conv_expr_from_number(unsigned long ); + +/* Construit une base d'expression de conversion composée. */ +conv_expr_t *build_composed_conv_expr(char *, char *); + +/* Etend une base d'expression de conversion composée. */ +conv_expr_t *extend_composed_conv_expr(conv_expr_t *, char *); + +/* Traduit une opération unaire sur expression de conversion. */ +conv_expr_t *build_unary_conv_expr(conv_expr_t *, ConvUnaryOperation); + +/* Traduit une opération binaire sur expression de conversion. */ +conv_expr_t *build_binary_conv_expr(conv_expr_t *, conv_expr_t *, ConvBinaryOperation); + + + + + + + + +/* ------------------------ LISTES D'ARGUMENTS DE CONVERSION ------------------------ */ + + +/* Liste d'expressions utilisées en arguments de conversion */ +typedef struct _conv_arg_list_t conv_arg_list_t; + + +/* Crée une liste d'arguments de conversion. */ +conv_arg_list_t *build_conv_arg_list(conv_expr_t *); + +/* Libère la mémoire occupée par une liste d'expressions. */ +void delete_conv_arg_list(conv_arg_list_t *); + +/* Ajoute un élément à une liste d'arguments de conversion. */ +conv_arg_list_t *extend_conv_arg_list(conv_arg_list_t *, conv_expr_t *); + + + + +/* ---------------------------- CONVERSION DES ARGUMENTS ---------------------------- */ + + +/* Fonction de conversion */ +typedef struct _conv_func conv_func; + + +/* Définit une conversion à partir d'une simple expression. */ +conv_func *make_conv_from_expr(char *, conv_expr_t *); + +/* Définit une conversion à partir d'une function à appeler. */ +conv_func *make_conv_from_func(char *, char *, conv_arg_list_t *); + +/* Libère de la mémoire une conversion enregistrée. */ +void delete_conv_func(conv_func *); + +/* Indique la variable de destination d'une conversion. */ +const char *get_conv_dest_name(const conv_func *); + +/* Marque les champs utilisés par une fonction de conversion. */ +bool mark_conv_func(conv_func *, const coding_bits *, const conv_list *); + +/* Déclare les variables associées à une fonction de conversion. */ +bool declare_conv_func(conv_func *, int, const coding_bits *, const conv_list *, unsigned int); + +/* Définit les variables associées à une fonction de conversion. */ +bool define_conv_func(conv_func *, bool, bool, int, const char *, const coding_bits *, const conv_list *, const pre_processor *); + + + +/* ---------------------------- ENSEMBLES DE CONVERSIONS ---------------------------- */ + + +/* Crée un nouvelle liste vierge de fonctions de conversion. */ +conv_list *create_conv_list(void); + +/* Supprime de la mémoire une de fonctions de conversion. */ +void delete_conv_list(conv_list *); + +/* Enregistre une function de conversion du brut à l'utile. */ +void register_conversion(conv_list *, conv_func *); + +/* Recherche un résultat précis dans une liste de fonctions. */ +conv_func *find_named_conv_in_list(const conv_list *, const char *); + + + +#endif /* _TOOLS_CONV_H */ |