summaryrefslogtreecommitdiff
path: root/src/analysis/disass
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-01-14 20:52:47 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-01-14 20:52:47 (GMT)
commitea60c6e86b0b86319cf2fc01ca1a7608c5fac9c0 (patch)
treec55808464e1a433c6147c460dded96d19df0b373 /src/analysis/disass
parenta4fde950b940582a0e21a84c6c98a79f945fde02 (diff)
Looked for code blocks by any contained address.
Diffstat (limited to 'src/analysis/disass')
-rw-r--r--src/analysis/disass/block.c42
1 files changed, 32 insertions, 10 deletions
diff --git a/src/analysis/disass/block.c b/src/analysis/disass/block.c
index 23393f6..ec8cf2a 100644
--- a/src/analysis/disass/block.c
+++ b/src/analysis/disass/block.c
@@ -68,8 +68,8 @@ static void g_basic_block_dispose(GBasicBlock *);
/* Procède à la libération totale de la mémoire. */
static void g_basic_block_finalize(GBasicBlock *);
-/* Détermine si un bloc de code débute à une adresse donnée. */
-static bool g_basic_block_is_starting_with(const GBasicBlock *, const vmpa2t *);
+/* Détermine si un bloc de code contient une adresse donnée. */
+static bool g_basic_block_contains_addr(const GBasicBlock *, const vmpa2t *);
/* Fournit les détails des origines d'un bloc de code donné. */
static block_link_t *g_basic_block_get_sources(const GBasicBlock *, const GBlockList *, size_t *);
@@ -115,7 +115,7 @@ static void g_basic_block_class_init(GBasicBlockClass *class)
block = G_CODE_BLOCK_CLASS(class);
- block->is_starting = (block_is_starting_fc)g_basic_block_is_starting_with;
+ block->contains = (block_contains_fc)g_basic_block_contains_addr;
block->get_src = (block_get_links_fc)g_basic_block_get_sources;
block->get_dest = (block_get_links_fc)g_basic_block_get_destinations;
block->build = (block_build_view_fc)g_basic_block_build_view;
@@ -229,7 +229,7 @@ GCodeBlock *g_basic_block_new(GLoadedBinary *binary, GArchInstruction *first, GA
* Paramètres : block = bloc de code à consulter. *
* addr = localisation à comparer. *
* *
-* Description : Détermine si un bloc de code débute à une adresse donnée. *
+* Description : Détermine si un bloc de code contient une adresse donnée. *
* *
* Retour : - *
* *
@@ -237,14 +237,36 @@ GCodeBlock *g_basic_block_new(GLoadedBinary *binary, GArchInstruction *first, GA
* *
******************************************************************************/
-static bool g_basic_block_is_starting_with(const GBasicBlock *block, const vmpa2t *addr)
+static bool g_basic_block_contains_addr(const GBasicBlock *block, const vmpa2t *addr)
{
bool result; /* Bilan à retourner */
- const mrange_t *range; /* Couverture d'instruction */
+ const mrange_t *frange; /* Couverture d'instruction #1 */
+ const mrange_t *lrange; /* Couverture d'instruction #2 */
+ phys_t diff; /* Ecart entre les positions */
+ mrange_t coverage; /* Couverture du bloc */
+
+ frange = g_arch_instruction_get_range(block->first);
+
+ result = (cmp_vmpa(addr, get_mrange_addr(frange)) == 0);
+
+ if (!result)
+ {
+ lrange = g_arch_instruction_get_range(block->last);
+
+ result = (cmp_vmpa(addr, get_mrange_addr(lrange)) == 0);
- range = g_arch_instruction_get_range(block->first);
+ if (!result)
+ {
+ diff = compute_vmpa_diff(get_mrange_addr(frange), get_mrange_addr(lrange));
+ diff += get_mrange_length(lrange);
+
+ init_mrange(&coverage, get_mrange_addr(frange), diff);
+
+ result = mrange_contains_addr(&coverage, addr);
- result = (cmp_vmpa(addr, get_mrange_addr(range)) == 0);
+ }
+
+ }
return result;
@@ -287,7 +309,7 @@ static block_link_t *g_basic_block_get_sources(const GBasicBlock *block, const G
range = g_arch_instruction_get_range(src->linked);
- target = g_block_list_find_by_starting_addr(list, get_mrange_addr(range));
+ target = g_block_list_find_by_addr(list, get_mrange_addr(range));
/**
* Les liens ne sont pas toujours internes !
@@ -359,7 +381,7 @@ static block_link_t *g_basic_block_get_destinations(const GBasicBlock *block, co
range = g_arch_instruction_get_range(dest->linked);
- target = g_block_list_find_by_starting_addr(list, get_mrange_addr(range));
+ target = g_block_list_find_by_addr(list, get_mrange_addr(range));
/**
* Les sauts ne se font pas toujours à l'intérieur d'une même fonction.