From 9d251ebd890342a3295eb264dfb4624eecb7dd99 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sat, 19 May 2012 12:43:52 +0000 Subject: [PATCH] Renamed the "Format" class to "AsmFormat" to avoid potential future conflicts --- include/Asm/format.h | 50 ++++++------- src/asm.c | 2 +- src/code.c | 8 +-- src/format.c | 82 +++++++++++----------- src/format.h | 38 +++++----- src/format/dex.c | 50 ++++++------- src/format/elf.c | 162 +++++++++++++++++++++---------------------- src/format/flat.c | 14 ++-- src/format/java.c | 112 +++++++++++++++--------------- src/format/pe.c | 46 ++++++------ 10 files changed, 283 insertions(+), 281 deletions(-) diff --git a/include/Asm/format.h b/include/Asm/format.h index 478ae38..399bb6d 100644 --- a/include/Asm/format.h +++ b/include/Asm/format.h @@ -24,58 +24,58 @@ /* AsmFormat */ /* types */ -typedef struct _Format Format; +typedef struct _AsmFormat AsmFormat; -typedef struct _FormatPlugin FormatPlugin; +typedef struct _AsmFormatPlugin AsmFormatPlugin; -typedef struct _FormatPluginHelper +typedef struct _AsmFormatPluginHelper { - Format * format; + AsmFormat * format; /* callbacks */ /* accessors */ - char const * (*get_filename)(Format * format); - void (*get_functions)(Format * format, AsmFunction ** functions, + char const * (*get_filename)(AsmFormat * format); + void (*get_functions)(AsmFormat * format, AsmFunction ** functions, size_t * functions_cnt); /* useful */ - ssize_t (*read)(Format * format, void * buf, size_t size); - off_t (*seek)(Format * format, off_t offset, int whence); + ssize_t (*read)(AsmFormat * format, void * buf, size_t size); + off_t (*seek)(AsmFormat * format, off_t offset, int whence); /* assembly */ - ssize_t (*write)(Format * format, void const * buf, size_t size); + ssize_t (*write)(AsmFormat * format, void const * buf, size_t size); /* disassembly */ /* FIXME let a different architecture be specified in the callback? */ - AsmSection * (*get_section_by_id)(Format * format, AsmSectionId id); - AsmString * (*get_string_by_id)(Format * format, AsmStringId id); - int (*set_function)(Format * format, int id, char const * name, + AsmSection * (*get_section_by_id)(AsmFormat * format, AsmSectionId id); + AsmString * (*get_string_by_id)(AsmFormat * format, AsmStringId id); + int (*set_function)(AsmFormat * format, int id, char const * name, off_t offset, ssize_t size); - int (*set_section)(Format * format, int id, char const * name, + int (*set_section)(AsmFormat * format, int id, char const * name, off_t offset, ssize_t size, off_t base); - int (*set_string)(Format * format, int id, char const * name, + int (*set_string)(AsmFormat * format, int id, char const * name, off_t offset, ssize_t size); - int (*decode)(Format * format, off_t offset, size_t size, off_t base, + int (*decode)(AsmFormat * format, off_t offset, size_t size, off_t base, AsmArchInstructionCall ** calls, size_t * calls_cnt); -} FormatPluginHelper; +} AsmFormatPluginHelper; -struct _FormatPlugin +struct _AsmFormatPlugin { - FormatPluginHelper * helper; + AsmFormatPluginHelper * helper; char const * name; char const * signature; size_t signature_len; - int (*init)(FormatPlugin * format, char const * arch); - int (*exit)(FormatPlugin * format); - int (*function)(FormatPlugin * format, char const * function); - int (*section)(FormatPlugin * format, char const * section); + int (*init)(AsmFormatPlugin * format, char const * arch); + int (*exit)(AsmFormatPlugin * format); + int (*function)(AsmFormatPlugin * format, char const * function); + int (*section)(AsmFormatPlugin * format, char const * section); - char const * (*detect)(FormatPlugin * format); - int (*decode)(FormatPlugin * format, int raw); - int (*decode_section)(FormatPlugin * format, AsmSection * section, + char const * (*detect)(AsmFormatPlugin * format); + int (*decode)(AsmFormatPlugin * format, int raw); + int (*decode_section)(AsmFormatPlugin * format, AsmSection * section, AsmArchInstructionCall ** calls, size_t * calls_cnt); void * priv; diff --git a/src/asm.c b/src/asm.c index b7f2d79..dda5f16 100644 --- a/src/asm.c +++ b/src/asm.c @@ -303,7 +303,7 @@ int asm_plugin_list(AsmPluginType type, int decode) size_t len; char const * sep = ""; AsmArch * arch; - Format * format; + AsmFormat * format; aspd = &_asm_plugin_description[type]; fprintf(stderr, "%s%s%s", "Available ", aspd->description, diff --git a/src/code.c b/src/code.c index 5f47e1d..b2a8cb0 100644 --- a/src/code.c +++ b/src/code.c @@ -40,7 +40,7 @@ struct _AsmCode { AsmArch * arch; AsmArchDescription * description; - Format * format; + AsmFormat * format; char * filename; FILE * fp; @@ -112,7 +112,7 @@ AsmCode * asmcode_new(char const * arch, char const * format) /* asmcode_new_file */ -static Format * _new_file_format(char const * filename, FILE * fp); +static AsmFormat * _new_file_format(char const * filename, FILE * fp); AsmCode * asmcode_new_file(char const * arch, char const * format, char const * filename) @@ -160,7 +160,7 @@ AsmCode * asmcode_new_file(char const * arch, char const * format, return code; } -static Format * _new_file_format(char const * filename, FILE * fp) +static AsmFormat * _new_file_format(char const * filename, FILE * fp) { char const path[] = LIBDIR "/" PACKAGE "/format"; DIR * dir; @@ -168,7 +168,7 @@ static Format * _new_file_format(char const * filename, FILE * fp) size_t len; char const ext[] = ".so"; int hasflat = 0; - Format * format = NULL; + AsmFormat * format = NULL; #ifdef DEBUG fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, filename); diff --git a/src/format.c b/src/format.c index d0d469e..33fdab1 100644 --- a/src/format.c +++ b/src/format.c @@ -25,14 +25,14 @@ #include "../config.h" -/* Format */ +/* AsmFormat */ /* private */ /* types */ -struct _Format +struct _AsmFormat { - FormatPluginHelper helper; + AsmFormatPluginHelper helper; Plugin * handle; - FormatPlugin * plugin; + AsmFormatPlugin * plugin; /* internal */ /* file */ @@ -46,36 +46,36 @@ struct _Format /* prototypes */ /* helpers */ -static char const * _format_helper_get_filename(Format * format); -static void _format_helper_get_functions(Format * format, +static char const * _format_helper_get_filename(AsmFormat * format); +static void _format_helper_get_functions(AsmFormat * format, AsmFunction ** functions, size_t * functions_cnt); -static AsmSection * _format_helper_get_section_by_id(Format * format, +static AsmSection * _format_helper_get_section_by_id(AsmFormat * format, AsmSectionId id); -static AsmString * _format_helper_get_string_by_id(Format * format, +static AsmString * _format_helper_get_string_by_id(AsmFormat * format, AsmStringId id); -static int _format_helper_set_function(Format * format, AsmFunctionId id, +static int _format_helper_set_function(AsmFormat * format, AsmFunctionId id, char const * name, off_t offset, ssize_t size); -static int _format_helper_set_section(Format * format, AsmSectionId id, +static int _format_helper_set_section(AsmFormat * format, AsmSectionId id, char const * name, off_t offset, ssize_t size, off_t base); -static int _format_helper_set_string(Format * format, AsmStringId id, +static int _format_helper_set_string(AsmFormat * format, AsmStringId id, char const * name, off_t offset, ssize_t size); -static int _format_helper_decode(Format * format, off_t offset, size_t size, +static int _format_helper_decode(AsmFormat * format, off_t offset, size_t size, off_t base, AsmArchInstructionCall ** calls, size_t * calls_cnt); -static ssize_t _format_helper_read(Format * format, void * buf, size_t size); -static off_t _format_helper_seek(Format * format, off_t offset, int whence); -static ssize_t _format_helper_write(Format * format, void const * buf, +static ssize_t _format_helper_read(AsmFormat * format, void * buf, size_t size); +static off_t _format_helper_seek(AsmFormat * format, off_t offset, int whence); +static ssize_t _format_helper_write(AsmFormat * format, void const * buf, size_t size); /* public */ /* functions */ /* format_new */ -Format * format_new(char const * format) +AsmFormat * format_new(char const * format) { - Format * f; + AsmFormat * f; Plugin * handle; - FormatPlugin * plugin; + AsmFormatPlugin * plugin; #ifdef DEBUG fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, format); @@ -113,7 +113,7 @@ Format * format_new(char const * format) /* format_delete */ -void format_delete(Format * format) +void format_delete(AsmFormat * format) { #ifdef DEBUG fprintf(stderr, "DEBUG: %s()\n", __func__); @@ -126,7 +126,7 @@ void format_delete(Format * format) /* accessors */ /* format_can_decode */ -int format_can_decode(Format * format) +int format_can_decode(AsmFormat * format) { return format->plugin->decode != NULL /* && format->plugin->decode_section != NULL */; @@ -134,7 +134,7 @@ int format_can_decode(Format * format) /* format_get_arch */ -char const * format_get_arch(Format * format) +char const * format_get_arch(AsmFormat * format) { if(format->plugin->detect == NULL) return NULL; @@ -143,7 +143,7 @@ char const * format_get_arch(Format * format) /* format_get_name */ -char const * format_get_name(Format * format) +char const * format_get_name(AsmFormat * format) { return format->plugin->name; } @@ -151,7 +151,7 @@ char const * format_get_name(Format * format) /* useful */ /* format_decode */ -int format_decode(Format * format, AsmCode * code, int raw) +int format_decode(AsmFormat * format, AsmCode * code, int raw) { int ret; @@ -166,7 +166,7 @@ int format_decode(Format * format, AsmCode * code, int raw) /* format_decode_section */ -int format_decode_section(Format * format, AsmCode * code, AsmSection * section, +int format_decode_section(AsmFormat * format, AsmCode * code, AsmSection * section, AsmArchInstructionCall ** calls, size_t * calls_cnt) { int ret; @@ -186,7 +186,7 @@ int format_decode_section(Format * format, AsmCode * code, AsmSection * section, /* format_detect_arch */ -char const * format_detect_arch(Format * format) +char const * format_detect_arch(AsmFormat * format) { if(format->plugin->detect == NULL) { @@ -199,7 +199,7 @@ char const * format_detect_arch(Format * format) /* format_exit */ -int format_exit(Format * format) +int format_exit(AsmFormat * format) { int ret = 0; @@ -216,7 +216,7 @@ int format_exit(Format * format) /* format_function */ -int format_function(Format * format, char const * function) +int format_function(AsmFormat * format, char const * function) { if(format->plugin->function == NULL) return 0; @@ -225,7 +225,7 @@ int format_function(Format * format, char const * function) /* format_init */ -int format_init(Format * format, char const * arch, char const * filename, +int format_init(AsmFormat * format, char const * arch, char const * filename, FILE * fp) { int ret = 0; @@ -247,7 +247,7 @@ int format_init(Format * format, char const * arch, char const * filename, /* format_match */ -int format_match(Format * format) +int format_match(AsmFormat * format) { int ret = 0; char const * s = format->plugin->signature; @@ -275,7 +275,7 @@ int format_match(Format * format) /* format_section */ -int format_section(Format * format, char const * section) +int format_section(AsmFormat * format, char const * section) { if(format->plugin->section == NULL) return 0; @@ -287,14 +287,14 @@ int format_section(Format * format, char const * section) /* functions */ /* helpers */ /* format_helper_get_filename */ -static char const * _format_helper_get_filename(Format * format) +static char const * _format_helper_get_filename(AsmFormat * format) { return format->filename; } /* format_helper_get_functions */ -static void _format_helper_get_functions(Format * format, +static void _format_helper_get_functions(AsmFormat * format, AsmFunction ** functions, size_t * functions_cnt) { asmcode_get_functions(format->code, functions, functions_cnt); @@ -302,7 +302,7 @@ static void _format_helper_get_functions(Format * format, /* format_helper_get_section_by_id */ -static AsmSection * _format_helper_get_section_by_id(Format * format, +static AsmSection * _format_helper_get_section_by_id(AsmFormat * format, AsmSectionId id) { return asmcode_get_section_by_id(format->code, id); @@ -310,7 +310,7 @@ static AsmSection * _format_helper_get_section_by_id(Format * format, /* format_helper_get_string_by_id */ -static AsmString * _format_helper_get_string_by_id(Format * format, +static AsmString * _format_helper_get_string_by_id(AsmFormat * format, AsmStringId id) { return asmcode_get_string_by_id(format->code, id); @@ -318,7 +318,7 @@ static AsmString * _format_helper_get_string_by_id(Format * format, /* format_helper_set_function */ -static int _format_helper_set_function(Format * format, AsmFunctionId id, +static int _format_helper_set_function(AsmFormat * format, AsmFunctionId id, char const * name, off_t offset, ssize_t size) { return asmcode_set_function(format->code, id, name, offset, size); @@ -326,7 +326,7 @@ static int _format_helper_set_function(Format * format, AsmFunctionId id, /* format_helper_set_section */ -static int _format_helper_set_section(Format * format, AsmSectionId id, +static int _format_helper_set_section(AsmFormat * format, AsmSectionId id, char const * name, off_t offset, ssize_t size, off_t base) { return asmcode_set_section(format->code, id, name, offset, size, base); @@ -334,7 +334,7 @@ static int _format_helper_set_section(Format * format, AsmSectionId id, /* format_helper_set_string */ -static int _format_helper_set_string(Format * format, AsmStringId id, +static int _format_helper_set_string(AsmFormat * format, AsmStringId id, char const * name, off_t offset, ssize_t size) { return asmcode_set_string(format->code, id, name, offset, size); @@ -342,7 +342,7 @@ static int _format_helper_set_string(Format * format, AsmStringId id, /* format_helper_decode */ -static int _format_helper_decode(Format * format, off_t offset, size_t size, +static int _format_helper_decode(AsmFormat * format, off_t offset, size_t size, off_t base, AsmArchInstructionCall ** calls, size_t * calls_cnt) { int ret; @@ -359,7 +359,7 @@ static int _format_helper_decode(Format * format, off_t offset, size_t size, /* format_helper_read */ -static ssize_t _format_helper_read(Format * format, void * buf, size_t size) +static ssize_t _format_helper_read(AsmFormat * format, void * buf, size_t size) { if(fread(buf, size, 1, format->fp) == 1) return size; @@ -374,7 +374,7 @@ static ssize_t _format_helper_read(Format * format, void * buf, size_t size) /* format_helper_seek */ -static off_t _format_helper_seek(Format * format, off_t offset, int whence) +static off_t _format_helper_seek(AsmFormat * format, off_t offset, int whence) { if(whence == SEEK_SET) { @@ -394,7 +394,7 @@ static off_t _format_helper_seek(Format * format, off_t offset, int whence) /* format_helper_write */ -static ssize_t _format_helper_write(Format * format, void const * buf, +static ssize_t _format_helper_write(AsmFormat * format, void const * buf, size_t size) { if(fwrite(buf, size, 1, format->fp) == 1) diff --git a/src/format.h b/src/format.h index 488625b..e3fd966 100644 --- a/src/format.h +++ b/src/format.h @@ -23,40 +23,42 @@ # include "code.h" -/* Format */ +/* AsmFormat */ /* public */ /* types */ -typedef int (*FormatDecodeCallback)(void * priv, char const * section, +typedef int (*AsmFormatDecodeCallback)(void * priv, char const * section, off_t offset, size_t size, off_t base); -typedef AsmString * (*FormatGetStringByIdCallback)(void * priv, AsmStringId id); -typedef int (*FormatSetFunctionCallback)(void * priv, AsmFunctionId id, +typedef AsmString * (*AsmFormatGetStringByIdCallback)(void * priv, + AsmStringId id); +typedef int (*AsmFormatSetFunctionCallback)(void * priv, AsmFunctionId id, char const * name, off_t offset, ssize_t length); -typedef int (*FormatSetStringCallback)(void * priv, AsmStringId id, +typedef int (*AsmFormatSetStringCallback)(void * priv, AsmStringId id, char const * name, off_t offset, ssize_t length); /* functions */ -Format * format_new(char const * format); -void format_delete(Format * format); +AsmFormat * format_new(char const * format); +void format_delete(AsmFormat * format); /* accessors */ -int format_can_decode(Format * format); +int format_can_decode(AsmFormat * format); -char const * format_get_name(Format * format); +char const * format_get_name(AsmFormat * format); /* useful */ /* assembly */ -int format_init(Format * format, char const * arch, char const * filename, +int format_init(AsmFormat * format, char const * arch, char const * filename, FILE * fp); -int format_exit(Format * format); +int format_exit(AsmFormat * format); -int format_function(Format * format, char const * function); -int format_section(Format * format, char const * section); +int format_function(AsmFormat * format, char const * function); +int format_section(AsmFormat * format, char const * section); /* disassembly */ -int format_decode(Format * format, AsmCode * code, int raw); -int format_decode_section(Format * format, AsmCode * code, AsmSection * section, - AsmArchInstructionCall ** calls, size_t * calls_cnt); -char const * format_detect_arch(Format * format); -int format_match(Format * format); +int format_decode(AsmFormat * format, AsmCode * code, int raw); +int format_decode_section(AsmFormat * format, AsmCode * code, + AsmSection * section, AsmArchInstructionCall ** calls, + size_t * calls_cnt); +char const * format_detect_arch(AsmFormat * format); +int format_match(AsmFormat * format); #endif /* !ASM_FORMAT_H */ diff --git a/src/format/dex.c b/src/format/dex.c index 28f4a68..e492b52 100644 --- a/src/format/dex.c +++ b/src/format/dex.c @@ -122,17 +122,17 @@ static char _dex_signature[4] = "dex\n"; /* prototypes */ /* plug-in */ -static int _dex_init(FormatPlugin * format, char const * arch); -static int _dex_exit(FormatPlugin * format); -static char const * _dex_detect(FormatPlugin * format); -static int _dex_decode(FormatPlugin * format, int raw); -static int _dex_decode_section(FormatPlugin * format, AsmSection * section, +static int _dex_init(AsmFormatPlugin * format, char const * arch); +static int _dex_exit(AsmFormatPlugin * format); +static char const * _dex_detect(AsmFormatPlugin * format); +static int _dex_decode(AsmFormatPlugin * format, int raw); +static int _dex_decode_section(AsmFormatPlugin * format, AsmSection * section, AsmArchInstructionCall ** calls, size_t * calls_cnt); /* public */ /* variables */ -FormatPlugin format_plugin = +AsmFormatPlugin format_plugin = { NULL, "dex", @@ -153,7 +153,7 @@ FormatPlugin format_plugin = /* functions */ /* plug-in */ /* dex_init */ -static int _dex_init(FormatPlugin * format, char const * arch) +static int _dex_init(AsmFormatPlugin * format, char const * arch) { Dex * dex; @@ -173,7 +173,7 @@ static int _dex_init(FormatPlugin * format, char const * arch) /* dex_exit */ -static int _dex_exit(FormatPlugin * format) +static int _dex_exit(AsmFormatPlugin * format) { Dex * dex = format->priv; @@ -184,7 +184,7 @@ static int _dex_exit(FormatPlugin * format) /* dex_detect */ -static char const * _dex_detect(FormatPlugin * format) +static char const * _dex_detect(AsmFormatPlugin * format) { /* XXX some sections might contain native code */ return "dalvik"; @@ -192,17 +192,17 @@ static char const * _dex_detect(FormatPlugin * format) /* dex_decode */ -static int _decode_map(FormatPlugin * format, DexHeader * dh, int raw); -static int _decode_map_code(FormatPlugin * format, size_t id, off_t offset, +static int _decode_map(AsmFormatPlugin * format, DexHeader * dh, int raw); +static int _decode_map_code(AsmFormatPlugin * format, size_t id, off_t offset, size_t size); -static int _decode_map_method_id(FormatPlugin * format, off_t offset, +static int _decode_map_method_id(AsmFormatPlugin * format, off_t offset, size_t size); -static int _decode_map_string_id(FormatPlugin * format, off_t offset, +static int _decode_map_string_id(AsmFormatPlugin * format, off_t offset, size_t size); -static int _dex_decode(FormatPlugin * format, int raw) +static int _dex_decode(AsmFormatPlugin * format, int raw) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; DexHeader dh; #ifdef DEBUG @@ -218,10 +218,10 @@ static int _dex_decode(FormatPlugin * format, int raw) return 0; } -static int _decode_map(FormatPlugin * format, DexHeader * dh, int raw) +static int _decode_map(AsmFormatPlugin * format, DexHeader * dh, int raw) { int ret = 0; - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; uint32_t size; uint32_t i; off_t offset; @@ -274,10 +274,10 @@ static int _decode_map(FormatPlugin * format, DexHeader * dh, int raw) return ret; } -static int _decode_map_code(FormatPlugin * format, size_t id, off_t offset, +static int _decode_map_code(AsmFormatPlugin * format, size_t id, off_t offset, size_t size) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; #ifdef DEBUG fprintf(stderr, "DEBUG: %s(%lu, %ld, %lu)\n", __func__, id, offset, @@ -287,10 +287,10 @@ static int _decode_map_code(FormatPlugin * format, size_t id, off_t offset, 0) == id) ? 0 : -1; } -static int _decode_map_method_id(FormatPlugin * format, off_t offset, +static int _decode_map_method_id(AsmFormatPlugin * format, off_t offset, size_t size) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; Dex * dex = format->priv; ssize_t s; size_t i; @@ -326,10 +326,10 @@ static int _decode_map_method_id(FormatPlugin * format, off_t offset, return 0; } -static int _decode_map_string_id(FormatPlugin * format, off_t offset, +static int _decode_map_string_id(AsmFormatPlugin * format, off_t offset, size_t size) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; DexStringIdItem * dsii; ssize_t s; size_t i; @@ -365,10 +365,10 @@ static int _decode_map_string_id(FormatPlugin * format, off_t offset, /* dex_decode_section */ -static int _dex_decode_section(FormatPlugin * format, AsmSection * section, +static int _dex_decode_section(AsmFormatPlugin * format, AsmSection * section, AsmArchInstructionCall ** calls, size_t * calls_cnt) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; DexMapCodeItem dmci; size_t i; off_t seek; diff --git a/src/format/elf.c b/src/format/elf.c index 52f49db..3ba6fed 100644 --- a/src/format/elf.c +++ b/src/format/elf.c @@ -73,36 +73,36 @@ typedef struct _Elf /* prototypes */ -static int _elf_error(FormatPlugin * format); +static int _elf_error(AsmFormatPlugin * format); /* plug-in */ -static int _elf_init(FormatPlugin * format, char const * arch); -static int _elf_exit(FormatPlugin * format); -static char const * _elf_detect(FormatPlugin * format); -static int _elf_decode(FormatPlugin * format, int raw); -static int _elf_decode32(FormatPlugin * format, int raw); -static int _elf_decode64(FormatPlugin * format, int raw); -static int _elf_decode_section(FormatPlugin * format, AsmSection * section, +static int _elf_init(AsmFormatPlugin * format, char const * arch); +static int _elf_exit(AsmFormatPlugin * format); +static char const * _elf_detect(AsmFormatPlugin * format); +static int _elf_decode(AsmFormatPlugin * format, int raw); +static int _elf_decode32(AsmFormatPlugin * format, int raw); +static int _elf_decode64(AsmFormatPlugin * format, int raw); +static int _elf_decode_section(AsmFormatPlugin * format, AsmSection * section, AsmArchInstructionCall ** calls, size_t * calls_cnt); /* ELF32 */ -static int _init_32(FormatPlugin * format); -static int _exit_32(FormatPlugin * format); -static int _section_32(FormatPlugin * format, char const * name); +static int _init_32(AsmFormatPlugin * format); +static int _exit_32(AsmFormatPlugin * format); +static int _section_32(AsmFormatPlugin * format, char const * name); static void _swap_32_ehdr(Elf32_Ehdr * ehdr); static void _swap_32_phdr(Elf32_Phdr * phdr); static void _swap_32_shdr(Elf32_Shdr * shdr); /* ELF64 */ -static int _init_64(FormatPlugin * format); -static int _exit_64(FormatPlugin * format); -static int _section_64(FormatPlugin * format, char const * name); +static int _init_64(AsmFormatPlugin * format); +static int _exit_64(AsmFormatPlugin * format); +static int _section_64(AsmFormatPlugin * format, char const * name); static void _swap_64_ehdr(Elf64_Ehdr * ehdr); static void _swap_64_phdr(Elf64_Phdr * phdr); static void _swap_64_shdr(Elf64_Shdr * shdr); /* ElfStrtab */ -static int _elfstrtab_set(FormatPlugin * format, ElfStrtab * strtab, +static int _elfstrtab_set(AsmFormatPlugin * format, ElfStrtab * strtab, char const * name); @@ -171,7 +171,7 @@ static ElfStrtab shstrtab = { NULL, 0 }; /* section string table */ /* public */ /* variables */ /* format_plugin */ -FormatPlugin format_plugin = +AsmFormatPlugin format_plugin = { NULL, "elf", @@ -191,7 +191,7 @@ FormatPlugin format_plugin = /* private */ /* functions */ /* elf_error */ -static int _elf_error(FormatPlugin * format) +static int _elf_error(AsmFormatPlugin * format) { return -error_set_code(1, "%s: %s", format->helper->get_filename( format->helper->format), strerror(errno)); @@ -201,7 +201,7 @@ static int _elf_error(FormatPlugin * format) /* elf_init */ static ElfArch * _init_arch(char const * arch); -static int _elf_init(FormatPlugin * format, char const * arch) +static int _elf_init(AsmFormatPlugin * format, char const * arch) { Elf * elf; @@ -257,7 +257,7 @@ static ElfArch * _init_arch(char const * arch) /* elf_exit */ -static int _elf_exit(FormatPlugin * format) +static int _elf_exit(AsmFormatPlugin * format) { Elf * elf = format->priv; @@ -272,12 +272,12 @@ static int _elf_exit(FormatPlugin * format) /* elf_detect */ -static char const * _detect_32(FormatPlugin * format, Elf32_Ehdr * ehdr); -static char const * _detect_64(FormatPlugin * format, Elf64_Ehdr * ehdr); +static char const * _detect_32(AsmFormatPlugin * format, Elf32_Ehdr * ehdr); +static char const * _detect_64(AsmFormatPlugin * format, Elf64_Ehdr * ehdr); -static char const * _elf_detect(FormatPlugin * format) +static char const * _elf_detect(AsmFormatPlugin * format) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; union { Elf32_Ehdr ehdr32; @@ -300,7 +300,7 @@ static char const * _elf_detect(FormatPlugin * format) return NULL; } -static char const * _detect_32(FormatPlugin * format, Elf32_Ehdr * ehdr) +static char const * _detect_32(AsmFormatPlugin * format, Elf32_Ehdr * ehdr) { format->decode = _elf_decode32; if(ehdr->e_ident[EI_DATA] != elf_arch_native->endian) @@ -325,7 +325,7 @@ static char const * _detect_32(FormatPlugin * format, Elf32_Ehdr * ehdr) return NULL; } -static char const * _detect_64(FormatPlugin * format, Elf64_Ehdr * ehdr) +static char const * _detect_64(AsmFormatPlugin * format, Elf64_Ehdr * ehdr) { format->decode = _elf_decode64; if(ehdr->e_ident[EI_DATA] != elf_arch_native->endian) @@ -346,7 +346,7 @@ static char const * _detect_64(FormatPlugin * format, Elf64_Ehdr * ehdr) /* elf_decode */ -static int _elf_decode(FormatPlugin * format, int raw) +static int _elf_decode(AsmFormatPlugin * format, int raw) { #ifdef DEBUG fprintf(stderr, "DEBUG: %s(%d)\n", __func__, raw); @@ -358,19 +358,19 @@ static int _elf_decode(FormatPlugin * format, int raw) /* elf_decode32 */ -static int _decode32_shdr(FormatPlugin * format, Elf32_Ehdr * ehdr, +static int _decode32_shdr(AsmFormatPlugin * format, Elf32_Ehdr * ehdr, Elf32_Shdr ** shdr); -static int _decode32_addr(FormatPlugin * format, Elf32_Ehdr * ehdr, +static int _decode32_addr(AsmFormatPlugin * format, Elf32_Ehdr * ehdr, Elf32_Addr * addr); -static int _decode32_strtab(FormatPlugin * format, Elf32_Shdr * shdr, +static int _decode32_strtab(AsmFormatPlugin * format, Elf32_Shdr * shdr, size_t shdr_cnt, uint16_t ndx, char ** strtab, size_t * strtab_cnt); -static int _decode32_symtab(FormatPlugin * format, Elf32_Ehdr * ehdr, +static int _decode32_symtab(AsmFormatPlugin * format, Elf32_Ehdr * ehdr, Elf32_Shdr * shdr, size_t shdr_cnt, uint16_t ndx); -static int _elf_decode32(FormatPlugin * format, int raw) +static int _elf_decode32(AsmFormatPlugin * format, int raw) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; Elf32_Ehdr ehdr; Elf32_Shdr * shdr = NULL; Elf32_Addr base = 0x0; @@ -422,10 +422,10 @@ static int _elf_decode32(FormatPlugin * format, int raw) return (i == ehdr.e_shnum) ? 0 : -1; } -static int _decode32_shdr(FormatPlugin * format, Elf32_Ehdr * ehdr, +static int _decode32_shdr(AsmFormatPlugin * format, Elf32_Ehdr * ehdr, Elf32_Shdr ** shdr) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; ssize_t size; size_t i; @@ -454,10 +454,10 @@ static int _decode32_shdr(FormatPlugin * format, Elf32_Ehdr * ehdr, return 0; } -static int _decode32_addr(FormatPlugin * format, Elf32_Ehdr * ehdr, +static int _decode32_addr(AsmFormatPlugin * format, Elf32_Ehdr * ehdr, Elf32_Addr * addr) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; Elf32_Half i; Elf32_Phdr phdr; @@ -480,11 +480,11 @@ static int _decode32_addr(FormatPlugin * format, Elf32_Ehdr * ehdr, return 0; } -static int _decode32_strtab(FormatPlugin * format, Elf32_Shdr * shdr, +static int _decode32_strtab(AsmFormatPlugin * format, Elf32_Shdr * shdr, size_t shdr_cnt, uint16_t ndx, char ** strtab, size_t * strtab_cnt) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; if(ndx >= shdr_cnt) return -error_set_code(1, "%s: %s", @@ -505,10 +505,10 @@ static int _decode32_strtab(FormatPlugin * format, Elf32_Shdr * shdr, return 0; } -static int _decode32_symtab(FormatPlugin * format, Elf32_Ehdr * ehdr, +static int _decode32_symtab(AsmFormatPlugin * format, Elf32_Ehdr * ehdr, Elf32_Shdr * shdr, size_t shdr_cnt, uint16_t ndx) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; char * strtab = NULL; size_t strtab_cnt = 0; Elf32_Sym sym; @@ -558,19 +558,19 @@ static int _decode32_symtab(FormatPlugin * format, Elf32_Ehdr * ehdr, /* elf_decode64 */ -static int _decode64_shdr(FormatPlugin * format, Elf64_Ehdr * ehdr, +static int _decode64_shdr(AsmFormatPlugin * format, Elf64_Ehdr * ehdr, Elf64_Shdr ** shdr); -static int _decode64_addr(FormatPlugin * format, Elf64_Ehdr * ehdr, +static int _decode64_addr(AsmFormatPlugin * format, Elf64_Ehdr * ehdr, Elf64_Addr * addr); -static int _decode64_strtab(FormatPlugin * format, Elf64_Shdr * shdr, +static int _decode64_strtab(AsmFormatPlugin * format, Elf64_Shdr * shdr, size_t shdr_cnt, uint16_t ndx, char ** strtab, size_t * strtab_cnt); -static int _decode64_symtab(FormatPlugin * format, Elf64_Ehdr * ehdr, +static int _decode64_symtab(AsmFormatPlugin * format, Elf64_Ehdr * ehdr, Elf64_Shdr * shdr, size_t shdr_cnt, uint16_t ndx); -static int _elf_decode64(FormatPlugin * format, int raw) +static int _elf_decode64(AsmFormatPlugin * format, int raw) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; Elf64_Ehdr ehdr; Elf64_Shdr * shdr = NULL; Elf64_Addr base = 0x0; @@ -621,10 +621,10 @@ static int _elf_decode64(FormatPlugin * format, int raw) return (i == ehdr.e_shnum) ? 0 : -1; } -static int _decode64_shdr(FormatPlugin * format, Elf64_Ehdr * ehdr, +static int _decode64_shdr(AsmFormatPlugin * format, Elf64_Ehdr * ehdr, Elf64_Shdr ** shdr) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; ssize_t size; size_t i; @@ -653,10 +653,10 @@ static int _decode64_shdr(FormatPlugin * format, Elf64_Ehdr * ehdr, return 0; } -static int _decode64_addr(FormatPlugin * format, Elf64_Ehdr * ehdr, +static int _decode64_addr(AsmFormatPlugin * format, Elf64_Ehdr * ehdr, Elf64_Addr * addr) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; Elf64_Quarter i; Elf64_Phdr phdr; @@ -679,11 +679,11 @@ static int _decode64_addr(FormatPlugin * format, Elf64_Ehdr * ehdr, return 0; } -static int _decode64_strtab(FormatPlugin * format, Elf64_Shdr * shdr, +static int _decode64_strtab(AsmFormatPlugin * format, Elf64_Shdr * shdr, size_t shdr_cnt, uint16_t ndx, char ** strtab, size_t * strtab_cnt) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; ssize_t size; if(ndx >= shdr_cnt) @@ -705,10 +705,10 @@ static int _decode64_strtab(FormatPlugin * format, Elf64_Shdr * shdr, return 0; } -static int _decode64_symtab(FormatPlugin * format, Elf64_Ehdr * ehdr, +static int _decode64_symtab(AsmFormatPlugin * format, Elf64_Ehdr * ehdr, Elf64_Shdr * shdr, size_t shdr_cnt, uint16_t ndx) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; char * strtab = NULL; size_t strtab_cnt = 0; Elf64_Sym sym; @@ -758,10 +758,10 @@ static int _decode64_symtab(FormatPlugin * format, Elf64_Ehdr * ehdr, /* elf_decode_section */ -static int _elf_decode_section(FormatPlugin * format, AsmSection * section, +static int _elf_decode_section(AsmFormatPlugin * format, AsmSection * section, AsmArchInstructionCall ** calls, size_t * calls_cnt) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; return helper->decode(helper->format, section->offset, section->size, section->base, calls, calls_cnt); @@ -789,9 +789,9 @@ static ElfSectionValues * _section_values(char const * name) /* ELF32 */ /* init_32 */ -static int _init_32(FormatPlugin * format) +static int _init_32(AsmFormatPlugin * format) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; Elf * elf = format->priv; ElfArch * ea = elf->arch; Elf32_Ehdr hdr; @@ -829,13 +829,13 @@ static int _init_32(FormatPlugin * format) /* exit_32 */ -static int _exit_32_phdr(FormatPlugin * format, Elf32_Off offset); -static int _exit_32_shdr(FormatPlugin * format, Elf32_Off offset); +static int _exit_32_phdr(AsmFormatPlugin * format, Elf32_Off offset); +static int _exit_32_shdr(AsmFormatPlugin * format, Elf32_Off offset); -static int _exit_32(FormatPlugin * format) +static int _exit_32(AsmFormatPlugin * format) { int ret = 0; - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; long offset; #ifdef DEBUG @@ -858,9 +858,9 @@ static int _exit_32(FormatPlugin * format) return ret; } -static int _exit_32_phdr(FormatPlugin * format, Elf32_Off offset) +static int _exit_32_phdr(AsmFormatPlugin * format, Elf32_Off offset) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; Elf * elf = format->priv; ElfArch * ea = elf->arch; Elf32_Ehdr hdr; @@ -893,9 +893,9 @@ static int _exit_32_phdr(FormatPlugin * format, Elf32_Off offset) return 0; } -static int _exit_32_shdr(FormatPlugin * format, Elf32_Off offset) +static int _exit_32_shdr(AsmFormatPlugin * format, Elf32_Off offset) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; Elf * elf = format->priv; ElfArch * ea = elf->arch; Elf32_Word addralign = ea->addralign; @@ -947,9 +947,9 @@ static int _exit_32_shdr(FormatPlugin * format, Elf32_Off offset) /* section_32 */ -static int _section_32(FormatPlugin * format, char const * name) +static int _section_32(AsmFormatPlugin * format, char const * name) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; Elf * elf = format->priv; int ss; Elf32_Shdr * p; @@ -1035,9 +1035,9 @@ static void _swap_32_shdr(Elf32_Shdr * shdr) /* ELF64 */ /* init_64 */ -static int _init_64(FormatPlugin * format) +static int _init_64(AsmFormatPlugin * format) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; Elf * elf = format->priv; ElfArch * ea = elf->arch; Elf64_Ehdr hdr; @@ -1074,13 +1074,13 @@ static int _init_64(FormatPlugin * format) /* exit_64 */ -static int _exit_64_phdr(FormatPlugin * format, Elf64_Off offset); -static int _exit_64_shdr(FormatPlugin * format, Elf64_Off offset); +static int _exit_64_phdr(AsmFormatPlugin * format, Elf64_Off offset); +static int _exit_64_shdr(AsmFormatPlugin * format, Elf64_Off offset); -static int _exit_64(FormatPlugin * format) +static int _exit_64(AsmFormatPlugin * format) { int ret = 0; - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; long offset; if(_section_64(format, ".shstrtab") != 0) @@ -1100,9 +1100,9 @@ static int _exit_64(FormatPlugin * format) return ret; } -static int _exit_64_phdr(FormatPlugin * format, Elf64_Off offset) +static int _exit_64_phdr(AsmFormatPlugin * format, Elf64_Off offset) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; Elf * elf = format->priv; ElfArch * ea = elf->arch; Elf64_Ehdr hdr; @@ -1132,9 +1132,9 @@ static int _exit_64_phdr(FormatPlugin * format, Elf64_Off offset) return 0; } -static int _exit_64_shdr(FormatPlugin * format, Elf64_Off offset) +static int _exit_64_shdr(AsmFormatPlugin * format, Elf64_Off offset) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; Elf * elf = format->priv; ElfArch * ea = elf->arch; Elf64_Xword addralign = ea->addralign; @@ -1180,9 +1180,9 @@ static int _exit_64_shdr(FormatPlugin * format, Elf64_Off offset) /* section_64 */ -static int _section_64(FormatPlugin * format, char const * name) +static int _section_64(AsmFormatPlugin * format, char const * name) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; Elf * elf = format->priv; int ss; Elf64_Shdr * p; @@ -1267,7 +1267,7 @@ static void _swap_64_shdr(Elf64_Shdr * shdr) /* private */ /* functions */ /* elfstrtab_get */ -static int _elfstrtab_set(FormatPlugin * format, ElfStrtab * strtab, +static int _elfstrtab_set(AsmFormatPlugin * format, ElfStrtab * strtab, char const * name) { size_t len; diff --git a/src/format/flat.c b/src/format/flat.c index bf96cfc..aa30ad7 100644 --- a/src/format/flat.c +++ b/src/format/flat.c @@ -24,14 +24,14 @@ /* private */ /* prototypes */ /* plug-in */ -static int _flat_decode(FormatPlugin * format, int raw); -static int _flat_decode_section(FormatPlugin * format, AsmSection * section, +static int _flat_decode(AsmFormatPlugin * format, int raw); +static int _flat_decode_section(AsmFormatPlugin * format, AsmSection * section, AsmArchInstructionCall ** calls, size_t * calls_cnt); /* public */ /* variables */ -FormatPlugin format_plugin = +AsmFormatPlugin format_plugin = { NULL, "flat", @@ -52,9 +52,9 @@ FormatPlugin format_plugin = /* functions */ /* plug-in */ /* flat_decode */ -static int _flat_decode(FormatPlugin * format, int raw) +static int _flat_decode(AsmFormatPlugin * format, int raw) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; off_t offset; if((offset = helper->seek(helper->format, 0, SEEK_END)) >= 0) @@ -65,10 +65,10 @@ static int _flat_decode(FormatPlugin * format, int raw) /* flat_decode_section */ -static int _flat_decode_section(FormatPlugin * format, AsmSection * section, +static int _flat_decode_section(AsmFormatPlugin * format, AsmSection * section, AsmArchInstructionCall ** calls, size_t * calls_cnt) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; if(section->id != 0) return -1; diff --git a/src/format/java.c b/src/format/java.c index c4d6347..ec2a373 100644 --- a/src/format/java.c +++ b/src/format/java.c @@ -142,18 +142,18 @@ static char _java_signature[4] = "\xca\xfe\xba\xbe"; /* prototypes */ /* plug-in */ -static int _java_init(FormatPlugin * format, char const * arch); -static int _java_exit(FormatPlugin * format); -static char const * _java_detect(FormatPlugin * format); -static int _java_decode(FormatPlugin * format, int raw); -static int _java_decode_section(FormatPlugin * format, AsmSection * section, +static int _java_init(AsmFormatPlugin * format, char const * arch); +static int _java_exit(AsmFormatPlugin * format); +static char const * _java_detect(AsmFormatPlugin * format); +static int _java_decode(AsmFormatPlugin * format, int raw); +static int _java_decode_section(AsmFormatPlugin * format, AsmSection * section, AsmArchInstructionCall ** calls, size_t * calls_cnt); /* public */ /* variables */ /* format_plugin */ -FormatPlugin format_plugin = +AsmFormatPlugin format_plugin = { NULL, "java", @@ -173,7 +173,7 @@ FormatPlugin format_plugin = /* private */ /* functions */ /* java_init */ -static int _java_init(FormatPlugin * format, char const * arch) +static int _java_init(AsmFormatPlugin * format, char const * arch) { JavaPlugin * java; @@ -197,16 +197,16 @@ static int _java_init(FormatPlugin * format, char const * arch) /* java_exit */ -static int _exit_constant_pool(FormatPlugin * format); -static int _exit_access_flags(FormatPlugin * format); -static int _exit_class_name(FormatPlugin * format); -static int _exit_super_name(FormatPlugin * format); -static int _exit_interface_table(FormatPlugin * format); -static int _exit_field_table(FormatPlugin * format); -static int _exit_method_table(FormatPlugin * format); -static int _exit_attribute_table(FormatPlugin * format); +static int _exit_constant_pool(AsmFormatPlugin * format); +static int _exit_access_flags(AsmFormatPlugin * format); +static int _exit_class_name(AsmFormatPlugin * format); +static int _exit_super_name(AsmFormatPlugin * format); +static int _exit_interface_table(AsmFormatPlugin * format); +static int _exit_field_table(AsmFormatPlugin * format); +static int _exit_method_table(AsmFormatPlugin * format); +static int _exit_attribute_table(AsmFormatPlugin * format); -static int _java_exit(FormatPlugin * format) +static int _java_exit(AsmFormatPlugin * format) { int ret = 0; JavaPlugin * java = format->priv; @@ -225,9 +225,9 @@ static int _java_exit(FormatPlugin * format) return ret; } -static int _exit_constant_pool(FormatPlugin * format) +static int _exit_constant_pool(AsmFormatPlugin * format) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; JavaPlugin * java = format->priv; uint16_t cnt = _htob16(java->constants_cnt + 1); @@ -237,9 +237,9 @@ static int _exit_constant_pool(FormatPlugin * format) return 0; } -static int _exit_access_flags(FormatPlugin * format) +static int _exit_access_flags(AsmFormatPlugin * format) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; JavaPlugin * java = format->priv; uint16_t flags = _htob16(java->access_flags); @@ -249,9 +249,9 @@ static int _exit_access_flags(FormatPlugin * format) return 0; } -static int _exit_class_name(FormatPlugin * format) +static int _exit_class_name(AsmFormatPlugin * format) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; uint16_t index = _htob16(0); /* FIXME really implement */ @@ -261,9 +261,9 @@ static int _exit_class_name(FormatPlugin * format) return 0; } -static int _exit_super_name(FormatPlugin * format) +static int _exit_super_name(AsmFormatPlugin * format) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; uint16_t index = _htob16(0); /* FIXME really implement */ @@ -273,9 +273,9 @@ static int _exit_super_name(FormatPlugin * format) return 0; } -static int _exit_interface_table(FormatPlugin * format) +static int _exit_interface_table(AsmFormatPlugin * format) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; JavaPlugin * java = format->priv; uint16_t cnt = _htob16(java->interfaces_cnt); @@ -285,9 +285,9 @@ static int _exit_interface_table(FormatPlugin * format) return 0; } -static int _exit_field_table(FormatPlugin * format) +static int _exit_field_table(AsmFormatPlugin * format) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; JavaPlugin * java = format->priv; uint16_t cnt = _htob16(java->fields_cnt); @@ -297,9 +297,9 @@ static int _exit_field_table(FormatPlugin * format) return 0; } -static int _exit_method_table(FormatPlugin * format) +static int _exit_method_table(AsmFormatPlugin * format) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; JavaPlugin * java = format->priv; uint16_t cnt = _htob16(java->methods_cnt); @@ -309,9 +309,9 @@ static int _exit_method_table(FormatPlugin * format) return 0; } -static int _exit_attribute_table(FormatPlugin * format) +static int _exit_attribute_table(AsmFormatPlugin * format) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; JavaPlugin * java = format->priv; uint16_t cnt = _htob16(java->attributes_cnt); @@ -323,9 +323,9 @@ static int _exit_attribute_table(FormatPlugin * format) /* java_detect */ -static char const * _java_detect(FormatPlugin * format) +static char const * _java_detect(AsmFormatPlugin * format) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; JavaHeader jh; if(helper->seek(helper->format, 0, SEEK_SET) != 0) @@ -344,9 +344,9 @@ static char const * _java_detect(FormatPlugin * format) /* java_decode */ -static int _java_decode(FormatPlugin * format, int raw) +static int _java_decode(AsmFormatPlugin * format, int raw) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; off_t end; /* XXX consider the whole file as a section */ @@ -357,20 +357,20 @@ static int _java_decode(FormatPlugin * format, int raw) /* java_decode_section */ -static int _decode_attributes(FormatPlugin * format, uint16_t cnt, +static int _decode_attributes(AsmFormatPlugin * format, uint16_t cnt, AsmArchInstructionCall ** calls, size_t * calls_cnt); -static int _decode_constants(FormatPlugin * format, uint16_t cnt); -static int _decode_fields(FormatPlugin * format, uint16_t cnt); -static int _decode_interfaces(FormatPlugin * format, uint16_t cnt); -static int _decode_methods(FormatPlugin * format, uint16_t cnt, +static int _decode_constants(AsmFormatPlugin * format, uint16_t cnt); +static int _decode_fields(AsmFormatPlugin * format, uint16_t cnt); +static int _decode_interfaces(AsmFormatPlugin * format, uint16_t cnt); +static int _decode_methods(AsmFormatPlugin * format, uint16_t cnt, AsmArchInstructionCall ** calls, size_t * calls_cnt); -static int _methods_add(FormatPlugin * format, uint16_t id, uint16_t name, +static int _methods_add(AsmFormatPlugin * format, uint16_t id, uint16_t name, off_t offset, size_t size); -static int _java_decode_section(FormatPlugin * format, AsmSection * section, +static int _java_decode_section(AsmFormatPlugin * format, AsmSection * section, AsmArchInstructionCall ** calls, size_t * calls_cnt) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; JavaPlugin * java = format->priv; JavaHeader jh; JavaHeader2 jh2; @@ -411,10 +411,10 @@ static int _java_decode_section(FormatPlugin * format, AsmSection * section, return 0; } -static int _decode_attributes(FormatPlugin * format, uint16_t cnt, +static int _decode_attributes(AsmFormatPlugin * format, uint16_t cnt, AsmArchInstructionCall ** calls, size_t * calls_cnt) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; size_t i; JavaAttributeInfo jai; off_t offset; @@ -446,9 +446,9 @@ static int _decode_attributes(FormatPlugin * format, uint16_t cnt, return 0; } -static int _decode_constants(FormatPlugin * format, uint16_t cnt) +static int _decode_constants(AsmFormatPlugin * format, uint16_t cnt) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; JavaPlugin * java = format->priv; size_t i; JavaCpInfo * jci; @@ -598,9 +598,9 @@ static int _decode_constants(FormatPlugin * format, uint16_t cnt) return 0; } -static int _decode_fields(FormatPlugin * format, uint16_t cnt) +static int _decode_fields(AsmFormatPlugin * format, uint16_t cnt) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; size_t i; JavaFieldInfo jfi; @@ -618,9 +618,9 @@ static int _decode_fields(FormatPlugin * format, uint16_t cnt) return 0; } -static int _decode_interfaces(FormatPlugin * format, uint16_t cnt) +static int _decode_interfaces(AsmFormatPlugin * format, uint16_t cnt) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; size_t i; uint16_t u16; @@ -634,10 +634,10 @@ static int _decode_interfaces(FormatPlugin * format, uint16_t cnt) return 0; } -static int _decode_methods(FormatPlugin * format, uint16_t cnt, +static int _decode_methods(AsmFormatPlugin * format, uint16_t cnt, AsmArchInstructionCall ** calls, size_t * calls_cnt) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; size_t i; JavaMethodInfo jmi; off_t begin; @@ -670,10 +670,10 @@ static int _decode_methods(FormatPlugin * format, uint16_t cnt, return 0; } -static int _methods_add(FormatPlugin * format, uint16_t id, uint16_t name, +static int _methods_add(AsmFormatPlugin * format, uint16_t id, uint16_t name, off_t offset, size_t size) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; JavaPlugin * java = format->priv; JavaCpInfo * jci; AsmString * as; diff --git a/src/format/pe.c b/src/format/pe.c index 80cf1cf..3862943 100644 --- a/src/format/pe.c +++ b/src/format/pe.c @@ -210,10 +210,10 @@ static char const _pe_header_signature[4] = "PE\0\0"; /* prototypes */ /* plug-in */ -static int _pe_init(FormatPlugin * format, char const * arch); -static char const * _pe_detect(FormatPlugin * format); -static int _pe_decode(FormatPlugin * format, int raw); -static int _pe_decode_section(FormatPlugin * format, AsmSection * section, +static int _pe_init(AsmFormatPlugin * format, char const * arch); +static char const * _pe_detect(AsmFormatPlugin * format); +static int _pe_decode(AsmFormatPlugin * format, int raw); +static int _pe_decode_section(AsmFormatPlugin * format, AsmSection * section, AsmArchInstructionCall ** calls, size_t * calls_cnt); /* useful */ @@ -223,7 +223,7 @@ static int _pe_get_machine(char const * arch); /* public */ /* variables */ -FormatPlugin format_plugin = +AsmFormatPlugin format_plugin = { NULL, "pe", @@ -243,9 +243,9 @@ FormatPlugin format_plugin = /* private */ /* functions */ /* pe_init */ -static int _pe_init(FormatPlugin * format, char const * arch) +static int _pe_init(AsmFormatPlugin * format, char const * arch) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; int machine; struct pe_msdos pm; struct pe_header ph; @@ -277,9 +277,9 @@ static int _pe_init(FormatPlugin * format, char const * arch) /* pe_detect */ -static char const * _pe_detect(FormatPlugin * format) +static char const * _pe_detect(AsmFormatPlugin * format) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; struct pe_msdos pm; struct pe_header ph; @@ -298,16 +298,16 @@ static char const * _pe_detect(FormatPlugin * format) /* pe_decode */ -static int _decode_data(FormatPlugin * format, uint32_t vaddr, uint32_t base, +static int _decode_data(AsmFormatPlugin * format, uint32_t vaddr, uint32_t base, struct pe_image_header_data * pid, size_t i); -static int _decode_data_export_directory(FormatPlugin * format, uint32_t vaddr, +static int _decode_data_export_directory(AsmFormatPlugin * format, uint32_t vaddr, uint32_t base, struct pe_image_header_data * pid); -static int _decode_error(FormatPlugin * format); -static char * _decode_string(FormatPlugin * format, off_t offset); +static int _decode_error(AsmFormatPlugin * format); +static char * _decode_string(AsmFormatPlugin * format, off_t offset); -static int _pe_decode(FormatPlugin * format, int raw) +static int _pe_decode(AsmFormatPlugin * format, int raw) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; struct pe_msdos pm; char buf[sizeof(_pe_header_signature)]; struct pe_header ph; @@ -440,7 +440,7 @@ static int _pe_decode(FormatPlugin * format, int raw) return 0; } -static int _decode_data(FormatPlugin * format, uint32_t vaddr, uint32_t base, +static int _decode_data(AsmFormatPlugin * format, uint32_t vaddr, uint32_t base, struct pe_image_header_data * pid, size_t i) { pid->vaddr = _htol32(pid->vaddr); @@ -461,10 +461,10 @@ static int _decode_data(FormatPlugin * format, uint32_t vaddr, uint32_t base, return 0; } -static int _decode_data_export_directory(FormatPlugin * format, uint32_t vaddr, +static int _decode_data_export_directory(AsmFormatPlugin * format, uint32_t vaddr, uint32_t base, struct pe_image_header_data * pid) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; struct pe_export_directory ped; size_t j; uint32_t f; @@ -518,15 +518,15 @@ static int _decode_data_export_directory(FormatPlugin * format, uint32_t vaddr, return 0; } -static int _decode_error(FormatPlugin * format) +static int _decode_error(AsmFormatPlugin * format) { return -error_set_code(1, "%s: %s", format->helper->get_filename( format->helper->format), strerror(errno)); } -static char * _decode_string(FormatPlugin * format, off_t offset) +static char * _decode_string(AsmFormatPlugin * format, off_t offset) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; char * ret = NULL; char * p; size_t len = 0; @@ -559,10 +559,10 @@ static char * _decode_string(FormatPlugin * format, off_t offset) /* pe_decode_section */ -static int _pe_decode_section(FormatPlugin * format, AsmSection * section, +static int _pe_decode_section(AsmFormatPlugin * format, AsmSection * section, AsmArchInstructionCall ** calls, size_t * calls_cnt) { - FormatPluginHelper * helper = format->helper; + AsmFormatPluginHelper * helper = format->helper; return helper->decode(helper->format, section->offset, section->size, section->base, calls, calls_cnt);