/* Chrysalide - Outil d'analyse de fichiers binaires * moffs.c - opérandes d'emplacements mémoire * * Copyright (C) 2012-2017 Cyrille Bagard * * This file is part of Chrysalide. * * Chrysalide 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. * * Chrysalide 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 . */ #include "moffs.h" #include "../../immediate.h" #include "../../operand-int.h" /* Définition d'un opérande visant un emplacement mémoire x86 (instance) */ struct _GX86MOffsOperand { GArchOperand parent; /* Instance parente */ GImmOperand *offset; /* Adresse mémoire visée */ }; /* Définition d'un opérande visant un emplacement mémoire x86 (classe) */ struct _GX86MOffsOperandClass { GArchOperandClass parent; /* Classe parente */ }; /* Initialise la classe des opérandes d'emplacement mémoire x86. */ static void g_x86_moffs_operand_class_init(GX86MOffsOperandClass *); /* Initialise une instance d'opérande d'emplacement mémoire x86. */ static void g_x86_moffs_operand_init(GX86MOffsOperand *); /* Indique le type défini par la GLib pour un opérande d'emplacement mémoire x86. */ G_DEFINE_TYPE(GX86MOffsOperand, g_x86_moffs_operand, G_TYPE_ARCH_OPERAND); /****************************************************************************** * * * Paramètres : klass = classe à initialiser. * * * * Description : Initialise la classe des opérandes d'emplacement mémoire x86.* * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ static void g_x86_moffs_operand_class_init(GX86MOffsOperandClass *klass) { } /****************************************************************************** * * * Paramètres : operand = instance à initialiser. * * * * Description : Initialise une instance d'opérande d'emplacement mémoire x86.* * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ static void g_x86_moffs_operand_init(GX86MOffsOperand *operand) { } /****************************************************************************** * * * Paramètres : data = flux de données à analyser. * * pos = position courante dans ce flux. [OUT] * * len = taille totale des données à analyser. * * size = taille de l'opérande, et donc du registre. * * * * Description : Crée un opérande d'emplacement mémoire x86. * * * * Retour : Opérande mis en place. * * * * Remarques : - * * * ******************************************************************************/ GArchOperand *g_x86_moffs_operand_new(const bin_t *data, off_t *pos, off_t len, MemoryDataSize size) { GX86MOffsOperand *result; /* Structure à retourner */ GImmOperand *offset; /* Emplacement lu */ result = NULL; assert(0); //offset = g_imm_operand_new_from_data_old(size, data, pos, len, SRE_LITTLE /* FIXME */); if (offset != NULL) { result = g_object_new(G_TYPE_X86_MOFFS_OPERAND, NULL); result->offset = offset; } return G_ARCH_OPERAND(result); } #if 0 /****************************************************************************** * * * Paramètres : operand = opérande à transcrire. * * options = options de rendu. * * rendering = support effectif final des lignes de code. * * stream = flux ouvert en écriture. * * * * Description : Ajoute du texte simple à un fichier ouvert en écriture. * * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ static void g_x86_moffs_operand_add_text(const GX86MOffsOperand *operand, GRenderingOptions *options, MainRendering rendering, FILE *stream) { g_content_exporter_insert_text(G_CONTENT_EXPORTER(operand), stream, "ds:", 3, RTT_SEGMENT); g_content_exporter_add_text(G_CONTENT_EXPORTER(operand->offset), options, rendering, stream); } /****************************************************************************** * * * Paramètres : operand = opérande à transcrire. * * buffer = espace où placer ledit contenu. * * options = options de rendu. * * * * Description : Ajoute à un tampon GLib le contenu de l'instance spécifiée. * * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ static void g_x86_moffs_operand_to_buffer(const GX86MOffsOperand *operand, GBufferLine *buffer, GRenderingOptions *options) { g_content_exporter_insert_into_buffer(G_CONTENT_EXPORTER(operand), buffer, BLC_ASSEMBLY, "ds:", 3, RTT_SEGMENT); g_content_exporter_to_buffer(G_CONTENT_EXPORTER(operand->offset), buffer, options); } #endif