Example #1
0
void
CfrTil_dlsym ( )
{
    char * sym = ( char* ) _DataStack_Pop ( ) ;
    char * lib = ( char* ) _DataStack_Pop ( ) ;
    _DataStack_Push ( ( int ) _dlsym ( lib, sym ) ) ;
}
Example #2
0
__private_extern__ kern_return_t
internal_catch_exception_raise(
    mach_port_t exception_port,
    mach_port_t thread,
    mach_port_t task,
    exception_type_t exception,
    exception_data_t code,
    mach_msg_type_number_t codeCnt)
{
#if defined(__DYNAMIC__)
	static _libkernel_exc_raise_func_t exc_raise_func = (void*)-1;
	
	if (exc_raise_func == ((void*)-1)) {
		exc_raise_func = _dlsym(RTLD_DEFAULT, "catch_exception_raise");
	}
	if (exc_raise_func == 0) {
		/* The user hasn't defined catch_exception_raise in their binary */
		abort();
	}
	return (*exc_raise_func)(exception_port, thread, task, exception, code, codeCnt);
#else
	extern kern_return_t catch_exception_raise(mach_port_t, mach_port_t, mach_port_t, exception_type_t, exception_data_t, mach_msg_type_number_t);
	return catch_exception_raise(exception_port, thread, task, exception, code, codeCnt);
#endif
}
Example #3
0
void *
dlOpen_dlSym ( char * lib, char * sym )
{
    void * hLibrary, *fp ;
    char * error, buffer [1024] ;

    sprintf ( buffer, "./%s.so", lib ) ;
    hLibrary = dlopen ( buffer, RTLD_GLOBAL | RTLD_LAZY ) ;
    if ( ! hLibrary )
    {
        sprintf ( buffer, "/usr/lib32/%s.so", lib ) ;
        hLibrary = dlopen ( buffer, RTLD_GLOBAL | RTLD_LAZY ) ;
    }
    if ( ! hLibrary )
    {
        sprintf ( buffer, "/usr/local/lib/%s.so", lib ) ;
        hLibrary = dlopen ( buffer, RTLD_GLOBAL | RTLD_LAZY ) ;
    }
    if ( ! hLibrary )
    {
        sprintf ( buffer, "/usr/lib/%s.so", lib ) ;
        hLibrary = dlopen ( buffer, RTLD_GLOBAL | RTLD_LAZY ) ;
    }
    if ( ! hLibrary )
    {
        Printf ( ( byte* ) "\nCannot open %s - cannot import library\n", buffer ) ;
        return 0 ;
    }
    fp = ( void* ) dlsym ( RTLD_DEFAULT /*hLibrary*/, ( char* ) sym ) ;
    //if ( ( error = dlerror ( ) ) != NULL )
    if ( ( ! fp ) || ( ( error = dlerror ( ) ) != NULL ) )
    {
        Printf ( ( byte* ) "dlOpen_dlSym : dlerror: %s\n", error ) ;
        return 0 ;
    }

    //void * hLibrary = dlopen ( lib, RTLD_DEFAULT |RTLD_GLOBAL | RTLD_LAZY ) ;
    void * fp = _dlsym ( lib, sym ) ;

    return fp ;
}