FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Address of Function in My EXE
Posts: 204
Joined: Mon Oct 17, 2005 09:09 PM
Address of Function in My EXE
Posted: Tue Apr 02, 2013 04:01 PM

I saw on a previous post I can retrieve the address of my function "test_func" as follows.

address := ( @testfunc() )

The valtype( address ) function returns "S"

I'm looking for a value to pass to a C-function DLL that requests a pointer to my function "test_func" in order to handle socket callback processing.

HTTPEVENTPROC lpfnEventProc,

What is valtype "S"?

My DLL function GPF's when I pass this value. I've tried to define it as LPSTR and PTR - both cause GPF.

is anybody aware of a way to get from "myapp.exe" the address of function "test()" in the form of c-data type lpfn ??

Don Lowenstein
www.laapc.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Address of Function in My EXE
Posted: Tue Apr 02, 2013 05:10 PM
Code (fw): Select all Collapse
#include <hbvmpub.h>

HB_FUNC( FUNPTR )
{
   PHB_SYMB pMySymbol = ( PHB_SYMB ) hb_param( 1, HB_IT_SYMBOL );

  hb_retnl( ( HB_LONG ) pMySymbol->value.pFunPtr );
}


or hb_retnll( ( HB_LONGLONG ) pMySymbol->value.pFunPtr ); for 64 bits pointers
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 204
Joined: Mon Oct 17, 2005 09:09 PM
Re: Address of Function in My EXE
Posted: Tue Apr 02, 2013 05:44 PM

I tried this but it caused a GPF.

exe map file shows the c-function is there:
0001:000008A8 _HB_FUN_FUNPTR

calling convention from my Harbour source code is:
PROCADDR := FUNPTR( '_HB_FUN_SSL_EVENTS' ) ===> GPF
PROCADDR := FUNPTR( 'SSL_EVENTS' ) ===> GPF

Lwinapi.c source code

// ********

include <Windows.h>

include <hbvmpub.h>

include <hbapi.h>

//----------------------------------------------------------------------------//

HB_FUNC( FUNPTR )
{
PHB_SYMB pMySymbol = ( PHB_SYMB ) hb_param( 1, HB_IT_SYMBOL );

hb_retnl( ( HB_LONG ) pMySymbol->value.pFunPtr );
}

//-- or hb_retnll( ( HB_LONGLONG ) pMySymbol->value.pFunPtr ); for 64 bits pointers

// -----------------------------------------------------------------------------------

Don Lowenstein
www.laapc.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Address of Function in My EXE
Posted: Tue Apr 02, 2013 09:44 PM

Don,

This way:

PROCADDR := FunPtr( @SSL_EVENTS() )
MsgInfo( PROCADDR ) // you should see a number

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 204
Joined: Mon Oct 17, 2005 09:09 PM
Re: Address of Function in My EXE
Posted: Tue Apr 02, 2013 10:42 PM

this does return a number.

unfortunately, the .dll function I pass it to still GPF's.

back to the drawing board.

I'm really close to having the SSL socket coded, but this eventhandler is really a challenge.

Don Lowenstein
www.laapc.com

Continue the discussion