Address of Function in My EXE

Address of Function in My EXE

Postby don lowenstein » Tue Apr 02, 2013 4: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
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Re: Address of Function in My EXE

Postby Antonio Linares » Tue Apr 02, 2013 5:10 pm

Code: Select all  Expand view
#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
Antonio Linares
Site Admin
 
Posts: 41898
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Address of Function in My EXE

Postby don lowenstein » Tue Apr 02, 2013 5: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
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Re: Address of Function in My EXE

Postby Antonio Linares » Tue Apr 02, 2013 9:44 pm

Don,

This way:

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41898
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Address of Function in My EXE

Postby don lowenstein » 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
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: nelido, Otto and 65 guests