diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2010-12-21 00:51:14 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2010-12-21 00:51:14 (GMT) |
commit | dbec8e8af5f296f0b95cd9c07e7d96b1a4277137 (patch) | |
tree | 4c5a9307bc4f0c168911e86459de5a51baaac226 /src/arch/dalvik/operand.c | |
parent | 56deaf395c65658102ef0111cfc072d65335331a (diff) |
Redefined all existing kinds of Dalvik operands in a proper way.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@203 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/dalvik/operand.c')
-rw-r--r-- | src/arch/dalvik/operand.c | 1008 |
1 files changed, 1 insertions, 1007 deletions
diff --git a/src/arch/dalvik/operand.c b/src/arch/dalvik/operand.c index 3227184..f6392b3 100644 --- a/src/arch/dalvik/operand.c +++ b/src/arch/dalvik/operand.c @@ -1,6 +1,6 @@ /* OpenIDA - Outil d'analyse de fichiers binaires - * operand.c - gestion des operandes de l'architecture Dalvik + * operand.c - aide à la création d'opérandes Dalvik * * Copyright (C) 2010 Cyrille Bagard * @@ -28,186 +28,6 @@ #include <stdarg.h> -#include "register.h" -#include "../operand-int.h" - - - -/* ----------------------- COQUILLE VIDE POUR OPERANDE DALVIK ----------------------- */ - - -/* Définition d'un opérande de Dalvik (instance) */ -struct _GDalvikOperand -{ - GArchOperand parent; /* Instance parente */ - -}; - - -/* Définition d'un opérande de Dalvik (classe) */ -struct _GDalvikOperandClass -{ - GArchOperandClass parent; /* Classe parente */ - -}; - - -/* Initialise la classe des opérandes Dalvik de base. */ -static void g_dalvik_operand_class_init(GDalvikOperandClass *); - -/* Initialise une instance d'opérande de base pour Dalvik. */ -static void g_dalvik_operand_init(GDalvikOperand *); - - - -/* --------------------- OPERANDES VISANT UN REGISTRE DE DALVIK --------------------- */ - - -/* Définition d'un opérande visant un registre Dalvik (instance) */ -struct _GDalvikRegisterOperand -{ - GDalvikOperand parent; /* Instance parente */ - - GDalvikRegister *reg; /* Registre représenté */ - -}; - - -/* Définition d'un opérande visant un registre Dalvik (classe) */ -struct _GDalvikRegisterOperandClass -{ - GDalvikOperandClass parent; /* Classe parente */ - -}; - - -/* Initialise la classe des opérandes de registre Dalvik. */ -static void g_dalvik_register_operand_class_init(GDalvikRegisterOperandClass *); - -/* Initialise une instance d'opérande de registre Dalvik. */ -static void g_dalvik_register_operand_init(GDalvikRegisterOperand *); - -/* Compare un opérande avec un autre. */ -static bool g_dalvik_register_operand_compare(const GDalvikRegisterOperand *, const GDalvikRegisterOperand *); - -/* Ajoute du texte simple à un fichier ouvert en écriture. */ -static void g_dalvik_register_operand_add_text(const GDalvikRegisterOperand *, GRenderingOptions *, MainRendering, FILE *); - -/* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ -static void g_dalvik_register_operand_to_buffer(const GDalvikRegisterOperand *, GBufferLine *, GRenderingOptions *); - - - -/* -------------------- LISTE D'OPERANDES RASSEMBLES EN ARGUMENT -------------------- */ - - - -/* Définition d'un opérande visant une liste d'opérandes Dalvik (instance) */ -struct _GDalvikArgsOperand -{ - GDalvikOperand parent; /* Instance parente */ - - GArchOperand **args; /* Liste d'arguments */ - size_t count; /* Taille de cette liste */ - -}; - - -/* Définition d'un opérande visant une liste d'opérandes Dalvik (classe) */ -struct _GDalvikArgsOperandClass -{ - GDalvikOperandClass parent; /* Classe parente */ - -}; - - -/* Initialise la classe des listes d'opérandes Dalvik. */ -static void g_dalvik_args_operand_class_init(GDalvikArgsOperandClass *); - -/* Initialise une instance de liste d'opérandes Dalvik. */ -static void g_dalvik_args_operand_init(GDalvikArgsOperand *); - -/* Ajoute du texte simple à un fichier ouvert en écriture. */ -static void g_dalvik_args_operand_add_text(const GDalvikArgsOperand *, GRenderingOptions *, MainRendering, FILE *); - -/* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ -static void g_dalvik_args_operand_to_buffer(const GDalvikArgsOperand *, GBufferLine *, GRenderingOptions *); - - - -/* ----------------- OPERANDES POINTANT VERS LA TABLE DE CONSTANTES ----------------- */ - - -/* Définition d'un opérande visant un élément de table de constantes Dalvik (instance) */ -struct _GDalvikPoolOperand -{ - GDalvikOperand parent; /* Instance parente */ - - DalvikPoolType type; /* Type de table visée */ - uint32_t index; /* Indice de l'élément visé */ - -}; - - -/* Définition d'un opérande visant un élément de table de constantes Dalvik (classe) */ -struct _GDalvikPoolOperandClass -{ - GDalvikOperandClass parent; /* Classe parente */ - -}; - - -/* Initialise la classe des opérandes de constante Dalvik. */ -static void g_dalvik_pool_operand_class_init(GDalvikPoolOperandClass *); - -/* Initialise une instance d'opérande de constante Dalvik. */ -static void g_dalvik_pool_operand_init(GDalvikPoolOperand *); - -/* Ajoute du texte simple à un fichier ouvert en écriture. */ -static void g_dalvik_pool_operand_add_text(const GDalvikPoolOperand *, GRenderingOptions *, MainRendering, FILE *); - -/* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ -static void g_dalvik_pool_operand_to_buffer(const GDalvikPoolOperand *, GBufferLine *, GRenderingOptions *); - - - -/* ---------------------- OPERANDES VISANT UNE ADRESSE DE CODE ---------------------- */ - - -/* Définition d'un opérande visant une adresse de code Dalvik (instance) */ -struct _GDalvikTargetOperand -{ - GDalvikOperand parent; /* Instance parente */ - - GImmOperand *immediate; /* Adresse visée reconstituée */ - -}; - - -/* Définition d'un opérande visant une adresse de code Dalvik (classe) */ -struct _GDalvikTargetOperandClass -{ - GDalvikOperandClass parent; /* Classe parente */ - -}; - - -/* Initialise la classe des opérandes de ciblage de code Dalvik. */ -static void g_dalvik_target_operand_class_init(GDalvikTargetOperandClass *); - -/* Initialise une instance d'opérande de ciblage de code Dalvik. */ -static void g_dalvik_target_operand_init(GDalvikTargetOperand *); - -/* Ajoute du texte simple à un fichier ouvert en écriture. */ -static void g_dalvik_target_operand_add_text(const GDalvikTargetOperand *, GRenderingOptions *, MainRendering, FILE *); - -/* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ -static void g_dalvik_target_operand_to_buffer(const GDalvikTargetOperand *, GBufferLine *, GRenderingOptions *); - - - -/* ------------------------- AIDE A LA CREATION D'OPERANDES ------------------------- */ - /* Liste de tous les types d'opérandes */ typedef enum _DalvikOperandID @@ -241,832 +61,6 @@ static bool dalvik_read_fixed_operands(GArchInstruction *, const bin_t *, off_t -/* ---------------------------------------------------------------------------------- */ -/* COQUILLE VIDE POUR OPERANDE DALVIK */ -/* ---------------------------------------------------------------------------------- */ - - -/* Indique le type défini par la GLib pour un opérande de Dalvik. */ -G_DEFINE_TYPE(GDalvikOperand, g_dalvik_operand, G_TYPE_ARCH_OPERAND); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des opérandes Dalvik de base. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_dalvik_operand_class_init(GDalvikOperandClass *klass) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance à initialiser. * -* * -* Description : Initialise une instance d'opérande de base pour Dalvik. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_dalvik_operand_init(GDalvikOperand *operand) -{ - -} - - - -/* ---------------------------------------------------------------------------------- */ -/* OPERANDES VISANT UN REGISTRE DE DALVIK */ -/* ---------------------------------------------------------------------------------- */ - - -/* Indique le type défini par la GLib pour un opérande de registre Dalvik. */ -G_DEFINE_TYPE(GDalvikRegisterOperand, g_dalvik_register_operand, G_TYPE_DALVIK_OPERAND); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des opérandes de registre Dalvik. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_dalvik_register_operand_class_init(GDalvikRegisterOperandClass *klass) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance à initialiser. * -* * -* Description : Initialise une instance d'opérande de registre Dalvik. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_dalvik_register_operand_init(GDalvikRegisterOperand *operand) -{ - GContentExporter *parent; /* Instance parente #1 */ - GArchOperand *arch; /* Instance parente #2 */ - - parent = G_CONTENT_EXPORTER(operand); - - parent->add_text = (add_text_fc)g_dalvik_register_operand_add_text; - parent->export_buffer = (export_buffer_fc)g_dalvik_register_operand_to_buffer; - - arch = G_ARCH_OPERAND(operand); - - arch->compare = (operand_compare_fc)g_dalvik_register_operand_compare; - -} - - -/****************************************************************************** -* * -* Paramètres : data = flux de données à analyser. * -* pos = position courante dans ce flux. [OUT] * -* len = taille totale des données à analyser. * -* low = position éventuelle des 4 bits visés. [OUT] * -* size = taille de l'opérande, et donc du registre. * -* endian = ordre des bits dans la source. * -* * -* Description : Crée un opérande visant un registre Dalvik. * -* * -* Retour : Opérande mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchOperand *g_dalvik_register_operand_new(const bin_t *data, off_t *pos, off_t len, bool *low, MemoryDataSize size, SourceEndian endian) -{ - GDalvikRegisterOperand *result; /* Structure à retourner */ - uint8_t index8; /* Indice sur 8 bits */ - uint16_t index16; /* Indice sur 16 bits */ - bool test; /* Bilan de lecture */ - - switch (size) - { - case MDS_4_BITS: - test = read_u4(&index8, data, pos, len, low, endian); - break; - case MDS_8_BITS: - test = read_u8(&index8, data, pos, len, endian); - break; - case MDS_16_BITS: - test = read_u16(&index16, data, pos, len, endian); - break; - default: - test = false; - break; - } - - if (!test) - return NULL; - - result = g_object_new(G_TYPE_DALVIK_REGISTER_OPERAND, NULL); - - switch (size) - { - case MDS_4_BITS: - case MDS_8_BITS: - result->reg = g_dalvik_register_new(index8); - break; - case MDS_16_BITS: - result->reg = g_dalvik_register_new(index16); - break; - default: - break; - } - - return G_ARCH_OPERAND(result); - -} - - -/****************************************************************************** -* * -* Paramètres : a = premier opérande à consulter. * -* b = second opérande à consulter. * -* * -* Description : Compare un opérande avec un autre. * -* * -* Retour : Bilan de la comparaison. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static bool g_dalvik_register_operand_compare(const GDalvikRegisterOperand *a, const GDalvikRegisterOperand *b) -{ - return g_dalvik_register_compare(a->reg, b->reg); - -} - - -/****************************************************************************** -* * -* 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_register_operand_add_text(const GDalvikRegisterOperand *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_register_operand_to_buffer(const GDalvikRegisterOperand *operand, GBufferLine *buffer, GRenderingOptions *options) -{ - g_content_exporter_to_buffer(G_CONTENT_EXPORTER(operand->reg), buffer, options); - -} - - - -/* ---------------------------------------------------------------------------------- */ -/* LISTE D'OPERANDES RASSEMBLES EN ARGUMENT */ -/* ---------------------------------------------------------------------------------- */ - - -/* Indique le type défini par la GLib pour une liste d'arguments Dalvik. */ -G_DEFINE_TYPE(GDalvikArgsOperand, g_dalvik_args_operand, G_TYPE_DALVIK_OPERAND); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des listes d'opérandes Dalvik. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_dalvik_args_operand_class_init(GDalvikArgsOperandClass *klass) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance à initialiser. * -* * -* Description : Initialise une instance de liste d'opérandes Dalvik. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_dalvik_args_operand_init(GDalvikArgsOperand *operand) -{ - GContentExporter *parent; /* Instance parente */ - - parent = G_CONTENT_EXPORTER(operand); - - parent->add_text = (add_text_fc)g_dalvik_args_operand_add_text; - parent->export_buffer = (export_buffer_fc)g_dalvik_args_operand_to_buffer; - -} - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Crée un réceptacle pour opérandes Dalvik servant d'arguments.* -* * -* Retour : Opérande mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchOperand *g_dalvik_args_operand_new(void) -{ - GDalvikArgsOperand *result; /* Structure à retourner */ - - result = g_object_new(G_TYPE_DALVIK_ARGS_OPERAND, NULL); - - return G_ARCH_OPERAND(result); - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à compléter. * -* arg = nouvel argument pour un appel. * -* * -* Description : Ajoute un élément à la liste d'arguments Dalvik. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_dalvik_args_operand_add(GDalvikArgsOperand *operand, GArchOperand *arg) -{ - operand->args = (GArchOperand **)realloc(operand->args, ++operand->count * sizeof(GArchOperand *)); - - operand->args[operand->count - 1] = arg; - -} - - -/****************************************************************************** -* * -* 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_args_operand_add_text(const GDalvikArgsOperand *operand, GRenderingOptions *options, MainRendering rendering, FILE *stream) -{ - GContentExporter *exporter; /* Autre vision de l'objet */ - size_t i; /* Boucle de parcours */ - - exporter = G_CONTENT_EXPORTER(operand); - - g_content_exporter_insert_text(exporter, stream, "{", 1, RTT_HOOK); - - if (operand->count > 0) - { - g_content_exporter_add_text(G_CONTENT_EXPORTER(operand->args[0]), - options, rendering, stream); - - for (i = 1; i < operand->count; i++) - { - g_content_exporter_insert_text(exporter, stream, ",", 1, RTT_NONE/* FIXME */); - - g_content_exporter_insert_text(exporter, stream, " ", 1, RTT_NONE); - - g_content_exporter_add_text(G_CONTENT_EXPORTER(operand->args[i]), - options, rendering, stream); - - } - - } - - g_content_exporter_insert_text(exporter, stream, "}", 1, RTT_HOOK); - -} - - -/****************************************************************************** -* * -* 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_args_operand_to_buffer(const GDalvikArgsOperand *operand, GBufferLine *buffer, GRenderingOptions *options) -{ - GContentExporter *exporter; /* Autre vision de l'objet */ - size_t i; /* Boucle de parcours */ - - exporter = G_CONTENT_EXPORTER(operand); - - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - "{", 1, RTT_HOOK); - - if (operand->count > 0) - { - g_content_exporter_to_buffer(G_CONTENT_EXPORTER(operand->args[0]), buffer, options); - - for (i = 1; i < operand->count; i++) - { - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - ",", 1, RTT_NONE/* FIXME */); - - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - " ", 1, RTT_NONE); - - g_content_exporter_to_buffer(G_CONTENT_EXPORTER(operand->args[i]), buffer, options); - - } - - } - - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - "}", 1, RTT_HOOK); - -} - - - -/* ---------------------------------------------------------------------------------- */ -/* 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(GDalvikPoolOperand, g_dalvik_pool_operand, G_TYPE_DALVIK_OPERAND); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des opérandes de constante Dalvik. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_dalvik_pool_operand_class_init(GDalvikPoolOperandClass *klass) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance à initialiser. * -* * -* Description : Initialise une instance d'opérande de constante Dalvik. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_dalvik_pool_operand_init(GDalvikPoolOperand *operand) -{ - GContentExporter *parent; /* Instance parente */ - - parent = G_CONTENT_EXPORTER(operand); - - parent->add_text = (add_text_fc)g_dalvik_pool_operand_add_text; - parent->export_buffer = (export_buffer_fc)g_dalvik_pool_operand_to_buffer; - -} - - -/****************************************************************************** -* * -* Paramètres : type = type de table visée avec la référence. * -* data = flux de données à analyser. * -* pos = position courante dans ce flux. [OUT] * -* len = taille totale des données à analyser. * -* size = taille de l'opérande, et donc du registre. * -* endian = ordre des bits dans la source. * -* * -* Description : Crée un opérande visant un élément constant Dalvik. * -* * -* Retour : Opérande mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchOperand *g_dalvik_pool_operand_new(DalvikPoolType type, const bin_t *data, off_t *pos, off_t len, MemoryDataSize size, SourceEndian endian) -{ - GDalvikPoolOperand *result; /* Structure à retourner */ - uint8_t index8; /* Indice sur 8 bits */ - uint16_t index16; /* Indice sur 16 bits */ - bool test; /* Bilan de lecture */ - - switch (size) - { - case MDS_8_BITS: - test = read_u8(&index8, data, pos, len, endian); - break; - case MDS_16_BITS: - test = read_u16(&index16, data, pos, len, endian); - break; - default: - test = false; - break; - } - - if (!test) - return NULL; - - result = g_object_new(G_TYPE_DALVIK_POOL_OPERAND, NULL); - - result->type = type; - result->index = (size == MDS_8_BITS ? index8 : index16); - - 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_pool_operand_add_text(const GDalvikPoolOperand *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_pool_operand_to_buffer(const GDalvikPoolOperand *operand, GBufferLine *buffer, GRenderingOptions *options) -{ - GContentExporter *exporter; /* Autre vision de l'opérande */ - - char value[20]; /* Chaîne à imprimer */ - size_t len; /* Taille de l'élément inséré */ - - - - - exporter = G_CONTENT_EXPORTER(operand); - - switch (operand->type) - { - case DPT_NONE: - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - "????", 4, RTT_SECTION); - break; - case DPT_STRING: - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - "string", 6, RTT_SECTION); - break; - case DPT_TYPE: - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - "type", 4, RTT_SECTION); - break; - case DPT_PROTO: - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - "proto", 5, RTT_SECTION); - break; - case DPT_FIELD: - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - "field", 5, RTT_SECTION); - break; - case DPT_METHOD: - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - "method", 6, RTT_SECTION); - break; - } - - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - "@", 1, RTT_SIGNS); - - - //g_content_exporter_to_buffer(G_CONTENT_EXPORTER(operand->reg), buffer, options); - - len = snprintf(value, 20, "%d", operand->index); - /* - strcpy(value, "12345"); - - len = 5; - */ - g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, - value, len, RTT_IMMEDIATE); - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à consulter. * -* * -* Description : Indique la nature de la table de constantes visée ici. * -* * -* Retour : Type de table constantes visée. * -* * -* Remarques : - * -* * -******************************************************************************/ - -DalvikPoolType g_dalvik_pool_operand_get_pool_type(const GDalvikPoolOperand *operand) -{ - return operand->type; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à consulter. * -* * -* Description : Indique l'indice de l'élément dans la table de constantes. * -* * -* Retour : Indice de l'élément visé dans la table de constantes. * -* * -* Remarques : - * -* * -******************************************************************************/ - -uint32_t g_dalvik_pool_operand_get_index(const GDalvikPoolOperand *operand) -{ - return operand->index; - -} - - - -/* ---------------------------------------------------------------------------------- */ -/* OPERANDES VISANT UNE ADRESSE DE CODE */ -/* ---------------------------------------------------------------------------------- */ - - -/* Indique le type défini par la GLib pour un opérande de ciblage de code Dalvik. */ -G_DEFINE_TYPE(GDalvikTargetOperand, g_dalvik_target_operand, G_TYPE_DALVIK_OPERAND); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des opérandes de ciblage de code Dalvik.* -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_dalvik_target_operand_class_init(GDalvikTargetOperandClass *klass) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance à initialiser. * -* * -* Description : Initialise une instance d'opérande de ciblage de code Dalvik.* -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_dalvik_target_operand_init(GDalvikTargetOperand *operand) -{ - GContentExporter *parent; /* Instance parente */ - - parent = G_CONTENT_EXPORTER(operand); - - parent->add_text = (add_text_fc)g_dalvik_target_operand_add_text; - parent->export_buffer = (export_buffer_fc)g_dalvik_target_operand_to_buffer; - -} - - -/****************************************************************************** -* * -* Paramètres : data = flux de données à analyser. * -* pos = position courante dans ce flux. [OUT] * -* len = taille totale des données à analyser. * -* size = taille de l'opérande. * -* endian = ordre des bits dans la source. * -* base = adresse de référence pour le calcul. * -* * -* Description : Crée un opérande visant un instruction Dalvik. * -* * -* Retour : Opérande mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchOperand *g_dalvik_target_operand_new(const bin_t *data, off_t *pos, off_t len, MemoryDataSize size, SourceEndian endian, vmpa_t base) -{ - GDalvikTargetOperand *result; /* Structure à retourner */ - int8_t val8; /* Valeur sur 8 bits */ - int16_t val16; /* Valeur sur 16 bits */ - int32_t val32; /* Valeur sur 32 bits */ - vmpa_t address; /* Adresse finale visée */ - - switch (size) - { - case MDS_8_BITS_SIGNED: - read_s8(&val8, data, pos, len, endian); - address = base + val8 * sizeof(uint16_t); - break; - case MDS_16_BITS_SIGNED: - read_s16(&val16, data, pos, len, endian); - address = base + val16 * sizeof(uint16_t); - break; - case MDS_32_BITS_SIGNED: - read_s32(&val32, data, pos, len, endian); - address = base + val32 * sizeof(uint16_t); - break; - default: - return NULL; - break; - } - - result = g_object_new(G_TYPE_DALVIK_TARGET_OPERAND, NULL); - result->immediate = G_IMM_OPERAND(g_imm_operand_new_from_value(MDS_32_BITS/*FIXME*/, (uint32_t)address/* FIXME */)); - - 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_target_operand_add_text(const GDalvikTargetOperand *operand, GRenderingOptions *options, MainRendering rendering, FILE *stream) -{ - g_content_exporter_add_text(G_CONTENT_EXPORTER(operand->immediate), 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_target_operand_to_buffer(const GDalvikTargetOperand *operand, GBufferLine *buffer, GRenderingOptions *options) -{ - g_content_exporter_to_buffer(G_CONTENT_EXPORTER(operand->immediate), buffer, options); - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à traiter. * -* * -* Description : Fournit l'adresse représentée par une opérande Dalvik. * -* * -* Retour : Valeur portée par l'opérande. * -* * -* Remarques : - * -* * -******************************************************************************/ - -const GImmOperand *g_dalvik_target_operand_get_value(const GDalvikTargetOperand *operand) -{ - return operand->immediate; - -} - - - -/* ---------------------------------------------------------------------------------- */ -/* AIDE A LA CREATION D'OPERANDES */ -/* ---------------------------------------------------------------------------------- */ - - /****************************************************************************** * * * Paramètres : instr = instruction dont la définition est incomplète. [OUT]* |