Skip to content

Commit

Permalink
Expose function RVA in pe.export_details[] (#1882)
Browse files Browse the repository at this point in the history
  • Loading branch information
TommYDeeee authored Aug 23, 2023
1 parent d7e67ff commit 0023a11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions libyara/modules/pe/pe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1655,6 +1655,9 @@ static void pe_parse_exports(PE* pe)
yr_set_integer(
ordinal_base + i, pe->object, "export_details[%i].ordinal", exp_sz);

yr_set_integer(
yr_le32toh(function_addrs[i]), pe->object, "export_details[%i].rva", exp_sz);

// Don't check for a failure here since some packers make this an invalid
// value.
offset = pe_rva_to_offset(pe, yr_le32toh(function_addrs[i]));
Expand Down Expand Up @@ -3805,6 +3808,7 @@ begin_declarations
declare_string("name");
declare_string("forward_name");
declare_integer("ordinal");
declare_integer("rva");
end_struct_array("export_details")

begin_struct_array("import_details")
Expand Down
7 changes: 6 additions & 1 deletion tests/test-pe.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,10 @@ int main(int argc, char** argv)
pe.export_details[0].offset == 1072 and \
pe.export_details[0].name == \"DllGetClassObject\" and \
pe.export_details[0].ordinal == 1 and \
pe.export_details[0].rva == 0x1030 and \
pe.export_details[1].rva == 0x267d and \
pe.export_details[2].rva == 0x26a8 and \
pe.export_details[3].rva == 0x26ca and \
pe.export_details[1].forward_name == \"COMSVCS.GetObjectContext\" \
}",
"tests/data/mtxex.dll");
Expand Down Expand Up @@ -554,7 +558,8 @@ int main(int argc, char** argv)
"import \"pe\" \
rule test { \
condition: \
pe.export_details[0].name == \"CP_PutItem\" \
pe.export_details[0].name == \"CP_PutItem\" and \
pe.export_details[0].rva == 0x106c \
}",
"tests/data/"
"079a472d22290a94ebb212aa8015cdc8dd28a968c6b4d3b88acdd58ce2d3b885.upx");
Expand Down

0 comments on commit 0023a11

Please sign in to comment.