summaryrefslogtreecommitdiff
path: root/src/arch/instruction.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/instruction.c')
-rw-r--r--src/arch/instruction.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/src/arch/instruction.c b/src/arch/instruction.c
index c9811cf..aced77e 100644
--- a/src/arch/instruction.c
+++ b/src/arch/instruction.c
@@ -1011,6 +1011,35 @@ GArchInstruction *g_arch_instruction_get_next_iter(const GArchInstruction *list,
/******************************************************************************
* *
+* Paramètres : list = liste de lignes à parcourir. *
+* range = emplacement mémoire à comparer. *
+* *
+* Description : Recherche une instruction d'après son emplacement mémoire. *
+* *
+* Retour : Instruction trouvée à l'adresse donnée, NULL si aucune. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GArchInstruction *g_arch_instruction_find_by_range(GArchInstruction *list, const mrange_t *range)
+{
+ GArchInstruction *result; /* Trouvaille à retourner */
+
+ ainstr_list_for_each(result, list)
+ {
+ if (cmp_mrange(&result->range, range) == 0)
+ break;
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : list = liste de lignes à parcourir. *
* addr = position en mémoire ou physique à chercher. *
* strict = définit la considération à porter à l'adresse. *
@@ -1023,16 +1052,19 @@ GArchInstruction *g_arch_instruction_get_next_iter(const GArchInstruction *list,
* *
******************************************************************************/
-GArchInstruction *g_arch_instruction_find_by_address(GArchInstruction *list, vmpa_t addr, bool strict)
+GArchInstruction *g_arch_instruction_find_by_address(GArchInstruction *list, const vmpa2t *addr, bool strict)
{
GArchInstruction *result; /* Trouvaille à retourner */
+ bool found; /* Bilan de comparaisons */
ainstr_list_for_each(result, list)
{
- if (strict && result->offset == addr) break;
+ if (strict)
+ found = (cmp_vmpa(get_mrange_addr(&result->range), addr) == 0);
+ else
+ found = mrange_contains_addr(&result->range, addr);
- else if (!strict && result->offset < addr
- && addr < (result->offset + result->length)) break;
+ if (found) break;
}