Cannot enumerate a DLL created with Visual Studio 2005

In converting routines that have worked in VS6 and .NET to VS8, the following item failed to work.

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
}
}

[2512 byte] By [DataMasters] at [2007-12-17]
# 1
Hello Stan,

Unfortunately, this forum focuses on VSTS Testing features. I would recommend that you post your question in different forum, for instance the CLR one:

http://forums.microsoft.com/msdn/ShowForum.aspx?ForumID=44

Although we can unswer some of your questions, you will have much better and robust explanations there.

Regards,
Boris

BorisVidolovMSFT at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Web and Load Testing...

Visual Studio Team System

Site Classified