diff options
Diffstat (limited to 'src/format/dex')
| -rw-r--r-- | src/format/dex/dex-int.c | 67 | ||||
| -rwxr-xr-x | src/format/dex/dex-int.h | 6 | ||||
| -rwxr-xr-x | src/format/dex/dex_def.h | 15 | ||||
| -rw-r--r-- | src/format/dex/pool.c | 50 | 
4 files changed, 137 insertions, 1 deletions
diff --git a/src/format/dex/dex-int.c b/src/format/dex/dex-int.c index 025429f..8f5b408 100644 --- a/src/format/dex/dex-int.c +++ b/src/format/dex/dex-int.c @@ -354,6 +354,73 @@ bool read_dex_encoded_method(const GDexFormat *format, off_t *pos, encoded_metho  *                pos    = position de début de lecture. [OUT]                 *  *                item   = structure lue à retourner. [OUT]                    *  *                                                                             * +*  Description : Procède à la lecture d'un type DEX.                          * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +bool read_dex_type_item(const GDexFormat *format, off_t *pos, type_item *item) +{ +    bool result;                            /* Bilan à retourner           */ +    const bin_t *content;                   /* Contenu binaire à lire      */ +    off_t length;                           /* Taille totale du contenu    */ + +    result = true; + +    content = G_BIN_FORMAT(format)->content; +    length = G_BIN_FORMAT(format)->length; + +    result &= read_u16(&item->type_idx, content, pos, length, SRE_LITTLE); + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : format = informations chargées à consulter.                  * +*                pos    = position de début de lecture. [OUT]                 * +*                list   = structure lue à retourner. [OUT]                    * +*                                                                             * +*  Description : Procède à la lecture d'une liste de types DEX.               * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +bool read_dex_type_list(const GDexFormat *format, off_t *pos, type_list *list) +{ +    bool result;                            /* Bilan à retourner           */ +    const bin_t *content;                   /* Contenu binaire à lire      */ +    off_t length;                           /* Taille totale du contenu    */ + +    result = true; + +    content = G_BIN_FORMAT(format)->content; +    length = G_BIN_FORMAT(format)->length; + +    result &= read_u32(&list->size, content, pos, length, SRE_LITTLE); + +    list->list = (type_item *)&content[*pos]; +    result &= ((*pos + list->size * sizeof(type_item)) <= length); + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : format = informations chargées à consulter.                  * +*                pos    = position de début de lecture. [OUT]                 * +*                item   = structure lue à retourner. [OUT]                    * +*                                                                             *  *  Description : Procède à la lecture d'un contenu de classe DEX.             *  *                                                                             *  *  Retour      : Bilan de l'opération.                                        * diff --git a/src/format/dex/dex-int.h b/src/format/dex/dex-int.h index 2e3cc00..4b15c83 100755 --- a/src/format/dex/dex-int.h +++ b/src/format/dex/dex-int.h @@ -94,6 +94,12 @@ bool read_dex_encoded_field(const GDexFormat *, off_t *, encoded_field *);  /* Procède à la lecture d'une méthode quelconque DEX. */  bool read_dex_encoded_method(const GDexFormat *, off_t *, encoded_method *); +/* Procède à la lecture d'un type DEX. */ +bool read_dex_type_item(const GDexFormat *, off_t *, type_item *); + +/* Procède à la lecture d'une liste de types DEX. */ +bool read_dex_type_list(const GDexFormat *, off_t *, type_list *); +  /* Procède à la lecture d'un contenu de classe DEX. */  bool read_dex_class_data_item(const GDexFormat *, off_t *, class_data_item *); diff --git a/src/format/dex/dex_def.h b/src/format/dex/dex_def.h index 9faf050..3f6950d 100755 --- a/src/format/dex/dex_def.h +++ b/src/format/dex/dex_def.h @@ -117,6 +117,21 @@ typedef struct _encoded_method  } encoded_method; +/* Type quelconque */ +typedef struct _type_item +{ +    uint16_t type_idx;                      /* Indice dans la table adaptée*/ + +} type_item; + +/* Liste de types */ +typedef struct _type_list +{ +    uint32_t size;                          /* Nombre d'éléments présents  */ +    type_item *list;                        /* Liste des éléments inscrits */ + +} type_list; +  /* Données de fonctionnement pour classe */  typedef struct _class_data_item  { diff --git a/src/format/dex/pool.c b/src/format/dex/pool.c index b2ca105..d82144f 100644 --- a/src/format/dex/pool.c +++ b/src/format/dex/pool.c @@ -92,7 +92,7 @@ GOpenidaType *get_type_from_dex_pool(const GDexFormat *format, uint16_t index)      string_data_item str_data;              /* Description de chaîne       */ -    //printf("Index :: 0x%04hx\n", index); +    //printf("Tp Index :: %hd / %d\n", index, format->header.type_ids_size);      if (index >= format->header.type_ids_size) @@ -255,6 +255,12 @@ GBinRoutine *get_routine_from_dex_pool(const GDexFormat *format, uint32_t index)      string_id_item str_id;                  /* Identifiant de chaîne       */      string_data_item str_data;              /* Description de chaîne       */ + +    proto_id_item proto_id;                 /* Information de prototypage  */ +    type_list args;                         /* Liste des arguments         */ +    uint32_t i;                             /* Boucle de parcours          */ +    GBinVariable *arg;                      /* Argument reconstitué        */ +      if (index >= format->header.method_ids_size)          return NULL; @@ -302,8 +308,50 @@ GBinRoutine *get_routine_from_dex_pool(const GDexFormat *format, uint32_t index)          g_binary_routine_set_namespace(result, type); + +    /* +    printf("  ####\n"); +    printf("  ####  ROUTINE '%s'\n", g_binary_routine_to_string(result)); +    printf("  ####\n"); +    printf("  ####\n"); +    */ +      //printf("==>>> routine :: '%s'\n", g_binary_routine_to_string(result)); + + + + + + +    /* Retour de la routine */ + +    pos = format->header.proto_ids_off + meth_id.proto_idx * sizeof(proto_id_item); + +    if (!read_dex_proto_id_item(format, &pos, &proto_id)) +        goto no_more_info; + +    type = get_type_from_dex_pool(format, proto_id.return_type_idx); + +    g_binary_routine_set_return_type(result, type); + +    /* Arguments de la routine */ + +    pos = proto_id.parameters_off; + +    if (read_dex_type_list(format, &pos, &args)) +        for (i = 0; i < args.size; i++) +        { +            type = get_type_from_dex_pool(format, args.list[i].type_idx); +            if (type == NULL) continue; + +            arg = g_binary_variable_new(type); +            g_binary_routine_add_arg(result, arg); + +        } + + no_more_info: +      return result;  }  | 
