/* OpenIDA - Outil d'analyse de fichiers binaires * gtkblockview.c - affichage d'un fragment de code d'assemblage * * Copyright (C) 2008-2012 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 . */ #include "gtkblockview.h" #include "gtkbufferview-int.h" /* -------------------------- INTERACTION DIRECTE AVEC GTK -------------------------- */ /* Composant d'affichage de bloc d'assembleur (instance) */ struct _GtkBlockView { GtkBufferView parent; /* A laisser en premier */ }; /* Composant d'affichage de code d'assembleur (classe) */ struct _GtkBlockViewClass { GtkBufferViewClass parent; /* A laisser en premier */ }; /* Procède à l'initialisation des afficheurs de bloc assembleur. */ static void gtk_block_view_class_init(GtkBlockViewClass *); /* Procède à l'initialisation de l'afficheur de bloc assembleur. */ static void gtk_block_view_init(GtkBlockView *); /* Prend acte de l'association d'un binaire chargé. */ static void gtk_block_view_attach_binary(GtkBlockView *, GLoadedBinary *, bool *, bool *); /* ---------------------------------------------------------------------------------- */ /* INTERACTION DIRECTE AVEC GTK */ /* ---------------------------------------------------------------------------------- */ /* Détermine le type du composant d'affichage de bloc en langage d'assemblage. */ G_DEFINE_TYPE(GtkBlockView, gtk_block_view, GTK_TYPE_BUFFER_VIEW) /****************************************************************************** * * * Paramètres : class = classe GTK à initialiser. * * * * Description : Procède à l'initialisation des afficheurs de bloc assembleur.* * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ static void gtk_block_view_class_init(GtkBlockViewClass *class) { } /****************************************************************************** * * * Paramètres : view = composant GTK à initialiser. * * * * Description : Procède à l'initialisation de l'afficheur de bloc assembleur.* * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ static void gtk_block_view_init(GtkBlockView *view) { GtkViewPanel *panel; /* Instance parente */ panel = GTK_VIEW_PANEL(view); panel->attach = (attach_binary_fc)gtk_block_view_attach_binary; } /****************************************************************************** * * * Paramètres : - * * * * Description : Crée un nouveau composant pour l'affichage de bloc en ASM. * * * * Retour : Composant GTK créé. * * * * Remarques : - * * * ******************************************************************************/ GtkWidget *gtk_block_view_new(void) { GtkBlockView *result; /* Composant à retourner */ result = g_object_new(GTK_TYPE_BLOCK_VIEW, NULL); return GTK_WIDGET(result); } /****************************************************************************** * * * Paramètres : view = composant GTK à mettre à jour. * * binary = binaire associé à intégrer. * * addr = indique si les positions doivent être affichées. * * code = indique si le code binaire doit être affiché. * * * * Description : Prend acte de l'association d'un binaire chargé. * * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ static void gtk_block_view_attach_binary(GtkBlockView *view, GLoadedBinary *binary, bool *addr, bool *code) { GCodeBuffer *buffer; /* Tampon par défaut */ buffer = g_loaded_binary_get_disassembled_buffer(binary); gtk_buffer_view_attach_buffer(GTK_BUFFER_VIEW(view), g_buffer_view_new(buffer), addr, code); }