mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-01 11:48:10 +00:00
pass over COFF layer
- updated naming convention on structs, enums, and macros to conform with code base style - moved related structs closer to each other - moved parser code to separate file
This commit is contained in:
@@ -469,9 +469,9 @@ dmn_w32_image_info_from_process_base_vaddr(HANDLE process, U64 base_vaddr)
|
||||
}
|
||||
|
||||
// rjf: get COFF header
|
||||
B32 got_coff_header = 0;
|
||||
U64 coff_header_off = 0;
|
||||
COFF_Header coff_header = {0};
|
||||
B32 got_file_header = 0;
|
||||
U64 file_header_off = 0;
|
||||
COFF_FileHeader file_header = {0};
|
||||
if(pe_offset > 0)
|
||||
{
|
||||
U64 pe_magic_off = base_vaddr + pe_offset;
|
||||
@@ -479,28 +479,28 @@ dmn_w32_image_info_from_process_base_vaddr(HANDLE process, U64 base_vaddr)
|
||||
dmn_w32_process_read_struct(process, pe_magic_off, &pe_magic);
|
||||
if(pe_magic == PE_MAGIC)
|
||||
{
|
||||
coff_header_off = pe_magic_off + sizeof(pe_magic);
|
||||
if(dmn_w32_process_read_struct(process, coff_header_off, &coff_header))
|
||||
file_header_off = pe_magic_off + sizeof(pe_magic);
|
||||
if(dmn_w32_process_read_struct(process, file_header_off, &file_header))
|
||||
{
|
||||
got_coff_header = 1;
|
||||
got_file_header = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: get arch and size
|
||||
DMN_W32_ImageInfo result = zero_struct;
|
||||
if(got_coff_header)
|
||||
if(got_file_header)
|
||||
{
|
||||
U64 optional_size_off = 0;
|
||||
Arch arch = Arch_Null;
|
||||
switch(coff_header.machine)
|
||||
switch(file_header.machine)
|
||||
{
|
||||
case COFF_MachineType_X86:
|
||||
case COFF_Machine_X86:
|
||||
{
|
||||
arch = Arch_x86;
|
||||
optional_size_off = OffsetOf(PE_OptionalHeader32, sizeof_image);
|
||||
}break;
|
||||
case COFF_MachineType_X64:
|
||||
case COFF_Machine_X64:
|
||||
{
|
||||
arch = Arch_x64;
|
||||
optional_size_off = OffsetOf(PE_OptionalHeader32Plus, sizeof_image);
|
||||
@@ -510,7 +510,7 @@ dmn_w32_image_info_from_process_base_vaddr(HANDLE process, U64 base_vaddr)
|
||||
}
|
||||
if(arch != Arch_Null)
|
||||
{
|
||||
U64 optional_off = coff_header_off + sizeof(coff_header);
|
||||
U64 optional_off = file_header_off + sizeof(COFF_FileHeader);
|
||||
U32 size = 0;
|
||||
if(dmn_w32_process_read_struct(process, optional_off+optional_size_off, &size) >= sizeof(size))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user