/* Chrysalide - Outil d'analyse de fichiers binaires * roptions.c - options de rendus des lignes de code * * 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 . */ #include "roptions.h" /* Options de représentation (instance) */ struct _GRenderingOptions { GExeFormat *format; /* Format du contenu bianire */ GArchProcessor *proc; /* Architecture utilisée */ AsmSyntax syntax; /* Style de rendu ASM */ bool show_address[MRD_COUNT]; /* Affichage de l'adresse ? */ bool show_code[MRD_COUNT]; /* Affichage du code brut ? */ }; /* Options de représentation (classe) */ struct _GRenderingOptionsClass { GObjectClass parent; /* A laisser en premier */ }; /* Initialise la classe des options pour le rendu des lignes. */ static void g_rendering_options_class_init(GRenderingOptionsClass *); /* Initialise une instance d'options pour le rendu des lignes. */ static void g_rendering_options_init(GRenderingOptions *); /* Indique le type définit pour une ligne de représentation. */ G_DEFINE_TYPE(GRenderingOptions, g_rendering_options, G_TYPE_OBJECT); /****************************************************************************** * * * Paramètres : klass = classe à initialiser. * * * * Description : Initialise la classe des options pour le rendu des lignes. * * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ static void g_rendering_options_class_init(GRenderingOptionsClass *klass) { } /****************************************************************************** * * * Paramètres : options = instance à initialiser. * * * * Description : Initialise une instance d'options pour le rendu des lignes. * * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ static void g_rendering_options_init(GRenderingOptions *options) { } /****************************************************************************** * * * Paramètres : format = format du contenu binaire. * * * * Description : Crée un un groupe d'options pour le rendu des lignes. * * * * Retour : Adresse de la structure mise en place. * * * * Remarques : - * * * ******************************************************************************/ GRenderingOptions *g_rendering_options_new(GExeFormat *format) { GRenderingOptions *result; /* Structure à retourner */ result = g_object_new(G_TYPE_RENDERING_OPTIONS, NULL); result->format = format; result->proc = NULL;//get_arch_processor_from_format(format); return result; } /****************************************************************************** * * * Paramètres : options = options à consulter. * * * * Description : Fournit le format du contenu binaire représenté. * * * * Retour : Format du contenu binaire. * * * * Remarques : - * * * ******************************************************************************/ GExeFormat *g_rendering_options_get_format(const GRenderingOptions *options) { return options->format; } /****************************************************************************** * * * Paramètres : options = options à consulter. * * * * Description : Fournit l'architecture du contenu binaire représenté. * * * * Retour : Architecture utilisée par le binaire. * * * * Remarques : - * * * ******************************************************************************/ GArchProcessor *g_rendering_options_get_processor(const GRenderingOptions *options) { return options->proc; } /****************************************************************************** * * * Paramètres : options = options à consulter. * * * * Description : Fournit le style de rendu pour le contenu ASM. * * * * Retour : Style de rendu pour le langage d'assemblage. * * * * Remarques : - * * * ******************************************************************************/ AsmSyntax g_rendering_options_get_syntax(const GRenderingOptions *options) { return options->syntax; } /****************************************************************************** * * * Paramètres : options = options à mettre à jour. * * rendering = type de rendu impliqué. * * state = nouvel état de l'option visée. * * * * Description : Affiche (ou non) les adresses des instructions. * * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ void g_rendering_options_show_address(GRenderingOptions *options, MainRendering rendering, bool state) { options->show_address[rendering] = state; } /****************************************************************************** * * * Paramètres : options = options à consulter. * * rendering = type de rendu impliqué. * * * * Description : Indique si les adresses des instructions sont à afficher. * * * * Retour : Etat courant de l'option visée. * * * * Remarques : - * * * ******************************************************************************/ bool g_rendering_options_has_to_show_address(const GRenderingOptions *options, MainRendering rendering) { return options->show_address[rendering]; } /****************************************************************************** * * * Paramètres : options = options à mettre à jour. * * rendering = type de rendu impliqué. * * state = nouvel état de l'option visée. * * * * Description : Affiche (ou non) le code des instructions. * * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ void g_rendering_options_show_code(GRenderingOptions *options, MainRendering rendering, bool state) { options->show_code[rendering] = state; } /****************************************************************************** * * * Paramètres : options = options à consulter. * * rendering = type de rendu impliqué. * * * * Description : Indique si le code des instructions est à afficher. * * * * Retour : Etat courant de l'option visée. * * * * Remarques : - * * * ******************************************************************************/ bool g_rendering_options_has_to_show_code(const GRenderingOptions *options, MainRendering rendering) { return options->show_code[rendering]; }