summaryrefslogtreecommitdiff
path: root/plugins/dalvik/context.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-06-10 12:41:33 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-06-10 12:41:33 (GMT)
commitb5ae276f78a1c1b1e6410ec4ff79cb68f0b35478 (patch)
tree11c547c672f6adb2bad2043f878f423f6b4b4bb3 /plugins/dalvik/context.c
parent4e44b566ba4577f7bab66e492cb4b53872ff3e0a (diff)
Handled padding in Dalvik fill data payloads.
Diffstat (limited to 'plugins/dalvik/context.c')
-rw-r--r--plugins/dalvik/context.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/plugins/dalvik/context.c b/plugins/dalvik/context.c
index d3f7c36..8eb600d 100644
--- a/plugins/dalvik/context.c
+++ b/plugins/dalvik/context.c
@@ -50,6 +50,8 @@ typedef struct _raw_data_area
phys_t item_len; /* Taille de chaque élément */
+ bool padding; /* Constitution d'un bourrage ?*/
+
} raw_data_area;
/* Définition d'un contexte pour processeur Dalkvik (instance) */
@@ -289,6 +291,7 @@ bool g_dalvik_context_register_switch_data(GDalvikContext *ctx, const vmpa2t *st
if (result)
{
new.item_len = 4;
+ new.padding = false;
ctx->data = qinsert(ctx->data, &ctx->count, sizeof(raw_data_area),
(__compar_fn_t)cmp_mrange_with_vmpa_swapped, &new);
@@ -339,6 +342,56 @@ bool g_dalvik_context_register_array_data(GDalvikContext *ctx, const vmpa2t *sta
if (result)
{
new.item_len = width;
+ new.padding = false;
+
+ ctx->data = qinsert(ctx->data, &ctx->count, sizeof(raw_data_area),
+ (__compar_fn_t)cmp_mrange_with_vmpa_swapped, &new);
+
+ }
+
+ g_mutex_unlock(&ctx->mutex);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : ctx = contexte de désassemblage Dalvik à actualiser. *
+* start = début de la zone à considérer. *
+* *
+* Description : Mémorise une zone comme étant un bourrage de fin de tableau. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_dalvik_context_register_array_data_padding(GDalvikContext *ctx, const vmpa2t *start)
+{
+ bool result; /* Bilan à retourner */
+ raw_data_area new; /* Nouvel élément à insérer */
+ size_t i; /* Boucle de parcours */
+
+ result = true;
+
+ g_mutex_lock(&ctx->mutex);
+
+ /* Vérification quant aux chevauchements */
+
+ init_mrange(&new.range, start, sizeof(uint8_t));
+
+ for (i = 0; i < ctx->count && result; i++)
+ result = !mrange_intersects_mrange(&ctx->data[i].range, &new.range);
+
+ /* Insertion d'une nouvelle zone */
+
+ if (result)
+ {
+ new.item_len = sizeof(uint8_t);
+ new.padding = true;
ctx->data = qinsert(ctx->data, &ctx->count, sizeof(raw_data_area),
(__compar_fn_t)cmp_mrange_with_vmpa_swapped, &new);
@@ -408,6 +461,9 @@ GArchInstruction *g_dalvik_context_get_raw_data(GDalvikContext *ctx, const GBinC
}
+ if (result != NULL && found->padding)
+ g_raw_instruction_mark_as_padding(G_RAW_INSTRUCTION(result), true);
+
g_object_unref(G_OBJECT(restricted));
}