summaryrefslogtreecommitdiff
path: root/src/arch/processor.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-12-29 01:40:13 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-12-29 01:40:13 (GMT)
commit73fb6dd90282dd10a6c3febe7348ad698c0336a8 (patch)
tree01fddcbd1c97c6fa6facfae6736b57c4f0317ee6 /src/arch/processor.c
parentb57e8ef5522dcbe126157fc2c50fcf879aa7d743 (diff)
Avoided to crash by being too strict with addresses provided by clicks on the binary strip.
Diffstat (limited to 'src/arch/processor.c')
-rw-r--r--src/arch/processor.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/arch/processor.c b/src/arch/processor.c
index 6b60c8c..cb00a2d 100644
--- a/src/arch/processor.c
+++ b/src/arch/processor.c
@@ -511,14 +511,11 @@ GArchInstruction *g_arch_processor_get_disassembled_instructions(const GArchProc
}
-
-
-
-
/******************************************************************************
* *
-* Paramètres : proc = processeur recensant diverses instructions. *
-* addr = position en mémoire ou physique à chercher. *
+* Paramètres : proc = processeur recensant diverses instructions. *
+* addr = position en mémoire ou physique à chercher. *
+* nearby = la recherche s'effectue-t-elle de façon stricte ? *
* *
* Description : Recherche une instruction d'après son adresse. *
* *
@@ -528,7 +525,7 @@ GArchInstruction *g_arch_processor_get_disassembled_instructions(const GArchProc
* *
******************************************************************************/
-GArchInstruction *g_arch_processor_find_instr_by_address(const GArchProcessor *proc, const vmpa2t *addr)
+GArchInstruction *_g_arch_processor_find_instr_by_address(const GArchProcessor *proc, const vmpa2t *addr, bool nearby)
{
GArchInstruction *result; /* Trouvaille à retourner */
const instr_coverage *coverage; /* Couverture fine à fouiller */
@@ -536,7 +533,7 @@ GArchInstruction *g_arch_processor_find_instr_by_address(const GArchProcessor *p
coverage = g_arch_processor_find_coverage_by_address(proc, addr);
if (coverage != NULL)
- result = g_arch_processor_find_covered_instr_by_address(proc, coverage, addr);
+ result = _g_arch_processor_find_covered_instr_by_address(proc, coverage, addr, nearby);
else
result = NULL;
@@ -550,6 +547,7 @@ GArchInstruction *g_arch_processor_find_instr_by_address(const GArchProcessor *p
* Paramètres : proc = processeur recensant diverses instructions. *
* coverage = zone de couverture fine à fouiller. *
* addr = position en mémoire ou physique à chercher. *
+* nearby = la recherche s'effectue-t-elle de façon stricte ? *
* *
* Description : Recherche rapidement une instruction d'après son adresse. *
* *
@@ -559,10 +557,11 @@ GArchInstruction *g_arch_processor_find_instr_by_address(const GArchProcessor *p
* *
******************************************************************************/
-GArchInstruction *g_arch_processor_find_covered_instr_by_address(const GArchProcessor *proc, const instr_coverage *coverage, const vmpa2t *addr)
+GArchInstruction *_g_arch_processor_find_covered_instr_by_address(const GArchProcessor *proc, const instr_coverage *coverage, const vmpa2t *addr, bool nearby)
{
GArchInstruction *result; /* Trouvaille à retourner */
void *ptr; /* Résultat des recherches */
+ __compar_fn_t fn; /* Fonction auxiliaire adaptée */
int search_for_instr_by_addr(const vmpa2t *a, const GArchInstruction **b)
{
@@ -574,8 +573,23 @@ GArchInstruction *g_arch_processor_find_covered_instr_by_address(const GArchProc
}
+ int search_for_instr_by_nearby_addr(const vmpa2t *a, const GArchInstruction **b)
+ {
+ const mrange_t *range_b; /* Emplacement pour l'instr. B */
+
+ range_b = g_arch_instruction_get_range(*b);
+
+ return cmp_mrange_with_vmpa(range_b, a);
+
+ }
+
+ if (nearby)
+ fn = (__compar_fn_t)search_for_instr_by_nearby_addr;
+ else
+ fn = (__compar_fn_t)search_for_instr_by_addr;
+
ptr = bsearch(addr, &proc->instructions[coverage->start], coverage->count,
- sizeof(GArchInstruction *), (__compar_fn_t)search_for_instr_by_addr);
+ sizeof(GArchInstruction *), fn);
result = (ptr != NULL ? *((GArchInstruction **)ptr) : NULL);