mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-08 14:58:08 +00:00
validate export table fields
This commit is contained in:
+6
-3
@@ -1247,10 +1247,11 @@ pe_exports_from_data(Arena *arena, U64 section_count, COFF_SectionHeader *sectio
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
|
||||
PE_ParsedExportTable exptab = {0};
|
||||
|
||||
String8 raw_dir = str8_substr(raw_data, dir_file_range);
|
||||
|
||||
PE_ExportTableHeader *header = str8_deserial_get_raw_ptr(raw_dir, 0, sizeof(*header));
|
||||
|
||||
if (header) {
|
||||
U64 name_table_off = coff_foff_from_voff(sections, section_count, header->name_pointer_table_voff);
|
||||
U64 export_table_off = coff_foff_from_voff(sections, section_count, header->export_address_table_voff);
|
||||
U64 ordinal_table_off = coff_foff_from_voff(sections, section_count, header->ordinal_table_voff);
|
||||
@@ -1259,6 +1260,7 @@ pe_exports_from_data(Arena *arena, U64 section_count, COFF_SectionHeader *sectio
|
||||
U32 *export_table = str8_deserial_get_raw_ptr(raw_data, export_table_off, sizeof(*export_table )*header->export_address_table_count);
|
||||
U16 *ordinal_table = str8_deserial_get_raw_ptr(raw_data, ordinal_table_off, sizeof(*ordinal_table)*header->name_pointer_table_count);
|
||||
|
||||
if (name_table && export_table && ordinal_table) {
|
||||
// Scan export address table to get accruate count of ordinals.
|
||||
// We can't rely on "name_pointer_table_count" becuase it is possible
|
||||
// to define an export without a name through NONAME attribute in DEF file
|
||||
@@ -1328,7 +1330,6 @@ pe_exports_from_data(Arena *arena, U64 section_count, COFF_SectionHeader *sectio
|
||||
}
|
||||
|
||||
// fill out result
|
||||
PE_ParsedExportTable exptab = {0};
|
||||
exptab.flags = header->flags;
|
||||
exptab.time_stamp = header->time_stamp;
|
||||
exptab.major_ver = header->major_ver;
|
||||
@@ -1336,6 +1337,8 @@ pe_exports_from_data(Arena *arena, U64 section_count, COFF_SectionHeader *sectio
|
||||
exptab.ordinal_base = header->ordinal_base;
|
||||
exptab.export_count = ordinal_count;
|
||||
exptab.exports = exports;
|
||||
}
|
||||
}
|
||||
|
||||
scratch_end(scratch);
|
||||
return exptab;
|
||||
|
||||
Reference in New Issue
Block a user