diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-04-03 12:48:41 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-04-03 12:48:41 (GMT) |
commit | f80c4c6ee0479070f7319a5ce7e30e05406cdb8f (patch) | |
tree | 94bc363a6d1aeac29c1985a9627ceda962d1c38a /src/arch | |
parent | 36a5b2577d67ab7c9f2c5817f6dba7a9601d1f20 (diff) |
Reorganized the whole disassembling process and displayed the relative progression.
Diffstat (limited to 'src/arch')
-rw-r--r-- | src/arch/arm/v7/post.c | 12 | ||||
-rw-r--r-- | src/arch/instruction.h | 3 | ||||
-rw-r--r-- | src/arch/processor.c | 52 | ||||
-rw-r--r-- | src/arch/processor.h | 6 |
4 files changed, 72 insertions, 1 deletions
diff --git a/src/arch/arm/v7/post.c b/src/arch/arm/v7/post.c index e066bb0..0692cea 100644 --- a/src/arch/arm/v7/post.c +++ b/src/arch/arm/v7/post.c @@ -57,6 +57,10 @@ void post_process_branch_instructions(GArchInstruction *instr, GArchProcessor *p op = g_arch_instruction_get_operand(instr, 0); + + if (!G_IS_IMM_OPERAND(op)) return; + + if (g_imm_operand_get_value(G_IMM_OPERAND(op), MDS_32_BITS_UNSIGNED, &addr) && g_exe_format_translate_address_into_vmpa(G_EXE_FORMAT(format), addr, &target)) { @@ -121,6 +125,10 @@ void post_process_branch_and_link_instructions(GArchInstruction *instr, GArchPro op = g_arch_instruction_get_operand(instr, 0); + + if (!G_IS_IMM_OPERAND(op)) return; + + if (g_imm_operand_get_value(G_IMM_OPERAND(op), MDS_32_BITS_UNSIGNED, &addr) && g_exe_format_translate_address_into_vmpa(G_EXE_FORMAT(format), addr, &target)) { @@ -195,6 +203,10 @@ void post_process_comp_and_branch_instructions(GArchInstruction *instr, GArchPro op = g_arch_instruction_get_operand(instr, 1); + + if (!G_IS_IMM_OPERAND(op)) return; + + if (g_imm_operand_get_value(G_IMM_OPERAND(op), MDS_32_BITS_UNSIGNED, &addr) && g_exe_format_translate_address_into_vmpa(G_EXE_FORMAT(format), addr, &target)) { diff --git a/src/arch/instruction.h b/src/arch/instruction.h index 0db68c7..d75cf54 100644 --- a/src/arch/instruction.h +++ b/src/arch/instruction.h @@ -248,7 +248,8 @@ GArchInstruction *g_arch_instruction_get_next_iter(const GArchInstruction *, con GArchInstruction *g_arch_instruction_find_by_range(GArchInstruction *, const mrange_t *); /* Recherche une instruction d'après son adresse. */ -GArchInstruction *g_arch_instruction_find_by_address(GArchInstruction *, const vmpa2t *, bool); +GArchInstruction *g_arch_instruction_find_by_address(GArchInstruction *, const vmpa2t *, bool) __attribute__ ((deprecated)); +/* -> g_arch_processor_find_instr_by_address */ diff --git a/src/arch/processor.c b/src/arch/processor.c index 21db869..da5ddce 100644 --- a/src/arch/processor.c +++ b/src/arch/processor.c @@ -520,6 +520,58 @@ GArchInstruction *g_arch_processor_get_disassembled_instructions(const GArchProc /****************************************************************************** * * +* Paramètres : proc = architecture visée par la procédure. * +* index = indice de l'instruction visée. * +* * +* Description : Fournit une instruction désassemblée pour une architecture. * +* * +* Retour : Instructions désassemblée trouvée ou NULL si aucune. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *g_arch_processor_get_disassembled_instruction(const GArchProcessor *proc, size_t index) +{ + GArchInstruction *result; /* Instruction à retourner */ + + if (proc->instr_count == 0) + result = NULL; + + else + { + assert(index < proc->instr_count); + + result = proc->instructions[index]; + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : proc = architecture visée par la procédure. * +* * +* Description : Compte le nombre d'instructions représentées. * +* * +* Retour : Nombre d'instructions présentes. * +* * +* Remarques : - * +* * +******************************************************************************/ + +size_t g_arch_processor_count_disassembled_instructions(const GArchProcessor *proc) +{ + return proc->instr_count; + +} + + +/****************************************************************************** +* * * 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 ? * diff --git a/src/arch/processor.h b/src/arch/processor.h index 82c4f18..9dee9f6 100644 --- a/src/arch/processor.h +++ b/src/arch/processor.h @@ -91,6 +91,12 @@ void g_arch_processor_set_disassembled_instructions(GArchProcessor *, GArchInstr /* Fournit les instructions désassemblées pour une architecture. */ GArchInstruction *g_arch_processor_get_disassembled_instructions(const GArchProcessor *); +/* Fournit une instruction désassemblée pour une architecture. */ +GArchInstruction *g_arch_processor_get_disassembled_instruction(const GArchProcessor *, size_t); + +/* Compte le nombre d'instructions représentées. */ +size_t g_arch_processor_count_disassembled_instructions(const GArchProcessor *); + /* Recherche un groupe d'instruction d'après son adresse. */ const instr_coverage *g_arch_processor_find_coverage_by_address(const GArchProcessor *, const vmpa2t *); |