dbghelp: Added helper to image_file_map to map also directory out of PE executables.

This commit is contained in:
Eric Pouech 2010-03-20 09:47:18 +01:00 committed by Alexandre Julliard
parent 3428b94a8d
commit 2ed8b9f6b6
2 changed files with 32 additions and 0 deletions

View File

@ -570,6 +570,9 @@ extern struct module*
DWORD64 base, DWORD64 size); DWORD64 base, DWORD64 size);
extern BOOL pe_load_debug_info(const struct process* pcs, extern BOOL pe_load_debug_info(const struct process* pcs,
struct module* module); struct module* module);
extern const char* pe_map_directory(struct module* module, int dirno, DWORD* size);
extern void pe_unmap_directoy(struct module* module, int dirno);
/* source.c */ /* source.c */
extern unsigned source_new(struct module* module, const char* basedir, const char* source); extern unsigned source_new(struct module* module, const char* basedir, const char* source);
extern const char* source_get(const struct module* module, unsigned idx); extern const char* source_get(const struct module* module, unsigned idx);

View File

@ -257,6 +257,35 @@ static void pe_unmap_file(struct image_file_map* fmap)
} }
} }
/******************************************************************
* pe_map_directory
*
* Maps a directory content out of a PE file
*/
const char* pe_map_directory(struct module* module, int dirno, DWORD* size)
{
IMAGE_NT_HEADERS* nth;
void* mapping;
if (module->type != DMT_PE || !module->format_info[DFI_PE]) return NULL;
if (dirno >= IMAGE_NUMBEROF_DIRECTORY_ENTRIES ||
!(mapping = pe_map_full(&module->format_info[DFI_PE]->u.pe_info->fmap, &nth)))
return NULL;
if (size) *size = nth->OptionalHeader.DataDirectory[dirno].Size;
return RtlImageRvaToVa(nth, mapping,
nth->OptionalHeader.DataDirectory[dirno].VirtualAddress, NULL);
}
/******************************************************************
* pe_unmap_directory
*
* Unmaps a directory content
*/
void pe_unmap_directory(struct image_file_map* fmap, int dirno)
{
pe_unmap_full(fmap);
}
static void pe_module_remove(struct process* pcs, struct module_format* modfmt) static void pe_module_remove(struct process* pcs, struct module_format* modfmt)
{ {
pe_unmap_file(&modfmt->u.pe_info->fmap); pe_unmap_file(&modfmt->u.pe_info->fmap);