Beispiel #1
0
void blysk__ADAPTATION_new() {
#if BLYSK_ENABLE_ADAPT != 0
    blysk_icv *icv = &bpc;


    void *dll_handle; // TODO remember handle so we can close it nicely?
    char *designated_adaptation = getenv("OMP_TASK_ADAPTATION");
    if (designated_adaptation == NULL || *designated_adaptation == 0) {
        fprintf(stderr, "\tOMP_TASK_ADAPTION not set or not found. Will not use adaptation.\n");
        icv->adaptation.adapt_online = 0;
        return;
    }

    dll_handle = dlopen(designated_adaptation, RTLD_LAZY);

    if (!dll_handle) {
        fprintf(stderr, "\t'%s' not found. Set LD_LIBRARY_PATH to point to the location of the libraries...\n", designated_adaptation);
        abort();
    }

    icv->adaptation.adapt_main = (void*(*)(void*)) mydlsym(dll_handle, "ADAPT_Main", designated_adaptation);
    icv->adaptation.adapt_kill = mydlsym(dll_handle, "ADAPT_Kill", designated_adaptation);
    pthread_create(&icv->adaptation.h_ID, NULL, icv->adaptation.adapt_main, icv);
//    fprintf(stderr, "Started %s\n", designated_adaptation);
    icv->adaptation.adapt_online = 1;
#endif
}
Beispiel #2
0
int
Yap_CallForeignFile(void *handle, char *f)
{
  YapInitProc proc = (YapInitProc) mydlsym(f);
  if (!proc)
    return FALSE;
  (*proc)();
  return TRUE;
}
Beispiel #3
0
/*
 * LoadForeign(ofiles,libs,proc_name,init_proc) dynamically loads foreign
 * code files and libraries and locates an initialization routine
*/
static Int
LoadForeign(StringList ofiles, StringList libs,
	       char *proc_name,	YapInitProc *init_proc)
{

  while (ofiles) {
    void *handle;

    /* mydlopen wants to follow the LD_CONFIG_PATH */
    if (!Yap_TrueFileName(AtomName(ofiles->name), LOCAL_FileNameBuf, TRUE)) {
      strcpy(LOCAL_ErrorSay, "%% Trying to open unexisting file in LoadForeign");
      return LOAD_FAILLED;
    }
    if((handle=mydlopen(LOCAL_FileNameBuf)) == 0)
    {
      fprintf(stderr,"calling dlopen with error %s\n", mydlerror());
/*      strcpy(LOCAL_ErrorSay,dlerror());*/
      return LOAD_FAILLED;
    }

    ofiles->handle = handle;

    ofiles = ofiles->next;
  }
  /* load libraries first so that their symbols are available to
     other routines */
  while (libs) {
    char *s = AtomName(lib->name);
    
    if (ls[0] == '-') {
      strcpy(LOCAL_FileNameBuf,"lib");
      strcat(LOCAL_FileNameBuf,s+2);
      strcat(LOCAL_FileNameBuf,".so");
    } else {
      strcpy(LOCAL_FileNameBuf,s);
    }

    if((libs->handle=mydlopen(LOCAL_FileNameBuf)) == NULL)
    {
      strcpy(LOCAL_ErrorSay,mydlerror());
      return LOAD_FAILLED;
    }
    libs = libs->next;
  }

  *init_proc = (YapInitProc) mydlsym(proc_name);

  if(! *init_proc) {
    strcpy(LOCAL_ErrorSay,"Could not locate initialization routine");
    return LOAD_FAILLED;
  }

  return LOAD_SUCCEEDED;
}
Beispiel #4
0
/* return 1 on success */
static jboolean mypam__init(loginfo_t* logger) {

    if (logger->isdebug) {
        shaj_log_debug(logger, "attempting to load libpam.so");
    }
    
    libpam = dlopen ("libpam.so", RTLD_NOW | RTLD_GLOBAL);
    if (libpam == NULL) {
        shaj_log_error(logger, "Could not dlopen libpam.so with RTLD_NOW|RTLD_GLOBAL: %s\n", dlerror());;
        return JNI_FALSE;
    }

    
    real_pam_start = (FUNC_pam_start*) mydlsym(libpam, "pam_start", logger);
    if (real_pam_start == NULL) {
        return JNI_FALSE;
    }

    real_pam_end = (FUNC_pam_end*) mydlsym(libpam, "pam_end", logger);
    if (real_pam_end == NULL) {
        return JNI_FALSE;
    }

    real_pam_authenticate =  (FUNC_pam_authenticate*) mydlsym(libpam, "pam_authenticate", logger);
    if (real_pam_authenticate == NULL) {
        return JNI_FALSE;
    }
    
    real_pam_strerror =  (FUNC_pam_strerror*) mydlsym(libpam, "pam_strerror", logger);
    if (real_pam_strerror == NULL) {
        return JNI_FALSE;
    }
    
    real_pam_setcred = (FUNC_pam_setcred*) mydlsym(libpam, "pam_setcred", logger);
    if (real_pam_setcred == NULL) {
        return JNI_FALSE;
    }

    return JNI_TRUE;
}
void resolve_symbols(struct artstuff_t *d){
	d->art_hand = dlopen("libart.so", RTLD_NOW);
	arthooklog("art_hand = 0x%08x \n", (unsigned int) d->art_hand);
	if(d->art_hand){
		d->JNI_GetCreatedJavaVMs_fnPtr = mydlsym(d->art_hand, "JNI_GetCreatedJavaVMs");
        d->art_th_currentFromGdb_fnPtr = mydlsym(d->art_hand, "_ZN3art6Thread14CurrentFromGdbEv");
        d->art_dbg_SuspendVM_fnPtr = mydlsym(d->art_hand, "_ZN3art3Dbg9SuspendVMEv");
        d->art_dbg_ResumeVM_fnPtr = mydlsym(d->art_hand, "_ZN3art3Dbg8ResumeVMEv");
        d->art_dbg_SuspendSelf_fnPtr = mydlsym(d->art_hand, "_ZN3art3Dbg11SuspendSelfEv");
        d->art_thlist_resumeAll_fnPtr = mydlsym(d->art_hand, "_ZN3art10ThreadList9ResumeAllEv");
	}
    
}
Beispiel #6
0
int gzipInit(){
	int code;

	if( 0 < zlib_dl ){
		if( isCYGWIN() ){
			if( zlib_pid != getpid() ){
				zlib_pid = 0;
				zlib_dl = 0;
			}
		}
	}
	if( zlib_dl != 0 ){
		if( 0 < zlib_dl )
			return 0;
		else	return -1;
	}
	code = gzipInit0();
	if( code == 0 ){
		if( isWindowsCE() )
		fprintf(stderr,"Loaded: %s\n",zlibVersion());
		if( mydlsym("gziocallback") )
		if( gziocallback("gzionotify",(void*)Znotify) == 0 ){
			_dg_zlib = 1;
			gziocallback("clearerr", (void*)Zclearerr);
			gziocallback("fclose",   (void*)Zfclose);
			gziocallback("fdopen",   (void*)Zfdopen);
			gziocallback("feof",     (void*)Zfeof);
			gziocallback("ferror",   (void*)Zferror);
			gziocallback("fflush",   (void*)Zfflush);
			gziocallback("fgetc",    (void*)Zfgetc);
			gziocallback("fprintf",  (void*)Zfprintf);
			gziocallback("fputc",    (void*)Zfputc);
			gziocallback("fread",    (void*)Zfread);
			gziocallback("fwrite",   (void*)Zfwrite);
			gziocallback("ftell",    (void*)Zftell);
			gziocallback("strerror", (void*)Zstrerror);
			if( strneq(zlibVersion(),"1.2.3.f-DeleGate-v",18) )
			if( 4 <= atoi(zlibVersion()+18) ){
				gziocallback("malloc",  (void*)Zmalloc);
				gziocallback("free",    (void*)Zfree);
				gziocallback("fgzflush",(void*)Zfgzflush);
				InitLog("+++ fgzflush() / %s\n",zlibVersion());
			}
		}
	}
	if( code == 0 ){
		InitLog("+++ loaded Zlib %s\n",zlibVersion());
		if( lDYLIB() )
		printf("+++ loaded Zlib %s\n",zlibVersion());
		zlib_pid = getpid();
		zlib_dl = 1;
		if( _gzfuncs = (GZFUNCS)mydlsym("gzfuncs") ){
//fprintf(stderr,"----------- fdopen=%X,fread=%X\n",fdopen,fread);
			(*_gzfuncs)((void*)xfdopen,(void*)xfread,(void*)xfwrite,0,0,(void*)xfflush,(void*)xfclose);
			DGzlibVer = 1;
		}
	}else{
		zlib_dl = -1;
	}
	return code;
}