summaryrefslogtreecommitdiff
path: root/plugins/dalvik/operands/pool.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/dalvik/operands/pool.c')
-rw-r--r--plugins/dalvik/operands/pool.c99
1 files changed, 98 insertions, 1 deletions
diff --git a/plugins/dalvik/operands/pool.c b/plugins/dalvik/operands/pool.c
index 9acfdb6..6bb1323 100644
--- a/plugins/dalvik/operands/pool.c
+++ b/plugins/dalvik/operands/pool.c
@@ -77,6 +77,17 @@ static void g_dalvik_pool_operand_print(const GDalvikPoolOperand *, GBufferLine
+/* --------------------- TRANSPOSITIONS VIA CACHE DES OPERANDES --------------------- */
+
+
+/* Charge un opérande depuis une mémoire tampon. */
+static bool g_dalvik_pool_operand_unserialize(GDalvikPoolOperand *, GAsmStorage *, GBinFormat *, packed_buffer *);
+
+/* Sauvegarde un opérande dans une mémoire tampon. */
+static bool g_dalvik_pool_operand_serialize(const GDalvikPoolOperand *, GAsmStorage *, packed_buffer *);
+
+
+
/* 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_ARCH_OPERAND);
@@ -108,6 +119,9 @@ static void g_dalvik_pool_operand_class_init(GDalvikPoolOperandClass *klass)
operand->compare = (operand_compare_fc)g_dalvik_pool_operand_compare;
operand->print = (operand_print_fc)g_dalvik_pool_operand_print;
+ operand->unserialize = (unserialize_operand_fc)g_dalvik_pool_operand_unserialize;
+ operand->serialize = (serialize_operand_fc)g_dalvik_pool_operand_serialize;
+
}
@@ -125,6 +139,7 @@ static void g_dalvik_pool_operand_class_init(GDalvikPoolOperandClass *klass)
static void g_dalvik_pool_operand_init(GDalvikPoolOperand *operand)
{
+ operand->format = NULL;
}
@@ -143,7 +158,8 @@ static void g_dalvik_pool_operand_init(GDalvikPoolOperand *operand)
static void g_dalvik_pool_operand_dispose(GDalvikPoolOperand *operand)
{
- g_object_unref(G_OBJECT(operand->format));
+ if (operand->format != NULL)
+ g_object_unref(G_OBJECT(operand->format));
G_OBJECT_CLASS(g_dalvik_pool_operand_parent_class)->dispose(G_OBJECT(operand));
@@ -453,3 +469,84 @@ uint32_t g_dalvik_pool_operand_get_index(const GDalvikPoolOperand *operand)
return operand->index;
}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* TRANSPOSITIONS VIA CACHE DES OPERANDES */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande d'assemblage à constituer. *
+* storage = mécanisme de sauvegarde à manipuler. *
+* format = format binaire chargé associé à l'architecture. *
+* pbuf = zone tampon à remplir. *
+* *
+* Description : Charge un opérande depuis une mémoire tampon. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_dalvik_pool_operand_unserialize(GDalvikPoolOperand *operand, GAsmStorage *storage, GBinFormat *format, packed_buffer *pbuf)
+{
+ bool result; /* Bilan à retourner */
+ GArchOperandClass *parent; /* Classe parente à consulter */
+
+ parent = G_ARCH_OPERAND_CLASS(g_dalvik_pool_operand_parent_class);
+
+ result = parent->unserialize(G_ARCH_OPERAND(operand), storage, format, pbuf);
+
+ if (result)
+ {
+ operand->format = G_DEX_FORMAT(format);
+ g_object_ref(G_OBJECT(format));
+ }
+
+ if (result)
+ result = extract_packed_buffer(pbuf, &operand->type, sizeof(DalvikPoolType), true);
+
+ if (result)
+ result = extract_packed_buffer(pbuf, &operand->index, sizeof(uint32_t), true);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : operand = opérande d'assemblage à consulter. *
+* storage = mécanisme de sauvegarde à manipuler. *
+* pbuf = zone tampon à remplir. *
+* *
+* Description : Sauvegarde un opérande dans une mémoire tampon. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_dalvik_pool_operand_serialize(const GDalvikPoolOperand *operand, GAsmStorage *storage, packed_buffer *pbuf)
+{
+ bool result; /* Bilan à retourner */
+ GArchOperandClass *parent; /* Classe parente à consulter */
+
+ parent = G_ARCH_OPERAND_CLASS(g_dalvik_pool_operand_parent_class);
+
+ result = parent->serialize(G_ARCH_OPERAND(operand), storage, pbuf);
+
+ if (result)
+ result = extend_packed_buffer(pbuf, &operand->type, sizeof(DalvikPoolType), true);
+
+ if (result)
+ result = extend_packed_buffer(pbuf, &operand->index, sizeof(uint32_t), true);
+
+ return result;
+
+}