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

dbghelp: Create the notion of image (PE, ELF modules) to uniformize some handlings.

parent fb169502
...@@ -474,8 +474,8 @@ typedef BOOL (*enum_modules_cb)(const WCHAR*, unsigned long addr, void* user); ...@@ -474,8 +474,8 @@ typedef BOOL (*enum_modules_cb)(const WCHAR*, unsigned long addr, void* user);
/* elf_module.c */ /* elf_module.c */
extern BOOL elf_enum_modules(HANDLE hProc, enum_modules_cb, void*); extern BOOL elf_enum_modules(HANDLE hProc, enum_modules_cb, void*);
extern BOOL elf_fetch_file_info(const WCHAR* name, DWORD* base, DWORD* size, DWORD* checksum); extern BOOL elf_fetch_file_info(const WCHAR* name, DWORD* base, DWORD* size, DWORD* checksum);
struct elf_file_map; struct image_file_map;
extern BOOL elf_load_debug_info(struct module* module, struct elf_file_map* fmap); extern BOOL elf_load_debug_info(struct module* module, struct image_file_map* fmap);
extern struct module* extern struct module*
elf_load_module(struct process* pcs, const WCHAR* name, unsigned long); elf_load_module(struct process* pcs, const WCHAR* name, unsigned long);
extern BOOL elf_read_wine_loader_dbg_info(struct process* pcs); extern BOOL elf_read_wine_loader_dbg_info(struct process* pcs);
......
...@@ -60,60 +60,110 @@ ...@@ -60,60 +60,110 @@
#define Elf_Dyn Elf32_Dyn #define Elf_Dyn Elf32_Dyn
#define Elf_Sym Elf32_Sym #define Elf_Sym Elf32_Sym
#endif #endif
#else
#ifndef SHT_NULL
#define SHT_NULL 0
#endif
#endif
/* structure holding information while handling an ELF image /* structure holding information while handling an ELF image
* allows one by one section mapping for memory savings * allows one by one section mapping for memory savings
*/ */
struct elf_file_map struct image_file_map
{ {
size_t elf_size; enum module_type modtype;
size_t elf_start; union
int fd;
const char* shstrtab;
struct elf_file_map* alternate; /* another ELF file (linked to this one) */
Elf_Ehdr elfhdr;
struct
{ {
Elf_Shdr shdr; struct elf_file_map
const char* mapped; {
}* sect; size_t elf_size;
}; size_t elf_start;
int fd;
const char* shstrtab;
struct image_file_map* alternate; /* another ELF file (linked to this one) */
#ifdef __ELF__
Elf_Ehdr elfhdr;
struct
{
Elf_Shdr shdr;
const char* mapped;
}* sect;
#endif #endif
} elf;
struct pe_file_map struct pe_file_map
{ {
HANDLE hMap; HANDLE hMap;
IMAGE_NT_HEADERS ntheader; IMAGE_NT_HEADERS ntheader;
unsigned full_count; unsigned full_count;
void* full_map; void* full_map;
struct struct
{ {
IMAGE_SECTION_HEADER shdr; IMAGE_SECTION_HEADER shdr;
const char* mapped; const char* mapped;
}* sect; }* sect;
const char* strtable; const char* strtable;
} pe;
} u;
}; };
struct elf_section_map struct image_section_map
{ {
struct elf_file_map* fmap; struct image_file_map* fmap;
long sidx; long sidx;
}; };
struct pe_section_map extern BOOL elf_find_section(struct image_file_map* fmap, const char* name,
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 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 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,
struct image_section_map* ism)
{ {
struct pe_file_map* fmap; switch (fmap->modtype)
long sidx; {
}; case DMT_ELF: return elf_find_section(fmap, name, SHT_NULL, ism);
case DMT_PE: return pe_find_section(fmap, name, ism);
default: assert(0); return FALSE;
}
}
static inline const char* image_map_section(struct image_section_map* ism)
{
if (!ism->fmap) return NULL;
switch (ism->fmap->modtype)
{
case DMT_ELF: return elf_map_section(ism);
case DMT_PE: return pe_map_section(ism);
default: assert(0); return NULL;
}
}
extern BOOL elf_find_section(struct elf_file_map* fmap, const char* name, static inline void image_unmap_section(struct image_section_map* ism)
unsigned sht, struct elf_section_map* esm); {
extern const char* elf_map_section(struct elf_section_map* esm); if (!ism->fmap) return;
extern void elf_unmap_section(struct elf_section_map* esm); switch (ism->fmap->modtype)
extern unsigned elf_get_map_size(const struct elf_section_map* esm); {
case DMT_ELF: elf_unmap_section(ism); break;
case DMT_PE: pe_unmap_section(ism); break;
default: assert(0); return;
}
}
extern BOOL pe_find_section(struct pe_file_map* fmap, const char* name, static inline unsigned image_get_map_size(struct image_section_map* ism)
struct pe_section_map* psm); {
extern const char* pe_map_section(struct pe_section_map* psm); if (!ism->fmap) return 0;
extern void pe_unmap_section(struct pe_section_map* psm); switch (ism->fmap->modtype)
extern unsigned pe_get_map_size(const struct pe_section_map* psm); {
case DMT_ELF: return elf_get_map_size(ism);
case DMT_PE: return pe_get_map_size(ism);
default: assert(0); return 0;
}
}
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