/* OpenIDA - Outil d'analyse de fichiers binaires * exe_format-int.h - prototypes utiles aux formats d'exécutables * * Copyright (C) 2008-2009 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 . */ #ifndef _FORMAT_EXE_FORMAT_INT_H #define _FORMAT_EXE_FORMAT_INT_H #include "exe_format.h" /* ------------------------ MANIPULATION DES PARTIES DE CODE ------------------------ */ /* Description d'une partie binaire */ struct _bin_part { char *name; /* Désignation humaine */ off_t offset; /* Position physique */ off_t size; /* Taille de la partie */ uint64_t voffset; /* Adresse virtuelle éventuelle*/ }; /* Fournit l'adresse mémoire du point d'entrée du programme. */ typedef uint64_t (* get_entry_point_fc) (const exe_format *); /* Indique le type d'architecture visée par le format. */ typedef FormatTargetMachine (* get_target_machine_fc) (const exe_format *); /* Fournit les références aux zones de code à analyser. */ typedef bin_part ** (* get_def_parts_fc) (const exe_format *, size_t *); /* Recherche une section donnée au sein de binaire. */ typedef bool (* find_section_fc) (const exe_format *, const char *, off_t *, off_t *, uint64_t *); /* Récupère tous les symboles présents dans le contenu binaire. */ typedef size_t (* get_symbols_fc) (const exe_format *, char ***, SymbolType **, uint64_t **); /* Récupère tous les symboles présents dans le contenu binaire. */ typedef size_t (* get_resolved_fc) (const exe_format *, char ***, ResolvedType **, uint64_t **); /* Recherche le symbole correspondant à une adresse. */ typedef bool (* resolve_symbol_fc) (const exe_format *, char **, SymbolType *, vmpa_t *); /* Fournit le prototype de toutes les routines détectées. */ typedef GBinRoutine ** (* get_all_routines_fc) (const exe_format *, size_t *); /* Support générique d'un format d'exécutable */ struct _exe_format { const uint8_t *content; /* Contenu binaire à étudier */ off_t length; /* Taille de ce contenu */ get_entry_point_fc get_entry_point; /* Obtention du point d'entrée */ get_target_machine_fc get_target_machine; /* Architecture ciblée */ get_def_parts_fc get_def_parts; /* Liste des parties de code */ find_section_fc find_section; /* Recherche d'une section */ get_symbols_fc get_symbols; /* Liste des symboles présents */ get_resolved_fc get_resolved; /* Liste des éléments présents */ resolve_symbol_fc resolve_symbol; /* Recherche de symboles */ get_all_routines_fc get_all_routines; /* Liste de routines détectées */ }; #define EXE_FORMAT(f) ((exe_format *)f) #endif /* _FORMAT_EXE_FORMAT_INT_H */