diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/d2c/conv.c | 2 | ||||
| -rw-r--r-- | tools/d2c/macros.c | 167 | ||||
| -rw-r--r-- | tools/d2c/macros.h | 30 | 
3 files changed, 1 insertions, 198 deletions
diff --git a/tools/d2c/conv.c b/tools/d2c/conv.c index 9947593..3fae6df 100644 --- a/tools/d2c/conv.c +++ b/tools/d2c/conv.c @@ -358,7 +358,7 @@ bool define_conv_func(conv_func *func, bool last, bool internal, int fd, const c      {          /* Si l'on doit manipuler une propriété d'instructon... */          if (internal) -            result = call_instr_func(callable, func->args, fd, bits, list, pp); +            result = checked_call_instr_func(callable, func->args, fd, bits, list, pp);          /* Si on doit constituer un opérande à ajouter... */          else diff --git a/tools/d2c/macros.c b/tools/d2c/macros.c deleted file mode 100644 index b1c44f0..0000000 --- a/tools/d2c/macros.c +++ /dev/null @@ -1,167 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * pproc.c - remplacements à la volée de chaînes de caractères - * - * 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/>. - */ - - -#include "pproc.h" - - -#include <malloc.h> - - - - - - -/* Conversion des chaînes en chaînes */ -typedef struct _string_exch -{ -    const char *src;                        /* Chaîne à trouver            */ -    const char *dest;                       /* Chaîne de remplacement      */ - -} string_exch; - - -/* Pré-processeur avec support des macros */ -struct _pre_processor -{ -    string_exch *macros;                    /* Remplacements de chaînes    */ -    size_t macros_count;                    /* Nombre de ces remplacements */ - - - -} - - - - - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : -                                                            * -*                                                                             * -*  Description : Crée un nouveau suivi de l'encodage d'une instruction.       * -*                                                                             * -*  Retour      : Nouvelle structure prête à emploi.                           * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -encoding_spec *create_encoding_spec(void) -{ -    encoding_spec *result;                  /* Définition vierge à renvoyer*/ - -    result = (encoding_spec *)calloc(1, sizeof(encoding_spec)); - -    result->bits = create_coding_bits(); -    result->syntax = create_asm_syntax(); -    result->conversions = create_conv_list(); -    result->rules = create_decoding_rules(); - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : spec = spécification d'encodage à libérer de la mémoire.     * -*                                                                             * -*  Description : Supprime de la mémoire un suivi d'encodage d'une instruction.* -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void delete_encoding_spec(encoding_spec *spec) -{ -    delete_coding_bits(spec->bits); -    delete_asm_syntax(spec->syntax); -    delete_conv_list(spec->conversions); -    delete_decoding_rules(spec->rules); - -    free(spec); - -} - - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : coder = gestion par la machine en remplacement de l'humain.  * -*                src   = chaîne à remplacer dans les définitions.             * -*                dest  = chaîne de remplacement.                              * -*                                                                             * -*  Description : Constitue la matière d'un système de macros.                 * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void define_macro_for_coder(rented_coder *coder, const char *src, const char *dest) -{ -    string_exch *macro;                     /* Nouvelle macro à constituer */ - -    coder->macros = (string_exch *)realloc(coder->macros, ++coder->macros_count * sizeof(string_exch)); - -    macro = &coder->macros[coder->macros_count - 1]; - -    macro->src = src; -    macro->dest = dest; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : coder = gestion par la machine en remplacement de l'humain.  * -*                src   = chaîne à remplacer dans les définitions.             * -*                                                                             * -*  Description : Recherche l'existence d'une macro pour un remplacement.      * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static const char *find_macro_in_coder(const rented_coder *coder, const char *src) -{ -    const char *result;                     /* Trouvaille à renvoyer       */ -    size_t i;                               /* Boucle de parcours          */ - -    result = NULL; - -    for (i = 0; i < coder->macros_count && result == NULL; i++) -        if (strcmp(coder->macros[i].src, src) == 0) -            result = coder->macros[i].dest; - -    return result; - -} - - diff --git a/tools/d2c/macros.h b/tools/d2c/macros.h deleted file mode 100644 index 3755f00..0000000 --- a/tools/d2c/macros.h +++ /dev/null @@ -1,30 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * macros.h - prototypes pour les remplacements à la volée de chaînes de caractères - * - * 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_MACROS_H -#define _TOOLS_MACROS_H - - - - -#endif  /* _TOOLS_MACROS_H */  | 
