diff options
Diffstat (limited to 'src/arch/artificial.c')
-rw-r--r-- | src/arch/artificial.c | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/src/arch/artificial.c b/src/arch/artificial.c new file mode 100644 index 0000000..d718a8c --- /dev/null +++ b/src/arch/artificial.c @@ -0,0 +1,168 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * artificial.c - instructions pures vues de l'esprit + * + * Copyright (C) 2009 Cyrille Bagard + * + * This file is part of OpenIDA. + * + * OpenIDA is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * OpenIDA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "artificial.h" + + +#include "immediate.h" +#include "instruction-int.h" + + + +/* ------------------------- INSTRUCTION INCONNUE / DONNEES ------------------------- */ + + +/* Définition générique d'une instruction d'architecture inconnue (instance) */ +struct _GDbInstruction +{ + GArchInstruction parent; /* A laisser en premier */ + +}; + +/* Définition générique d'une instruction d'architecture inconnue (classe) */ +struct _GDbInstructionClass +{ + GArchInstructionClass parent; /* A laisser en premier */ + +}; + + +/* Initialise la classe générique des opérandes. */ +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 exe_format *, AsmSyntax); + + +/* ---------------------------------------------------------------------------------- */ +/* INSTRUCTION INCONNUE / DONNEES */ +/* ---------------------------------------------------------------------------------- */ + + +/* Indique le type défini pour une instruction inconnue d'architecture. */ +G_DEFINE_TYPE(GDbInstruction, g_db_instruction, G_TYPE_ARCH_INSTRUCTION); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe générique des opérandes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_db_instruction_class_init(GDbInstructionClass *klass) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instance à initialiser. * +* * +* Description : Initialise une instance d'instruction d'architecture. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_db_instruction_init(GDbInstruction *instr) +{ + GArchInstruction *parent; /* Instance parente */ + + parent = G_ARCH_INSTRUCTION(instr); + + parent->get_text = (get_instruction_text_fc)g_db_instruction_get_text; + +} + + +/****************************************************************************** +* * +* Paramètres : data = flux de données à analyser. * +* pos = position courante dans ce flux. [OUT] * +* len = taille totale des données à analyser. * +* addr = adresse, virtuelle ou physique, de l'instruction. * +* proc = architecture ciblée par le désassemblage. * +* * +* Description : Crée une instruction de type 'db' à partir de données. * +* * +* Retour : Instruction mise en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *g_db_instruction_new_from_data(const bin_t *data, off_t *pos, off_t len, vmpa_t addr, const GArchProcessor *proc) +{ + GArchInstruction *result; /* Instruction à retourner */ + GArchOperand *operand; /* Octet non décodé à afficher */ + + result = g_object_new(G_TYPE_DB_INSTRUCTION, NULL); + + operand = g_imm_operand_new_from_data(MDS_8_BITS, data, pos, len, + g_arch_processor_get_endianness(proc)); + if (operand == NULL) goto gdinfd_error; + + g_arch_instruction_attach_one_operand(result, operand); + + return result; + + gdinfd_error: + + /* TODO */ + + return NULL; + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instruction à traiter. * +* format = format du binaire manipulé. * +* syntax = type de représentation demandée. * +* * +* Description : Traduit une instruction en version humainement lisible. * +* * +* Retour : Chaîne de caractères à libérer de la mémoire. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static const char *g_db_instruction_get_text(const GDbInstruction *instr, const exe_format *format, AsmSyntax syntax) +{ + return "db"; + +} |