diff options
Diffstat (limited to 'src/analysis')
| -rw-r--r-- | src/analysis/block-int.h | 4 | ||||
| -rw-r--r-- | src/analysis/block.c | 21 | ||||
| -rw-r--r-- | src/analysis/block.h | 6 | ||||
| -rw-r--r-- | src/analysis/blocks/flow.c | 57 | ||||
| -rw-r--r-- | src/analysis/blocks/flow.h | 3 | ||||
| -rw-r--r-- | src/analysis/blocks/virtual.c | 34 | ||||
| -rw-r--r-- | src/analysis/disass/disassembler.c | 4 | ||||
| -rw-r--r-- | src/analysis/disass/macro.c | 218 | ||||
| -rw-r--r-- | src/analysis/routine.c | 43 | ||||
| -rw-r--r-- | src/analysis/routine.h | 6 | 
10 files changed, 369 insertions, 27 deletions
| diff --git a/src/analysis/block-int.h b/src/analysis/block-int.h index f89fa3c..e194ace 100644 --- a/src/analysis/block-int.h +++ b/src/analysis/block-int.h @@ -29,6 +29,9 @@ +/* Etablit la liste de tous les blocs présents. */ +typedef void (* list_all_blocks_fc) (const GInstrBlock *, GInstrBlock ***, size_t *); +  /* Fournit les différents accès aux registres. */  typedef const reg_access * (* list_regs_accesses_fc) (const GInstrBlock *, size_t *); @@ -39,6 +42,7 @@ struct _GInstrBlock  {      GObject parent;                         /* A laisser en premier        */ +    list_all_blocks_fc list_blocks;         /* Liste de tous les blocs     */      list_regs_accesses_fc list_regs;        /* Liste des accès registres   */  }; diff --git a/src/analysis/block.c b/src/analysis/block.c index 58b1fee..3093a98 100644 --- a/src/analysis/block.c +++ b/src/analysis/block.c @@ -153,3 +153,24 @@ static void g_instr_block_finalize(GInstrBlock *block)      G_OBJECT_CLASS(g_instr_block_parent_class)->finalize(G_OBJECT(block));  } + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : block = bloc d'instructions à consulter.                     * +*                list  = ensemble de blocs à compléter. [OUT]                 * +*                count = nombre de blocs au total. [OUT]                      * +*                                                                             * +*  Description : Etablit la liste de tous les blocs présents.                 * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +void g_instr_block_list_all_blocks(const GInstrBlock *block, GInstrBlock ***list, size_t *count) +{ +    block->list_blocks(block, list, count); + +} diff --git a/src/analysis/block.h b/src/analysis/block.h index 2a7fb90..9e136a3 100644 --- a/src/analysis/block.h +++ b/src/analysis/block.h @@ -82,10 +82,8 @@ typedef struct _GInstrBlockClass GInstrBlockClass;  /* Indique le type défini pour un bloc d'instructions. */  GType g_instr_block_get_type(void); - - - - +/* Etablit la liste de tous les blocs présents. */ +void g_instr_block_list_all_blocks(const GInstrBlock *, GInstrBlock ***, size_t *); diff --git a/src/analysis/blocks/flow.c b/src/analysis/blocks/flow.c index 2bdd0cf..f80b7c8 100644 --- a/src/analysis/blocks/flow.c +++ b/src/analysis/blocks/flow.c @@ -71,6 +71,9 @@ static void g_flow_block_memorize_access(GFlowBlock *, GArchRegister *, RegAcces  /* Note les différents accès aux registres. */  static void g_flow_block_compute_regs_access(GFlowBlock *); +/* Etablit la liste de tous les blocs présents. */ +static void g_flow_block_list_all_blocks(const GFlowBlock *, GInstrBlock ***, size_t *); +  /* Fournit les différents accès aux registres. */  static const reg_access *g_flow_block_list_regs_accesses(const GFlowBlock *, size_t *); @@ -122,6 +125,7 @@ static void g_flow_block_init(GFlowBlock *block)      parent = G_INSTR_BLOCK(block); +    parent->list_blocks = (list_all_blocks_fc)g_flow_block_list_all_blocks;      parent->list_regs = (list_regs_accesses_fc)g_flow_block_list_regs_accesses;  } @@ -201,13 +205,13 @@ GInstrBlock *g_flow_block_new(GArchInstruction *instrs, GArchInstruction *first,      result = g_object_new(G_TYPE_FLOW_BLOCK, NULL); - +    /*      g_arch_instruction_get_location(first, NULL, NULL, &addr); -    //printf(" ! new block @ 0x%llx - ", addr); +    printf(" ! new block @ 0x%llx - ", addr);      g_arch_instruction_get_location(last, NULL, NULL, &addr); -    //printf("0x%llx\n", addr); - +    printf("0x%llx\n", addr); +    */ @@ -228,6 +232,29 @@ GInstrBlock *g_flow_block_new(GArchInstruction *instrs, GArchInstruction *first,  /******************************************************************************  *                                                                             * +*  Paramètres  : block = bloc d'instructions à consulter.                     * +*                list  = ensemble de blocs à compléter. [OUT]                 * +*                count = nombre de blocs au total. [OUT]                      * +*                                                                             * +*  Description : Etablit la liste de tous les blocs présents.                 * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void g_flow_block_list_all_blocks(const GFlowBlock *block, GInstrBlock ***list, size_t *count) +{ +    (*list) = (GInstrBlock **)realloc(*list, ++(*count) * sizeof(GInstrBlock *)); + +    (*list)[*count - 1] = G_INSTR_BLOCK(block); + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : block = bloc d'instructions à mettre à jour.                 *  *                reg   = registre visé par l'opération.                       *  *                type  = type d'accès à l'opérande.                           * @@ -362,3 +389,25 @@ static const reg_access *g_flow_block_list_regs_accesses(const GFlowBlock *block      return block->accesses;  } + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : block = bloc d'instructions à consulter.                     * +*                start = adresse de départ du bloc. [OUT]                     * +*                end   = dernière adresse du bloc. [OUT]                      * +*                                                                             * +*  Description : Fournit les adresses limites d'un bloc d'exécution.          * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +void g_flow_block_get_boundary_addresses(const GFlowBlock *block, vmpa_t *start, vmpa_t *end) +{ +    g_arch_instruction_get_location(block->first, NULL, NULL, start); +    g_arch_instruction_get_location(block->last, NULL, NULL, end); + +} diff --git a/src/analysis/blocks/flow.h b/src/analysis/blocks/flow.h index cc2eb66..14f49ec 100644 --- a/src/analysis/blocks/flow.h +++ b/src/analysis/blocks/flow.h @@ -55,6 +55,9 @@ GType g_flow_block_get_type(void);  /* Crée un bloc d'exécution d'instructions. */  GInstrBlock *g_flow_block_new(GArchInstruction *, GArchInstruction *, GArchInstruction *); +/* Fournit les adresses limites d'un bloc d'exécution. */ +void g_flow_block_get_boundary_addresses(const GFlowBlock *, vmpa_t *, vmpa_t *); +  #endif  /* _ANALYSIS_BLOCKS_FLOW_H */ diff --git a/src/analysis/blocks/virtual.c b/src/analysis/blocks/virtual.c index 113e333..c981ece 100644 --- a/src/analysis/blocks/virtual.c +++ b/src/analysis/blocks/virtual.c @@ -40,13 +40,13 @@ struct _GVirtualBlock      GArchInstruction *first;                /* Première instruction        */      GArchInstruction *last;                 /* Dernière instruction        */ +    GInstrBlock **children;                 /* Sous-blocs intégrés         */ +    size_t children_count;                  /* Nombre de ces sous-blocs    */ +      reg_access *accesses;                   /* Commodités d'accès #1       */      size_t count;                           /* Commodités d'accès #2       */ -    GInstrBlock **children;                 /* Sous-blocs intégrés         */ -    size_t children_count;                  /* Nombre de ces sous-blocs    */ -  };  /* Description d'un bloc d'exécution d'instructions (classe) */ @@ -69,6 +69,9 @@ static void g_virtual_block_dispose(GVirtualBlock *);  /* Procède à la libération totale de la mémoire. */  static void g_virtual_block_finalize(GVirtualBlock *); +/* Etablit la liste de tous les blocs présents. */ +static void g_virtual_block_list_all_blocks(const GVirtualBlock *, GInstrBlock ***, size_t *); +  /* Fournit les différents accès aux registres. */  static const reg_access *g_virtual_block_list_regs_accesses(const GVirtualBlock *, size_t *); @@ -120,6 +123,7 @@ static void g_virtual_block_init(GVirtualBlock *block)      parent = G_INSTR_BLOCK(block); +    parent->list_blocks = (list_all_blocks_fc)g_virtual_block_list_all_blocks;      parent->list_regs = (list_regs_accesses_fc)g_virtual_block_list_regs_accesses;  } @@ -200,6 +204,30 @@ GInstrBlock *g_virtual_block_new(void)  /******************************************************************************  *                                                                             *  *  Paramètres  : block = bloc d'instructions à consulter.                     * +*                list  = ensemble de blocs à compléter. [OUT]                 * +*                count = nombre de blocs au total. [OUT]                      * +*                                                                             * +*  Description : Etablit la liste de tous les blocs présents.                 * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void g_virtual_block_list_all_blocks(const GVirtualBlock *block, GInstrBlock ***list, size_t *count) +{ +    size_t i;                               /* Boucle de parcours          */ + +    for (i = 0; i < block->children_count; i++) +        g_instr_block_list_all_blocks(block->children[i], list, count); + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : block = bloc d'instructions à consulter.                     *  *                count = nombre de registres consignés. [OUT]                 *  *                                                                             *  *  Description : Fournit les différents accès aux registres.                  * diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c index 6147f3b..e7c972d 100644 --- a/src/analysis/disass/disassembler.c +++ b/src/analysis/disass/disassembler.c @@ -257,7 +257,7 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkExtSta      run_plugins_on_binary(disass->binary, PGA_BINARY_BOUNDED, true);      /* Quatrième étape */ -#if 0 +      id = gtk_extended_status_bar_push(statusbar, _("Grouping routines instructions..."), true);      qsort(routines, routines_count, sizeof(GBinRoutine *), (__compar_fn_t)g_binary_routine_rcompare); @@ -267,7 +267,7 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkExtSta      gtk_extended_status_bar_remove(statusbar, id);      run_plugins_on_binary(disass->binary, PGA_BINARY_GROUPED, true); -#endif +      /* Cinquième étape */      id = gtk_extended_status_bar_push(statusbar, _("Printing disassembled code..."), true); diff --git a/src/analysis/disass/macro.c b/src/analysis/disass/macro.c index 7fda6b9..46dc0d3 100644 --- a/src/analysis/disass/macro.c +++ b/src/analysis/disass/macro.c @@ -41,6 +41,16 @@ typedef struct _branch_info  } branch_info; +/** + * Macros pour le marquage des instructions traitées. + * Dans un soucis d'optimisation, on ne traite que les instructions + * démarrant un bloc. + */ +#define MACRO_MARK_AS_PROCESSED(_instr) g_object_set_data(G_OBJECT(_instr), "macro_done", _instr) +#define MACRO_IS_PROCESSED(_instr) (g_object_get_data(G_OBJECT(_instr), "macro_done") != NULL) +#define MACRO_CLEAR_PROCESSED(_instr) g_object_set_data(G_OBJECT(_instr), "macro_done", NULL) + +  /* Indique si une adresse est retenue comme point de passage. */  static bool is_addr_in_branch(const branch_info *, const vmpa_t *, bool); @@ -50,6 +60,9 @@ static void find_next_jumps(GArchInstruction *, vmpa_t, vmpa_t, branch_info *);  /* Retrouve le point de ralliement entre deux branches. */  static vmpa_t compute_first_common_addr(branch_info *, branch_info *); +/* Retrouve le point de ralliement entre un groupe de branches. */ +static vmpa_t compute_first_common_addr_in_group(const branch_info *, size_t); +  /* Procède à la définition de bloc regroupant des instructions. */  static GInstrBlock *build_instruction_block(GArchInstruction *, vmpa_t, vmpa_t, vmpa_t); @@ -144,6 +157,7 @@ static void find_next_jumps(GArchInstruction *instrs, vmpa_t start, vmpa_t end,              {                  case ILT_EXEC_FLOW:                  case ILT_JUMP: +                case ILT_CASE_JUMP:                  case ILT_JUMP_IF_TRUE:                  case ILT_JUMP_IF_FALSE:                      g_arch_instruction_get_location(dests[i], NULL, NULL, &addr); @@ -204,6 +218,49 @@ static vmpa_t compute_first_common_addr(branch_info *a, branch_info *b)  /******************************************************************************  *                                                                             * +*  Paramètres  : list  = liste d'ensembles de jalons à parcourir.             * +*                count = taille de cette liste.                               * +*                                                                             * +*  Description : Retrouve le point de ralliement entre un groupe de branches. * +*                                                                             * +*  Retour      : Adresse commune aux branches.                                * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static vmpa_t compute_first_common_addr_in_group(const branch_info *list, size_t count) +{ +    vmpa_t result;                          /* Adresse trouvée à retourner */ +    size_t i;                               /* Boucle de parcours #1       */ +    bool keep;                              /* Candidate à garder ?        */ +    size_t j;                               /* Boucle de parcours #2       */ + +    /* Valeur conceptuellement impossible à renvoyer */ +    result = VMPA_MAX; + +    //qsort(a->jumps, a->count, sizeof(vmpa_t), (__compar_fn_t)compare_vmpa); +    //qsort(b->jumps, b->count, sizeof(vmpa_t), (__compar_fn_t)compare_vmpa); + +    for (i = 0; i < list[0].count && result == VMPA_MAX; i++) +    { +        keep = true; + +        for (j = 1; j < count && keep; j++) +            keep = is_addr_in_branch(&list[j], &list[0].jumps[i], false); + +        if (keep) +            result = list[0].jumps[i]; + +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : instrs = ensemble des instructions d'assemblage.             *  *                start  = adresse de début du bloc.                           *  *                end    = adresse de fin du bloc (exclusive).                 * @@ -220,6 +277,7 @@ static vmpa_t compute_first_common_addr(branch_info *a, branch_info *b)  static GInstrBlock *build_instruction_block(GArchInstruction *instrs, vmpa_t start, vmpa_t end, vmpa_t stop)  {      GInstrBlock *result;                    /* Regroupement à retourner    */ +    branch_info main_branch;                /* Flot d'exécution complet    */      GArchInstruction *first;                /* Première instruction        */      GArchInstruction *last;                 /* Dernière instruction        */      GArchInstruction *iter;                 /* Boucle de parcours          */ @@ -227,17 +285,26 @@ static GInstrBlock *build_instruction_block(GArchInstruction *instrs, vmpa_t sta      GArchInstruction **dests;               /* Instr. visée par une autre  */      InstructionLinkType *types;             /* Type de lien entre lignes   */      size_t dcount;                          /* Nombre de liens de dest.    */ -    size_t i;                               /* Boucle de parcours          */ +    size_t i;                               /* Boucle de parcours #1       */      GInstrBlock *block;                     /* Nouveau bloc mis en place   */ +    branch_info *cases_branches;            /* Branches d'un aiguillage    */ +    size_t cases_count;                     /* Nombre d'aiguillages        */      branch_info true_branch;                /* Branche 'condition vraie'   */      branch_info false_branch;               /* Branche 'condition fausse'  */ +    branch_info *excep_branches;            /* Branches d'exceptions       */ +    size_t excep_count;                     /* Nombre d'exceptions         */      vmpa_t next_addr;                       /* Prochaine instruction visée */ +    size_t j;                               /* Boucle de parcours #2       */ +    vmpa_t stop_addr;                       /* Adresse de fin de bloc      */      result = NULL;      first = NULL;      last = NULL; +    memset(&main_branch, 0, sizeof(branch_info)); +    find_next_jumps(instrs, start, end, &main_branch); +      //printf("[+] blocking 0x%08llx -> 0x%08llx... stop @ 0x%08llx\n", start, end, stop);      for (iter = g_arch_instruction_find_by_address(instrs, start, true); @@ -247,15 +314,14 @@ static GInstrBlock *build_instruction_block(GArchInstruction *instrs, vmpa_t sta          g_arch_instruction_get_location(iter, NULL, NULL, &addr);          if (addr == stop) break; +        /* On s'arrêter si l'instruction est déjà décompilée */ +        if (MACRO_IS_PROCESSED(iter)) break; +          if (first == NULL)              first = iter;          last = iter; -        /* On s'arrêter si l'instruction est déjà décompilée */ -        if (g_object_get_data(G_OBJECT(iter), "decomp_done") != NULL) break; -        g_object_set_data(G_OBJECT(iter), "decomp_done", iter); -          /* On n'approfondit que les chemins qui se séparent */          if (!g_arch_instruction_has_destinations(iter))          { @@ -268,8 +334,12 @@ static GInstrBlock *build_instruction_block(GArchInstruction *instrs, vmpa_t sta          dcount = g_arch_instruction_get_destinations(iter, &dests, &types);          next_addr = 0; +        cases_branches = NULL; +        cases_count = 0;          memset(&true_branch, 0, sizeof(branch_info));          memset(&false_branch, 0, sizeof(branch_info)); +        excep_branches = NULL; +        excep_count = 0;          for (i = 0; i < dcount; i++)              switch (types[i]) @@ -281,6 +351,7 @@ static GInstrBlock *build_instruction_block(GArchInstruction *instrs, vmpa_t sta                          result = g_virtual_block_new();                      block = g_flow_block_new(instrs, first, iter); +                    MACRO_MARK_AS_PROCESSED(first);                      g_virtual_block_add_child(G_VIRTUAL_BLOCK(result), block);                      first = NULL; @@ -288,6 +359,17 @@ static GInstrBlock *build_instruction_block(GArchInstruction *instrs, vmpa_t sta                      break; +                case ILT_CASE_JUMP: + +                    g_arch_instruction_get_location(dests[i], NULL, NULL, &addr); + +                    cases_branches = (branch_info *)realloc(cases_branches, +                                                            ++cases_count * sizeof(branch_info)); +                    memset(&cases_branches[cases_count - 1], 0, sizeof(branch_info)); +                    find_next_jumps(instrs, addr, end, &cases_branches[cases_count - 1]); + +                    break; +                  case ILT_JUMP_IF_TRUE:                      g_arch_instruction_get_location(dests[i], NULL, NULL, &addr);                      find_next_jumps(instrs, addr, end, &true_branch); @@ -298,12 +380,97 @@ static GInstrBlock *build_instruction_block(GArchInstruction *instrs, vmpa_t sta                      find_next_jumps(instrs, addr, end, &false_branch);                      break; +                case ILT_CATCH_EXCEPTION: + +                    g_arch_instruction_get_location(dests[i], NULL, NULL, &addr); + +                    excep_branches = (branch_info *)realloc(excep_branches, +                                                            ++excep_count * sizeof(branch_info)); +                    memset(&excep_branches[excep_count - 1], 0, sizeof(branch_info)); +                    find_next_jumps(instrs, addr, end, &excep_branches[excep_count - 1]); + +                    break; +                  default: -                    next_addr = VMPA_MAX; +                    if (next_addr == 0) +                        next_addr = VMPA_MAX;                      break;              } +        /* Post-traitements de ILT_CASE_JUMP */ +        if (cases_count > 0) +        { +            if (result == NULL) +                result = g_virtual_block_new(); + +            if (first != NULL) +            { +                block = g_flow_block_new(instrs, first, iter); +                MACRO_MARK_AS_PROCESSED(first); +                g_virtual_block_add_child(G_VIRTUAL_BLOCK(result), block); +                first = NULL; +            } + +            //printf(" --- cases --- start\n"); + +            next_addr = compute_first_common_addr_in_group(cases_branches, cases_count); +            //printf("    stop :: 0x%08llx\n", next_addr); + +            for (j = 0; j < cases_count; j++) +            { +                //printf(" ## %zu\n", j); + +                block = build_instruction_block(instrs, cases_branches[j].jumps[0], end, next_addr); + +                if (block != NULL) + +                g_virtual_block_add_child(G_VIRTUAL_BLOCK(result), block); + +                free(cases_branches[j].jumps); + +            } + +            //printf(" --- cases --- end\n"); + + +            free(cases_branches); + +        } + +        /* Post-traitements de ILT_CATCH_EXCEPTION */ +        if (excep_count > 0) +        { +            if (result == NULL) +                result = g_virtual_block_new(); + +            if (first != NULL) +            { +                block = g_flow_block_new(instrs, first, iter); +                MACRO_MARK_AS_PROCESSED(first); +                g_virtual_block_add_child(G_VIRTUAL_BLOCK(result), block); +                first = NULL; +            } + +            for (j = 0; j < excep_count; j++) +            { +                stop_addr = compute_first_common_addr(&main_branch, &excep_branches[j]); +                //next_addr = MIN(next_addr, end); + +                block = build_instruction_block(instrs, excep_branches[j].jumps[0], end, stop_addr); + +                if (block != NULL) + +                g_virtual_block_add_child(G_VIRTUAL_BLOCK(result), block); + +                free(excep_branches[j].jumps); + +            } + +            free(excep_branches); + +        } +          if (next_addr == VMPA_MAX)          {              iter = g_arch_instruction_get_next_iter(instrs, iter, end); @@ -318,14 +485,24 @@ static GInstrBlock *build_instruction_block(GArchInstruction *instrs, vmpa_t sta              if (result == NULL)                  result = g_virtual_block_new(); -            block = g_flow_block_new(instrs, first, iter); -            g_virtual_block_add_child(G_VIRTUAL_BLOCK(result), block); -            first = NULL; +            if (first != NULL) +            { +                block = g_flow_block_new(instrs, first, iter); +                MACRO_MARK_AS_PROCESSED(first); +                g_virtual_block_add_child(G_VIRTUAL_BLOCK(result), block); +                first = NULL; +            }              block = build_instruction_block(instrs, true_branch.jumps[0], end, next_addr); + +                if (block != NULL) +              g_virtual_block_add_child(G_VIRTUAL_BLOCK(result), block);              block = build_instruction_block(instrs, false_branch.jumps[0], end, next_addr); + +                if (block != NULL) +              g_virtual_block_add_child(G_VIRTUAL_BLOCK(result), block);              free(true_branch.jumps); @@ -342,15 +519,27 @@ static GInstrBlock *build_instruction_block(GArchInstruction *instrs, vmpa_t sta      if (first != NULL && last != NULL)      { -        block = g_flow_block_new(instrs, first, last); +        if (!MACRO_IS_PROCESSED(first)) +        { +            //printf("--close?--\n"); +            block = g_flow_block_new(instrs, first, last); +            MACRO_MARK_AS_PROCESSED(first); +            //printf("--close!--\n"); -        if (result == NULL) -            result = block; -        else -            g_virtual_block_add_child(G_VIRTUAL_BLOCK(result), block); +            if (result == NULL) +                result = block; +            else +                g_virtual_block_add_child(G_VIRTUAL_BLOCK(result), block); +        }      } +    if (result == NULL) +    { +        //printf("WARNING :: null !\n"); +        //exit(0); +    } +      return result;  } @@ -389,6 +578,7 @@ void group_routines_instructions(GArchInstruction *list, GBinRoutine **routines,          block = build_instruction_block(list, start, end, VMPA_MAX); +        g_binary_routine_set_basic_blocks(routines[i], block);          gtk_extended_status_bar_update_activity(statusbar, id, (i + 1) * 1.0 / count); diff --git a/src/analysis/routine.c b/src/analysis/routine.c index d52b74a..048d11a 100644 --- a/src/analysis/routine.c +++ b/src/analysis/routine.c @@ -57,6 +57,7 @@ struct _GBinRoutine      size_t locals_count;                    /* Nombre de variables locales */      GArchInstruction *instr;                /* Instructions natives        */ +    GInstrBlock *blocks;                    /* Blocs basiques d'instruct°  */      GDecInstruction *dinstr;                /* Instructions décompilées    */  }; @@ -800,6 +801,48 @@ void g_binary_routine_set_instructions(GBinRoutine *routine, GArchInstruction *i  *                                                                             *  *  Paramètres  : routine = routine à consulter.                               *  *                                                                             * +*  Description : Fournit les blocs basiques de la routine.                    * +*                                                                             * +*  Retour      : Ensemble de blocs déterminés via les instructions.           * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GInstrBlock *g_binary_routine_get_basic_blocks(const GBinRoutine *routine) +{ +    return routine->blocks; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : routine = routine à mettre à jour.                           * +*                blocks  = ensemble de blocs déterminés via les instructions. * +*                                                                             * +*  Description : Définit les blocs basiques de la routine.                    * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +void g_binary_routine_set_basic_blocks(GBinRoutine *routine, GInstrBlock *blocks) +{ +    if (routine->blocks != NULL) +        g_object_unref(G_OBJECT(routine->blocks)); + +    routine->blocks = blocks; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : routine = routine à consulter.                               * +*                                                                             *  *  Description : Fournit les instructions décompilées correspondantes.        *  *                                                                             *  *  Retour      : Ensemble d'instructions décompilées ou NULL.                 * diff --git a/src/analysis/routine.h b/src/analysis/routine.h index c6de039..fd77f5e 100644 --- a/src/analysis/routine.h +++ b/src/analysis/routine.h @@ -152,6 +152,12 @@ GArchInstruction *g_binary_routine_get_instructions(const GBinRoutine *);  /* Définit les instructions natives de la routine. */  void g_binary_routine_set_instructions(GBinRoutine *, GArchInstruction *); +/* Fournit les blocs basiques de la routine. */ +GInstrBlock *g_binary_routine_get_basic_blocks(const GBinRoutine *); + +/* Définit les blocs basiques de la routine. */ +void g_binary_routine_set_basic_blocks(GBinRoutine *, GInstrBlock *); +  /* Fournit les instructions décompilées correspondantes. */  GDecInstruction *g_binary_routine_get_decomp_instructions(const GBinRoutine *); | 
