diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2014-08-05 20:19:08 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2014-08-05 20:19:08 (GMT) |
commit | 56ee4d3ecddeee05f11083fcc1595e3756b91790 (patch) | |
tree | 5ec6e5449214093280629047c36016a0de09cbeb /src/arch/artificial.c | |
parent | a2eb5483fe74923e488013b2d8b94ded6340499e (diff) |
Defined the first steps for a new disassembling approach.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@387 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/artificial.c')
-rw-r--r-- | src/arch/artificial.c | 80 |
1 files changed, 72 insertions, 8 deletions
diff --git a/src/arch/artificial.c b/src/arch/artificial.c index 6fbd6d9..4131e5f 100644 --- a/src/arch/artificial.c +++ b/src/arch/artificial.c @@ -57,8 +57,14 @@ static void g_db_instruction_class_init(GDbInstructionClass *); /* Initialise une instance d'opérande d'architecture. */ static void g_db_instruction_init(GDbInstruction *); -/* Traduit une instruction en version humainement lisible. */ -static const char *g_db_instruction_get_text(const GDbInstruction *, const GExeFormat *, AsmSyntax); +/* Supprime toutes les références externes. */ +static void g_db_instruction_dispose(GDbInstruction *); + +/* Procède à la libération totale de la mémoire. */ +static void g_db_instruction_finalize(GDbInstruction *); + +/* Fournit le nom humain de l'instruction manipulée. */ +static const char *g_db_instruction_get_keyword(const GDbInstruction *, AsmSyntax); /* Informe sur une éventuelle référence à une autre instruction. */ static InstructionLinkType g_db_instruction_get_link(const GDbInstruction *, vmpa_t *); @@ -91,6 +97,17 @@ G_DEFINE_TYPE(GDbInstruction, g_db_instruction, G_TYPE_ARCH_INSTRUCTION); static void g_db_instruction_class_init(GDbInstructionClass *klass) { + GObjectClass *object; /* Autre version de la classe */ + GArchInstructionClass *instr; /* Encore une autre vision... */ + + object = G_OBJECT_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_db_instruction_dispose; + object->finalize = (GObjectFinalizeFunc)g_db_instruction_finalize; + + instr = G_ARCH_INSTRUCTION_CLASS(klass); + + instr->get_key = (get_instruction_keyword_fc)g_db_instruction_get_keyword; } @@ -113,7 +130,6 @@ static void g_db_instruction_init(GDbInstruction *instr) parent = G_ARCH_INSTRUCTION(instr); - parent->get_text = (get_instruction_text_fc)g_db_instruction_get_text; parent->get_link = (get_instruction_link_fc)g_db_instruction_get_link; parent->is_return = (is_instruction_return_fc)g_db_instruction_is_return; @@ -122,6 +138,44 @@ static void g_db_instruction_init(GDbInstruction *instr) /****************************************************************************** * * +* Paramètres : instr = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_db_instruction_dispose(GDbInstruction *instr) +{ + G_OBJECT_CLASS(g_db_instruction_parent_class)->dispose(G_OBJECT(instr)); + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_db_instruction_finalize(GDbInstruction *instr) +{ + G_OBJECT_CLASS(g_db_instruction_parent_class)->finalize(G_OBJECT(instr)); + +} + + +/****************************************************************************** +* * * Paramètres : data = flux de données à analyser. * * pos = position courante dans ce flux. [OUT] * * end = limite des données à analyser. * @@ -136,16 +190,26 @@ static void g_db_instruction_init(GDbInstruction *instr) * * ******************************************************************************/ -GArchInstruction *g_db_instruction_new_from_data(const bin_t *data, off_t *pos, off_t end, vmpa_t addr, const GArchProcessor *proc) +GArchInstruction *g_db_instruction_new_from_data(const bin_t *data, vmpa2t *address, off_t end, const GArchProcessor *proc) { GArchInstruction *result; /* Instruction à retourner */ + off_t pos; + off_t old; GArchOperand *operand; /* Octet non décodé à afficher */ result = g_object_new(G_TYPE_DB_INSTRUCTION, NULL); + pos = get_phy_addr(address); + old = pos; + operand = g_imm_operand_new_from_data(g_arch_processor_get_instruction_size(proc), - data, pos, end, + data, &pos, end, g_arch_processor_get_endianness(proc)); + + address->physical += (pos - old); + + /* FIXME : essayer une taille plus petite en cas d'échec (on peut être en bout de binaire) */ + if (operand == NULL) goto gdinfd_error; g_imm_operand_pad(G_IMM_OPERAND(operand), true); @@ -169,15 +233,15 @@ GArchInstruction *g_db_instruction_new_from_data(const bin_t *data, off_t *pos, * format = format du binaire manipulé. * * syntax = type de représentation demandée. * * * -* Description : Traduit une instruction en version humainement lisible. * +* Description : Fournit le nom humain de l'instruction manipulée. * * * -* Retour : Chaîne de caractères à libérer de la mémoire. * +* Retour : Mot clef de bas niveau. * * * * Remarques : - * * * ******************************************************************************/ -static const char *g_db_instruction_get_text(const GDbInstruction *instr, const GExeFormat *format, AsmSyntax syntax) +static const char *g_db_instruction_get_keyword(const GDbInstruction *instr, AsmSyntax syntax) { return "db"; |