Skip to content

Commit

Permalink
Expose function RVA in pe.export_details[]
Browse files Browse the repository at this point in the history
  • Loading branch information
TommYDeeee authored and duristomas67 committed Mar 7, 2023
1 parent 17ae552 commit 0c5ad8a
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 @@ -1573,6 +1573,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 @@ -3720,6 +3723,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 @@ -561,6 +561,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 @@ -607,7 +611,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 0c5ad8a

Please sign in to comment.