Cannot enumerate a DLL created with Visual Studio 2005
Purpose: To enumerate routines in a DLL
Problem: The ImageDirectoryEntryToDataEx call fails for the V8 library but works for the V6 library. LoadLibrary returns a handle for both.
Question: Does A) VS8 create a DLL that cannot be processed with this call or
B) is this a problem with ImageDirectoryEntryToDataEx or
C) Did install not put a correct DbgHelp.dll or ImageHelp.dll in the appropriate path?
Code Section:
for ( Item = 0; Item < 2; Item++ )
{
switch ( Item )
{
case 0:
DLLHandle = LoadLibrary("F:\\Temp\\V6\\filter1.dll" );
break;
case 1:
DLLHandle = LoadLibrary("F:\\Temp\\V8\\filter1.dll" );
break;
}
PIMAGE_SECTION_HEADER FoundHeader;
PointerExportDirectory = (PIMAGE_EXPORT_DIRECTORY) ImageDirectoryEntryToDataEx( (LPVOID) DLLHandle,
FALSE,
IMAGE_DIRECTORY_ENTRY_EXPORT,
&value,
&FoundHeader );
PointerExportDirectory = (PIMAGE_EXPORT_DIRECTORY) ImageDirectoryEntryToData(
(LPVOID) DLLHandle,
FALSE,
IMAGE_DIRECTORY_ENTRY_EXPORT,
&value );
PointerHeaders = ImageNtHeader( DLLHandle );
PointerExportNames = (PDWORD *) PointerExportDirectory->AddressOfNames;
PointerExportNames = (PDWORD *)ImageRvaToVa(
PointerHeaders,
DLLHandle,
(DWORD)PointerExportNames,
0 );
PointerExportFunctions = (PDWORD *) PointerExportDirectory->AddressOfFunctions;
PointerExportFunctions = (PDWORD *)ImageRvaToVa( PointerHeaders, DLLHandle, (DWORD)PointerExportFunctions, 0 );
for ( i=0; i < PointerExportDirectory->NumberOfNames; i++ )
{
PSTR p = (PSTR)ImageRvaToVa(
PointerHeaders,
DLLHandle,
(DWORD)*PointerExportNames,
0 );
... code to inspect each function
}
}

