Eric Pouech : dbghelp: Extend the image (ELF/PE) scheme to get the RVA out of a section.
Alexandre Julliard
julliard at winehq.org
Fri Mar 19 11:16:37 CDT 2010
Module: wine
Branch: master
Commit: c9bac2efd2b3590230aed946d5ed7086d19182a4
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c9bac2efd2b3590230aed946d5ed7086d19182a4
Author: Eric Pouech <eric.pouech at orange.fr>
Date: Thu Mar 18 21:31:19 2010 +0100
dbghelp: Extend the image (ELF/PE) scheme to get the RVA out of a section.
---
dlls/dbghelp/elf_module.c | 12 ++++++++++++
dlls/dbghelp/image_private.h | 13 +++++++++++++
dlls/dbghelp/pe_module.c | 12 ++++++++++++
3 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c
index 64b8481..4719aed 100644
--- a/dlls/dbghelp/elf_module.c
+++ b/dlls/dbghelp/elf_module.c
@@ -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
diff --git a/dlls/dbghelp/image_private.h b/dlls/dbghelp/image_private.h
index 4eb5f83..b768deb 100644
--- a/dlls/dbghelp/image_private.h
+++ b/dlls/dbghelp/image_private.h
@@ -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;
diff --git a/dlls/dbghelp/pe_module.c b/dlls/dbghelp/pe_module.c
index 171d616..67c2e8d 100644
--- a/dlls/dbghelp/pe_module.c
+++ b/dlls/dbghelp/pe_module.c
@@ -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
More information about the wine-cvs
mailing list