diff options
Diffstat (limited to 'src/format/format.c')
-rw-r--r-- | src/format/format.c | 54 |
1 files changed, 22 insertions, 32 deletions
diff --git a/src/format/format.c b/src/format/format.c index e782996..533d641 100644 --- a/src/format/format.c +++ b/src/format/format.c @@ -192,22 +192,21 @@ static void g_binary_format_dispose(GBinFormat *format) static void g_binary_format_finalize(GBinFormat *format) { - size_t i; /* Boucle de parcours */ - - if (format->entry_points != NULL) - free(format->entry_points); + DisassPriorityLevel i; /* Boucle de parcours #1 */ + size_t k; /* Boucle de parcours #2 */ - if (format->extra_points != NULL) - free(format->extra_points); + for (i = 0; i < DPL_COUNT; i++) + if (format->start_points[i] != NULL) + free(format->start_points[i]); if (format->symbols != NULL) free(format->symbols); if (format->errors != NULL) { - for (i = 0; i < format->error_count; i++) - if (format->errors[i].desc != NULL) - free(format->errors[i].desc); + for (k = 0; k < format->error_count; k++) + if (format->errors[k].desc != NULL) + free(format->errors[k].desc); free(format->errors); @@ -388,7 +387,7 @@ SourceEndian g_binary_format_get_endianness(const GBinFormat *format) * * * Paramètres : format = description de l'exécutable à compléter. * * pt = point de l'espace mémoire à considérer. * -* entry = nature du point fourni. * +* level = indication de priorité et d'origine de l'adresse. * * * * Description : Enregistre une adresse comme début d'une zone de code. * * * @@ -398,30 +397,22 @@ SourceEndian g_binary_format_get_endianness(const GBinFormat *format) * * ******************************************************************************/ -void g_binary_format_register_code_point(GBinFormat *format, virt_t pt, bool entry) +void g_binary_format_register_code_point(GBinFormat *format, virt_t pt, DisassPriorityLevel level) { + assert(level < DPL_COUNT); + g_rw_lock_writer_lock(&format->pt_lock); - if (entry) + if (format->pt_count[level] == format->pt_allocated[level]) { - format->entry_points = realloc(format->entry_points, ++format->ep_count * sizeof(virt_t)); + format->pt_allocated[level] += EXTRA_POINT_BLOCK; - format->entry_points[format->ep_count - 1] = pt; + format->start_points[level] = realloc(format->start_points[level], + format->pt_allocated[level] * sizeof(virt_t)); } - else - { - if (format->xp_count == format->xp_allocated) - { - format->xp_allocated += EXTRA_POINT_BLOCK; - format->extra_points = realloc(format->extra_points, format->xp_allocated * sizeof(virt_t)); - - } - - format->extra_points[format->xp_count++] = pt; - - } + format->start_points[level][format->pt_count[level]++] = pt; g_rw_lock_writer_unlock(&format->pt_lock); @@ -465,15 +456,14 @@ void g_binary_format_preload_disassembling_context(GBinFormat *format, GProcCont void g_binary_format_activate_disassembling_context(GBinFormat *format, GProcContext *ctx, GtkStatusStack *status) { - size_t i; /* Boucle de parcours */ + DisassPriorityLevel i; /* Boucle de parcours #1 */ + size_t k; /* Boucle de parcours #2 */ g_rw_lock_reader_lock(&format->pt_lock); - for (i = 0; i < format->ep_count; i++) - g_proc_context_push_drop_point(ctx, DPL_ENTRY_POINT, format->entry_points[i]); - - for (i = 0; i < format->xp_count; i++) - g_proc_context_push_drop_point(ctx, DPL_SYMBOL, format->extra_points[i]); + for (i = 0; i < DPL_COUNT; i++) + for (k = 0; k < format->pt_count[i]; k++) + g_proc_context_push_drop_point(ctx, i, format->start_points[i][k]); g_rw_lock_reader_unlock(&format->pt_lock); |