Skip to content

Commit 62d99e1

Browse files
author
vdisasmdev
committed
* parsing export: a bit more checks, more verbose
1 parent e25a95f commit 62d99e1

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

PE.Parser.Export.pas

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,34 @@ function TPEExportParser.Parse: TParserResult;
5454

5555
// If can't read whole table, failure.
5656
if not PE.ReadEx(@ExpDir, Sizeof(ExpDir)) then
57+
begin
58+
PE.Msg.Write('Export Parser: not enough space to read dir. header.');
5759
exit(PR_ERROR);
60+
end;
5861

5962
// If no addresses, ok.
6063
if ExpDir.AddressTableEntries = 0 then
64+
begin
65+
PE.Msg.Write('Export Parser: directory present, but there are no functions.');
6166
exit(PR_OK);
67+
end;
6268

6369
if ExpDir.ExportFlags <> 0 then
70+
begin
71+
PE.Msg.Write('Export Parser: reserved directory flags <> 0');
6472
exit(PR_ERROR);
73+
end;
6574

6675
// Read lib exported name.
67-
if (ExpDir.NameRVA <> 0) and (PE.SeekRVA(ExpDir.NameRVA)) then
76+
if (ExpDir.NameRVA <> 0) then
77+
begin
78+
if not PE.SeekRVA(ExpDir.NameRVA) then
79+
begin
80+
PE.Msg.Write('Export Parser: Wrong RVA of dll exported name = 0x%x', [ExpDir.NameRVA]);
81+
exit(PR_ERROR);
82+
end;
6883
PE.ExportedName := PE.ReadAnsiString;
84+
end;
6985

7086
base := ExpDir.OrdinalBase;
7187

0 commit comments

Comments
 (0)