Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PE section flags #23520

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libr/bin/format/pe/pe.c
Original file line number Diff line number Diff line change
Expand Up @@ -4377,6 +4377,7 @@ static struct r_bin_pe_section_t* PE_(r_bin_pe_get_sections)(RBinPEObj* pe) {
}
}
}
sections[j].flags = shdr[i].Characteristics;
sections[j].perm = shdr[i].Characteristics;
sections[j].last = 0;
j++;
Expand Down
1 change: 1 addition & 0 deletions libr/bin/format/pe/pe.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct r_bin_pe_section_t {
ut64 vaddr;
ut64 paddr;
ut64 perm;
ut32 flags;
int last;
};

Expand Down
1 change: 1 addition & 0 deletions libr/bin/p/bin_pe.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ static RList* sections(RBinFile *bf) {
sec->vaddr = sections[i].vaddr + ba;
sec->add = true;
sec->perm = 0;
sec->flags = sections[i].flags;
if (R_BIN_PE_SCN_IS_EXECUTABLE (sections[i].perm)) {
sec->perm |= R_PERM_X;
sec->perm |= R_PERM_R; // implicit
Expand Down
17 changes: 9 additions & 8 deletions libr/core/cbin.c
Original file line number Diff line number Diff line change
Expand Up @@ -3047,11 +3047,11 @@ static bool bin_sections(RCore *r, PJ *pj, int mode, ut64 laddr, int va, ut64 at
}
if (IS_MODE_NORMAL (mode)) {
if (hashtypes) {
r_table_set_columnsf (table, "dXxXxssss",
"nth", "paddr", "size", "vaddr", "vsize", "perm", hashtypes, "type", "name");
r_table_set_columnsf (table, "dXxXxssssx",
"nth", "paddr", "size", "vaddr", "vsize", "perm", hashtypes, "type", "name", "flags");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put flags before or after perm. But not after name

} else {
r_table_set_columnsf (table, "dXxXxsss",
"nth", "paddr", "size", "vaddr", "vsize", "perm", "type", "name");
r_table_set_columnsf (table, "dXxXxsssx",
"nth", "paddr", "size", "vaddr", "vsize", "perm", "type", "name", "flags");
}
// r_table_align (table, 0, R_TABLE_ALIGN_CENTER);
r_table_align (table, 2, R_TABLE_ALIGN_RIGHT);
Expand Down Expand Up @@ -3228,6 +3228,7 @@ static bool bin_sections(RCore *r, PJ *pj, int mode, ut64 laddr, int va, ut64 at
pj_ks (pj, "type", section->type);
}
pj_ks (pj, "perm", perms);
pj_kN (pj, "flags", section->flags);
if (hashtypes && (int)section->size > 0) {
int datalen = section->size;
if (datalen > 0 && datalen < plimit) {
Expand Down Expand Up @@ -3287,15 +3288,15 @@ static bool bin_sections(RCore *r, PJ *pj, int mode, ut64 laddr, int va, ut64 at
stype = print_segments? "MAP": "----";
}
if (hashtypes) {
r_table_add_rowf (table, "dXxXxssss", i,
r_table_add_rowf (table, "dXxXxssssx", i,
(ut64)section->paddr, (ut64)section->size,
(ut64)addr, (ut64)section->vsize,
perms, r_str_get (hashstr), stype, section_name);
perms, r_str_get (hashstr), stype, section_name, section->flags);
} else {
r_table_add_rowf (table, "dXxXxsss", i,
r_table_add_rowf (table, "dXxXxsssx", i,
(ut64)section->paddr, (ut64)section->size,
(ut64)addr, (ut64)section->vsize,
perms, stype, section_name);
perms, stype, section_name, section->flags);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this should be after before perms not after the name

}
free (hashstr);
}
Expand Down
Loading