diff options
Diffstat (limited to 'src/arch/artificial.c')
-rw-r--r-- | src/arch/artificial.c | 309 |
1 files changed, 0 insertions, 309 deletions
diff --git a/src/arch/artificial.c b/src/arch/artificial.c deleted file mode 100644 index a6fea56..0000000 --- a/src/arch/artificial.c +++ /dev/null @@ -1,309 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * artificial.c - instructions pures vues de l'esprit - * - * Copyright (C) 2009-2012 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * 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 <string.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 */ - -#ifdef DEBUG - bool skipped; /* Donnée traitée */ -#endif - -}; - -/* 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 *); - -/* 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 *); - -/* Reconstruit le cache complet d'une désignation d'instruction. */ -static void g_db_instruction_build_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 *); - - - -/* ---------------------------------------------------------------------------------- */ -/* 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) -{ - 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->build_key = (build_instruction_keyword_fc)g_db_instruction_build_keyword; - -} - - -/****************************************************************************** -* * -* 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_link = (get_instruction_link_fc)g_db_instruction_get_link; - -} - - -/****************************************************************************** -* * -* 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. * -* 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, 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_old(g_arch_processor_get_instruction_size(proc), - 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); - - g_arch_instruction_attach_extra_operand(result, operand); - - return result; - - gdinfd_error: - - g_object_unref(G_OBJECT(result)); - - return NULL; - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction à traiter. * -* format = format du binaire manipulé. * -* syntax = type de représentation demandée. * -* * -* Description : Reconstruit le cache complet d'une désignation d'instruction.* -* * -* Retour : Mot clef de bas niveau. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_db_instruction_build_keyword(const GDbInstruction *instr, AsmSyntax syntax) -{ - G_ARCH_INSTRUCTION(instr)->cached_keyword = strdup("db"); - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction à consulter. * -* addr = eventuelle adresse associée à faire connaître. [OUT] * -* * -* Description : Informe sur une éventuelle référence à une autre instruction.* -* * -* Retour : Type de lien trouvé ou ILT_NONE si aucun. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static InstructionLinkType g_db_instruction_get_link(const GDbInstruction *instr, vmpa_t *addr) -{ - return ILT_NONE; - -} - - -#ifdef DEBUG - -/****************************************************************************** -* * -* Paramètres : instr = instruction à mettre à jour. * -* * -* Description : Marque une donnée comme ayant été considérée au sein du code.* -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_db_instruction_mark_as_skipped(GDbInstruction *instr) -{ - instr->skipped = true; - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction à consulter. * -* * -* Description : Indique si une donnée fait partie du code exécutable. * -* * -* Retour : true si la donnée est intégrée dans le code, false sinon. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool g_db_instruction_is_skipped(const GDbInstruction *instr) -{ - return instr->skipped; - -} - -#endif |