ImageDirectoryEntryToDataEx() not working
-
Hi All, I am trying to make tool like PE viewer in VC++.NET 2005. After enumerating process module I am using
ImageDirectoryEntryToData()
function to get Import section. It is working fine but this function has been superseded byImageDirectoryEntryToDataEx()
function. I am able to get import section usingImageDirectoryEntryToData()
but not usingImageDirectoryEntryToDataEx()
. It gives me NULL every time. Here is my code for getting Import Section of the process.DWORD aProcesses[1024], cbNeeded;
unsigned int i;
HMODULE hMods[1024];
char modName[255];
PIMAGE_IMPORT_DESCRIPTOR pImportDesc;
PIMAGE_SECTION_HEADER pImageHeader;
PSTR pszModName;
ULONG ulSize;if(EnumProcessModules(::GetCurrentProcess(), hMods, sizeof(hMods), &cbNeeded))
{
for ( i = 0; i < (cbNeeded / sizeof(HMODULE)); i++ )
{
::GetModuleFileNameA(hMods[i], modName, 255);ImageDirectoryEntryToDataEx(hMods[i], TRUE,
IMAGE_DIRECTORY_ENTRY_IMPORT, &ulSize, &pImageHeader);if(pImageHeader)
{
while (pImageHeader->Name)
{
pszModName = (PSTR) pImageHeader->Name;
pImageHeader++;
} // while
}/*if(pImportDesc = (PIMAGE_IMPORT_DESCRIPTOR) ImageDirectoryEntryToData(hMods[i], TRUE, IMAGE_DIRECTORY_ENTRY_IMPORT, &ulSize))
{
while (pImportDesc->Name)
{
pszModName = (PSTR)((PBYTE) hMods[i] + pImportDesc->Name);
pImportDesc++;
} // while
}*/
}
}Can I know what is the problem with ImageDirectoryEntryToDataEx() function? Thanks, Priyank