Address of Function in My EXE

Post Reply
User avatar
don lowenstein
Posts: 196
Joined: Mon Oct 17, 2005 9:09 pm
Contact:

Address of Function in My EXE

Post by don lowenstein »

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Address of Function in My EXE

Post by Antonio Linares »

Code: Select all

#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
User avatar
don lowenstein
Posts: 196
Joined: Mon Oct 17, 2005 9:09 pm
Contact:

Re: Address of Function in My EXE

Post by don lowenstein »

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Address of Function in My EXE

Post by Antonio Linares »

Don,

This way:

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

Antonio Linares
www.fivetechsoft.com
User avatar
don lowenstein
Posts: 196
Joined: Mon Oct 17, 2005 9:09 pm
Contact:

Re: Address of Function in My EXE

Post by don lowenstein »

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
Post Reply