mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-16 02:28:12 +00:00
Fix #64 (handle 8 char length section names in PE and TE)
This commit is contained in:
parent
89992670e1
commit
fcbe3cac4a
@ -1,4 +1,4 @@
|
|||||||
/* radare - LGPL - Copyright 2008-2012 nibble, pancake */
|
/* radare - LGPL - Copyright 2008-2013 nibble, pancake */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -110,7 +110,7 @@ static int PE_(r_bin_pe_parse_imports)(struct PE_(r_bin_pe_obj_t)* bin, struct r
|
|||||||
return R_FALSE;
|
return R_FALSE;
|
||||||
}
|
}
|
||||||
memcpy((*importp)[*nimp].name, import_name, PE_NAME_LENGTH);
|
memcpy((*importp)[*nimp].name, import_name, PE_NAME_LENGTH);
|
||||||
(*importp)[*nimp].name[PE_NAME_LENGTH-1] = '\0';
|
(*importp)[*nimp].name[PE_NAME_LENGTH] = '\0';
|
||||||
(*importp)[*nimp].rva = FirstThunk + i * sizeof(PE_DWord);
|
(*importp)[*nimp].rva = FirstThunk + i * sizeof(PE_DWord);
|
||||||
(*importp)[*nimp].offset = PE_(r_bin_pe_rva_to_offset)(bin, FirstThunk) + i * sizeof(PE_DWord);
|
(*importp)[*nimp].offset = PE_(r_bin_pe_rva_to_offset)(bin, FirstThunk) + i * sizeof(PE_DWord);
|
||||||
(*importp)[*nimp].hint = import_hint;
|
(*importp)[*nimp].hint = import_hint;
|
||||||
@ -349,10 +349,10 @@ struct r_bin_pe_export_t* PE_(r_bin_pe_get_exports)(struct PE_(r_bin_pe_obj_t)*
|
|||||||
exports[i].rva = function_rva;
|
exports[i].rva = function_rva;
|
||||||
exports[i].offset = PE_(r_bin_pe_rva_to_offset)(bin, function_rva);
|
exports[i].offset = PE_(r_bin_pe_rva_to_offset)(bin, function_rva);
|
||||||
exports[i].ordinal = function_ordinal;
|
exports[i].ordinal = function_ordinal;
|
||||||
memcpy(exports[i].forwarder, forwarder_name, PE_NAME_LENGTH);
|
memcpy (exports[i].forwarder, forwarder_name, PE_NAME_LENGTH);
|
||||||
exports[i].forwarder[PE_NAME_LENGTH-1] = '\0';
|
exports[i].forwarder[PE_NAME_LENGTH] = '\0';
|
||||||
memcpy(exports[i].name, export_name, PE_NAME_LENGTH);
|
memcpy (exports[i].name, export_name, PE_NAME_LENGTH);
|
||||||
exports[i].name[PE_NAME_LENGTH-1] = '\0';
|
exports[i].name[PE_NAME_LENGTH] = '\0';
|
||||||
exports[i].last = 0;
|
exports[i].last = 0;
|
||||||
}
|
}
|
||||||
exports[i].last = 1;
|
exports[i].last = 1;
|
||||||
@ -447,7 +447,7 @@ struct r_bin_pe_lib_t* PE_(r_bin_pe_get_libs)(struct PE_(r_bin_pe_obj_t) *bin) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < j; i++) {
|
for (i = 0; i < j; i++) {
|
||||||
libs[i].name[PE_STRING_LENGTH-1] = '\0';
|
libs[i].name[PE_STRING_LENGTH] = '\0';
|
||||||
libs[i].last = 0;
|
libs[i].last = 0;
|
||||||
}
|
}
|
||||||
libs[i].last = 1;
|
libs[i].last = 1;
|
||||||
@ -633,7 +633,7 @@ struct r_bin_pe_section_t* PE_(r_bin_pe_get_sections)(struct PE_(r_bin_pe_obj_t)
|
|||||||
}
|
}
|
||||||
for (i = 0; i < sections_count; i++) {
|
for (i = 0; i < sections_count; i++) {
|
||||||
memcpy (sections[i].name, shdr[i].Name, PE_IMAGE_SIZEOF_SHORT_NAME);
|
memcpy (sections[i].name, shdr[i].Name, PE_IMAGE_SIZEOF_SHORT_NAME);
|
||||||
sections[i].name[PE_IMAGE_SIZEOF_SHORT_NAME-1] = '\0';
|
sections[i].name[PE_IMAGE_SIZEOF_SHORT_NAME] = '\0';
|
||||||
sections[i].rva = shdr[i].VirtualAddress;
|
sections[i].rva = shdr[i].VirtualAddress;
|
||||||
sections[i].size = shdr[i].SizeOfRawData;
|
sections[i].size = shdr[i].SizeOfRawData;
|
||||||
sections[i].vsize = shdr[i].Misc.VirtualSize;
|
sections[i].vsize = shdr[i].Misc.VirtualSize;
|
||||||
|
@ -229,7 +229,7 @@ typedef struct {
|
|||||||
#define PE_IMAGE_SCN_MEM_WRITE 0x80000000
|
#define PE_IMAGE_SCN_MEM_WRITE 0x80000000
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ut8 Name[PE_IMAGE_SIZEOF_SHORT_NAME];
|
ut8 Name[PE_IMAGE_SIZEOF_SHORT_NAME];
|
||||||
union {
|
union {
|
||||||
ut32 PhysicalAddress;
|
ut32 PhysicalAddress;
|
||||||
ut32 VirtualSize;
|
ut32 VirtualSize;
|
||||||
|
@ -276,7 +276,7 @@ struct r_bin_te_section_t* r_bin_te_get_sections(struct r_bin_te_obj_t* bin) {
|
|||||||
}
|
}
|
||||||
for (i = 0; i < sections_count; i++) {
|
for (i = 0; i < sections_count; i++) {
|
||||||
memcpy (sections[i].name, shdr[i].Name, TE_IMAGE_SIZEOF_NAME);
|
memcpy (sections[i].name, shdr[i].Name, TE_IMAGE_SIZEOF_NAME);
|
||||||
sections[i].name[TE_IMAGE_SIZEOF_NAME-1] = '\0';
|
sections[i].name[TE_IMAGE_SIZEOF_NAME] = '\0';
|
||||||
sections[i].rva = shdr[i].VirtualAddress;
|
sections[i].rva = shdr[i].VirtualAddress;
|
||||||
sections[i].size = shdr[i].SizeOfRawData;
|
sections[i].size = shdr[i].SizeOfRawData;
|
||||||
sections[i].vsize = shdr[i].VirtualSize;
|
sections[i].vsize = shdr[i].VirtualSize;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* radare - LGPL - Copyright 2008 nibble, xvilka */
|
/* radare - LGPL - Copyright 2008-2013 nibble, xvilka */
|
||||||
|
|
||||||
#undef TE_
|
#undef TE_
|
||||||
#undef TE_Word
|
#undef TE_Word
|
||||||
@ -12,8 +12,8 @@
|
|||||||
#ifndef _INCLUDE_R_BIN_TE_SPECS_H_
|
#ifndef _INCLUDE_R_BIN_TE_SPECS_H_
|
||||||
#define _INCLUDE_R_BIN_TE_SPECS_H_
|
#define _INCLUDE_R_BIN_TE_SPECS_H_
|
||||||
|
|
||||||
#define TE_NAME_LENGTH 256
|
#define TE_NAME_LENGTH 256
|
||||||
#define TE_STRING_LENGTH 256
|
#define TE_STRING_LENGTH 256
|
||||||
|
|
||||||
#define TE_IMAGE_FILE_MACHINE_UNKNOWN 0x0000
|
#define TE_IMAGE_FILE_MACHINE_UNKNOWN 0x0000
|
||||||
#define TE_IMAGE_FILE_MACHINE_ALPHA 0x0184
|
#define TE_IMAGE_FILE_MACHINE_ALPHA 0x0184
|
||||||
@ -46,7 +46,7 @@
|
|||||||
#define TE_IMAGE_FILE_MACHINE_TRICORE 0x0520
|
#define TE_IMAGE_FILE_MACHINE_TRICORE 0x0520
|
||||||
#define TE_IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
|
#define TE_IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
|
||||||
|
|
||||||
#define TE_IMAGE_DIRECTORY_ENTRIES 2
|
#define TE_IMAGE_DIRECTORY_ENTRIES 2
|
||||||
|
|
||||||
#define TE_IMAGE_DIRECTORY_ENTRY_BASERELOC 0
|
#define TE_IMAGE_DIRECTORY_ENTRY_BASERELOC 0
|
||||||
#define TE_IMAGE_DIRECTORY_ENTRY_DEBUG 1
|
#define TE_IMAGE_DIRECTORY_ENTRY_DEBUG 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user