diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-10-14 16:24:34 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-10-14 16:24:34 (GMT) |
commit | 722539ffc6005c6cd9c8ebd37f93999014ae6d24 (patch) | |
tree | 5f78dce6057f904d689c9ff073cc69f33d057abf /src/analysis/disass | |
parent | 8dff3daac4d2dc98b90adaecea834fb65db4fb10 (diff) |
Handled Dalvik simple switch cases without fallthrough.
Diffstat (limited to 'src/analysis/disass')
-rw-r--r-- | src/analysis/disass/disassembler.c | 44 | ||||
-rw-r--r-- | src/analysis/disass/fetch.c | 10 | ||||
-rw-r--r-- | src/analysis/disass/fetch.h | 2 | ||||
-rw-r--r-- | src/analysis/disass/instructions.c | 9 | ||||
-rw-r--r-- | src/analysis/disass/instructions.h | 2 |
5 files changed, 41 insertions, 26 deletions
diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c index 2cfa6a5..364348a 100644 --- a/src/analysis/disass/disassembler.c +++ b/src/analysis/disass/disassembler.c @@ -79,7 +79,7 @@ static void g_delayed_disassembly_init(GDelayedDisassembly *); static GDelayedDisassembly *g_delayed_disassembly_new(GLoadedBinary *, GArchInstruction **, GCodeBuffer *); /* Opère sur toutes les instructions. */ -static void process_all_instructions(wgroup_id_t, GtkStatusStack *, const char *, ins_fallback_cb, GArchProcessor *, GExeFormat *); +static void process_all_instructions(wgroup_id_t, GtkStatusStack *, const char *, ins_fallback_cb, GArchProcessor *, GProcContext *, GExeFormat *); /* Opère sur toutes les routines. */ static void process_all_routines(wgroup_id_t, GtkStatusStack *, const char *, rtn_fallback_cb, GArchProcessor *, GExeFormat *); @@ -182,10 +182,11 @@ static GDelayedDisassembly *g_delayed_disassembly_new(GLoadedBinary *binary, GAr /****************************************************************************** * * * Paramètres : gid = groupe de travail impliqué. * - status = barre de statut à tenir informée. * +* status = barre de statut à tenir informée. * * msg = message à faire paraître pour la patience. * * fallback = routine de traitements particuliers. * * proc = ensemble d'instructions désassemblées. * +* ctx = contexte fourni pour suivre le désassemblage. * * format = accès aux données du binaire d'origine. * * * * Description : Opère sur toutes les instructions. * @@ -196,7 +197,7 @@ static GDelayedDisassembly *g_delayed_disassembly_new(GLoadedBinary *binary, GAr * * ******************************************************************************/ -static void process_all_instructions(wgroup_id_t gid, GtkStatusStack *status, const char *msg, ins_fallback_cb fallback, GArchProcessor *proc, GExeFormat *format) +static void process_all_instructions(wgroup_id_t gid, GtkStatusStack *status, const char *msg, ins_fallback_cb fallback, GArchProcessor *proc, GProcContext *ctx, GExeFormat *format) { guint runs_count; /* Qté d'exécutions parallèles */ size_t ins_count; /* Quantité d'instructions */ @@ -227,7 +228,7 @@ static void process_all_instructions(wgroup_id_t gid, GtkStatusStack *status, co else end = begin + run_size; - study = g_instructions_study_new(proc, G_BIN_FORMAT(format), begin, end, id, fallback); + study = g_instructions_study_new(proc, ctx, G_BIN_FORMAT(format), begin, end, id, fallback); g_work_queue_schedule_work(queue, G_DELAYED_WORK(study), gid); @@ -329,24 +330,26 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkStatus //GBinFormat *format; /* Format du fichier binaire */ GArchProcessor *proc; /* Architecture du binaire */ - + GProcContext *ctx; /* Contexte de suivi dédié */ //size_t i; /* Boucle de parcours */ + _curbin = disass->binary; + //format = G_BIN_FORMAT(g_loaded_binary_get_format(binary)); + proc = g_loaded_binary_get_processor(disass->binary); + ctx = g_arch_processor_get_context(proc); - gid = g_work_queue_define_work_group(get_work_queue()); + gid = g_work_queue_define_work_group(get_work_queue()); - //format = G_BIN_FORMAT(g_loaded_binary_get_format(binary)); - proc = g_loaded_binary_get_processor(disass->binary); @@ -361,7 +364,7 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkStatus - *disass->instrs = disassemble_binary_content(disass->binary, gid, status); + *disass->instrs = disassemble_binary_content(disass->binary, ctx, gid, status); g_arch_processor_set_disassembled_instructions(proc, *disass->instrs); @@ -374,7 +377,7 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkStatus process_all_instructions(gid, status, _("Calling 'link' hook on all instructions..."), g_instructions_study_do_link_operation, - proc, disass->format); + proc, ctx, disass->format); // plugins ////////////////////////// @@ -390,7 +393,7 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkStatus process_all_instructions(gid, status, _("Calling 'post' hook on all instructions..."), g_instructions_study_do_post_operation, - proc, disass->format); + proc, ctx, disass->format); @@ -426,7 +429,7 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkStatus process_all_instructions(gid, status, _("Establishing links betweek all instructions..."), g_instructions_study_establish_links, - proc, disass->format); + proc, ctx, disass->format); @@ -515,16 +518,29 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkStatus - proc = g_loaded_binary_get_processor(disass->binary); print_disassembled_instructions(disass->buffer, disass->format, proc, status); - g_object_unref(G_OBJECT(proc)); + /* Rajout de tous les éléments mis en place automatiquement */ + + void add_to_collection(GDbItem *item, GLoadedBinary *binary) + { + g_object_ref(G_OBJECT(item)); + g_loaded_binary_add_to_collection(binary, item); + + } + g_proc_context_foreach_db_item(ctx, (GFunc)add_to_collection, disass->binary); + + /* Nettoyage final et sortie ! */ + + g_object_unref(G_OBJECT(ctx)); + + g_object_unref(G_OBJECT(proc)); process_disassembly_event(PGA_DISASSEMBLY_ENDED, disass->binary); diff --git a/src/analysis/disass/fetch.c b/src/analysis/disass/fetch.c index 4b162e8..7d8161a 100644 --- a/src/analysis/disass/fetch.c +++ b/src/analysis/disass/fetch.c @@ -480,6 +480,7 @@ static GDelayedFetching template; /* Patron des tâches à venir /****************************************************************************** * * * Paramètres : binary = représentation de binaire chargé. * +* ctx = contexte fourni pour suivre le désassemblage. * * gid = identifiant du groupe de travail à utiliser. * * status = barre de statut avec progression à mettre à jour. * * * @@ -491,12 +492,11 @@ static GDelayedFetching template; /* Patron des tâches à venir * * ******************************************************************************/ -GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, wgroup_id_t gid, GtkStatusStack *status) +GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, GProcContext *ctx, wgroup_id_t gid, GtkStatusStack *status) { GArchInstruction *result; /* Instruction désassemblées */ //GDelayedFetching template; /* Patron des tâches à venir */ GBinFormat *format; /* Format du fichier binaire */ - GArchProcessor *proc; /* Architecture du binaire */ GBinContent *content; /* Contenu binaire à manipuler */ phys_t length; /* Taille des données à lire */ GWorkQueue *queue; /* Gestionnaire de différés */ @@ -509,9 +509,7 @@ GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, wgroup template.format = g_loaded_binary_get_format(binary); format = G_BIN_FORMAT(template.format); - proc = g_loaded_binary_get_processor(binary); - template.ctx = g_arch_processor_get_context(proc); - g_object_unref(G_OBJECT(proc)); + template.ctx = ctx; content = g_binary_format_get_content(format); length = g_binary_content_compute_size(content); @@ -577,8 +575,6 @@ GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, wgroup //g_object_unref(G_OBJECT(template.format)); - g_object_unref(G_OBJECT(template.ctx)); - /* TODO / del(areas); */ return result; diff --git a/src/analysis/disass/fetch.h b/src/analysis/disass/fetch.h index 3ebb4d8..eb1d0d3 100644 --- a/src/analysis/disass/fetch.h +++ b/src/analysis/disass/fetch.h @@ -32,7 +32,7 @@ /* Procède au désassemblage basique d'un contenu binaire. */ -GArchInstruction *disassemble_binary_content(const GLoadedBinary *, wgroup_id_t, GtkStatusStack *); +GArchInstruction *disassemble_binary_content(const GLoadedBinary *, GProcContext *, wgroup_id_t, GtkStatusStack *); diff --git a/src/analysis/disass/instructions.c b/src/analysis/disass/instructions.c index b88d69f..47633d0 100644 --- a/src/analysis/disass/instructions.c +++ b/src/analysis/disass/instructions.c @@ -39,6 +39,7 @@ struct _GInstructionsStudy GDelayedWork parent; /* A laisser en premier */ GArchProcessor *proc; /* Processeurs avec ses instr. */ + GProcContext *ctx; /* Suivi du désassemblage */ GBinFormat *format; /* Format binaire à manipuler */ ins_fallback_cb fallback; /* Routine de traitement finale*/ @@ -169,6 +170,7 @@ static void g_instructions_study_finalize(GInstructionsStudy *study) /****************************************************************************** * * * Paramètres : proc = ensemble d'instructions désassemblées. * +* ctx = contexte fourni pour suivre le désassemblage. * * format = accès aux données du binaire d'origine. * * begin = point de départ du parcours de liste. * * end = point d'arrivée exclu du parcours. * @@ -183,13 +185,14 @@ static void g_instructions_study_finalize(GInstructionsStudy *study) * * ******************************************************************************/ -GInstructionsStudy *g_instructions_study_new(GArchProcessor *proc, GBinFormat *format, size_t begin, size_t end, activity_id_t id, ins_fallback_cb fallback) +GInstructionsStudy *g_instructions_study_new(GArchProcessor *proc, GProcContext *ctx, GBinFormat *format, size_t begin, size_t end, activity_id_t id, ins_fallback_cb fallback) { GInstructionsStudy *result; /* Tâche à retourner */ result = g_object_new(G_TYPE_INSTRUCTIONS_STUDY, NULL); result->proc = proc; + result->ctx = ctx; result->format = format; result->fallback = fallback; @@ -250,7 +253,7 @@ void g_instructions_study_do_link_operation(GInstructionsStudy *study, size_t in instr = g_arch_processor_get_disassembled_instruction(study->proc, index); - g_arch_instruction_call_hook(instr, IPH_LINK, study->proc, NULL, study->format); + g_arch_instruction_call_hook(instr, IPH_LINK, study->proc, study->ctx, study->format); } @@ -274,7 +277,7 @@ void g_instructions_study_do_post_operation(GInstructionsStudy *study, size_t in instr = g_arch_processor_get_disassembled_instruction(study->proc, index); - g_arch_instruction_call_hook(instr, IPH_POST, study->proc, NULL, study->format); + g_arch_instruction_call_hook(instr, IPH_POST, study->proc, study->ctx, study->format); } diff --git a/src/analysis/disass/instructions.h b/src/analysis/disass/instructions.h index 20b853d..c18322c 100644 --- a/src/analysis/disass/instructions.h +++ b/src/analysis/disass/instructions.h @@ -52,7 +52,7 @@ typedef void (* ins_fallback_cb) (GInstructionsStudy *, size_t); /* Crée une tâche d'étude de instructions différée. */ -GInstructionsStudy *g_instructions_study_new(GArchProcessor *, GBinFormat *, size_t, size_t, activity_id_t, ins_fallback_cb); +GInstructionsStudy *g_instructions_study_new(GArchProcessor *, GProcContext *, GBinFormat *, size_t, size_t, activity_id_t, ins_fallback_cb); /* Réalise l'appel de type IPH_LINK sur une instruction. */ void g_instructions_study_do_link_operation(GInstructionsStudy *, size_t); |