diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2016-09-11 21:37:36 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2016-09-11 21:37:36 (GMT) | 
| commit | 0f1473cba267ad809c8e7d207b5ff5e3998745fc (patch) | |
| tree | 8aea43688d78c10ee7758e2feed80be9abbfaaf6 /src/format | |
| parent | fe39a487b4db5564036a436bfcb7cf3561889fb5 (diff) | |
Displayed more details about the loading process in the status bar.
Diffstat (limited to 'src/format')
| -rwxr-xr-x | src/format/dex/dex.c | 8 | ||||
| -rw-r--r-- | src/format/dex/pool.c | 36 | ||||
| -rw-r--r-- | src/format/dex/pool.h | 9 | ||||
| -rw-r--r-- | src/format/elf/elf.c | 9 | ||||
| -rw-r--r-- | src/format/format-int.h | 2 | ||||
| -rw-r--r-- | src/format/format.c | 5 | 
6 files changed, 50 insertions, 19 deletions
diff --git a/src/format/dex/dex.c b/src/format/dex/dex.c index 3388861..582390a 100755 --- a/src/format/dex/dex.c +++ b/src/format/dex/dex.c @@ -265,16 +265,16 @@ GBinFormat *g_dex_format_new(GBinContent *content, GExeFormat *parent, GtkStatus      /* TODO : vérifier que les *_id ne se chevauchent pas */ -    if (!load_all_dex_types(result)) +    if (!load_all_dex_types(result, status))          goto gdfn_error; -    if (!load_all_dex_fields(result)) +    if (!load_all_dex_fields(result, status))          goto gdfn_error; -    if (!load_all_dex_classes(result)) +    if (!load_all_dex_classes(result, status))          goto gdfn_error; -    if (!g_binary_format_complete_loading(base)) +    if (!g_binary_format_complete_loading(base, status))          goto gdfn_error;      return base; diff --git a/src/format/dex/pool.c b/src/format/dex/pool.c index 3842aa9..f624ff3 100644 --- a/src/format/dex/pool.c +++ b/src/format/dex/pool.c @@ -28,6 +28,9 @@  #include <string.h> +#include <i18n.h> + +  #include "dex-int.h"  #include "../mangling/demangler.h"  #include "../mangling/dex/context.h" @@ -122,6 +125,7 @@ const char *get_string_from_dex_pool(const GDexFormat *format, uint32_t index)  /******************************************************************************  *                                                                             *  *  Paramètres  : format = description de l'exécutable à compléter.            * +                 status = barre de statut à tenir informée.                   *  *                                                                             *  *  Description : Charge en mémoire l'ensemble des types du format DEX.        *  *                                                                             * @@ -131,9 +135,10 @@ const char *get_string_from_dex_pool(const GDexFormat *format, uint32_t index)  *                                                                             *  ******************************************************************************/ -bool load_all_dex_types(GDexFormat *format) +bool load_all_dex_types(GDexFormat *format, GtkStatusStack *status)  {      bool result;                            /* Bilan à retourner           */ +    activity_id_t msg;                      /* Message de progression      */      uint32_t i;                             /* Boucle de parcours          */      GDataType *type;                        /* Type récupéré               */ @@ -141,6 +146,9 @@ bool load_all_dex_types(GDexFormat *format)      format->types = (GDataType **)calloc(format->header.type_ids_size, sizeof(GDataType *)); +    msg = gtk_status_stack_add_activity(status, _("Loading all types from the Dex pool..."), +                                        format->header.type_ids_size); +      for (i = 0; i < format->header.type_ids_size && result; i++)      {          type = get_type_from_dex_pool(format, i); @@ -150,8 +158,12 @@ bool load_all_dex_types(GDexFormat *format)          else              result = false; +        gtk_status_stack_update_activity_value(status, msg, 1); +      } +    gtk_status_stack_remove_activity(status, msg); +      return result;  } @@ -223,6 +235,7 @@ GDataType *get_type_from_dex_pool(GDexFormat *format, uint32_t index)  /******************************************************************************  *                                                                             *  *  Paramètres  : format = description de l'exécutable à compléter.            * +*                status = barre de statut à tenir informée.                   *  *                                                                             *  *  Description : Charge en mémoire l'ensemble des champs du format DEX.       *  *                                                                             * @@ -232,9 +245,10 @@ GDataType *get_type_from_dex_pool(GDexFormat *format, uint32_t index)  *                                                                             *  ******************************************************************************/ -bool load_all_dex_fields(GDexFormat *format) +bool load_all_dex_fields(GDexFormat *format, GtkStatusStack *status)  {      bool result;                            /* Bilan à retourner           */ +    activity_id_t msg;                      /* Message de progression      */      uint32_t i;                             /* Boucle de parcours          */      GBinVariable *field;                    /* Champ récupéré              */ @@ -242,6 +256,9 @@ bool load_all_dex_fields(GDexFormat *format)      format->fields = (GBinVariable **)calloc(format->header.field_ids_size, sizeof(GBinVariable *)); +    msg = gtk_status_stack_add_activity(status, _("Loading all fields from the Dex pool..."), +                                        format->header.field_ids_size); +      for (i = 0; i < format->header.field_ids_size && result; i++)      {          field = get_field_from_dex_pool(format, i); @@ -251,8 +268,12 @@ bool load_all_dex_fields(GDexFormat *format)          else              result = false; +        gtk_status_stack_update_activity_value(status, msg, 1); +      } +    gtk_status_stack_remove_activity(status, msg); +      return result;  } @@ -495,6 +516,7 @@ GDexMethod *get_method_from_dex_pool(GDexFormat *format, uint32_t index)  /******************************************************************************  *                                                                             *  *  Paramètres  : format = représentation interne du format DEX à compléter.   * +*                status = barre de statut à tenir informée.                   *  *                                                                             *  *  Description : Charge toutes les classes listées dans le contenu binaire.   *  *                                                                             * @@ -504,9 +526,10 @@ GDexMethod *get_method_from_dex_pool(GDexFormat *format, uint32_t index)  *                                                                             *  ******************************************************************************/ -bool load_all_dex_classes(GDexFormat *format) +bool load_all_dex_classes(GDexFormat *format, GtkStatusStack *status)  {      bool result;                            /* Bilan à retourner           */ +    activity_id_t msg;                      /* Message de progression      */      uint32_t i;                             /* Boucle de parcours          */      GDexClass *class;                       /* Classe récupérée            */ @@ -514,6 +537,9 @@ bool load_all_dex_classes(GDexFormat *format)      format->classes = (GDexClass **)calloc(format->header.class_defs_size, sizeof(GDexClass *)); +    msg = gtk_status_stack_add_activity(status, _("Loading all classes from the Dex pool..."), +                                        format->header.class_defs_size); +      for (i = 0; i < format->header.class_defs_size && result; i++)      {          class = get_class_from_dex_pool(format, i); @@ -523,8 +549,12 @@ bool load_all_dex_classes(GDexFormat *format)          else              result = false; +        gtk_status_stack_update_activity_value(status, msg, 1); +      } +    gtk_status_stack_remove_activity(status, msg); +      return result;  } diff --git a/src/format/dex/pool.h b/src/format/dex/pool.h index 8043153..4b804cc 100644 --- a/src/format/dex/pool.h +++ b/src/format/dex/pool.h @@ -43,13 +43,13 @@ const char *get_string_from_dex_pool(const GDexFormat *, uint32_t);  /* Charge en mémoire l'ensemble des types du format DEX. */ -bool load_all_dex_types(GDexFormat *); +bool load_all_dex_types(GDexFormat *, GtkStatusStack *);  /* Extrait une représentation de type d'une table DEX. */  GDataType *get_type_from_dex_pool(GDexFormat *, uint32_t);  /* Charge en mémoire l'ensemble des champs du format DEX. */ -bool load_all_dex_fields(GDexFormat *); +bool load_all_dex_fields(GDexFormat *, GtkStatusStack *);  /* Extrait une représentation de champ d'une table DEX. */  GBinVariable *get_field_from_dex_pool(GDexFormat *, uint32_t); @@ -57,14 +57,11 @@ GBinVariable *get_field_from_dex_pool(GDexFormat *, uint32_t);  /* Extrait une représentation de routine d'une table DEX. */  GBinRoutine *get_prototype_from_dex_pool(GDexFormat *, uint32_t); -/* Charge toutes les méthodes listées dans le contenu binaire. */ -bool load_all_dex_methods(GDexFormat *); -  /* Extrait une représentation de méthode d'une table DEX. */  GDexMethod *get_method_from_dex_pool(GDexFormat *, uint32_t);  /* Charge toutes les classes listées dans le contenu binaire. */ -bool load_all_dex_classes(GDexFormat *); +bool load_all_dex_classes(GDexFormat *, GtkStatusStack *);  /* Extrait une représentation de classe d'une table DEX. */  GDexClass *get_class_from_dex_pool(GDexFormat *, uint32_t); diff --git a/src/format/elf/elf.c b/src/format/elf/elf.c index d09b845..7ea9417 100644 --- a/src/format/elf/elf.c +++ b/src/format/elf/elf.c @@ -243,10 +243,13 @@ static void g_elf_format_finalize(GElfFormat *format)  GBinFormat *g_elf_format_new(GBinContent *content, GExeFormat *parent, GtkStatusStack *status)  {      GElfFormat *result;                     /* Structure à retourner       */ +    GBinFormat *base;                       /* Version basique du format   */      result = g_object_new(G_TYPE_ELF_FORMAT, NULL); -    g_binary_format_set_content(G_BIN_FORMAT(result), content); +    base = G_BIN_FORMAT(result); + +    g_binary_format_set_content(base, content);      if (!read_elf_header(result, &result->header, &result->is_32b, &result->endian))      { @@ -302,10 +305,10 @@ GBinFormat *g_elf_format_new(GBinContent *content, GExeFormat *parent, GtkStatus      } -    if (!g_binary_format_complete_loading(G_BIN_FORMAT(result))) +    if (!g_binary_format_complete_loading(base, status))          goto gefn_error; -    return G_BIN_FORMAT(result); +    return base;   gefn_error: diff --git a/src/format/format-int.h b/src/format/format-int.h index b19749d..9282b3c 100644 --- a/src/format/format-int.h +++ b/src/format/format-int.h @@ -84,7 +84,7 @@ struct _GBinFormatClass  /* Effectue les ultimes opérations de chargement d'un binaire. */ -bool g_binary_format_complete_loading(GBinFormat *); +bool g_binary_format_complete_loading(GBinFormat *, GtkStatusStack *);  /* Définit le contenu binaire à analyser. */  void g_binary_format_set_content(GBinFormat *, GBinContent *); diff --git a/src/format/format.c b/src/format/format.c index ef8258f..5e5755c 100644 --- a/src/format/format.c +++ b/src/format/format.c @@ -107,6 +107,7 @@ static void g_binary_format_init(GBinFormat *format)  /******************************************************************************  *                                                                             *  *  Paramètres  : format = instance à traiter.                                 * +*                status = barre de statut à tenir informée.                   *  *                                                                             *  *  Description : Effectue les ultimes opérations de chargement d'un binaire.  *  *                                                                             * @@ -116,9 +117,9 @@ static void g_binary_format_init(GBinFormat *format)  *                                                                             *  ******************************************************************************/ -bool g_binary_format_complete_loading(GBinFormat *format) +bool g_binary_format_complete_loading(GBinFormat *format, GtkStatusStack *status)  { -    handle_binary_format(PGA_FORMAT_LOADER_LAST, format); +    handle_binary_format(PGA_FORMAT_LOADER_LAST, format, status);      g_binary_format_delete_duplicated_symbols(format);  | 
