test.prg
- Code: Select all Expand view RUN
#include "FiveWin.ch"
static pOld
function Main()
pOld := FunSwap( "TIME", "MYTIME" )
MsgInfo( Time() ) // Hemos reemplazado la función Time() original ! :-)
return nil
function MyTime()
local uRet := ExecPtr( pOld ) // en caso de que queramos llamar a la función original
return "now"
#pragma BEGINDUMP
#include <hbapi.h>
typedef void ( * PFUNC ) ( void );
HB_FUNC( FUNSWAP )
{
PHB_SYMB symFirst = hb_dynsymSymbol( hb_dynsymFindName( hb_parc( 1 ) ) );
PHB_SYMB symLast = hb_dynsymSymbol( hb_dynsymFindName( hb_parc( 2 ) ) );
PHB_FUNC pFirst = symFirst->value.pFunPtr;
symFirst->value.pFunPtr = symLast->value.pFunPtr;
hb_retnl( ( LONG ) pFirst );
}
HB_FUNC( EXECPTR )
{
PFUNC p = ( PFUNC ) hb_parnl( hb_pcount() );
p();
}
#pragma ENDDUMP