diff options
Diffstat (limited to 'src/format')
| -rwxr-xr-x | src/format/dex/dex.c | 8 | ||||
| -rw-r--r-- | src/format/dex/pool.c | 38 | ||||
| -rw-r--r-- | src/format/dex/pool.h | 3 | ||||
| -rw-r--r-- | src/format/symbol.c | 2 | 
4 files changed, 50 insertions, 1 deletions
| diff --git a/src/format/dex/dex.c b/src/format/dex/dex.c index b286f7c..f0fb421 100755 --- a/src/format/dex/dex.c +++ b/src/format/dex/dex.c @@ -197,6 +197,14 @@ GBinFormat *g_dex_format_new(const bin_t *content, off_t length)      g_dex_format_find_all_sources(result); + +    if (!find_all_dex_strings(result)) +    { +        g_object_unref(G_OBJECT(result)); +        return NULL; +    } + +      return G_BIN_FORMAT(result);  } diff --git a/src/format/dex/pool.c b/src/format/dex/pool.c index 9237839..f8c5a4a 100644 --- a/src/format/dex/pool.c +++ b/src/format/dex/pool.c @@ -24,6 +24,9 @@  #include "pool.h" +#include <string.h> + +  #include "dex-int.h"  #include "../mangling/demangler.h" @@ -31,6 +34,41 @@  /******************************************************************************  *                                                                             * +*  Paramètres  : format = description de l'exécutable à analyser.             * +*                                                                             * +*  Description : Charge en mémoire toutes les chaînes trouvées.               * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +bool find_all_dex_strings(GDexFormat *format) +{ +    uint32_t i;                             /* Boucle de parcours          */ +    const char *text;                       /* Texte issu du binaire       */ +    GBinSymbol *symbol;                     /* Nouveau symbole construit   */ + +    for (i = 0; i < format->header.string_ids_size; i++) +    { +        text = get_string_from_dex_pool(format, i); +        if (text == NULL) continue; + +        symbol = g_binary_symbol_new(STP_STRING, NULL, i); +        g_binary_symbol_set_alt_name(symbol, strdup(text)); + +        g_binary_format_add_symbol(G_BIN_FORMAT(format), symbol); + +    } + +    return true; + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : format = représentation interne du format DEX à consulter.   *  *                index  = index du type recherchée.                           *  *                                                                             * diff --git a/src/format/dex/pool.h b/src/format/dex/pool.h index 6894da1..62c3aef 100644 --- a/src/format/dex/pool.h +++ b/src/format/dex/pool.h @@ -30,6 +30,9 @@ +/* Charge en mémoire toutes les chaînes trouvées. */ +bool find_all_dex_strings(GDexFormat *); +  /* Extrait une chaîne de caractères d'une table DEX. */  const char *get_string_from_dex_pool(const GDexFormat *, uint32_t); diff --git a/src/format/symbol.c b/src/format/symbol.c index 3ac2d6d..986586c 100644 --- a/src/format/symbol.c +++ b/src/format/symbol.c @@ -247,7 +247,7 @@ off_t g_binary_symbol_get_size(const GBinSymbol *symbol)  void g_binary_symbol_set_alt_name(GBinSymbol *symbol, char *alt)  { -    return symbol->alt = alt; +    symbol->alt = alt;  } | 
