summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/instruction-int.h3
-rw-r--r--src/arch/instruction.c21
-rw-r--r--src/arch/instruction.h2
-rw-r--r--src/arch/processor.c4
-rw-r--r--src/arch/processor.h2
5 files changed, 30 insertions, 2 deletions
diff --git a/src/arch/instruction-int.h b/src/arch/instruction-int.h
index 895c29f..32c8c8c 100644
--- a/src/arch/instruction-int.h
+++ b/src/arch/instruction-int.h
@@ -65,6 +65,9 @@ struct _asm_instr
uint64_t vaddress; /* Adresse virtuelle associée */
+ off_t offset; /* Position physique de départ */
+ off_t length; /* Taille de l'instruction */
+
AsmInstrType type; /* Type d'instruction */
asm_operand **operands; /* Liste des opérandes */
diff --git a/src/arch/instruction.c b/src/arch/instruction.c
index ada3d58..a03ced4 100644
--- a/src/arch/instruction.c
+++ b/src/arch/instruction.c
@@ -66,3 +66,24 @@ asm_instr *create_db_instruction(const uint8_t *data, off_t *pos, off_t len)
}
+
+/******************************************************************************
+* *
+* Paramètres : instr = instruction quelconque à traiter. *
+* offset = position physique dans le code binaire / NULL. [OUT]*
+* length = taille de l'instruction ou NULL. [OUT] *
+* *
+* Description : Indique la position et/ou la taille d'une instruction. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void get_asm_instr_offset_and_length(const asm_instr *instr, off_t *offset, off_t *length)
+{
+ if (offset != NULL) *offset = instr->offset;
+ if (length != NULL) *length = instr->length;
+
+}
diff --git a/src/arch/instruction.h b/src/arch/instruction.h
index 19cc6ab..6af865b 100644
--- a/src/arch/instruction.h
+++ b/src/arch/instruction.h
@@ -38,6 +38,8 @@ typedef struct _asm_instr asm_instr;
/* Crée une instruction de type 'db' à partir de données. */
asm_instr *create_db_instruction(const uint8_t *, off_t *, off_t);
+/* Indique la position et/ou la taille d'une instruction. */
+void get_asm_instr_offset_and_length(const asm_instr *, off_t *, off_t *);
diff --git a/src/arch/processor.c b/src/arch/processor.c
index 17f88b3..71cdfba 100644
--- a/src/arch/processor.c
+++ b/src/arch/processor.c
@@ -52,7 +52,7 @@
* *
******************************************************************************/
-asm_instr *decode_instruction(const asm_processor *proc, const uint8_t *data, off_t *pos, off_t len, uint64_t offset)
+asm_instr *decode_instruction(const asm_processor *proc, const uint8_t *data, off_t *pos, off_t len, off_t off, uint64_t offset)
{
asm_instr *result; /* Représentation à renvoyer */
@@ -79,6 +79,8 @@ asm_instr *decode_instruction(const asm_processor *proc, const uint8_t *data, of
result->vaddress = offset;
+ result->offset = off + old_pos;
+ result->length = *pos - old_pos;
return result;
diff --git a/src/arch/processor.h b/src/arch/processor.h
index 287a761..7fc1023 100644
--- a/src/arch/processor.h
+++ b/src/arch/processor.h
@@ -40,7 +40,7 @@ typedef struct _asm_processor asm_processor;
/* Décode une instruction dans un flux de données. */
-asm_instr *decode_instruction(const asm_processor *, const uint8_t *, off_t *, off_t, uint64_t);
+asm_instr *decode_instruction(const asm_processor *, const uint8_t *, off_t *, off_t, off_t, uint64_t);
/* Traduit une instruction en version humainement lisible. */
void print_hinstruction(const asm_processor *, const exe_format *, const asm_instr *, char *, size_t, AsmSyntax);