summaryrefslogtreecommitdiff
path: root/src/arch/dalvik/operands
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2012-03-05 00:17:30 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2012-03-05 00:17:30 (GMT)
commit13bd8d546b2de76b1f5a1d758c9e476f7d859f39 (patch)
tree3d1c7dc3343ad4d460a9245bd2bb138fada611b3 /src/arch/dalvik/operands
parentaba1a14ba28f6df51b3be15648b6f55eea4a0e19 (diff)
Printed the string values of the Dex pool in the operand rendering.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@237 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/dalvik/operands')
-rw-r--r--src/arch/dalvik/operands/pool.c23
-rw-r--r--src/arch/dalvik/operands/pool.h5
2 files changed, 22 insertions, 6 deletions
diff --git a/src/arch/dalvik/operands/pool.c b/src/arch/dalvik/operands/pool.c
index a7b264b..3e0a948 100644
--- a/src/arch/dalvik/operands/pool.c
+++ b/src/arch/dalvik/operands/pool.c
@@ -2,7 +2,7 @@
/* OpenIDA - Outil d'analyse de fichiers binaires
* pool.c - opérandes pointant vers la table des constantes
*
- * Copyright (C) 2010 Cyrille Bagard
+ * Copyright (C) 2010-2012 Cyrille Bagard
*
* This file is part of OpenIDA.
*
@@ -24,7 +24,11 @@
#include "pool.h"
+#include <string.h>
+
+
#include "../../operand-int.h"
+#include "../../../format/dex/pool.h"
@@ -33,6 +37,7 @@ struct _GDalvikPoolOperand
{
GArchOperand parent; /* Instance parente */
+ const GDexFormat *format; /* Lien vers le contenu réel */
DalvikPoolType type; /* Type de table visée */
uint32_t index; /* Indice de l'élément visé */
@@ -105,7 +110,8 @@ static void g_dalvik_pool_operand_init(GDalvikPoolOperand *operand)
/******************************************************************************
* *
-* Paramètres : type = type de table visée avec la référence. *
+* Paramètres : format = format du fichier contenant le code. *
+* 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. *
@@ -120,7 +126,7 @@ static void g_dalvik_pool_operand_init(GDalvikPoolOperand *operand)
* *
******************************************************************************/
-GArchOperand *g_dalvik_pool_operand_new(DalvikPoolType type, const bin_t *data, off_t *pos, off_t len, MemoryDataSize size, SourceEndian endian)
+GArchOperand *g_dalvik_pool_operand_new(const GDexFormat *format, 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 */
@@ -145,6 +151,7 @@ GArchOperand *g_dalvik_pool_operand_new(DalvikPoolType type, const bin_t *data,
result = g_object_new(G_TYPE_DALVIK_POOL_OPERAND, NULL);
+ result->format = format;
result->type = type;
result->index = (size == MDS_8_BITS ? index8 : index16);
@@ -169,6 +176,8 @@ GArchOperand *g_dalvik_pool_operand_new(DalvikPoolType type, const bin_t *data,
static void g_dalvik_pool_operand_print(const GDalvikPoolOperand *operand, GBufferLine *line, AsmSyntax syntax)
{
+ const char *string; /* Chaîne de caractères */
+
char value[20]; /* Chaîne à imprimer */
size_t len; /* Taille de l'élément inséré */
@@ -178,7 +187,10 @@ static void g_dalvik_pool_operand_print(const GDalvikPoolOperand *operand, GBuff
g_buffer_line_insert_text(line, BLC_ASSEMBLY, "????", 4, RTT_SECTION);
break;
case DPT_STRING:
- g_buffer_line_insert_text(line, BLC_ASSEMBLY, "string", 6, RTT_SECTION);
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "\"", 1, RTT_STRING);
+ string = get_string_from_dex_pool(operand->format, operand->index);
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, string, strlen(string), RTT_STRING);
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY, "\"", 1, RTT_STRING);
break;
case DPT_TYPE:
g_buffer_line_insert_text(line, BLC_ASSEMBLY, "type", 4, RTT_SECTION);
@@ -194,6 +206,9 @@ static void g_dalvik_pool_operand_print(const GDalvikPoolOperand *operand, GBuff
break;
}
+ if (operand->type == DPT_STRING)
+ return;
+
g_buffer_line_insert_text(line, BLC_ASSEMBLY, "@", 1, RTT_SIGNS);
len = snprintf(value, 20, "%d", operand->index);
diff --git a/src/arch/dalvik/operands/pool.h b/src/arch/dalvik/operands/pool.h
index b74692d..3905664 100644
--- a/src/arch/dalvik/operands/pool.h
+++ b/src/arch/dalvik/operands/pool.h
@@ -2,7 +2,7 @@
/* OpenIDA - Outil d'analyse de fichiers binaires
* pool.h - prototypes pour les opérandes pointant vers la table des constantes
*
- * Copyright (C) 2010 Cyrille Bagard
+ * Copyright (C) 2010-2012 Cyrille Bagard
*
* This file is part of OpenIDA.
*
@@ -31,6 +31,7 @@
#include "../../operand.h"
#include "../../../common/endianness.h"
+#include "../../../format/dex/pool.h"
@@ -66,7 +67,7 @@ typedef enum _DalvikPoolType
GType g_dalvik_pool_operand_get_type(void);
/* Crée un opérande visant un élément constant Dalvik. */
-GArchOperand *g_dalvik_pool_operand_new(DalvikPoolType, const bin_t *, off_t *, off_t, MemoryDataSize, SourceEndian);
+GArchOperand *g_dalvik_pool_operand_new(const GDexFormat *, DalvikPoolType, const bin_t *, off_t *, off_t, MemoryDataSize, SourceEndian);
/* Indique la nature de la table de constantes visée ici. */
DalvikPoolType g_dalvik_pool_operand_get_pool_type(const GDalvikPoolOperand *);