/* OpenIDA - Outil d'analyse de fichiers binaires * operand.c - opérandes de substitution pour variables * * Copyright (C) 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 . */ #include "operand.h" #include #include #include /* Définition d'un opérande de substitution pour variable de pile (instance) */ struct _GStackVarOperand { GArchOperand parent; /* Instance parente */ const GArchOperand *child; /* Opérand d'origine substitué */ }; /* Définition d'un opérande de substitution pour variable de pile (classe) */ struct _GStackVarOperandClass { GArchOperandClass parent; /* Classe parente */ }; /* Initialise la classe des opérandes de substitution. */ static void g_stack_var_operand_class_init(GStackVarOperandClass *); /* Initialise l'instande d'un opérandes de substitution. */ static void g_stack_var_operand_init(GStackVarOperand *); /* Traduit un opérande en version humainement lisible. */ static char *g_stack_var_operand_get_text(const GStackVarOperand *, const GExeFormat *, AsmSyntax); /* Indique le type défini pour un opérande de substitution pour variable de pile. */ G_DEFINE_TYPE(GStackVarOperand, g_stack_var_operand, G_TYPE_ARCH_OPERAND); /****************************************************************************** * * * Paramètres : klass = classe à initialiser. * * * * Description : Initialise la classe des opérandes de substitution. * * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ static void g_stack_var_operand_class_init(GStackVarOperandClass *klass) { } /****************************************************************************** * * * Paramètres : operand = instance à initialiser. * * * * Description : Initialise l'instande d'un opérandes de substitution. * * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ static void g_stack_var_operand_init(GStackVarOperand *operand) { GArchOperand *parent; /* Instance parente */ parent = G_ARCH_OPERAND(operand); parent->get_text = (get_operand_text_fc)g_stack_var_operand_get_text; } /****************************************************************************** * * * Paramètres : child = opérande d'origine à substituer. * * * * Description : Crée un opérande de substitution pour variable de pile. * * * * Retour : Instruction mise en place. * * * * Remarques : - * * * ******************************************************************************/ GArchOperand *g_stack_var_operand_new(const GArchOperand *child) { GStackVarOperand *result; /* Opérande à retourner */ result = g_object_new(G_TYPE_STACK_VAR_OPERAND, NULL); result->child = child; return result; } /****************************************************************************** * * * Paramètres : operand = opérande à traiter. * * format = format du binaire manipulé. * * syntax = type de représentation demandée. * * * * Description : Traduit un opérande en version humainement lisible. * * * * Retour : Chaîne de caractères à libérer de la mémoire. * * * * Remarques : - * * * ******************************************************************************/ static char *g_stack_var_operand_get_text(const GStackVarOperand *operand, const GExeFormat *format, AsmSyntax syntax) { char *result; /* Chaîne à retourner */ result = (char *)calloc(19, sizeof(char)); snprintf(result, 19, "[varX]"); return result; }