diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/analysis/binary.c | 23 | ||||
| -rw-r--r-- | src/analysis/binary.h | 3 | ||||
| -rw-r--r-- | src/analysis/disass/area.c | 25 | ||||
| -rw-r--r-- | src/analysis/disass/fetch.c | 7 | ||||
| -rw-r--r-- | src/arch/processor.c | 18 | ||||
| -rw-r--r-- | src/arch/processor.h | 12 | ||||
| -rw-r--r-- | src/glibext/gbincontent.c | 23 | ||||
| -rw-r--r-- | src/glibext/gbincontent.h | 3 | 
8 files changed, 54 insertions, 60 deletions
| diff --git a/src/analysis/binary.c b/src/analysis/binary.c index 7e16990..e5b9a46 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -938,29 +938,6 @@ const char *g_loaded_binary_get_name(const GLoadedBinary *binary, bool full)  /******************************************************************************  *                                                                             *  *  Paramètres  : binary = élément binaire à consulter.                        * -*                length = taille en octets des données chargées. [OUT]        * -*                                                                             * -*  Description : Fournit les détails du contenu binaire chargé en mémoire.    * -*                                                                             * -*  Retour      : Pointeur vers le début des données.                          * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bin_t *g_loaded_binary_get_data(const GLoadedBinary *binary, off_t *length) -{ -    if (length != NULL) -        *length = binary->bin_length; - -    return binary->bin_data; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : binary = élément binaire à consulter.                        *  *                                                                             *  *  Description : Fournit le format de fichier reconnu dans le contenu binaire.*  *                                                                             * diff --git a/src/analysis/binary.h b/src/analysis/binary.h index 163caaa..b67881c 100644 --- a/src/analysis/binary.h +++ b/src/analysis/binary.h @@ -151,9 +151,6 @@ void g_loaded_binary_analyse(GLoadedBinary *);  /* Fournit le nom associé à l'élément binaire. */  const char *g_loaded_binary_get_name(const GLoadedBinary *, bool); -/* Fournit les détails du contenu binaire chargé en mémoire. */ -bin_t *g_loaded_binary_get_data(const GLoadedBinary *, off_t *); -  /* Fournit le format de fichier reconnu dans le contenu binaire. */  GExeFormat *g_loaded_binary_get_format(const GLoadedBinary *); diff --git a/src/analysis/disass/area.c b/src/analysis/disass/area.c index 4c54a27..a7c44c0 100644 --- a/src/analysis/disass/area.c +++ b/src/analysis/disass/area.c @@ -474,8 +474,7 @@ bool load_code_from_mem_area(mem_area **list, size_t *count, size_t *index, cons      GBinFormat *format;                     /* Format du fichier binaire   */      GArchProcessor *proc;                   /* Architecture du binaire     */ -    off_t bin_length;                       /* Taille des données à lire   */ -    bin_t *bin_data;                        /* Données binaires à lire     */ +    GBinContent *content;                   /* Données binaires à lire     */      phys_t diff;                            /* Volume de données traité    */      phys_t alen;                            /* Taille de l'aire utilisée   */ @@ -510,7 +509,8 @@ bool load_code_from_mem_area(mem_area **list, size_t *count, size_t *index, cons      format = G_BIN_FORMAT(g_loaded_binary_get_format(binary));      proc = g_loaded_binary_get_processor(binary); -    bin_data = g_loaded_binary_get_data(binary, &bin_length); +    content = g_binary_format_get_conten_(format); +    /* TODO : unref */      area = (*list) + *index; @@ -532,8 +532,6 @@ bool load_code_from_mem_area(mem_area **list, size_t *count, size_t *index, cons      printf(" START @ 0x%08x\n", (unsigned int)get_virt_addr(&pos)); -    bin_length = (get_phy_addr(get_mrange_addr(&area->range)) + alen); -      for (i = diff; i < alen; i += diff)      { @@ -544,7 +542,9 @@ bool load_code_from_mem_area(mem_area **list, size_t *count, size_t *index, cons          copy_vmpa(&prev, &pos); -        instr = g_arch_processor_disassemble(proc, ctx, bin_data, &pos, bin_length); +        instr = g_arch_processor_disassemble(proc, ctx, content, &pos); + +        /* TODO : valider que la taille de l'instruction obtenue ne dépasse pas la zone */          //printf(" @ 0x%08x -> %p\n", (uint32_t)get_virt_addr(&prev), instr); @@ -660,10 +660,9 @@ bool load_code_from_mem_area(mem_area **list, size_t *count, size_t *index, cons  static void load_data_from_mem_area(mem_area *area, mem_area *list, size_t count, const GLoadedBinary *binary, GProcContext *ctx, const vmpa2t *start, status_blob_info *info)  {      GBinFormat *format;                     /* Format du fichier binaire   */ +    GBinContent *content;                   /* Données binaires à lire     */      GArchProcessor *proc;                   /* Architecture du binaire     */      SourceEndian endianness;                /* Boutisme de cette machine   */ -    off_t bin_length;                       /* Taille des données à lire   */ -    bin_t *bin_data;                        /* Données binaires à lire     */      phys_t diff;                            /* Volume de données traité    */      phys_t alen;                            /* Taille de l'aire utilisée   */      phys_t i;                               /* Boucle de parcours          */ @@ -681,13 +680,13 @@ static void load_data_from_mem_area(mem_area *area, mem_area *list, size_t count      /* Récupération des informations de base */      format = G_BIN_FORMAT(g_loaded_binary_get_format(binary)); +    content = g_binary_format_get_conten_(format); +    /* TODO g_object_unref(G_OBJECT(format)); */      proc = g_loaded_binary_get_processor(binary);      endianness = g_arch_processor_get_endianness(proc);      g_object_unref(G_OBJECT(proc)); -    bin_data = g_loaded_binary_get_data(binary, &bin_length); -      diff = compute_vmpa_diff(get_mrange_addr(&area->range), start);      alen = get_mrange_length(&area->range); @@ -718,7 +717,7 @@ static void load_data_from_mem_area(mem_area *area, mem_area *list, size_t count              init_mrange(&range, &pos, 4);              if (is_range_blank_in_mem_areas(list, count, &range)) -                instr = g_raw_instruction_new_array_old(bin_data, MDS_32_BITS, 1, &pos, bin_length, endianness); +                instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endianness);          }          */ @@ -728,7 +727,7 @@ static void load_data_from_mem_area(mem_area *area, mem_area *list, size_t count              init_mrange(&range, &pos, 2);              if (is_range_blank_in_mem_areas(list, count, &range)) -                instr = g_raw_instruction_new_array_old(bin_data, MDS_16_BITS, 1, &pos, bin_length, endianness); +                instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endianness);          } @@ -738,7 +737,7 @@ static void load_data_from_mem_area(mem_area *area, mem_area *list, size_t count              init_mrange(&range, &pos, 1);              if (is_range_blank_in_mem_areas(list, count, &range)) -                instr = g_raw_instruction_new_array_old(bin_data, MDS_8_BITS, 1, &pos, bin_length, endianness); +                instr = g_raw_instruction_new_array(content, MDS_8_BITS, 1, &pos, endianness);              else              {                  /** diff --git a/src/analysis/disass/fetch.c b/src/analysis/disass/fetch.c index b30d5a6..d7de724 100644 --- a/src/analysis/disass/fetch.c +++ b/src/analysis/disass/fetch.c @@ -148,7 +148,8 @@ GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, GtkExt      GBinFormat *format;                     /* Format du fichier binaire   */      GArchProcessor *proc;                   /* Architecture du binaire     */      GProcContext *ctx;                      /* Contexte de désassemblage   */ -    off_t length;                           /* Taille des données à lire   */ +    GBinContent *content;                   /* Contenu binaire à manipuler */ +    phys_t length;                          /* Taille des données à lire   */      mem_area *areas;                        /* Zone de productions         */      size_t count;                           /* Nombre de ces zones         */      status_blob_info *info;                 /* Informations de progression */ @@ -168,7 +169,9 @@ GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, GtkExt      /* Définition à la découpe des parties à traiter */ -    g_loaded_binary_get_data(binary, &length); +    content = g_binary_format_get_conten_(format); +    length = g_binary_content_compute_size(content); +      areas = compute_memory_areas(G_EXE_FORMAT(format), length, &count);      /** diff --git a/src/arch/processor.c b/src/arch/processor.c index 2c86ffe..86e7845 100644 --- a/src/arch/processor.c +++ b/src/arch/processor.c @@ -269,11 +269,10 @@ GArchInstruction *g_arch_processor_decode_instruction(const GArchProcessor *proc  /******************************************************************************  *                                                                             * -*  Paramètres  : proc = architecture visée par la procédure.                  * -*                ctx  = contexte lié à l'exécution du processeur.             * -*                data = flux de données à analyser.                           * -*                pos  = position courante dans ce flux. [OUT]                 * -*                end  = limite des données à analyser.                        * +*  Paramètres  : proc    = architecture visée par la procédure.               * +*                ctx     = contexte lié à l'exécution du processeur.          * +*                content = flux de données à analyser.                        * +*                pos     = position courante dans ce flux. [OUT]              *  *                                                                             *  *  Description : Désassemble une instruction dans un flux de données.         *  *                                                                             * @@ -283,14 +282,19 @@ GArchInstruction *g_arch_processor_decode_instruction(const GArchProcessor *proc  *                                                                             *  ******************************************************************************/ -GArchInstruction *g_arch_processor_disassemble(const GArchProcessor *proc, GProcContext *ctx, const bin_t *data, vmpa2t *pos, phys_t end) +GArchInstruction *g_arch_processor_disassemble(const GArchProcessor *proc, GProcContext *ctx, const GBinContent *content, vmpa2t *pos)  {      GArchInstruction *result;               /* Instruction à renvoyer      */      vmpa2t back;                            /* Position sauvegardée        */ +    /* FIXME */ +    const bin_t *_bin_data; +    off_t _bin_length;      copy_vmpa(&back, pos); -    result = G_ARCH_PROCESSOR_GET_CLASS(proc)->disassemble(proc, ctx, data, pos, end); +    _bin_data = g_binary_content_get(content, &_bin_length); + +    result = G_ARCH_PROCESSOR_GET_CLASS(proc)->disassemble(proc, ctx, _bin_data, pos, _bin_length);      if (result == NULL)          copy_vmpa(pos, &back); diff --git a/src/arch/processor.h b/src/arch/processor.h index a856942..f7d474a 100644 --- a/src/arch/processor.h +++ b/src/arch/processor.h @@ -74,17 +74,7 @@ MemoryDataSize g_arch_processor_get_instruction_size(const GArchProcessor *);  GArchInstruction *g_arch_processor_decode_instruction(const GArchProcessor *, GProcContext *, const bin_t *, off_t *, off_t, vmpa_t, GBinFormat *) __attribute__ ((deprecated));  /* Désassemble une instruction dans un flux de données. */ -GArchInstruction *g_arch_processor_disassemble(const GArchProcessor *, GProcContext *, const bin_t *, vmpa2t *, phys_t) __attribute__ ((deprecated)); - - - -#define g_arch_processor_disassemble_nextgen(_proc, _ctx, _cnt, _pos)               \ -    ({                                                                              \ -        const bin_t *_bin_data;                                                     \ -        off_t _bin_length;                                                          \ -        _bin_data = g_binary_content_get(_cnt, &_bin_length);                       \ -        g_arch_processor_disassemble(_proc, _ctx, _bin_data, _pos, _bin_length);    \ -    }) +GArchInstruction *g_arch_processor_disassemble(const GArchProcessor *, GProcContext *, const GBinContent *, vmpa2t *); diff --git a/src/glibext/gbincontent.c b/src/glibext/gbincontent.c index a9fe907..4ea0b03 100644 --- a/src/glibext/gbincontent.c +++ b/src/glibext/gbincontent.c @@ -257,7 +257,7 @@ GBinContent *g_binary_content_new_from_file(const char *filename)  /******************************************************************************  *                                                                             * -*  Paramètres  : binary = contenu binaire à consulter.                        * +*  Paramètres  : content = contenu binaire à venir lire.                      *  *                                                                             *  *  Description : Fournit une empreinte unique (SHA256) pour les données.      *  *                                                                             * @@ -292,10 +292,31 @@ const gchar *g_binary_content_get_cheksum(GBinContent *content) +/****************************************************************************** +*                                                                             * +*  Paramètres  : content = contenu binaire à venir lire.                      * +*                                                                             * +*  Description : Détermine le nombre d'octets lisibles.                       * +*                                                                             * +*  Retour      : Quantité représentée.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +phys_t g_binary_content_compute_size(const GBinContent *content) +{ +    phys_t result;                          /* Quantité trouvée à retourner*/ +    size_t i;                               /* Boucle de parcours          */ +    result = 0; +    for (i = 0; i < content->count; i++) +        result = get_mrange_length(&content->parts[i].range); +    return result; +}  /****************************************************************************** diff --git a/src/glibext/gbincontent.h b/src/glibext/gbincontent.h index 246d626..9dd7264 100644 --- a/src/glibext/gbincontent.h +++ b/src/glibext/gbincontent.h @@ -59,6 +59,9 @@ GBinContent *g_binary_content_new_from_file(const char *);  /* Fournit une empreinte unique (SHA256) pour les données. */  const gchar *g_binary_content_get_cheksum(GBinContent *); +/* Détermine le nombre d'octets lisibles. */ +phys_t g_binary_content_compute_size(const GBinContent *); +  /* Fournit une portion des données représentées. */  bool g_binary_content_get_raw(const GBinContent *, vmpa2t *, phys_t, bin_t *); | 
