Commit 9e2c76c6 authored by Andrey Turkin's avatar Andrey Turkin Committed by Alexandre Julliard

dbghelp: Implement ImageDirectoryEntryToDataEx.

parent 5e10ef04
......@@ -15,8 +15,8 @@
@ stub FindFileInPath
@ stub FindFileInSearchPath
@ stdcall GetTimestampForLoadedLibrary(long)
@ stdcall ImageDirectoryEntryToData(ptr long long ptr) ntdll.RtlImageDirectoryEntryToData
@ stub ImageDirectoryEntryToDataEx
@ stdcall ImageDirectoryEntryToData(ptr long long ptr)
@ stdcall ImageDirectoryEntryToDataEx(ptr long long ptr ptr)
@ stdcall ImageNtHeader(ptr) ntdll.RtlImageNtHeader
@ stdcall ImageRvaToSection(ptr ptr long) ntdll.RtlImageRvaToSection
@ stdcall ImageRvaToVa(ptr ptr long ptr) ntdll.RtlImageRvaToVa
......
......@@ -417,3 +417,53 @@ struct module* pe_load_builtin_module(struct process* pcs, const WCHAR* name,
}
return module;
}
/***********************************************************************
* ImageDirectoryEntryToDataEx (DBGHELP.@)
*
* Search for specified directory in PE image
*
* PARAMS
*
* base [in] Image base address
* image [in] TRUE - image has been loaded by loader, FALSE - raw file image
* dir [in] Target directory index
* size [out] Receives directory size
* section [out] Receives pointer to section header of section containing directory data
*
* RETURNS
* Success: pointer to directory data
* Failure: NULL
*
*/
PVOID WINAPI ImageDirectoryEntryToDataEx( PVOID base, BOOLEAN image, USHORT dir, PULONG size, PIMAGE_SECTION_HEADER *section )
{
const IMAGE_NT_HEADERS *nt;
DWORD addr;
*size = 0;
if (!(nt = RtlImageNtHeader( base ))) return NULL;
if (dir >= nt->OptionalHeader.NumberOfRvaAndSizes) return NULL;
if (!(addr = nt->OptionalHeader.DataDirectory[dir].VirtualAddress)) return NULL;
*size = nt->OptionalHeader.DataDirectory[dir].Size;
if (image || addr < nt->OptionalHeader.SizeOfHeaders)
{
if (*section) *section = NULL;
return (char *)base + addr;
}
return RtlImageRvaToVa( nt, (HMODULE)base, addr, section );
}
/***********************************************************************
* ImageDirectoryEntryToData (DBGHELP.@)
*
* NOTES
* See ImageDirectoryEntryToDataEx
*/
PVOID WINAPI ImageDirectoryEntryToData( PVOID base, BOOLEAN image, USHORT dir, PULONG size )
{
return ImageDirectoryEntryToDataEx( base, image, dir, size, NULL );
}
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