diff options
Diffstat (limited to 'src/analysis')
| -rw-r--r-- | src/analysis/blocks/flow.c | 154 | ||||
| -rw-r--r-- | src/analysis/blocks/flow.h | 15 | ||||
| -rw-r--r-- | src/analysis/blocks/virtual.c | 4 | ||||
| -rw-r--r-- | src/analysis/blocks/virtual.h | 4 | ||||
| -rw-r--r-- | src/analysis/disass/Makefile.am | 3 | ||||
| -rw-r--r-- | src/analysis/disass/disassembler.c | 13 | ||||
| -rw-r--r-- | src/analysis/disass/rank.c | 413 | ||||
| -rw-r--r-- | src/analysis/disass/rank.h | 41 | 
8 files changed, 628 insertions, 19 deletions
| diff --git a/src/analysis/blocks/flow.c b/src/analysis/blocks/flow.c index 0b68a14..799931d 100644 --- a/src/analysis/blocks/flow.c +++ b/src/analysis/blocks/flow.c @@ -25,6 +25,7 @@  #include <malloc.h> +#include <sys/param.h>  #include "../block-int.h" @@ -36,6 +37,9 @@ struct _GFlowBlock  {      GInstrBlock parent;                     /* A laisser en premier        */ +    unsigned int rank;                      /* Rang dans l'exécution       */ +    unsigned int next_rank;                 /* Rang suivant de l'exécution */ +      GArchInstruction *instrs;               /* Liste complète d'instruct°  */      GArchInstruction *first;                /* Première instruction        */      GArchInstruction *last;                 /* Dernière instruction        */ @@ -140,6 +144,8 @@ static void g_flow_block_init(GFlowBlock *block)      parent->list_leafs = (list_leafs_blocks_fc)g_flow_block_list_leafs_blocks;      //parent->list_regs = (list_regs_accesses_fc)g_flow_block_list_regs_accesses; +    g_flow_block_set_rank(block, 0); +      block->regs = g_raccess_list_new();      block->awaited = g_raccess_list_new(); @@ -209,22 +215,8 @@ GInstrBlock *g_flow_block_new(GArchInstruction *instrs, GArchInstruction *first,  {      GFlowBlock *result;                     /* Structure à retourner       */ -    //vmpa_t addr;                            /* Adresse de la destination   */ - -      result = g_object_new(G_TYPE_FLOW_BLOCK, NULL); - -    /* -    g_arch_instruction_get_location(first, NULL, NULL, &addr); -    printf(" ! new block @ 0x%llx - ", addr); - -    g_arch_instruction_get_location(last, NULL, NULL, &addr); -    printf("0x%llx\n", addr); -    */ - - -      result->instrs = instrs;      result->first = first;      result->last = last; @@ -242,6 +234,85 @@ GInstrBlock *g_flow_block_new(GArchInstruction *instrs, GArchInstruction *first,  /******************************************************************************  *                                                                             * +*  Paramètres  : block = bloc d'instruction à consulter.                      * +*                                                                             * +*  Description : Fournit le rang du bloc dans le flot d'exécution.            * +*                                                                             * +*  Retour      : Indice supérieur ou égal à zéro.                             * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +unsigned int g_flow_block_get_rank(const GFlowBlock *block) +{ +    return block->rank; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : block = bloc d'instruction à consulter.                      * +*                rank  = Indice supérieur à zéro à prendre en compte.         * +*                                                                             * +*  Description : Définit le rang du bloc dans le flot d'exécution.            * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +void g_flow_block_set_rank(GFlowBlock *block, unsigned int rank) +{ +    block->rank = MAX(block->rank, rank); +    g_flow_block_set_next_rank(block, block->rank + 1); + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : block = bloc d'instruction à consulter.                      * +*                                                                             * +*  Description : Fournit le rang minimal du bloc suivant pour l'exécution.    * +*                                                                             * +*  Retour      : Indice supérieur à zéro.                                     * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +unsigned int g_flow_block_get_next_rank(const GFlowBlock *block) +{ +    return block->next_rank; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : block = bloc d'instruction à consulter.                      * +*                rank  = Indice supérieur à zéro à prendre en compte.         * +*                                                                             * +*  Description : Définit le rang minimal du bloc suivant pour l'exécution.    * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +void g_flow_block_set_next_rank(GFlowBlock *block, unsigned int rank) +{ +    block->next_rank = MAX(block->next_rank, rank); + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : block = bloc de départ des recherches.                       *  *                addr  = ensemble de blocs à parcourir.                       *  *                final = indique si la cible ou le conteneur est renvoyée.    * @@ -508,6 +579,61 @@ void g_flow_block_get_boundary_addresses(const GFlowBlock *block, vmpa_t *start,  /******************************************************************************  *                                                                             * +*  Paramètres  : block  = bloc d'instructions démarrant la visite.            * +*                list   = ensemble des blocs basiques à parcourir.            * +*                target = bloc de fin de parcours.                            * +*                                                                             * +*  Description : Détermine si un bloc peut conduire à un autre.               * +*                                                                             * +*  Retour      : true si un lien existe entre les deux blocs fournis.         * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +bool g_flow_block_is_looping_to(GFlowBlock *block, const GInstrBlock *list, GFlowBlock *target) +{ +    bool result;                            /* Bilan à retourner           */ +    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          */ +    vmpa_t addr;                            /* Adresse de la destination   */ +    GInstrBlock *next;                      /* Bloc suivant à visiter      */ + +    result = (block == target); + +    dcount = g_arch_instruction_get_destinations(block->last, &dests, &types, NULL); + +    for (i = 0; i < dcount && !result; i++) +        switch (types[i]) +        { +            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); +                next = g_instr_block_find_by_addr(list, addr, true); +                result = g_flow_block_is_looping_to(G_FLOW_BLOCK(next), list, target); +                break; + +            case ILT_LOOP: +                g_arch_instruction_get_location(dests[i], NULL, NULL, &addr); +                next = g_instr_block_find_by_addr(list, addr, true); +                result = (G_FLOW_BLOCK(next) == target); +            default: +                break; + +        } + +    return result; + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : block    = bloc d'instructions démarrant la visite.          *  *                list     = ensemble des blocs basiques à parcourir.          *  *                mask     = points de passage à marquer.                      * diff --git a/src/analysis/blocks/flow.h b/src/analysis/blocks/flow.h index a01ef64..ab8fada 100644 --- a/src/analysis/blocks/flow.h +++ b/src/analysis/blocks/flow.h @@ -70,6 +70,18 @@ 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 le rang du bloc dans le flot d'exécution. */ +unsigned int g_flow_block_get_rank(const GFlowBlock *); + +/* Définit le rang du bloc dans le flot d'exécution. */ +void g_flow_block_set_rank(GFlowBlock *, unsigned int); + +/* Fournit le rang minimal du bloc suivant pour l'exécution. */ +unsigned int g_flow_block_get_next_rank(const GFlowBlock *); + +/* Définit le rang minimal du bloc suivant pour l'exécution. */ +void g_flow_block_set_next_rank(GFlowBlock *, unsigned int); +  /* Fournit la liste d'appartenance des instructions du bloc. */  GArchInstruction *g_flow_block_get_all_instructions_list(const GFlowBlock *); @@ -79,6 +91,9 @@ void g_flow_block_get_boundary(const GFlowBlock *, GArchInstruction **, GArchIns  /* Fournit les adresses limites d'un bloc d'exécution. */  void g_flow_block_get_boundary_addresses(const GFlowBlock *, vmpa_t *, vmpa_t *); +/* Détermine si un bloc peut conduire à un autre. */ +bool g_flow_block_is_looping_to(GFlowBlock *, const GInstrBlock *, GFlowBlock *); +  /* Suit le flot d'excution bloc par bloc. */  bool g_flow_block_follow(GFlowBlock *, const GInstrBlock *, BlockFollowPosition, flow_block_follow_cb, void *); diff --git a/src/analysis/blocks/virtual.c b/src/analysis/blocks/virtual.c index 0cc6a0d..7f238d4 100644 --- a/src/analysis/blocks/virtual.c +++ b/src/analysis/blocks/virtual.c @@ -388,7 +388,7 @@ void g_virtual_block_add_child(GVirtualBlock *block, GInstrBlock *child)  *                                                                             *  ******************************************************************************/ -size_t g_virtual_block_count_children(GVirtualBlock *block) +size_t g_virtual_block_count_children(const GVirtualBlock *block)  {      return block->children_count; @@ -408,7 +408,7 @@ size_t g_virtual_block_count_children(GVirtualBlock *block)  *                                                                             *  ******************************************************************************/ -GInstrBlock *g_virtual_block_get_child(GVirtualBlock *block, size_t index) +GInstrBlock *g_virtual_block_get_child(const GVirtualBlock *block, size_t index)  {      if (index >= block->children_count)          return NULL; diff --git a/src/analysis/blocks/virtual.h b/src/analysis/blocks/virtual.h index b254a27..1e4b51d 100644 --- a/src/analysis/blocks/virtual.h +++ b/src/analysis/blocks/virtual.h @@ -59,10 +59,10 @@ GInstrBlock *g_virtual_block_new(void);  void g_virtual_block_add_child(GVirtualBlock *, GInstrBlock *);  /* Compte le nombre de blocs contenus dans le groupe courant. */ -size_t g_virtual_block_count_children(GVirtualBlock *); +size_t g_virtual_block_count_children(const GVirtualBlock *);  /* Renvoie un des blocs contenus dans le groupe courant. */ -GInstrBlock *g_virtual_block_get_child(GVirtualBlock *, size_t); +GInstrBlock *g_virtual_block_get_child(const GVirtualBlock *, size_t); diff --git a/src/analysis/disass/Makefile.am b/src/analysis/disass/Makefile.am index 45fc3fd..0f58100 100644 --- a/src/analysis/disass/Makefile.am +++ b/src/analysis/disass/Makefile.am @@ -8,7 +8,8 @@ libanalysisdisass_la_SOURCES =			\  	links.h links.c						\  	loop.h loop.c						\  	macro.h macro.c						\ -	output.h output.c +	output.h output.c					\ +	rank.h rank.c  libanalysisdisass_la_LDFLAGS =  diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c index 8c816f6..74b3add 100644 --- a/src/analysis/disass/disassembler.c +++ b/src/analysis/disass/disassembler.c @@ -38,6 +38,7 @@  #include "loop.h"  #include "macro.h"  #include "output.h" +#include "rank.h"  #include "../../decomp/lang/asm.h"  #include "../../format/format.h"  #include "../../glibext/delayed-int.h" @@ -279,6 +280,18 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkExtSta      /* Sixième étape */ +    id = gtk_extended_status_bar_push(statusbar, _("Ranking each instructions block..."), true); + +    qsort(routines, routines_count, sizeof(GBinRoutine *), (__compar_fn_t)g_binary_routine_rcompare); + +    rank_routines_blocks(routines, routines_count, statusbar, id); + +    gtk_extended_status_bar_remove(statusbar, id); + +    run_plugins_on_binary(disass->binary, PGA_BINARY_GROUPED, true); + +    /* Septième étape */ +      id = gtk_extended_status_bar_push(statusbar, _("Printing disassembled code..."), true);      qsort(routines, routines_count, sizeof(GBinRoutine *), (__compar_fn_t)g_binary_routine_compare); diff --git a/src/analysis/disass/rank.c b/src/analysis/disass/rank.c new file mode 100644 index 0000000..6f12f31 --- /dev/null +++ b/src/analysis/disass/rank.c @@ -0,0 +1,413 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * rank.c - classement des blocs d'instructions + * + * Copyright (C) 2013 Cyrille Bagard + * + *  This file is part of OpenIDA. + * + *  OpenIDA is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 3 of the License, or + *  (at your option) any later version. + * + *  OpenIDA is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "rank.h" + + +#include "../blocks/flow.h" +#include "../blocks/virtual.h" + + +#if 0 +/* Marque la profondeur d'un bloc d'instructions. */ +static void rank_flow_block_content(GFlowBlock *, const GInstrBlock *); + + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : block = bloc d'instructions démarrant la visite.             * +*                list  = ensemble des blocs basiques à parcourir.             * +*                                                                             * +*  Description : Marque la profondeur d'un bloc d'instructions.               * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void rank_flow_block_content(GFlowBlock *block, const GInstrBlock *list) +{ +    GArchInstruction *last;                 /* Dernière instruction du bloc*/ +    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 k;                               /* Boucle de parcours #1       */ +    size_t i;                               /* Boucle de parcours #2       */ +    vmpa_t addr;                            /* Adresse de la destination   */ +    GInstrBlock *next;                      /* Bloc suivant à visiter      */ +    bool loop;                              /* Détection de rebouclage     */ +    //unsigned int old_rank;                  /* Rang avant intervention     */ + +    g_flow_block_get_boundary(block, NULL, &last); +    dcount = g_arch_instruction_get_destinations(last, &dests, &types, NULL); + +    for (k = 0; k < 2; k++) +        for (i = 0; i < dcount; i++) +            switch (types[i]) +            { +                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); +                    next = g_instr_block_find_by_addr(list, addr, true); + +                    /** +                     * On traite en premier les liens qui conduisent à un rebouclage, +                     * afin d'avoir des indices importants à offrir pour les autres liens +                     * par la suite. +                     */ +                    loop = g_flow_block_is_looping_to(G_FLOW_BLOCK(next), list, block); +                    //if (loop != (k == 0)) continue; + +                    if (loop) +                    printf("next :: %u (i=%zu k=%zu)\n", g_flow_block_get_next_rank(block), i, k); + + +                    if (loop == (k == 0)) +                    { +                    g_flow_block_set_rank(G_FLOW_BLOCK(next), g_flow_block_get_next_rank(block)); + +                    rank_flow_block_content(G_FLOW_BLOCK(next), list); +                    } +                    break; + +                case ILT_LOOP: +                    g_arch_instruction_get_location(dests[i], NULL, NULL, &addr); +                    next = g_instr_block_find_by_addr(list, addr, true); + + +                    /** +                     * On traite en premier les liens qui conduisent à un rebouclage, +                     * afin d'avoir des indices importants à offrir pour les autres liens +                     * par la suite. +                     */ +                    loop = g_flow_block_is_looping_to(G_FLOW_BLOCK(next), list, block); +                    //if (loop != (k == 0)) continue; + + +                    if (loop == (k == 0)) +                    { +                        printf("loop next :: %u (i=%zu k=%zu)\n", g_flow_block_get_next_rank(block), i, k); + + +                    g_flow_block_set_next_rank(G_FLOW_BLOCK(next), +                                               g_flow_block_get_next_rank(block)); + +                    } + +                    break; + +                default: +                    break; + +            } + + + + + + + +#if 0 +    /** +     * Si un bloc contient un retour sur lui même, on définit l'indice pour les +     * blocs suivants découlant de cette boucle avant de traiter ces blocs suivants. +     */ +    for (i = 0; i < dcount; i++) +        switch (types[i]) +        { +            case ILT_LOOP: +                g_arch_instruction_get_location(dests[i], NULL, NULL, &addr); +                next = g_instr_block_find_by_addr(list, addr, true); +                g_flow_block_set_next_rank(G_FLOW_BLOCK(next), g_flow_block_get_next_rank(block)); +                break; + +            default: +                break; + +        } + +    for (i = 0; i < dcount; i++) +        switch (types[i]) +        { +            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); +                next = g_instr_block_find_by_addr(list, addr, true); + +                old_rank = g_flow_block_get_rank(G_FLOW_BLOCK(next)); +                g_flow_block_set_rank(G_FLOW_BLOCK(next), g_flow_block_get_next_rank(block)); + +                /* Si un traitement n'a pas déjà été fait... */ +                if (old_rank == 0 || 1) +                    rank_flow_block_content(G_FLOW_BLOCK(next), list); + +            default: +                break; + +        } +#endif + +} + +#endif + + + + +/* Classe le contenu d'un bloc d'instructions exécutées. */ +static unsigned int rank_flow_block(GFlowBlock *, const GInstrBlock *, unsigned int); + +/* Classe le contenu d'un bloc d'instructions virtuel. */ +static unsigned int rank_virtual_block(GVirtualBlock *, const GInstrBlock *, unsigned int); + +/* Classe le contenu d'un bloc d'instructions quelconque. */ +static unsigned int rank_instructions_block(GInstrBlock *, const GInstrBlock *, unsigned int); + + + + + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : block = bloc d'instructions concerné par la visite.          * +*                list  = ensemble des blocs basiques à parcourir.             * +*                rank  = rang courant du classement en courant.               * +*                                                                             * +*  Description : Classe le contenu d'un bloc d'instructions exécutées.        * +*                                                                             * +*  Retour      : Rang pour les blocs suivants.                                * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static unsigned int rank_flow_block(GFlowBlock *block, const GInstrBlock *list, unsigned int rank) +{ +    unsigned int result;                    /* Rang suivant à retourner    */ +    GInstrBlock *links;                     /* Blocs liés au bloc courant  */ +    GArchInstruction *last;                 /* Dernière instruction du bloc*/ +    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 k;                               /* Boucle de parcours #1       */ +    size_t i;                               /* Boucle de parcours #2       */ +    vmpa_t addr;                            /* Adresse de la destination   */ +    GInstrBlock *next;                      /* Bloc suivant à visiter      */ +    bool loop;                              /* Détection de rebouclage     */ + +    /* On traite le bloc courant */ + +    result = rank; +    g_flow_block_set_rank(block, result++); + +    /* Viennent ensuite les blocs rattachés */ + +    links = g_instr_block_get_links_block(G_INSTR_BLOCK(block)); + +    if (links != NULL) +    { +        g_flow_block_get_boundary(block, NULL, &last); +        dcount = g_arch_instruction_get_destinations(last, &dests, &types, NULL); + +        for (k = 0; k < 2; k++) +            for (i = 0; i < dcount; i++) +                switch (types[i]) +                { +                    case ILT_CASE_JUMP: +                    case ILT_JUMP_IF_TRUE: +                    case ILT_JUMP_IF_FALSE: + +                        g_arch_instruction_get_location(dests[i], NULL, NULL, &addr); + +                        next = g_instr_block_find_by_addr(links, addr, true); + +                        /** +                         * En cas d'une branche unique, l'adresse peut ne pas être trouvée +                         * dans les sous-blocs ; logiquement, elle sera traitée plus tard, +                         * dans la continuité de ce bloc. +                         */ +                        if (next == NULL) break; + +                        /** +                         * On traite en premier les liens qui conduisent à un rebouclage, +                         * afin d'avoir des indices importants à offrir pour les autres liens +                         * par la suite. +                         */ +                        loop = g_flow_block_is_looping_to(G_FLOW_BLOCK(next), list, block); +                        if (loop != (k == 0)) continue; + +                        next = g_instr_block_find_by_addr(links, addr, false); +                        result = MAX(rank_instructions_block(next, list, rank + 1), result); + +                        break; + +                    default: +                        break; + +                } + +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : block = bloc d'instructions concerné par la visite.          * +*                list  = ensemble des blocs basiques à parcourir.             * +*                rank  = rang courant du classement en courant.               * +*                                                                             * +*  Description : Classe le contenu d'un bloc d'instructions virtuel.          * +*                                                                             * +*  Retour      : Rang pour les blocs suivants.                                * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static unsigned int rank_virtual_block(GVirtualBlock *block, const GInstrBlock *list, unsigned int rank) +{ +    unsigned int result;                    /* Rang suivant à retourner    */ +    size_t max;                             /* Borne du parcours           */ +    size_t i;                               /* Boucle de parcours          */ +    GInstrBlock *child;                     /* Sous-bloc à traiter         */ + +    result = rank; + +    max = g_virtual_block_count_children(block); + +    for (i = 0; i < max; i++) +    { +        child = g_virtual_block_get_child(block, i); +        if (!G_IS_FLOW_BLOCK(child)) continue; + +        result = rank_instructions_block(child, list, result); + +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : block = bloc d'instructions concerné par la visite.          * +*                list  = ensemble des blocs basiques à parcourir.             * +*                rank  = rang courant du classement en courant.               * +*                                                                             * +*  Description : Classe le contenu d'un bloc d'instructions quelconque.       * +*                                                                             * +*  Retour      : Rang pour les blocs suivants.                                * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static unsigned int rank_instructions_block(GInstrBlock *block, const GInstrBlock *list, unsigned int rank) +{ +    unsigned int result;                    /* Rang suivant à retourner    */ + +    if (G_IS_VIRTUAL_BLOCK(block)) +        result = rank_virtual_block(G_VIRTUAL_BLOCK(block), list, rank); + +    else if (G_FLOW_BLOCK(block)) +        result = rank_flow_block(G_FLOW_BLOCK(block), list, rank); + +    else +        result = rank; + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : routine = routine à traiter.                                 * +*                                                                             * +*  Description : Classe les blocs d'une routine donnée.                       * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +void rank_routine_blocks(GBinRoutine *routine) +{ +    GInstrBlock *list;                      /* Ensemble des blocs d'instr. */ +    //vmpa_t start;                           /* Adresse de départ           */ +    //GFlowBlock *first;                      /* Premier bloc de la routine  */ + +    list = g_binary_routine_get_basic_blocks(routine); + +    rank_instructions_block(list, list, 0); + +    /* +    start = g_binary_routine_get_address(routine); +    first = G_FLOW_BLOCK(g_instr_block_find_by_addr(list, start, true)); + +    rank_flow_block_content(first, list); +    */ + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : list      = ensemble d'instructions à relier.                * +*                routines  = prototypes existants à insérer.                  * +*                count     = quantité de ces prototypes.                      * +*                statusbar = barre de statut avec progression à mettre à jour.* +*                id        = identifiant du message affiché à l'utilisateur.  * +*                                                                             * +*  Description : Classe les blocs des routines.                               * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +void rank_routines_blocks(GBinRoutine **routines, size_t count, GtkExtStatusBar *statusbar, guint id) +{ +    size_t i;                               /* Boucle de parcours          */ + +    for (i = 0; i < count; i++) +        rank_routine_blocks(routines[i]); + +} diff --git a/src/analysis/disass/rank.h b/src/analysis/disass/rank.h new file mode 100644 index 0000000..04da689 --- /dev/null +++ b/src/analysis/disass/rank.h @@ -0,0 +1,41 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * rank.h - prototypes pour le classement des blocs d'instructions + * + * Copyright (C) 2013 Cyrille Bagard + * + *  This file is part of OpenIDA. + * + *  OpenIDA is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 3 of the License, or + *  (at your option) any later version. + * + *  OpenIDA is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>. + */ + + +#ifndef _ANALYSIS_DISASS_RANK_H +#define _ANALYSIS_DISASS_RANK_H + + +#include "../routine.h" +#include "../../gtkext/gtkextstatusbar.h" + + + +/* Classe les blocs d'une routine donnée. */ +void rank_routine_blocks(GBinRoutine *); + +/* Classe les blocs des routines. */ +void rank_routines_blocks(GBinRoutine **, size_t, GtkExtStatusBar *, guint); + + + +#endif  /* _ANALYSIS_DISASS_RANK_H */ | 
