diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2019-05-30 11:03:07 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2019-05-30 11:03:07 (GMT) |
commit | 92737ef0fa002248b0a656ca441ad5f018a12cf3 (patch) | |
tree | 67ae7887735d79fd543ad24d16865a6fc2daa63d | |
parent | 8d822539c4a5625ec57fc440f0ad8c6c1057b2ca (diff) |
Provided instruction iterators for basic blocks.
-rw-r--r-- | src/analysis/disass/block.c | 46 | ||||
-rw-r--r-- | src/analysis/disass/block.h | 3 |
2 files changed, 49 insertions, 0 deletions
diff --git a/src/analysis/disass/block.c b/src/analysis/disass/block.c index 8da671b..8cdbc8f 100644 --- a/src/analysis/disass/block.c +++ b/src/analysis/disass/block.c @@ -875,3 +875,49 @@ void g_basic_block_get_boundaries(const GBasicBlock *block, GArchInstruction **f } } + + +/****************************************************************************** +* * +* Paramètres : block = bloc d'instructions à consulter. * +* proc = processeur contenant l'ensemble des instructions. * +* * +* Description : Fournit un itérateur d'instructions limité au bloc basique. * +* * +* Retour : Itérateur mis en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +instr_iter_t *g_basic_block_get_iterator(const GBasicBlock *block, GArchProcessor *proc) +{ + instr_iter_t *result; /* Itérateur à renvoyer */ + const mrange_t *first_range; /* Emplacement d'instruction #1*/ + const vmpa2t *first_addr; /* Point de départ associé */ + const mrange_t *last_range; /* Emplacement d'instruction #2*/ + phys_t length; /* Taille de la couverture */ + mrange_t range; /* Couverture du bloc */ + + first_range = g_arch_instruction_get_range(block->first); + + first_addr = get_mrange_addr(first_range); + + result = g_arch_processor_get_iter_from_address(proc, first_addr); + + if (result != NULL) + { + last_range = g_arch_instruction_get_range(block->last); + + length = compute_vmpa_diff(first_addr, get_mrange_addr(last_range)); + length += get_mrange_length(last_range); + + init_mrange(&range, first_addr, length); + + restrict_instruction_iterator(result, &range); + + } + + return result; + +} diff --git a/src/analysis/disass/block.h b/src/analysis/disass/block.h index a7c157d..f622b61 100644 --- a/src/analysis/disass/block.h +++ b/src/analysis/disass/block.h @@ -62,6 +62,9 @@ GCodeBlock *g_basic_block_new(GLoadedBinary *, GArchInstruction *, GArchInstruct /* Fournit les instructions limites d'un bloc basique. */ void g_basic_block_get_boundaries(const GBasicBlock *, GArchInstruction **, GArchInstruction **); +/* Fournit un itérateur d'instructions limité au bloc basique. */ +instr_iter_t *g_basic_block_get_iterator(const GBasicBlock *, GArchProcessor *); + #endif /* _ANALYSIS_DISASS_BLOCK_H */ |