mirror of
https://github.com/radareorg/radare2.git
synced 2025-03-05 04:50:43 +00:00
TE format plugin cleanups - removed unused code
This commit is contained in:
parent
5d67033220
commit
ca7296c848
@ -8,13 +8,6 @@
|
||||
#include "te_specs.h"
|
||||
#include "te.h"
|
||||
|
||||
|
||||
/* TODO:
|
||||
* 1. Implement import/export
|
||||
* 2. Implement symbols support
|
||||
* 3. Implement debugging info support
|
||||
* 4. More sections parse
|
||||
*/
|
||||
ut64 r_bin_te_get_main_offset(struct r_bin_te_obj_t *bin) {
|
||||
struct r_bin_te_addr_t *entry = r_bin_te_get_entrypoint (bin);
|
||||
ut64 addr = 0LL;
|
||||
@ -81,8 +74,6 @@ static int r_bin_te_init_sections(struct r_bin_te_obj_t* bin) {
|
||||
static int r_bin_te_init(struct r_bin_te_obj_t* bin) {
|
||||
bin->header = NULL;
|
||||
bin->section_header = NULL;
|
||||
//bin->export_directory = NULL;
|
||||
//bin->import_directory = NULL;
|
||||
bin->endian = 0;
|
||||
if (!r_bin_te_init_hdr(bin)) {
|
||||
eprintf("Warning: File is not TE\n");
|
||||
@ -92,9 +83,6 @@ static int r_bin_te_init(struct r_bin_te_obj_t* bin) {
|
||||
eprintf("Warning: Cannot initialize sections\n");
|
||||
return R_FALSE;
|
||||
}
|
||||
// FIXME: Not yet implemented!
|
||||
//r_bin_te_init_imports(bin);
|
||||
//r_bin_te_init_exports(bin);
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
@ -147,10 +135,6 @@ ut64 r_bin_te_get_image_base(struct r_bin_te_obj_t* bin)
|
||||
return (ut64)bin->header->ImageBase;
|
||||
}
|
||||
|
||||
int r_bin_te_get_image_size(struct r_bin_te_obj_t* bin) {
|
||||
return bin->header->StrippedSize;
|
||||
}
|
||||
|
||||
char* r_bin_te_get_machine(struct r_bin_te_obj_t* bin) {
|
||||
char *machine;
|
||||
|
||||
@ -339,20 +323,10 @@ char* r_bin_te_get_subsystem(struct r_bin_te_obj_t* bin) {
|
||||
return subsystem;
|
||||
}
|
||||
|
||||
struct r_bin_te_export_t* r_bin_te_get_exports(struct r_bin_te_obj_t* bin) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct r_bin_te_import_t* r_bin_te_get_imports(struct r_bin_te_obj_t *bin) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* r_bin_te_free(struct r_bin_te_obj_t* bin) {
|
||||
if (!bin) return NULL;
|
||||
free (bin->header);
|
||||
free (bin->section_header);
|
||||
//free (bin->export_directory);
|
||||
//free (bin->import_directory);
|
||||
r_buf_free (bin->b);
|
||||
free (bin);
|
||||
return NULL;
|
||||
|
@ -25,24 +25,6 @@ struct r_bin_te_section_t {
|
||||
int last;
|
||||
};
|
||||
|
||||
struct r_bin_te_import_t {
|
||||
ut8 name[TE_NAME_LENGTH];
|
||||
ut64 rva;
|
||||
ut64 offset;
|
||||
ut64 hint;
|
||||
ut64 ordinal;
|
||||
int last;
|
||||
};
|
||||
|
||||
struct r_bin_te_export_t {
|
||||
ut8 name[TE_NAME_LENGTH];
|
||||
ut8 forwarder[TE_NAME_LENGTH];
|
||||
ut64 rva;
|
||||
ut64 offset;
|
||||
ut64 ordinal;
|
||||
int last;
|
||||
};
|
||||
|
||||
struct r_bin_te_string_t {
|
||||
char string[TE_STRING_LENGTH];
|
||||
ut64 rva;
|
||||
@ -52,8 +34,6 @@ struct r_bin_te_string_t {
|
||||
int last;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
struct r_bin_te_obj_t {
|
||||
TE_image_file_header *header;
|
||||
TE_image_section_header *section_header;
|
||||
@ -75,3 +55,5 @@ char* r_bin_te_get_subsystem(struct r_bin_te_obj_t* bin);
|
||||
void* r_bin_te_free(struct r_bin_te_obj_t* bin);
|
||||
struct r_bin_te_obj_t* r_bin_te_new(const char* file);
|
||||
struct r_bin_te_obj_t* r_bin_te_new_buf(struct r_buf_t *buf);
|
||||
|
||||
#endif
|
||||
|
@ -48,6 +48,9 @@
|
||||
|
||||
#define TE_IMAGE_DIRECTORY_ENTRIES 2
|
||||
|
||||
#define TE_IMAGE_DIRECTORY_ENTRY_BASERELOC 0
|
||||
#define TE_IMAGE_DIRECTORY_ENTRY_DEBUG 1
|
||||
|
||||
#define TE_IMAGE_SUBSYSTEM_UNKNOWN 0
|
||||
#define TE_IMAGE_SUBSYSTEM_NATIVE 1
|
||||
#define TE_IMAGE_SUBSYSTEM_WINDOWS_GUI 2
|
||||
|
@ -88,62 +88,6 @@ static RList* sections(RBinArch *arch) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
static RList* symbols(RBinArch *arch) {
|
||||
RList *ret = NULL;
|
||||
RBinSymbol *ptr = NULL;
|
||||
struct r_bin_te_export_t *symbols = NULL;
|
||||
int i;
|
||||
|
||||
if (!(ret = r_list_new ()))
|
||||
return NULL;
|
||||
ret->free = free;
|
||||
if (!(symbols = r_bin_te_get_exports(arch->bin_obj)))
|
||||
return ret;
|
||||
for (i = 0; !symbols[i].last; i++) {
|
||||
if (!(ptr = R_NEW (RBinSymbol)))
|
||||
break;
|
||||
strncpy (ptr->name, (char*)symbols[i].name, R_BIN_SIZEOF_STRINGS);
|
||||
strncpy (ptr->forwarder, (char*)symbols[i].forwarder, R_BIN_SIZEOF_STRINGS);
|
||||
strncpy (ptr->bind, "NONE", R_BIN_SIZEOF_STRINGS);
|
||||
strncpy (ptr->type, "FUNC", R_BIN_SIZEOF_STRINGS); //XXX Get the right type
|
||||
ptr->size = 0;
|
||||
ptr->rva = symbols[i].rva;
|
||||
ptr->offset = symbols[i].offset;
|
||||
ptr->ordinal = symbols[i].ordinal;
|
||||
r_list_append (ret, ptr);
|
||||
}
|
||||
free (symbols);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static RList* imports(RBinArch *arch) {
|
||||
RList *ret = NULL;
|
||||
RBinImport *ptr = NULL;
|
||||
struct r_bin_te_import_t *imports = NULL;
|
||||
int i;
|
||||
|
||||
if (!(ret = r_list_new ()))
|
||||
return NULL;
|
||||
ret->free = free;
|
||||
if (!(imports = r_bin_te_get_imports(arch->bin_obj)))
|
||||
return ret;
|
||||
for (i = 0; !imports[i].last; i++) {
|
||||
if (!(ptr = R_NEW (RBinImport)))
|
||||
break;
|
||||
strncpy (ptr->name, (char*)imports[i].name, R_BIN_SIZEOF_STRINGS);
|
||||
strncpy (ptr->bind, "NONE", R_BIN_SIZEOF_STRINGS);
|
||||
strncpy (ptr->type, "FUNC", R_BIN_SIZEOF_STRINGS);
|
||||
ptr->rva = imports[i].rva;
|
||||
ptr->offset = imports[i].offset;
|
||||
ptr->size = 0;
|
||||
ptr->ordinal = imports[i].ordinal;
|
||||
ptr->hint = imports[i].hint;
|
||||
r_list_append (ret, ptr);
|
||||
}
|
||||
free (imports);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static RBinInfo* info(RBinArch *arch) {
|
||||
char *str;
|
||||
RBinInfo *ret = R_NEW0 (RBinInfo);
|
||||
@ -195,12 +139,12 @@ struct r_bin_plugin_t r_bin_plugin_te = {
|
||||
.binsym = &binsym,
|
||||
.entries = &entries,
|
||||
.sections = §ions,
|
||||
.symbols = &symbols,
|
||||
.imports = &imports,
|
||||
.symbols = NULL, // TE doesn't have exports data directory
|
||||
.imports = NULL, // TE doesn't have imports data directory
|
||||
.strings = NULL,
|
||||
.info = &info,
|
||||
.fields = NULL,
|
||||
.libs = NULL,
|
||||
.libs = NULL, // TE doesn't have imports data directory
|
||||
.relocs = NULL,
|
||||
.meta = NULL,
|
||||
.write = NULL,
|
||||
|
Loading…
x
Reference in New Issue
Block a user