diff options
Diffstat (limited to 'plugins/dexresolver/operand.c')
-rw-r--r-- | plugins/dexresolver/operand.c | 306 |
1 files changed, 0 insertions, 306 deletions
diff --git a/plugins/dexresolver/operand.c b/plugins/dexresolver/operand.c deleted file mode 100644 index 7293599..0000000 --- a/plugins/dexresolver/operand.c +++ /dev/null @@ -1,306 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * operand.c - remplacement d'opérandes par d'autres plus explicites - * - * Copyright (C) 2010 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 <http://www.gnu.org/licenses/>. - */ - - -#include "operand.h" - - -#include <string.h> - - -#include <arch/operand-int.h> -#include <format/dex/pool.h> - - - -/* ----------------- OPERANDES POINTANT VERS LA TABLE DE CONSTANTES ----------------- */ - - -/* Définition d'un opérande visant un élément de table de constantes Dalvik (instance) */ -struct _GDalvikHPoolOperand -{ - GArchOperand parent; /* Instance parente */ - - const GDexFormat *format; /* Format de binaire utilisé */ - const GDalvikPoolOperand *child; /* Opérande encapsulé */ - - union - { - GBinVariable *field; /* Champ à représenter */ - GBinRoutine *method; /* Méthode à représenter */ - - } cache; - -}; - - -/* Définition d'un opérande visant un élément de table de constantes Dalvik (classe) */ -struct _GDalvikHPoolOperandClass -{ - GArchOperandClass parent; /* Classe parente */ - -}; - - -/* Initialise la classe des opérandes de constante Dalvik. */ -static void g_dalvik_hpool_operand_class_init(GDalvikHPoolOperandClass *); - -/* Initialise une instance d'opérande de constante Dalvik. */ -static void g_dalvik_hpool_operand_init(GDalvikHPoolOperand *); - -/* Ajoute du texte simple à un fichier ouvert en écriture. */ -static void g_dalvik_hpool_operand_add_text(const GDalvikHPoolOperand *, GRenderingOptions *, MainRendering, FILE *); - -/* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ -static void g_dalvik_hpool_operand_to_buffer(/*const */GDalvikHPoolOperand *, GBufferLine *, GRenderingOptions *); - - - - - - - - - - - -/* ---------------------------------------------------------------------------------- */ -/* OPERANDES POINTANT VERS LA TABLE DE CONSTANTES */ -/* ---------------------------------------------------------------------------------- */ - - -/* Indique le type défini par la GLib pour un un élément de table de constantes Dalvik. */ -G_DEFINE_TYPE(GDalvikHPoolOperand, g_dalvik_hpool_operand, G_TYPE_ARCH_OPERAND); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des opérandes de constante Dalvik. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_dalvik_hpool_operand_class_init(GDalvikHPoolOperandClass *klass) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance à initialiser. * -* * -* Description : Initialise une instance d'opérande de constante Dalvik. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_dalvik_hpool_operand_init(GDalvikHPoolOperand *operand) -{ - GContentExporter *parent; /* Instance parente */ - - parent = G_CONTENT_EXPORTER(operand); - - parent->add_text = (add_text_fc)g_dalvik_hpool_operand_add_text; - parent->export_buffer = (export_buffer_fc)g_dalvik_hpool_operand_to_buffer; - -} - - -/****************************************************************************** -* * -* Paramètres : format = représentation interne du format DEX à consulter. * -* child = instance existante à encapsuler. * -* * -* Description : Crée un opérande explicitant l'usage d'un élément constant. * -* * -* Retour : Opérande mis en place ou NULL si soucis. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchOperand *g_dalvik_hpool_operand_new(const GDexFormat *format, const GDalvikPoolOperand *child) -{ - GDalvikHPoolOperand *result; /* Structure à retourner */ - - if (g_dalvik_pool_operand_get_pool_type(child) == DPT_NONE) - return NULL; - - result = g_object_new(G_TYPE_DALVIK_HPOOL_OPERAND, NULL); - - result->format = format; - result->child = child; - - return G_ARCH_OPERAND(result); - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à transcrire. * -* options = options de rendu. * -* rendering = support effectif final des lignes de code. * -* stream = flux ouvert en écriture. * -* * -* Description : Ajoute du texte simple à un fichier ouvert en écriture. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_dalvik_hpool_operand_add_text(const GDalvikHPoolOperand *operand, GRenderingOptions *options, MainRendering rendering, FILE *stream) -{ - //g_content_exporter_add_text(G_CONTENT_EXPORTER(operand->reg), options, rendering, stream); - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à transcrire. * -* buffer = espace où placer ledit contenu. * -* options = options de rendu. * -* * -* Description : Ajoute à un tampon GLib le contenu de l'instance spécifiée. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_dalvik_hpool_operand_to_buffer(/*const */GDalvikHPoolOperand *operand, GBufferLine *buffer, GRenderingOptions *options) -{ - GContentExporter *exporter; /* Autre vision de l'opérande */ - uint32_t index; /* Indice de l'élément visé */ - const char *string; /* Chaîne à afficher */ - GDataType *type; /* Type quelconque */ - char *tmp; /* Chaîne à afficher & libérer */ - - exporter = G_CONTENT_EXPORTER(operand); - - index = g_dalvik_pool_operand_get_index(operand->child); - - switch (g_dalvik_pool_operand_get_pool_type(operand->child)) - { - case DPT_STRING: - - string = get_string_from_dex_pool(operand->format, index); - - if (string == NULL) - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - "<bad_string_index>", 18, RTT_STRING); - else - { - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - "\"", 1, RTT_STRING); - - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - string, strlen(string), RTT_STRING); - - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - "\"", 1, RTT_STRING); - - } - - break; - - case DPT_FIELD: - - if (operand->cache.field == NULL) - operand->cache.field = get_field_from_dex_pool(operand->format, index); - - if (operand->cache.field == NULL) - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - "<bad_field_index>", 17, RTT_VAR_NAME); - - else - { - type = g_binary_variable_get_vtype(operand->cache.field); - tmp = g_data_type_to_string(type); - - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - tmp, strlen(tmp), RTT_VAR_NAME); - - free(tmp); - - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - "->", 2, RTT_LTGT); - - string = g_binary_variable_get_name(operand->cache.field); - - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - string, strlen(string), RTT_VAR_NAME); - - } - - break; - - case DPT_METHOD: - - if (operand->cache.method == NULL) - operand->cache.method = get_routine_from_dex_pool(operand->format, index); - - if (operand->cache.method == NULL) - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - "<bad_method_index>", 18, RTT_VAR_NAME); - - else - { - tmp = g_binary_routine_to_string(operand->cache.method); - - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - tmp, strlen(tmp), RTT_VAR_NAME); - - free(tmp); - - } - - break; - - default: - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - "<-?->", 5, RTT_SECTION); - break; - - } - - - - -} - - - - |