Commit c9bac2ef authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

dbghelp: Extend the image (ELF/PE) scheme to get the RVA out of a section.

parent a2e65f13
......@@ -195,6 +195,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
*
* Get the size of an ELF section
......
......@@ -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;
......
......@@ -148,6 +148,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
*
* Get the size of an PE section
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment