diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2008-09-14 20:54:43 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2008-09-14 20:54:43 (GMT) |
commit | 06cf576b280cbabb73a956161693a63ee846f57b (patch) | |
tree | 3ac4b32e869cc8aaa1d4b7429d7d4a12f9a8ae7f /src/arch/x86/operand.c | |
parent | ab1489b6a6ef1f09957f6f805f143fceb42f6a08 (diff) |
Made the program able to disassemble a simple binary completely.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@30 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/x86/operand.c')
-rw-r--r-- | src/arch/x86/operand.c | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/src/arch/x86/operand.c b/src/arch/x86/operand.c index 281c139..10a908e 100644 --- a/src/arch/x86/operand.c +++ b/src/arch/x86/operand.c @@ -505,7 +505,7 @@ asm_x86_operand *x86_create_rm8_operand(const uint8_t *data, off_t *pos, off_t l free(result); result = create_new_x86_operand(); - if (!fill_imm_operand(ASM_OPERAND(result), AOS_8_BITS, data, pos, len)) + if (!fill_imm_operand(ASM_OPERAND(result), AOS_32_BITS/* FIXME! 16/32 */, data, pos, len)) { free(result); return NULL; @@ -573,7 +573,7 @@ asm_x86_operand *x86_create_rm8_operand(const uint8_t *data, off_t *pos, off_t l case 0x80: result->displacement = create_new_x86_operand(); - if (!fill_imm_operand(ASM_OPERAND(result->displacement), AOS_8_BITS, data, pos, len)) + if (!fill_imm_operand(ASM_OPERAND(result->displacement), AOS_32_BITS/* FIXME ! 16/32 */, data, pos, len)) { free(result->displacement); free(result); @@ -1188,3 +1188,54 @@ void x86_print_moffs_operand(const asm_x86_operand *operand, char *buffer, size_ } } + + + +/* ---------------------------------------------------------------------------------- */ +/* OPERANDES D'ADRESSES RELATIVES */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +* * +* Paramètres : data = flux de données à analyser. * +* pos = position courante dans ce flux. [OUT] * +* len = taille totale des données à analyser. * +* * +* Description : Crée une opérande à partir d'une adresse relative (8 bits). * +* * +* Retour : Opérande mise en place ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +asm_x86_operand *x86_create_rel8_operand_in_32b(uint64_t base, const uint8_t *data, off_t *pos, off_t len) +{ + asm_x86_operand *result; /* Emplacement à retourner */ + off_t init_pos; /* Position avant lecture */ + int8_t offset; /* Décallage à appliquer */ + uint32_t address; /* Adresse finale visée */ + + result = create_new_x86_operand(); + + init_pos = *pos; + address = base; + + if (!read_imm_value(AOS_8_BITS, data, pos, len, &offset)) + { + free(result); + return NULL; + } + + address = base + (*pos - init_pos) + offset; + + if (!fill_imm_operand_with_value(ASM_OPERAND(result), AOS_32_BITS, &address)) + { + free(result); + return NULL; + } + + return result; + +} |