diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/analysis/routine.c | 37 | ||||
| -rw-r--r-- | src/analysis/routine.h | 5 | ||||
| -rw-r--r-- | src/format/format.c | 44 | ||||
| -rw-r--r-- | src/format/format.h | 3 | 
4 files changed, 87 insertions, 2 deletions
diff --git a/src/analysis/routine.c b/src/analysis/routine.c index 7a191c9..d52b74a 100644 --- a/src/analysis/routine.c +++ b/src/analysis/routine.c @@ -48,6 +48,7 @@ struct _GBinRoutine      GDataType *namespace;                   /* Espace de noms / classe     */      char *name;                             /* Désignation humaine         */      GDataType *full_name;                   /* Désignation très complète   */ +    char *long_name;                        /* Désignation très complète ??*/      GBinVariable **args;                    /* Arguments de la routines    */      size_t args_count;                      /* Nombre d'arguments          */ @@ -421,7 +422,7 @@ void g_binary_routine_set_name(GBinRoutine *routine, char *name)  *                                                                             *  ******************************************************************************/ -const char *g_binary_routine_get_name(const GBinRoutine *routine) +const char *g_binary_routine_get_name(GBinRoutine *routine)  {      if (routine->name == NULL && routine->full_name != NULL)          g_binary_routine_set_name(routine, g_data_type_to_string(routine->full_name)); @@ -434,6 +435,40 @@ const char *g_binary_routine_get_name(const GBinRoutine *routine)  /******************************************************************************  *                                                                             *  *  Paramètres  : routine = routine à mettre à jour.                           * +*                                                                             * +*  Description : Fournit le nom long et humain d'une routine.                 * +*                                                                             * +*  Retour      : Désignation humainement lisible ou NULL si non définie.      * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +const char *g_binary_routine_get_long_name(GBinRoutine *routine) +{ +    if (routine->long_name == NULL) +    { +        if (routine->namespace != NULL) +        { +            routine->long_name = strdup(""); +            routine->long_name = g_data_type_to_string(routine->namespace); +            routine->long_name = stradd(routine->long_name, "." /* FIXME */); +        } +        else +            routine->long_name = strdup(""); + +        routine->long_name = stradd(routine->long_name, g_binary_routine_get_name(routine)); + +    } + +    return routine->long_name; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : routine = routine à mettre à jour.                           *  *                type    = désignation complète du nom de la routine.         *  *                                                                             *  *  Description : Définit de façon indirecte le nom humain d'une routine.      * diff --git a/src/analysis/routine.h b/src/analysis/routine.h index de28f38..c6de039 100644 --- a/src/analysis/routine.h +++ b/src/analysis/routine.h @@ -111,7 +111,10 @@ GDataType *g_binary_routine_get_namespace(const GBinRoutine *);  void g_binary_routine_set_name(GBinRoutine *, char *);  /* Désignation humainement lisible ou NULL si non définie. */ -const char *g_binary_routine_get_name(const GBinRoutine *); +const char *g_binary_routine_get_name(GBinRoutine *); + +/* Fournit le nom long et humain d'une routine. */ +const char *g_binary_routine_get_long_name(GBinRoutine *);  /* Définit de façon indirecte le nom humain d'une routine. */  void g_binary_routine_set_name_from_type(GBinRoutine *, GDataType *); diff --git a/src/format/format.c b/src/format/format.c index c7d95c4..79ef5dd 100644 --- a/src/format/format.c +++ b/src/format/format.c @@ -454,6 +454,50 @@ bool g_binary_format_resolve_symbol(const GBinFormat *format, const char **label  } +/****************************************************************************** +*                                                                             * +*  Paramètres  : format  = informations chargées à consulter.                 * +*                label   = étiquette du symbole si trouvé. [OUT]              * +*                address = adresse à cibler, puis décallage final. [OUT]      * +*                                                                             * +*  Description : Recherche une position dans une routine selon une adresse.   * +*                                                                             * +*  Retour      : true si l'opération a été un succès, false sinon.            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +bool g_binary_format_resolve_relative_routine(const GBinFormat *format, const char **label, vmpa_t *address) +{ +    bool result;                            /* Bilan à retourner           */ +    size_t i;                               /* Boucle de parcours          */ +    vmpa_t addr;                            /* Adresse de symbole          */ +    off_t size;                             /* Taille du symole            */ + +    result = false; + +    for (i = 0; i < format->routines_count && !result; i++) +    { +        addr = g_binary_routine_get_address(format->routines[i]); +        size = g_binary_routine_get_size(format->routines[i]); + +        if (addr <= *address && *address < (addr + size)) +        { +            *label = g_binary_routine_get_long_name(format->routines[i]); +            *address -= addr; + +            result = true; + +        } + +    } + +    return result; + +} + +  /* ---------------------------------------------------------------------------------- */  /*                         MANIPULATION D'ENSEMBLE DE FORMATS                         */ diff --git a/src/format/format.h b/src/format/format.h index ef85fbb..fec03ea 100644 --- a/src/format/format.h +++ b/src/format/format.h @@ -84,6 +84,9 @@ void g_binary_format_decompile(const GBinFormat *, GCodeBuffer *, const char *fi  /* Recherche le symbole correspondant à une adresse. */  bool g_binary_format_resolve_symbol(const GBinFormat *, const char **, SymbolType *, vmpa_t *); +/* Recherche une position dans une routine selon une adresse. */ +bool g_binary_format_resolve_relative_routine(const GBinFormat *, const char **, vmpa_t *); +  /* ----------------------- MANIPULATION D'ENSEMBLE DE FORMATS ----------------------- */  | 
