Primeiramente muito obrigado por responder e com suas dicas eu consegui fazer o que eu precisava.
Obs: Claudio eu consegui compilar e executar o código abaixo normalmente mas ele está correto ?
Código: Selecionar todos
function main( cDll )
cls
? hb_valtoexp( HMG_GetDLLFunctions( cDll ) )
return NIL
#pragma BEGINDUMP
#include <shlobj.h>
#include <windows.h>
#include <commctrl.h>
#include <psapi.h>
#include <tchar.h>
//#include <winreg.h>
//#include <uxtheme.h>
#include <imagehlp.h>
#include "hbapiitm.h"
#include "hbapi.h"
#include "hbapifs.h"
/*****************************************************************************************
* MACRO DEFINITION FOR CALL DLL FUNCTION
******************************************************************************************/
#define HMG_DEFINE_DLL_FUNC(\
_FUNC_NAME, \
_DLL_LIBNAME, \
_DLL_FUNC_RET, \
_DLL_FUNC_TYPE, \
_DLL_FUNC_NAMESTRINGAW, \
_DLL_FUNC_PARAM, \
_DLL_FUNC_CALLPARAM, \
_DLL_FUNC_RETFAILCALL \
)\
\
_DLL_FUNC_RET _DLL_FUNC_TYPE _FUNC_NAME _DLL_FUNC_PARAM \
{\
typedef _DLL_FUNC_RET (_DLL_FUNC_TYPE *PFUNC) _DLL_FUNC_PARAM;\
static PFUNC pfunc = NULL;\
if (pfunc == NULL)\
{\
HMODULE hLib = LoadLibrary (_TEXT (_DLL_LIBNAME) );\
pfunc = (PFUNC) GetProcAddress (hLib, _DLL_FUNC_NAMESTRINGAW);\
}\
if(pfunc == NULL)\
return ((_DLL_FUNC_RET) _DLL_FUNC_RETFAILCALL);\
else\
return pfunc _DLL_FUNC_CALLPARAM;\
}
HMG_DEFINE_DLL_FUNC ( win_Shell_GetImageLists, // user function name
"Shell32.dll", // dll name
BOOL, // function return type
WINAPI, // function type
"Shell_GetImageLists", // dll function name
(HIMAGELIST *phimlLarge, HIMAGELIST *phimlSmall), // dll function parameters (types and names)
(phimlLarge, phimlSmall), // function parameters (only names)
FALSE // return value if fail call function of dll
)
//********************************
// by Dr. Claudio Soto, June 2015
//********************************
HMG_DEFINE_DLL_FUNC ( win_MapAndLoad, // user function name
"Imagehlp.dll", // dll name
WINBOOL, // function return type
WINAPI, // function type
"MapAndLoad", // dll function name
(PCSTR ImageName, PCSTR DllPath, PLOADED_IMAGE LoadedImage, WINBOOL DotDll, WINBOOL ReadOnly), // dll function parameters (types and names)
(ImageName, DllPath, LoadedImage, DotDll, ReadOnly), // function parameters (only names)
FALSE // return value if fail call function of dll
)
HMG_DEFINE_DLL_FUNC ( win_UnMapAndLoad, // user function name
"Imagehlp.dll", // dll name
WINBOOL, // function return type
WINAPI, // function type
"UnMapAndLoad", // dll function name
(PLOADED_IMAGE LoadedImage), // dll function parameters (types and names)
(LoadedImage), // function parameters (only names)
FALSE // return value if fail call function of dll
)
HMG_DEFINE_DLL_FUNC ( win_ImageDirectoryEntryToData, // user function name
"Dbghelp.dll", // dll name
PVOID, // function return type
WINAPI, // function type
"ImageDirectoryEntryToData", // dll function name
(PVOID Base, BOOLEAN MappedAsImage, USHORT DirectoryEntry, PULONG Size), // dll function parameters (types and names)
(Base, MappedAsImage, DirectoryEntry, Size), // function parameters (only names)
NULL // return value if fail call function of dll
)
HMG_DEFINE_DLL_FUNC ( win_ImageRvaToVa, // user function name
"Dbghelp.dll", // dll name
PVOID, // function return type
WINAPI, // function type
"ImageRvaToVa", // dll function name
(PIMAGE_NT_HEADERS NtHeaders,PVOID Base,ULONG Rva,PIMAGE_SECTION_HEADER *LastRvaSection), // dll function parameters (types and names)
(NtHeaders, Base, Rva, LastRvaSection), // function parameters (only names)
NULL // return value if fail call function of dll
)
// HMG_GetDLLFunctions( cDllName ) --> return array { cFuncName1, cFuncName2, ... }
HB_FUNC ( HMG_GETDLLFUNCTIONS )
{
CHAR *cDllName = (CHAR *) hb_parc (1);
DWORD *dNameRVAs = NULL;
LOADED_IMAGE LI;
IMAGE_EXPORT_DIRECTORY *IED;
ULONG DirSize;
CHAR *cFuncName;
if ( win_MapAndLoad (cDllName, NULL, &LI, TRUE, TRUE) )
{
IED = (IMAGE_EXPORT_DIRECTORY *) win_ImageDirectoryEntryToData (LI.MappedAddress, FALSE, IMAGE_DIRECTORY_ENTRY_EXPORT, &DirSize);
if (IED != NULL)
{
dNameRVAs = (DWORD *) win_ImageRvaToVa (LI.FileHeader, LI.MappedAddress, IED->AddressOfNames, NULL);
ULONG i;
hb_reta ( IED->NumberOfNames );
for(i = 0; i < IED->NumberOfNames; i++)
{
cFuncName = (CHAR *) win_ImageRvaToVa (LI.FileHeader, LI.MappedAddress, dNameRVAs[i], NULL);
hb_storvc ( cFuncName, -1, i + 1 );
}
}
win_UnMapAndLoad (&LI);
}
}
#pragma ENDDUMP