diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2014-09-17 21:36:49 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2014-09-17 21:36:49 (GMT) | 
| commit | 65768127dea4c2760fe07cf843da7b4ad9e67da5 (patch) | |
| tree | d0023eb7f378a4118fd074f3f61d5eae02e0882b /src/analysis | |
| parent | af083f8bd6da340214ae392451dde5782fb79039 (diff) | |
Introduced memory ranges.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@406 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis')
| -rw-r--r-- | src/analysis/disass/fetch.c | 16 | ||||
| -rw-r--r-- | src/analysis/disass/limit.c | 2 | ||||
| -rw-r--r-- | src/analysis/disass/output.c | 14 | ||||
| -rw-r--r-- | src/analysis/routine.c | 64 | ||||
| -rw-r--r-- | src/analysis/routine.h | 17 | 
5 files changed, 51 insertions, 62 deletions
| diff --git a/src/analysis/disass/fetch.c b/src/analysis/disass/fetch.c index 55ea1d4..763b37a 100644 --- a/src/analysis/disass/fetch.c +++ b/src/analysis/disass/fetch.c @@ -70,6 +70,7 @@ GArchInstruction *load_raw_binary(const GLoadedBinary *binary, const vmpa2t *bas      off_t old_phy;                          /* Ancienne position physique  */      GArchInstruction *instr;                /* Instruction décodée         */      off_t new_phy;                          /* Nouvelle position physique  */ +    mrange_t range;                         /* Couverture de l'instruction */      result = NULL; @@ -90,8 +91,10 @@ GArchInstruction *load_raw_binary(const GLoadedBinary *binary, const vmpa2t *bas          if (instr == NULL) break;          new_phy = get_phy_addr(&pos); +        init_mrange(&range, &prev, new_phy - old_phy); + +        g_arch_instruction_set_range(instr, &range); -        g_arch_instruction_set_location(instr, &prev, new_phy - old_phy);          g_arch_instruction_add_to_list(&result, instr);          copy_vmpa(&prev, &pos); @@ -146,7 +149,7 @@ GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, GtkExt      size_t i;                               /* Boucle de parcours          */ - +    const mrange_t *range;                  /* Couverture d'un symbole     */      const vmpa2t *border;                   /* Nouvelle bordure rencontrée */      off_t length;                           /* Taille d'une partie traitée */ @@ -183,7 +186,14 @@ GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, GtkExt -        border = g_binary_symbol_get_location(symbols[i], &length); + +        range = g_binary_symbol_get_range(symbols[i]); + +        border = get_mrange_addr(range); +        length = get_mrange_length(range); + + +          switch (g_binary_symbol_get_target_type(symbols[i]))          { diff --git a/src/analysis/disass/limit.c b/src/analysis/disass/limit.c index 8501251..6d5bc35 100644 --- a/src/analysis/disass/limit.c +++ b/src/analysis/disass/limit.c @@ -87,7 +87,7 @@ void limit_all_routines(GArchInstruction *list, GBinRoutine **routines, size_t c          lengths[i] = find_best_ending_address_for_routine(instr, i, starts, lengths, count);          lengths[i] -= starts[i]; -        g_binary_routine_set_size(routines[i], lengths[i]); +        /////////g_binary_routine_set_size(routines[i], lengths[i]);   lar_next: diff --git a/src/analysis/disass/output.c b/src/analysis/disass/output.c index f368796..a6d7845 100644 --- a/src/analysis/disass/output.c +++ b/src/analysis/disass/output.c @@ -55,8 +55,14 @@ void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *form      GArchProcessor *proc;                   /* Architecture du binaire     */      MemoryDataSize msize;                   /* Taille du bus d'adresses    */      const bin_t *content;                   /* Contenu binaire global      */ + +#if 0 +    const mrange_t *range;                  /* Cou +      vmpa_t start;                           /* Adresse de départ           */      vmpa_t end;                             /* Adresse de fin              */ +#endif +      const GArchInstruction *iter;           /* Boucle de parcours #1       */      size_t i;                               /* Boucle de parcours #2       */      const vmpa2t *iaddr;                    /* Adresse d'instruction       */ @@ -100,9 +106,13 @@ void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *form      content = g_binary_format_get_content(G_BIN_FORMAT(format), NULL); +#if 0      g_arch_instruction_get_location(instrs, NULL, NULL, &start); +    start =  +      iter = g_arch_instruction_find_last(instrs);      g_arch_instruction_get_location(iter, NULL, NULL, &end); +#endif      for (iter = instrs, i = 0;           iter != NULL; @@ -129,8 +139,8 @@ void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *form          if (sym_index < sym_count)          { -            iaddr = g_arch_instruction_get_location2(iter, NULL); -            saddr = g_binary_symbol_get_location(symbols[sym_index], NULL); +            iaddr = get_mrange_addr(g_arch_instruction_get_range(iter)); +            saddr = get_mrange_addr(g_binary_symbol_get_range(symbols[sym_index]));              if (cmp_vmpa_by_phy(iaddr, saddr) == 0)              { diff --git a/src/analysis/routine.c b/src/analysis/routine.c index eebcb69..a91e53a 100644 --- a/src/analysis/routine.c +++ b/src/analysis/routine.c @@ -38,8 +38,7 @@ struct _GBinRoutine  {      GObject parent;                         /* A laisser en premier        */ -    vmpa2t addr;                           /* Position physique/mémoire   */ -    off_t size;                             /* Taille du code associé      */ +    mrange_t range;                         /* Couverture mémoire          */      RoutineType type;                       /* Type de routine             */ @@ -214,7 +213,7 @@ void g_binary_routine_finalize(GBinRoutine *routine)  int g_binary_routine_compare(const GBinRoutine **a, const GBinRoutine **b)  { -    return cmp_vmpa(&(*a)->addr, &(*b)->addr); +    return cmp_mrange(&(*a)->range, &(*b)->range);  } @@ -234,7 +233,7 @@ int g_binary_routine_compare(const GBinRoutine **a, const GBinRoutine **b)  int g_binary_routine_rcompare(const GBinRoutine **a, const GBinRoutine **b)  { -    return (-1) * cmp_vmpa(&(*a)->addr, &(*b)->addr); +    return (-1) * cmp_mrange(&(*a)->range, &(*b)->range);  } @@ -242,9 +241,9 @@ int g_binary_routine_rcompare(const GBinRoutine **a, const GBinRoutine **b)  /******************************************************************************  *                                                                             *  *  Paramètres  : routine = routine à mettre à jour.                           * -*                addr    = position mémoire ou physique déclarée.             * +*                range   = plage mémoire ou physique déclarée.                *  *                                                                             * -*  Description : Définit la position physique / en mémoire d'une routine.     * +*  Description : Définit la couverture physique / en mémoire d'une routine.   *  *                                                                             *  *  Retour      : -                                                            *  *                                                                             * @@ -252,67 +251,28 @@ int g_binary_routine_rcompare(const GBinRoutine **a, const GBinRoutine **b)  *                                                                             *  ******************************************************************************/ -void g_binary_routine_set_address(GBinRoutine *routine, const vmpa2t *addr) +void g_binary_routine_set_range(GBinRoutine *routine, const mrange_t *range)  { -    copy_vmpa(&routine->addr, addr); +    copy_mrange(&routine->range, range);  }  /******************************************************************************  *                                                                             * -*  Paramètres  : routine = routine à mettre à jour.                           * -*                                                                             * -*  Description : Fournit la position physique / en mémoire d'une routine.     * -*                                                                             * -*  Retour      : Position mémoire ou physique déclarée.                       * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -const vmpa2t *g_binary_routine_get_address(const GBinRoutine *routine) -{ -    return &routine->addr; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : routine = routine à mettre à jour.                           * -*                size    = taille du code associé.                            * -*                                                                             * -*  Description : Définit la taille du code d'une routine.                     * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -void g_binary_routine_set_size(GBinRoutine *routine, off_t size) -{ -    routine->size = size; - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : routine = routine à mettre à jour.                           * +*  Paramètres  : routine = routine à consulter.                               *  *                                                                             * -*  Description : Fournit la taille du code associé à une routine.             * +*  Description : Fournit la couverture physique / en mémoire d'une routine.   *  *                                                                             * -*  Retour      : Taille du code associée.                                     * +*  Retour      : Plage mémoire ou physique déclarée.                          *  *                                                                             *  *  Remarques   : -                                                            *  *                                                                             *  ******************************************************************************/ -off_t g_binary_routine_get_size(const GBinRoutine *routine) +const mrange_t *g_binary_routine_get_range(const GBinRoutine *routine)  { -    return routine->size; +    return &routine->range;  } diff --git a/src/analysis/routine.h b/src/analysis/routine.h index 29f6e63..3aa33ac 100644 --- a/src/analysis/routine.h +++ b/src/analysis/routine.h @@ -86,17 +86,26 @@ int g_binary_routine_compare(const GBinRoutine **, const GBinRoutine **);  /* Etablit la comparaison descendante entre deux routines. */  int g_binary_routine_rcompare(const GBinRoutine **, const GBinRoutine **); -/* Définit la position physique / en mémoire d'une routine. */ -void g_binary_routine_set_address(GBinRoutine *, const vmpa2t *); +/* Définit la couverture physique / en mémoire d'une routine. */ +void g_binary_routine_set_range(GBinRoutine *, const mrange_t *); + +/* Fournit la couverture physique / en mémoire d'une routine. */ +const mrange_t *g_binary_routine_get_range(const GBinRoutine *); + +  /* Fournit la position physique / en mémoire d'une routine. */ -const vmpa2t *g_binary_routine_get_address(const GBinRoutine *); +//const vmpa2t *g_binary_routine_get_address(const GBinRoutine *); +#define g_binary_routine_get_address(r) 0  /* Définit la taille du code d'une routine. */  void g_binary_routine_set_size(GBinRoutine *, off_t);  /* Fournit la taille du code associé à une routine. */ -off_t g_binary_routine_get_size(const GBinRoutine *); +//off_t g_binary_routine_get_size(const GBinRoutine *); +#define g_binary_routine_get_size(r) 0 + +  /* Définit le type d'une routine. */  void g_binary_routine_set_type(GBinRoutine *, RoutineType); | 
