diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2014-09-21 21:26:42 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2014-09-21 21:26:42 (GMT) | 
| commit | 15c0cc127f0f4551c88de6c0d46b7d38f4b3ed4b (patch) | |
| tree | 5ae9be5d45152486b7cc594c192216bd393dd5b0 /src/format | |
| parent | 65768127dea4c2760fe07cf843da7b4ad9e67da5 (diff) | |
Showed information about a selected address in the status bar.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@407 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/format')
| -rw-r--r-- | src/format/format.c | 94 | ||||
| -rw-r--r-- | src/format/format.h | 6 | 
2 files changed, 48 insertions, 52 deletions
| diff --git a/src/format/format.c b/src/format/format.c index 4fec391..ff62b80 100644 --- a/src/format/format.c +++ b/src/format/format.c @@ -225,6 +225,51 @@ GBinSymbol **g_binary_format_get_symbols(const GBinFormat *format, size_t *count  /******************************************************************************  *                                                                             * +*  Paramètres  : format = informations chargées à consulter.                  * +*                addr   = adresse à cibler lors des recherches.               * +*                symbol = éventuel symbole trouvé à déréfenrencer. [OUT]      * +*                diff   = décallage entre l'adresse et le symbole. [OUT]      * +*                                                                             * +*  Description : Recherche le symbole correspondant à une adresse.            * +*                                                                             * +*  Retour      : true si l'opération a été un succès, false sinon.            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +bool g_binary_format_resolve_symbol(const GBinFormat *format, const vmpa2t *addr, GBinSymbol **symbol, phys_t *diff) +{ +    bool result;                            /* Bilan à retourner           */ +    size_t i;                               /* Boucle de parcours          */ +    const mrange_t *range;                  /* Espace mémoire parcouru     */ + +    result = false; + +    for (i = 0; i < format->symbols_count && !result; i++) +    { +        range = g_binary_symbol_get_range(format->symbols[i]); + +        if (mrange_contains_addr(range, addr)) +        { +            *symbol = format->symbols[i]; +            g_object_ref(G_OBJECT(*symbol)); + +            *diff = compute_vmpa_diff(get_mrange_addr(range), addr); + +            result = true; + +        } + +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : format  = informations chargées à compléter.                 *  *                routine = routine à ajouter à la liste.                      *  *                                                                             * @@ -351,55 +396,6 @@ void g_binary_format_decompile(const GBinFormat *format, GCodeBuffer *buffer, co  *                                                                             *  *  Paramètres  : format  = informations chargées à consulter.                 *  *                label   = étiquette du symbole si trouvé. [OUT]              * -*                type    = type du symbole trouvé. [OUT]                      * -*                address = adresse à cibler, puis décallage final. [OUT]      * -*                                                                             * -*  Description : Recherche le symbole correspondant à une adresse.            * -*                                                                             * -*  Retour      : true si l'opération a été un succès, false sinon.            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool g_binary_format_resolve_symbol(const GBinFormat *format, const char **label, SymbolType *type, 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->symbols_count && !result; i++) -    { -        addr = g_binary_symbol_get_address(format->symbols[i]); -        size = 0;//////g_binary_symbol_get_size(format->symbols[i]); - -        if (addr <= *address && *address < (addr + size)) -        { -            *label = g_binary_symbol_to_string(format->symbols[i]); -            *type = g_binary_symbol_get_target_type(format->symbols[i]); -            *address -= addr; - -            if (*type == STP_STRING) -                *label += *address; - -            result = true; - -        } - -    } - -    return result; - -} - - -/****************************************************************************** -*                                                                             * -*  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.   * diff --git a/src/format/format.h b/src/format/format.h index 2eed669..3c74b50 100644 --- a/src/format/format.h +++ b/src/format/format.h @@ -64,6 +64,9 @@ void g_binary_format_add_symbol(GBinFormat *, GBinSymbol *);  /* Fournit la liste de tous les symboles détectés. */  GBinSymbol **g_binary_format_get_symbols(const GBinFormat *, size_t *); +/* Recherche le symbole correspondant à une adresse. */ +bool g_binary_format_resolve_symbol(const GBinFormat *, const vmpa2t *, GBinSymbol **, phys_t *); +  /* Ajoute une routine à la collection du format binaire. */  void g_binary_format_add_routine(GBinFormat *, GBinRoutine *) __attribute__ ((deprecated)); @@ -76,9 +79,6 @@ const char * const *g_binary_format_get_source_files(const GBinFormat *, size_t  /* Procède à la décompilation complète du format. */  void g_binary_format_decompile(const GBinFormat *, GCodeBuffer *, const char *filename); -/* 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 *); | 
