/* Chrysalide - Outil d'analyse de fichiers binaires * binary.h - prototypes pour le traitement des flots de code binaire * * Copyright (C) 2008-2014 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 . */ #ifndef _ANALYSIS_BINARY_H #define _ANALYSIS_BINARY_H #include #include #include "content.h" #include "db/collection.h" #include "db/client.h" #include "db/protocol.h" #include "../arch/processor.h" #include "../common/xml.h" #include "../format/debuggable.h" #include "../format/executable.h" #include "../glibext/gcodebuffer.h" /* Redéfinition depuis project.c : projet d'étude regroupant les binaires analysés (instance) */ typedef struct _GStudyProject GStudyProject; #define G_TYPE_LOADED_BINARY g_loaded_binary_get_type() #define G_LOADED_BINARY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_loaded_binary_get_type(), GLoadedBinary)) #define G_IS_LOADED_BINARY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_loaded_binary_get_type())) #define G_LOADED_BINARY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_LOADED_BINARY, GLoadedBinaryClass)) #define G_IS_LOADED_BINARY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_LOADED_BINARY)) #define G_LOADED_BINARY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_LOADED_BINARY, GLoadedBinaryClass)) /* Description de fichier binaire (instance) */ typedef struct _GLoadedBinary GLoadedBinary; /* Description de fichier binaire (classe) */ typedef struct _GLoadedBinaryClass GLoadedBinaryClass; /* Modèle de sélection des parties */ typedef enum _BinaryPartModel { BPM_DEFAULT, /* Selon le modèle par défaut */ BPM_ROUTINES, /* Sélection par les routines */ BPM_USER, /* Définitions utilisateur */ BPM_COUNT } BinaryPartModel; /* Type de représentations */ typedef enum _BinaryView { BVW_BLOCK, /* Version basique */ BVW_GRAPH, /* Affichage en graphique */ BVW_SOURCE, /* Code décompilé */ BVW_COUNT } BinaryView; /* Indique le type défini pour une description de fichier binaire. */ GType g_loaded_binary_get_type(void); /* Interprète un contenu binaire chargé. */ GLoadedBinary *g_loaded_binary_new(GBinContent *); /* Interprète un contenu binaire chargé avec un appui XML. */ GLoadedBinary *g_loaded_binary_new_from_xml(xmlXPathContextPtr, const char *, GStudyProject *); /* Ecrit une sauvegarde du binaire dans un fichier XML. */ bool g_loaded_binary_save(const GLoadedBinary *, xmlDocPtr, xmlXPathContextPtr, const char *); /* Fournit le nom associé à l'élément binaire. */ const char *g_loaded_binary_get_name(const GLoadedBinary *, bool); /* ------------------------- INFORMATIONS D'ENREGISTREMENTS ------------------------- */ /* Identifie l'utilisateur analysant le binaire courant. */ const char *g_loaded_binary_get_username(const GLoadedBinary *); /* Définit l'utilisateur analysant le binaire courant. */ void g_loaded_binary_set_username(GLoadedBinary *, const char *); /* Identifie le serveur distant associé au binaire courant. */ bool g_loaded_binary_get_remote_server(const GLoadedBinary *, const char **, unsigned short *); /* Définit le serveur distant associé au binaire courant. */ void g_loaded_binary_set_remote_server(GLoadedBinary *, const char *, unsigned short, bool); /* Indique la forme d'enregistrement d'une fonctionnalité. */ DBStorage g_loaded_binary_get_storage(const GLoadedBinary *, DBFeatures); /* Définit la forme d'enregistrement d'une fonctionnalité. */ void g_loaded_binary_set_storage(GLoadedBinary *, DBFeatures, DBStorage); /* Etablit une connexion à un serveur en tant que client. */ bool g_loaded_binary_connect(GLoadedBinary *); /* -------------------------- MANIPULATION DES COLLECTIONS -------------------------- */ /* Fournit le client assurant la liaison avec un serveur. */ GDbClient *g_loaded_binary_get_db_client(const GLoadedBinary *); /* Fournit l'ensemble des collections utilisées par un binaire. */ GList *g_loaded_binary_get_all_collections(const GLoadedBinary *); /* Trouve une collection assurant une fonctionnalité donnée. */ GDbCollection *g_loaded_binary_find_collection(const GLoadedBinary *, DBFeatures); /* Demande l'intégration d'une modification dans une collection. */ bool _g_loaded_binary_add_to_collection(GLoadedBinary *, DBFeatures, GDbItem *, bool); #define g_loaded_binary_add_to_collection(b, f, i) \ _g_loaded_binary_add_to_collection(b, f, i, true) /* Demande la suppression de modification dans une collection. */ bool _g_loaded_binary_remove_from_collection(GLoadedBinary *, DBFeatures, GDbItem *, bool); #define g_loaded_binary_remove_from_collection(b, f, i) \ _g_loaded_binary_remove_from_collection(b, f, i, true) /** * TODO : * * - connect_signal * - add_obj * */ /* Lance l'analyse d'un élément binaire chargé. */ void g_loaded_binary_analyse(GLoadedBinary *); /* Fournit le format de fichier reconnu dans le contenu binaire. */ bool g_loaded_binary_attach_debug_info(GLoadedBinary *, GBinContent *); /* Fournit le format de fichier reconnu dans le contenu binaire. */ GExeFormat *g_loaded_binary_get_format(const GLoadedBinary *); /* Fournit le processeur de l'architecture liée au binaire. */ GArchProcessor *g_loaded_binary_get_processor(const GLoadedBinary *); /* Fournit le tampon associé au contenu assembleur d'un binaire. */ GCodeBuffer *g_loaded_binary_get_disassembled_buffer(const GLoadedBinary *); /* Fournit le tampon associé au contenu d'un fichier source. */ GCodeBuffer *g_loaded_binary_get_decompiled_buffer(const GLoadedBinary *, size_t); /* Définit si une colonne donnée doit apparaître dans le rendu. */ void g_loaded_binary_set_column_display(GLoadedBinary *, BinaryView, BufferLineColumn, bool); /* Indique quelles colonnes doivent apparaître dans le rendu. */ const bool *g_loaded_binary_get_column_display(GLoadedBinary *, BinaryView); /* Indique si les lignes doivent apparaître dans le rendu. */ bool *g_loaded_binary_display_decomp_lines(GLoadedBinary *); #endif /* _ANALYSIS_BINARY_H */