mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-12 23:46:36 +00:00
Handle sized bitfields and enums in pf
This commit is contained in:
parent
931c358d46
commit
5a2c50f8dc
@ -194,8 +194,9 @@ static int PE_(r_bin_pe_init_hdr)(struct PE_(r_bin_pe_obj_t)* bin) {
|
||||
" sizeOfStackReserve sizeOfStackCommit sizeOfHeapReserve sizeOfHeapCommit loaderFlags numberOfRvaAndSizes"
|
||||
" (pe_image_data_directory)dataDirectory", 0);
|
||||
#endif
|
||||
sdb_set (bin->kv, "pe_image_file_header.format", "wwxxxww"
|
||||
" machine numberOfSections timeDateStamp pointerToSymbolTable"
|
||||
sdb_set (bin->kv, "pe_machine.cparse", "enum pe_machine { IMAGE_FILE_MACHINE_I386=0x014c, IMAGE_FILE_MACHINE_IA64=0x0200, IMAGE_FILE_MACHINE_AMD64=0x8664 };", 0);
|
||||
sdb_set (bin->kv, "pe_image_file_header.format", "[2]Ewxxxww"
|
||||
" (pe_machine)machine numberOfSections timeDateStamp pointerToSymbolTable"
|
||||
" numberOfSymbols sizeOfOptionalHeader characteristics", 0);
|
||||
sdb_set (bin->kv, "pe_image_data_directory.format", "xx virtualAddress size",0);
|
||||
if (strncmp ((char*)&bin->dos_header->e_magic, "MZ", 2) ||
|
||||
|
@ -779,6 +779,11 @@ R_API int r_print_format(RPrint *p, ut64 seek, const ut8* b, const int len,
|
||||
char *structname, *osn;
|
||||
char *bitfield = NULL;
|
||||
structname = osn = strdup (r_str_word_get0 (args, idx-1));
|
||||
switch (size) {
|
||||
case 1: addr &= UT8_MAX; break;
|
||||
case 2: addr &= UT16_MAX; break;
|
||||
case 4: addr &= UT32_MAX; break;
|
||||
}
|
||||
if (*structname == '(') {
|
||||
name = strchr (structname, ')');
|
||||
} else {
|
||||
@ -808,6 +813,11 @@ R_API int r_print_format(RPrint *p, ut64 seek, const ut8* b, const int len,
|
||||
char *enumname, *osn;
|
||||
char *enumvalue = NULL;
|
||||
enumname = osn = strdup (r_str_word_get0 (args, idx-1));
|
||||
switch (size) {
|
||||
case 1: addr &= UT8_MAX; break;
|
||||
case 2: addr &= UT16_MAX; break;
|
||||
case 4: addr &= UT32_MAX; break;
|
||||
}
|
||||
if (*enumname == '(') {
|
||||
name = strchr (enumname, ')');
|
||||
} else {
|
||||
@ -818,7 +828,6 @@ R_API int r_print_format(RPrint *p, ut64 seek, const ut8* b, const int len,
|
||||
enumname++;
|
||||
if (name) *(name++) = '\0';
|
||||
else eprintf ("No ')'\n");
|
||||
// TODO: add a callback in RPrint to resolve an enum
|
||||
if (p->get_enumname)
|
||||
enumvalue = p->get_enumname (p->user, enumname, addr);
|
||||
if (enumvalue && *enumvalue) {
|
||||
|
Loading…
Reference in New Issue
Block a user