Page 3 of 4

Re: HMG.3.4.0 Ejemplos DLL no funcionan

Posted: Wed Jun 17, 2015 3:58 am
by srvet_claudio
danielmaximiliano wrote:
Pablo César wrote:Provisional solution (unofficial) for the current version HMG 3.4.0:

This is what I've done and worked perfectly. :D
Hola Pablo:
estoy trabajando con .dll y si tuvieras la amabilidad de subir las correcciones tanto en .c y .prg seria muy bueno asi no equivocarme y reconstruir las librerias ..

Gracias
Daniel,
todos los cambios están incluidos en HMG.3.4.0 parche 1 viewtopic.php?f=43&t=4176&start=110#p41353

Re: HMG.3.4.0 Ejemplos DLL no funcionan

Posted: Wed Jun 17, 2015 4:01 am
by srvet_claudio
danielmaximiliano wrote:Hola Claudio Soto :
hay alguna forma de exportar o ver las funciones de una .DLL cargada en Harbour
Estas nuevas funciones (HMG_GetHBSymbols, HMG_GetDLLFunctions) serán incluidas en la proxima versión:

Code: Select all


#include "hmg.ch"

Function Main

   DEFINE WINDOW Form_1 ;
      AT 0,0 ;
      WIDTH 700 ;
      HEIGHT 700 ;
      MAIN 

aRows1 := HMG_GetHBSymbols()

      @ 10,10 GRID Grid_1 ;
         WIDTH 620 ;
         HEIGHT 300 ;
         HEADERS {'Index','Symbol','Type'} ;
         WIDTHS {140,240,140} ;
         ITEMS aRows1


aRows2 := {}
aData := HMG_GetDLLFunctions ("user32.dll")
FOR i := 1 TO HMG_LEN (aData)
   AAdd(aRows2, { str( i ), aData[ i ] } ) 
NEXT

      @ 350,10 GRID Grid_2 ;
         WIDTH 620 ;
         HEIGHT 300 ;
         HEADERS {'Index','Function'} ;
         WIDTHS {140, 240} ;
         ITEMS aRows2

   END WINDOW

   MAXIMIZE WINDOW Form_1
   ACTIVATE WINDOW Form_1
Return


FUNCTION HMG_GetHBSymbols()
LOCAL cSymName, aSym := {}
/*
__DYNSCOUNT()    // How much symbols do we have:    dsCount = __dynsCount()
__DYNSGETNAME()  // Get name of symbol:             cSymbol = __dynsGetName( dsIndex )
__DYNSGETINDEX() // Get index number of symbol:     dsIndex = __dynsGetIndex( cSymbol )
__DYNSISFUN()    // returns .T. if a symbol has a function/procedure pointer given its symbol index or name:   __DynsIsFun( cSymbol | dsIndex )
HB_ISFUNCTION()  // returns .T. if a symbol has a function/procedure pointer:                                  hb_IsFunction( cSymbol )
*/

   FOR i := 1 TO __DYNSCOUNT()
      cSymName := __DYNSGETNAME( i )
      AAdd( aSym, { str( i ), cSymName, IIF( __DYNSISFUN( cSymName ), "FUNC/PROC","" ) } )
   NEXT

RETURN aSym



#pragma BEGINDUMP
#include "SET_COMPILE_HMG_UNICODE.ch"
#include "HMG_UNICODE.h"
#include <windows.h>
#include <imagehlp.h>
#include "hbapi.h"


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
                    )


HB_FUNC ( HMG_GETDLLFUNCTIONS )
{
    CHAR *cDllName = (CHAR *) hb_parc (1);
    DWORD *dNameRVAs = NULL;
    LOADED_IMAGE LI;
    IMAGE_EXPORT_DIRECTORY *IED;
    ULONG DirSize;
    CHAR *cName;

    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++)
            {
                cName = (CHAR *) win_ImageRvaToVa (LI.FileHeader, LI.MappedAddress, dNameRVAs[i], NULL);
                hb_storvc ( cName, -1, i + 1 );
            }
        }
        win_UnMapAndLoad (&LI);
    }
}


#pragma ENDDUMP

Re: HMG.3.4.0 Ejemplos DLL no funcionan

Posted: Wed Jun 17, 2015 8:32 am
by esgici
srvet_claudio wrote: Estas nuevas funciones (HMG_GetHBSymbols, HMG_GetDLLFunctions) serán incluidas en la proxima versión:
:?
Is this problem, this solution, this two new functions and this notification to next release are exclusive for non-English spoken people only :?: :mrgreen:

Viva INTERNATIONAL HMG :D

Re: HMG.3.4.0 Ejemplos DLL no funcionan

Posted: Wed Jun 17, 2015 2:12 pm
by srvet_claudio
esgici wrote:
srvet_claudio wrote: Estas nuevas funciones (HMG_GetHBSymbols, HMG_GetDLLFunctions) serán incluidas en la proxima versión:
:?
Is this problem, this solution, this two new functions and this notification to next release are exclusive for non-English spoken people only :?: :mrgreen:

Viva INTERNATIONAL HMG :D
Hi Friend.

I think it was a misunderstanding.

I answered a specific question by Daniel, I only added that I will include these functions in the next version.

I not announced the release of a new version.

Re: HMG.3.4.0 Ejemplos DLL no funcionan

Posted: Wed Jun 17, 2015 2:35 pm
by esgici
srvet_claudio wrote:
esgici wrote:
srvet_claudio wrote: Estas nuevas funciones (HMG_GetHBSymbols, HMG_GetDLLFunctions) serán incluidas en la proxima versión:
:?
Is this problem, this solution, this two new functions and this notification to next release are exclusive for non-English spoken people only :?: :mrgreen:

Viva INTERNATIONAL HMG :D
Hi Friend.

I think it was a misunderstanding.

I answered a specific question by Daniel, I only added that I will include these functions in the next version.

I not announced the release of a new version.
IMO we have no misunderstanding, but mistaking.

Specific question and specific answer SHOULD flow specific way, such as PM or private e-mail;

Talking a specific language open public, such as in an open and MUST BE INTERNATIONAL forum is a SHAME !

This is my personal point of view, repeated and probably will be repeated too may time.

Viva INTERNATIONAL HMG :D

Re: HMG.3.4.0 Ejemplos DLL no funcionan

Posted: Wed Jun 17, 2015 3:19 pm
by srvet_claudio
esgici wrote:Specific question and specific answer SHOULD flow specific way, such as PM or private e-mail;
You are right, for me it is much easier that way.
Note that others will be lost the code of my answer, but if that is the price they are willing to pay so that I do not write more in Spanish for me no problem.

PS: the above code is a complete demo that not needs translation, IMHO this discussion is unnecessary.

Re: HMG.3.4.0 Ejemplos DLL no funcionan

Posted: Wed Jun 17, 2015 3:45 pm
by esgici
srvet_claudio wrote:
esgici wrote:Specific question and specific answer SHOULD flow specific way, such as PM or private e-mail;
You are right, for me it is much easier that way.
Note that others will be lost the code of my answer, but if that is the price they are willing to pay so that I do not write more in Spanish for me no problem.

PS: the above code is a complete demo that not needs translation, IMHO this discussion is unnecessary.
Dear friend,

Problem isn't you or me or anyone else;

problem is future of HMG,

does HMG is and will be an INTERNATIONAL product or not :? :?:

problem is that.

Believe me, absolutely is not my matter, I don't care "who talking about what ?"

Viva INTERNATIONAL HMG :D

Re: HMG.3.4.0 Ejemplos DLL no funcionan

Posted: Wed Jun 17, 2015 4:33 pm
by bpd2000
srvet_claudio wrote:
danielmaximiliano wrote:Hola Claudio Soto :
hay alguna forma de exportar o ver las funciones de una .DLL cargada en Harbour
Estas nuevas funciones (HMG_GetHBSymbols, HMG_GetDLLFunctions) serán incluidas en la proxima versión:
Great Extension
Thank you

HMG.3.4.0 Ejemplos DLL no funcionan

Posted: Wed Jun 17, 2015 5:16 pm
by Pablo César
bpd2000 wrote:
srvet_claudio wrote:
danielmaximiliano wrote:Hola Claudio Soto :
hay alguna forma de exportar o ver las funciones de una .DLL cargada en Harbour
Estas nuevas funciones (HMG_GetHBSymbols, HMG_GetDLLFunctions) serán incluidas en la proxima versión:
Great Extension
Thank you
+1

Gracias Claudio por tu bello trabajo !

Re: HMG.3.4.0 Ejemplos DLL no funcionan

Posted: Wed Jun 17, 2015 5:55 pm
by serge_girard
Thanks !

Serge