mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-15 08:32:22 -07:00
move magic check to PE layer
This commit is contained in:
+14
@@ -408,6 +408,20 @@ pe_subsystem_from_string(String8 string)
|
||||
////////////////////////////////
|
||||
//~ rjf: Parser Functions
|
||||
|
||||
internal B32
|
||||
pe_check_magic(String8 data)
|
||||
{
|
||||
B32 is_pe = 0;
|
||||
PE_DosHeader dos_header = {0};
|
||||
str8_deserial_read_struct(data, 0, &dos_header);
|
||||
if (dos_header.magic == PE_DOS_MAGIC) {
|
||||
U32 pe_magic = 0;
|
||||
str8_deserial_read_struct(data, dos_header.coff_file_offset, &pe_magic);
|
||||
is_pe= pe_magic == PE_MAGIC;
|
||||
}
|
||||
return is_pe;
|
||||
}
|
||||
|
||||
internal PE_BinInfo
|
||||
pe_bin_info_from_data(Arena *arena, String8 data)
|
||||
{
|
||||
|
||||
@@ -1072,6 +1072,7 @@ internal String8 pe_string_from_dll_characteristics(Arena *arena, PE_DllCharacte
|
||||
////////////////////////////////
|
||||
//~ rjf: Parser Functions
|
||||
|
||||
internal B32 pe_check_magic(String8 data);
|
||||
internal PE_BinInfo pe_bin_info_from_data(Arena *arena, String8 data);
|
||||
|
||||
internal PE_DebugInfoList pe_parse_debug_directory(Arena *arena, String8 raw_image, String8 raw_debug_dir);
|
||||
|
||||
@@ -214,14 +214,6 @@ rd_format_line_from_voff(Arena *arena, RDI_Parsed *rdi, U64 voff, PathStyle path
|
||||
return result;
|
||||
}
|
||||
|
||||
internal B32
|
||||
rd_is_pe(String8 raw_data)
|
||||
{
|
||||
PE_DosHeader header = {0};
|
||||
str8_deserial_read_struct(raw_data, 0, &header);
|
||||
return header.magic == PE_DOS_MAGIC;
|
||||
}
|
||||
|
||||
internal B32
|
||||
rd_is_rdi(String8 raw_data)
|
||||
{
|
||||
@@ -316,7 +308,7 @@ rd_format_preamble(Arena *arena, String8List *out, String8 indent, String8 input
|
||||
input_type_string = "Big Obj";
|
||||
} else if (coff_is_obj(raw_data)) {
|
||||
input_type_string = "Obj";
|
||||
} else if (rd_is_pe(raw_data)) {
|
||||
} else if (pe_check_magic(raw_data)) {
|
||||
input_type_string = "COFF/PE";
|
||||
} else if (rd_is_rdi(raw_data)) {
|
||||
input_type_string = "RDI";
|
||||
|
||||
@@ -140,7 +140,6 @@ typedef struct RD_Line
|
||||
|
||||
// raddump
|
||||
|
||||
internal B32 rd_is_pe (String8 raw_data);
|
||||
internal B32 rd_is_rdi(String8 raw_data);
|
||||
|
||||
internal String8 rd_string_from_flags(Arena *arena, String8List list, U64 remaining_flags);
|
||||
|
||||
@@ -269,7 +269,7 @@ entry_point(CmdLine *cmdline)
|
||||
coff_print_big_obj(arena, out, indent, raw_data, opts);
|
||||
} else if (coff_is_obj(raw_data)) {
|
||||
coff_print_obj(arena, out, indent, raw_data, opts);
|
||||
} else if (rd_is_pe(raw_data)) {
|
||||
} else if (pe_check_magic(raw_data)) {
|
||||
RDI_Parsed *rdi = 0;
|
||||
if (!(opts & RD_Option_NoRdi)) {
|
||||
rdi = rd_rdi_from_pe(arena, file_path, raw_data);
|
||||
|
||||
Reference in New Issue
Block a user