dbghelp: Extend the image (ELF/PE) scheme to get the RVA out of a section.
This commit is contained in:
parent
a2e65f1311
commit
c9bac2efd2
|
@ -194,6 +194,18 @@ static void elf_end_find(struct image_file_map* fmap)
|
|||
}
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* elf_get_map_rva
|
||||
*
|
||||
* Get the RVA of an ELF section
|
||||
*/
|
||||
DWORD_PTR elf_get_map_rva(const struct image_section_map* ism)
|
||||
{
|
||||
if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.elf.elfhdr.e_shnum)
|
||||
return 0;
|
||||
return ism->fmap->u.elf.sect[ism->sidx].shdr.sh_addr - ism->fmap->u.elf.elf_start;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* elf_get_map_size
|
||||
*
|
||||
|
|
|
@ -116,12 +116,14 @@ extern BOOL elf_find_section(struct image_file_map* fmap, const char* na
|
|||
unsigned sht, struct image_section_map* ism);
|
||||
extern const char* elf_map_section(struct image_section_map* ism);
|
||||
extern void elf_unmap_section(struct image_section_map* ism);
|
||||
extern DWORD_PTR elf_get_map_rva(const struct image_section_map* ism);
|
||||
extern unsigned elf_get_map_size(const struct image_section_map* ism);
|
||||
|
||||
extern BOOL pe_find_section(struct image_file_map* fmap, const char* name,
|
||||
struct image_section_map* ism);
|
||||
extern const char* pe_map_section(struct image_section_map* psm);
|
||||
extern void pe_unmap_section(struct image_section_map* psm);
|
||||
extern DWORD_PTR pe_get_map_rva(const struct image_section_map* psm);
|
||||
extern unsigned pe_get_map_size(const struct image_section_map* psm);
|
||||
|
||||
static inline BOOL image_find_section(struct image_file_map* fmap, const char* name,
|
||||
|
@ -157,6 +159,17 @@ static inline void image_unmap_section(struct image_section_map* ism)
|
|||
}
|
||||
}
|
||||
|
||||
static inline DWORD_PTR image_get_map_rva(struct image_section_map* ism)
|
||||
{
|
||||
if (!ism->fmap) return 0;
|
||||
switch (ism->fmap->modtype)
|
||||
{
|
||||
case DMT_ELF: return elf_get_map_rva(ism);
|
||||
case DMT_PE: return pe_get_map_rva(ism);
|
||||
default: assert(0); return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned image_get_map_size(struct image_section_map* ism)
|
||||
{
|
||||
if (!ism->fmap) return 0;
|
||||
|
|
|
@ -147,6 +147,18 @@ void pe_unmap_section(struct image_section_map* ism)
|
|||
}
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* pe_get_map_rva
|
||||
*
|
||||
* Get the RVA of an PE section
|
||||
*/
|
||||
DWORD_PTR pe_get_map_rva(const struct image_section_map* ism)
|
||||
{
|
||||
if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.pe.ntheader.FileHeader.NumberOfSections)
|
||||
return 0;
|
||||
return ism->fmap->u.pe.sect[ism->sidx].shdr.VirtualAddress;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* pe_get_map_size
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue