From 9714ddda44f92f2939299c6b0aa203d549c32b0d Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Wed, 7 Mar 2012 00:13:16 +0000
Subject: Printed raw types, fields and methods when rendering the disassembled
 code.

git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@238 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
---
 ChangeLog                       |  5 +++
 src/arch/dalvik/operands/pool.c | 71 +++++++++++++++++++++++++++++++----------
 2 files changed, 60 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3aa1893..55216e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+12-03-07  Cyrille Bagard <nocbos@gmail.com>
+
+	* src/arch/dalvik/operands/pool.c:
+	Print raw types, fields and methods when rendering the disassembled code.
+
 12-03-05  Cyrille Bagard <nocbos@gmail.com>
 
 	* plugins/theseus/theseus.c:
diff --git a/src/arch/dalvik/operands/pool.c b/src/arch/dalvik/operands/pool.c
index 3e0a948..7ec370c 100644
--- a/src/arch/dalvik/operands/pool.c
+++ b/src/arch/dalvik/operands/pool.c
@@ -27,6 +27,9 @@
 #include <string.h>
 
 
+#include <i18n.h>
+
+
 #include "../../operand-int.h"
 #include "../../../format/dex/pool.h"
 
@@ -176,43 +179,79 @@ GArchOperand *g_dalvik_pool_operand_new(const GDexFormat *format, DalvikPoolType
 
 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é  */
+    const char *string;                     /* Chaîne de caractères #1     */
+    GOpenidaType *type;                     /* Type à représenter          */
+    char *tmp;                              /* Chaîne de caractères #2     */
+    GBinVariable *field;                    /* Champ à représenter         */
+    GBinRoutine *routine;                   /* Routine à représenter       */
 
     switch (operand->type)
     {
         case DPT_NONE:
             g_buffer_line_insert_text(line, BLC_ASSEMBLY, "????", 4, RTT_SECTION);
             break;
+
         case DPT_STRING:
             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);
+            type = get_type_from_dex_pool(operand->format, operand->index);
+
+            if (type != NULL)
+            {
+                tmp = g_openida_type_to_string(type);
+                g_object_unref(G_OBJECT(type));
+            }
+            else
+                tmp = strdup(_("invalid type"));
+
+            g_buffer_line_insert_text(line, BLC_ASSEMBLY, "<", 1, RTT_HOOK);
+            g_buffer_line_insert_text(line, BLC_ASSEMBLY, tmp, strlen(tmp), RTT_VAR_NAME);
+            g_buffer_line_insert_text(line, BLC_ASSEMBLY, ">", 1, RTT_HOOK);
+            free(tmp);
             break;
+
         case DPT_PROTO:
-            g_buffer_line_insert_text(line, BLC_ASSEMBLY, "proto", 5, RTT_SECTION);
+            g_buffer_line_insert_text(line, BLC_ASSEMBLY, "proto(/*TODO*/)", 5, RTT_SECTION);
             break;
+
         case DPT_FIELD:
-            g_buffer_line_insert_text(line, BLC_ASSEMBLY, "field", 5, RTT_SECTION);
+            field = get_field_from_dex_pool(operand->format, operand->index);
+
+            if (field != NULL)
+            {
+                tmp = g_binary_variable_to_string(field, false);
+                g_object_unref(G_OBJECT(field));
+            }
+            else
+                tmp = strdup(_("invalid field"));
+
+            g_buffer_line_insert_text(line, BLC_ASSEMBLY, "<", 1, RTT_HOOK);
+            g_buffer_line_insert_text(line, BLC_ASSEMBLY, tmp, strlen(tmp), RTT_VAR_NAME);
+            g_buffer_line_insert_text(line, BLC_ASSEMBLY, ">", 1, RTT_HOOK);
             break;
+
         case DPT_METHOD:
-            g_buffer_line_insert_text(line, BLC_ASSEMBLY, "method", 6, RTT_SECTION);
+            routine = get_routine_from_dex_pool(operand->format, operand->index);
+
+            if (routine != NULL)
+            {
+                tmp = g_binary_routine_to_string(routine);
+                g_object_unref(G_OBJECT(routine));
+            }
+            else
+                tmp = strdup(_("invalid method"));
+
+            g_buffer_line_insert_text(line, BLC_ASSEMBLY, "<", 1, RTT_HOOK);
+            g_buffer_line_insert_text(line, BLC_ASSEMBLY, tmp, strlen(tmp), RTT_VAR_NAME);
+            g_buffer_line_insert_text(line, BLC_ASSEMBLY, ">", 1, RTT_HOOK);
             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);
-    g_buffer_line_insert_text(line, BLC_ASSEMBLY, value, len, RTT_IMMEDIATE);
+    }
 
 }
 
-- 
cgit v0.11.2-87-g4458