Ejemplo n.º 1
0
Archivo: drew.c Proyecto: bk2204/drew
int drew_loader_load_plugin(DrewLoader *ldr, const char *plugin,
                            const char *path)
{
    int retval = 0, err = 0;
    library_t *lib;

    g_rw_lock_writer_lock(&ldr->lock);

    if (plugin && !path) {
        int npaths = drew_loader_get_search_path(ldr, 0, NULL), i;

        if (npaths < 0) {
            retval = npaths;
            goto out;
        }

        for (i = 0; i < npaths; i++) {
            drew_loader_get_search_path(ldr, i, &path);
            if (!load_library(ldr, plugin, path, &lib))
                break;
        }
        if (i == npaths) {
            retval = -DREW_ERR_RESOLUTION;
            goto out;
        }
    }
    else if ((err = load_library(ldr, plugin, path, &lib))) {
        retval = err;
        goto out;
    }
    retval = load_library_info(ldr, lib);
out:
    g_rw_lock_writer_unlock(&ldr->lock);
    return retval;
}
Ejemplo n.º 2
0
/*
	ANT_PLUGIN_MANAGER::LOAD()
	--------------------------
*/
void ANT_plugin_manager::load()
{
if (loaded)
    return;

char *name = 0;

for (int i = 0; i < num_of_plugins; i++)
	{
	name = plugin_names[i];
	#ifdef _MSC_VER
		char sep[] = { "\\" };
	#else
		char sep[] = { "/" };
	#endif
	size_t len = strlen(PLUGIN_DIRECTORY_NAME) + strlen(sep) + strlen(name);
	char *name_with_plugin_path = new char[len + 1];
	strcpy(name_with_plugin_path, PLUGIN_DIRECTORY_NAME);
	strcat(name_with_plugin_path, sep);
	strcat(name_with_plugin_path, name);
	name_with_plugin_path[len] = '\0';
	struct stat plugin_stat;
	if (stat( name_with_plugin_path, &plugin_stat ) != -1)
		load_library(name_with_plugin_path, i);
	else
		load_library(name, i);
//	else
//		fprintf(stderr, "no plugin found for : %s\n", name_with_plugin_path);
	delete [] name_with_plugin_path;
	}

loaded = true;
}
Ejemplo n.º 3
0
int lua_sandbox_init(lua_sandbox* lsb, const char* data_file)
{
    if (lsb == NULL || lsb->m_lua != NULL) {
        return 0;
    }
    if (lsb->m_lua_file == NULL) {
        snprintf(lsb->m_error_message, ERROR_SIZE, "no Lua script provided");
        sandbox_terminate(lsb);
        return 1;
    }
    lsb->m_lua = lua_newstate(memory_manager, lsb);
    if (lsb->m_lua == NULL) {
        snprintf(lsb->m_error_message, ERROR_SIZE, "out of memory");
        sandbox_terminate(lsb);
        return 2;
    }

    load_library(lsb->m_lua, "", luaopen_base, disable_base_functions);
    load_library(lsb->m_lua, LUA_MATHLIBNAME, luaopen_math, disable_none);
    load_library(lsb->m_lua, LUA_OSLIBNAME, luaopen_os, disable_os_functions);
    load_library(lsb->m_lua, LUA_STRLIBNAME, luaopen_string, disable_none);
    load_library(lsb->m_lua, LUA_TABLIBNAME, luaopen_table, disable_none);
    luaopen_circular_buffer(lsb->m_lua);

    lua_pushlightuserdata(lsb->m_lua, (void*)lsb);
    lua_pushcclosure(lsb->m_lua, &read_message, 1);
    lua_setglobal(lsb->m_lua, "read_message");

    lua_pushlightuserdata(lsb->m_lua, (void*)lsb);
    lua_pushcclosure(lsb->m_lua, &output, 1);
    lua_setglobal(lsb->m_lua, "output");

    lua_pushlightuserdata(lsb->m_lua, (void*)lsb);
    lua_pushcclosure(lsb->m_lua, &inject_message, 1);
    lua_setglobal(lsb->m_lua, "inject_message");
    lua_sethook(lsb->m_lua, instruction_manager, LUA_MASKCOUNT,
                lsb->m_usage[USAGE_TYPE_INSTRUCTION][USAGE_STAT_LIMIT]);

    if (luaL_dofile(lsb->m_lua, lsb->m_lua_file) != 0) {
        snprintf(lsb->m_error_message, ERROR_SIZE, "%s",
                 lua_tostring(lsb->m_lua, -1));
        sandbox_terminate(lsb);
        return 3;
    } else {
        lua_gc(lsb->m_lua, LUA_GCCOLLECT, 0);
        lsb->m_usage[USAGE_TYPE_INSTRUCTION][USAGE_STAT_CURRENT] =
          instruction_usage(lsb);
        if (lsb->m_usage[USAGE_TYPE_INSTRUCTION][USAGE_STAT_CURRENT]
            > lsb->m_usage[USAGE_TYPE_INSTRUCTION][USAGE_STAT_MAXIMUM]) {
            lsb->m_usage[USAGE_TYPE_INSTRUCTION][USAGE_STAT_MAXIMUM] =
              lsb->m_usage[USAGE_TYPE_INSTRUCTION][USAGE_STAT_CURRENT];
        }
        lsb->m_status = STATUS_RUNNING;
        if (data_file != NULL && strlen(data_file) > 0) {
            return restore_global_data(lsb, data_file);
        }
    }
    return 0;
}
Ejemplo n.º 4
0
static int bb_load(struct soap_session *ps, const char *so)
{
   int stat=1;

   /* Load hpmud manually with symbols exported. Otherwise the plugin will not find it. */ 
   if ((ps->hpmud_handle = load_library("libhpmud.so.0")) == NULL)
   {
	   if ((ps->hpmud_handle = load_library("libhpmud.so.0")) == NULL)
           goto bugout;
   }

   /* Load math library manually with symbols exported (Ubuntu 8.04). Otherwise the plugin will not find it. */ 
   if ((ps->math_handle = load_library("libm.so")) == NULL)
   {
      if ((ps->math_handle = load_library("libm.so.6")) == NULL)
         goto bugout;
   } 

   if ((ps->bb_handle = load_plugin_library(UTILS_SCAN_PLUGIN_LIBRARY, so)) == NULL)
   {
      SendScanEvent(ps->uri, EVENT_PLUGIN_FAIL);
      goto bugout;
   } 

   if ((ps->bb_open = get_library_symbol(ps->bb_handle, "bb_open")) == NULL)
      goto bugout;
 
   if ((ps->bb_close = get_library_symbol(ps->bb_handle, "bb_close")) == NULL)
      goto bugout;

   if ((ps->bb_get_parameters = get_library_symbol(ps->bb_handle, "bb_get_parameters")) == NULL)
      goto bugout;

   if ((ps->bb_is_paper_in_adf = get_library_symbol(ps->bb_handle, "bb_is_paper_in_adf")) == NULL)
      goto bugout;

   if ((ps->bb_start_scan = get_library_symbol(ps->bb_handle, "bb_start_scan")) == NULL)
      goto bugout;

   if ((ps->bb_end_scan = get_library_symbol(ps->bb_handle, "bb_end_scan")) == NULL)
      goto bugout;

   if ((ps->bb_get_image_data = get_library_symbol(ps->bb_handle, "bb_get_image_data")) == NULL)
      goto bugout;

   if ((ps->bb_end_page = get_library_symbol(ps->bb_handle, "bb_end_page")) == NULL)
      goto bugout;


   stat=0;

bugout:
   return stat;
} /* bb_load */
Ejemplo n.º 5
0
int main(int argc, const char** argv) {

    // check that the program name was specified
    if (argc < 2) {
        printf("ERROR: No program_name was specified\n");
        usage();
        return -1;
    }

    // attempt to lookup the location of the skia app
    const char* appLocation = "/data/data/com.skia";
    if (!file_exists(appLocation)) {
        printf("ERROR: Unable to find the com.skia app on the device.\n");
        return -1;
    }

    // load the local skia shared library
    void* skiaLibrary = load_library(appLocation, "skia_android");
    if (NULL == skiaLibrary)
    {
        return -1;
    }

    // load the appropriate library
    void* appLibrary = load_library(appLocation, argv[1]);
    if (NULL == appLibrary) {
        return -1;
    }

    // find the address of the main function
    int (*app_main)(int, const char**);
    *(void **) (&app_main) = dlsym(appLibrary, "main");

    if (!app_main) {
        printf("ERROR: Unable to load the main function of the selected program.\n");
        printf("ERROR: %s\n", dlerror());
        return -1;
    }

    // find the address of the SkPrintToConsole function
    void (*app_SkDebugToStdOut)(bool);
    *(void **) (&app_SkDebugToStdOut) = dlsym(skiaLibrary, "AndroidSkDebugToStdOut");

    if (app_SkDebugToStdOut) {
        (*app_SkDebugToStdOut)(true);
    } else {
        printf("WARNING: Unable to redirect output to the console.\n");
        printf("WARNING: %s\n", dlerror());
    }

    // pass all additional arguments to the main function
    return launch_app(app_main, argc - 1, ++argv);
}
Ejemplo n.º 6
0
void configure_enchant_provider(EnchantProvider * me, const char *dir_name)
{
#if defined(_WIN32)
	if(!load_library(me, dir_name, L"aspell-15.dll") &&
       !load_library(me, dir_name, L"libaspell-15.dll"))
    {
            /* we can't seem to load aspell. Avoid late binding problems later */
            g_warning("Unable to load library aspell-15.dll.");
            me->request_dict = NULL;
            me->dispose_dict = NULL;
            me->list_dicts = NULL;
    }
#endif
}
Ejemplo n.º 7
0
/**
 * Open the named driver and find its bootstrap function: _eglMain().
 */
static _EGLMain_t
_eglOpenLibrary(const char *driverPath, lib_handle *handle)
{
   lib_handle lib;
   _EGLMain_t mainFunc = NULL;
   const char *error = "unknown error";

   assert(driverPath);

   _eglLog(_EGL_DEBUG, "dlopen(%s)", driverPath);
   lib = load_library(driverPath);
   if (!lib) {
      _eglLog(_EGL_WARNING, "Could not open driver %s (%s)",
              driverPath, error);
      return NULL;
   }

   mainFunc = (_EGLMain_t) get_proc_address(lib, "_eglMain");

   if (!mainFunc) {
      _eglLog(_EGL_WARNING, "_eglMain not found in %s (%s)",
              driverPath, error);
      return NULL;
   }

   *handle = lib;
   return mainFunc;
}
Ejemplo n.º 8
0
dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
				    const char *pathname, FILE *fp)
{
	void *p;
	int lib;
	char funcname[258];

	if (Py_VerboseFlag)
		printf("load_library %s\n", pathname);

	lib = load_library(pathname, 0);
	if (lib < 0) {
		char buf[512];
		if (Py_VerboseFlag)
			perror(pathname);
		PyOS_snprintf(buf, sizeof(buf), "Failed to load %.200s: %.200s",
			      pathname, strerror(errno));
		PyErr_SetString(PyExc_ImportError, buf);
		return NULL;
	}
	PyOS_snprintf(funcname, sizeof(funcname), "init%.200s", shortname);
	if (Py_VerboseFlag)
		printf("get_symbol_address %s\n", funcname);
	if (get_symbol_address(lib, funcname, -1, &p) < 0) {
		p = NULL;
		if (Py_VerboseFlag)
			perror(funcname);
	}

	return (dl_funcptr) p;
}
Ejemplo n.º 9
0
void *
__libc_dlopen_mode (const char *name, int mode)
{
  int *dl, kernmode = 0;

  if( name == NULL )
    return NULL;

  /* We can ignore the RTLD_LAZY and RTLD_NOW flags.  Syllable always does the
     equivilent of RTLD_NOW and the spec allows RTLD_LAZY to be implementation
     dependent; so we let it be RTLD_NOW too */

  /* Note that RTLD_GLOBAL and RTLD_LOCAL arn't exactly correct either.  They're
     probably close enough for now though. */

  if( mode & RTLD_GLOBAL )
    kernmode |= IM_APP_SPACE;

  if( mode & RTLD_LOCAL )
    kernmode |= IM_LIBRARY_SPACE;

  dl = (int*)malloc( sizeof( int ) );
  if( dl != NULL )
    *dl = load_library( name, kernmode );

  return (void*)dl;
}
Ejemplo n.º 10
0
WinLibrary *new_winlibrary_from_file(const char *fn, wres_error *err)
{
	WinLibrary *fl = calloc(sizeof(WinLibrary), 1);
	
	fl->name = strdup(fn);
	if (!fl->name) {
		if (err) *err = WRES_ERROR_OUTOFMEMORY;
		free(fl);
		return NULL;
	}
	
	/* open file */
	fl->file = fopen(fl->name, "rb");
	if (fl->file == NULL) {
		if (err) *err = -errno;
		free(fl->name);
		free(fl);
		return NULL;
	}
	
	/* identify file and find resource table */
	wres_error e;
	if ((e = load_library(fl))) {
		/* error reported by load_library */
		free_winlibrary(fl);
		if (err) *err = e;
		return NULL;
	}
	
	return fl;
}
Ejemplo n.º 11
0
Archivo: plugin.c Proyecto: jheinen/gr
void gks_qt_plugin(int fctid, int dx, int dy, int dimx, int *ia, int lr1, double *r1, int lr2, double *r2, int lc,
                   char *chars, void **ptr)
{
  static const char *name = NULL;
  static void (*entry)(ENTRY_ARGS) = NULL;
  const char *qt_version_string;
  int qt_major_version;

  if (name == NULL)
    {
      qt_version_string = getenv("GKS_QT_VERSION");
      if (!qt_version_string)
        {
          qt_version_string = get_qt_version_string();
        }
      if (qt_version_string != NULL)
        {
          qt_major_version = atoi(qt_version_string);
          if (qt_major_version == 5) name = "qt5plugin";
        }
      if (name == NULL) name = "qtplugin";
      *(void **)(&entry) = load_library(name);
    }

  if (entry != NULL) (*entry)(fctid, dx, dy, dimx, ia, lr1, r1, lr2, r2, lc, chars, ptr);
}
Ejemplo n.º 12
0
void *dlopen(const char *file, int mode)
{
	int dl, kernmode = 0;
	void *ret = NULL;

	if( file == 0 )
	{
		__dl_set_errno( _DL_ENOGLOBAL );
		return( ret );
	}

	/* We can ignore the RTLD_LAZY and RTLD_NOW flags.  Syllable always does the
	   equivilent of RTLD_NOW and the spec allows RTLD_LAZY to be implementation
	   dependent; so we let it be RTLD_NOW too */

	/* Note that RTLD_GLOBAL and RTLD_LOCAL arn't exactly correct either.  They're
	   probably close enough for now though. */

	if( mode & RTLD_GLOBAL )
		kernmode |= IM_APP_SPACE;

	if( mode & RTLD_LOCAL )
		kernmode |= IM_LIBRARY_SPACE;

	dl = load_library( file, kernmode );
	if( dl >= 0 )
		ret = (void*)dl;
	else
		__dl_set_errno( _DL_EBADLIBRARY );

	return( ret );
}
Ejemplo n.º 13
0
int main (int argc, char *argv[])
{
	void * lib = NULL;
	int (*fun) ();
	struct compiler * compiler;
	int rc = EXIT_FAILURE;

	char prog[] = "int foo () { return 42; }";
	compiler = compiler_get_gcc ();

	if (comp_failed == compile_from_string (compiler, prog, libname))
		goto out;

	if (! (lib = load_library (libname)))
		goto out;

	fun = (int (*) ()) get_function (lib, funcname);
	if (!fun)
		goto out;

	printf ("function '%s' from '%s' returned '%d'\n", funcname, libname, fun ());

out:
	if (lib)
		if (close_library (lib))
			rc = EXIT_SUCCESS;
	return rc;
	
}
Ejemplo n.º 14
0
Named_interface*
Manager::new_interface_raw(const std::string& type_param,
                       const std::string& name  ) {

  // Look for the required manager and create the new interface without smart pointer.
  // The memory allocated is not managed, it is the user to delete it when not needed
  // If no factory method can be found to create the interface, look
  // for a plugin that would provide a factory method.


  Prefixed_name split = split_name(name);

  if( split.second == "" ) {
    // we're at the end of the path

    //----------
    // Extract the type of the object to be created
    // and the parameters for the creation. These information are
    // contained in string "type_param"
    String_Op::string_pair split_params =
      String_Op::split_string( type_param, "://", true );
    std::string type = split_params.first;
    std::string param = split_params.second;

    CallBackMap::iterator it = factory_.find(type);

    if( it == factory_.end() ) {
      // No factory method found => try loading a plugin
      bool loaded = load_library( type );
      if( loaded )
	      it = factory_.find(type);
    }

    if( it == factory_.end() ) {
      // No factory method could be found, and no plugin provides a
      // suitable one
      appli_warning( "No factory method to create type " << type << std::endl
		    <<  "Interface ..." << name << " could not be created" << std::endl );
      return 0;
    }

    // If we've reached this point, it means we have a factory method
    // to create the requested interface.
    std::pair<InterfaceMap::iterator, bool> pos;
    return (it->second)( param );
  }

  else {
    // we're not at the end of the path.
    // go down one level of the tree, if it exists, and try again
    SmartPtr<Directory> subdir = get_subdir( split.first );
    if( subdir.raw_ptr() == 0 ) {
       appli_warning( "Could not descend into directory " << split.first << std::endl );
      return 0;
    }
    else
      return subdir->new_interface_raw( type_param, split.second );
  }
}
Ejemplo n.º 15
0
int
export_dl_open(char const *name, unsigned flags)
{
	(void)(name);
	(void)(flags);

	return load_library(name);
}
Ejemplo n.º 16
0
int require_library(lua_State* lua)
{
    const char* name = luaL_checkstring(lua, 1);
    if (strcmp(name, LUA_LPEGLIBNAME) == 0) {
        const char* disable[] = { NULL };
        load_library(lua, name, luaopen_lpeg, disable);
    } else if (strcmp(name, "cjson") == 0) {
        const char* disable[] = { "encode",  "encode_sparse_array", 
            "encode_max_depth", "encode_number_precision", "encode_keep_buffer",
            "encode_invalid_numbers", NULL};
        load_library(lua, name, luaopen_cjson_safe, disable);
        lua_pushvalue(lua, -1);
        lua_setglobal(lua, name);
    } else {
        luaL_error(lua, "library '%s' is not available", name);
    }
    return 1;
}
Ejemplo n.º 17
0
//pszFilename must have room for at least MaxPath+1 characters
static inline bool get_file_name_from_handle_function
(void * hFile, wchar_t *pszFilename, std::size_t length, std::size_t &out_length)
{
    if(length <= MaxPath) {
        return false;
    }

    void *hiPSAPI = load_library("PSAPI.DLL");
    if (0 == hiPSAPI)
        return 0;

    class library_unloader
    {
        void *lib_;

    public:
        library_unloader(void *module) : lib_(module) {}
        ~library_unloader() {
            free_library(lib_);
        }
    } unloader(hiPSAPI);

    //  Pointer to function getMappedFileName() in PSAPI.DLL
    GetMappedFileName_t pfGMFN =
        (GetMappedFileName_t)get_proc_address(hiPSAPI, "GetMappedFileNameW");
    if (! pfGMFN) {
        return 0;      //  Failed: unexpected error
    }

    bool bSuccess = false;

    // Create a file mapping object.
    void * hFileMap = create_file_mapping(hFile, page_readonly, 0, 1, 0);
    if(hFileMap)
    {
        // Create a file mapping to get the file name.
        void* pMem = map_view_of_file_ex(hFileMap, file_map_read, 0, 0, 1, 0);

        if (pMem) {
            out_length = pfGMFN(get_current_process(), pMem, pszFilename, MaxPath);
            if(out_length) {
                bSuccess = true;
            }
            unmap_view_of_file(pMem);
        }
        close_handle(hFileMap);
    }

    return(bSuccess);
}
Ejemplo n.º 18
0
Archivo: plugin.c Proyecto: jheinen/gr
void gks_video_plugin(int fctid, int dx, int dy, int dimx, int *ia, int lr1, double *r1, int lr2, double *r2, int lc,
                      char *chars, void **ptr)
{
  static const char *name = NULL;
  static void (*entry)(ENTRY_ARGS) = NULL;

  if (name == NULL)
    {
      name = "videoplugin";
      *(void **)(&entry) = load_library(name);
    }

  if (entry != NULL) (*entry)(fctid, dx, dy, dimx, ia, lr1, r1, lr2, r2, lc, chars, ptr);
}
Ejemplo n.º 19
0
int main(int argc, char** argv)
{
    load_library(library_name);

    void (*selfloaded_func)() = resolve_symbol(library_name, function_name);
    if (!selfloaded_func)
    {
        fprintf(stderr, "failed to locate %s()\n", function_name);
        return 1;
    }

    fprintf(stderr, "calling %s() by programically located pointer:\n", function_name);
    selfloaded_func();
}
Ejemplo n.º 20
0
int kr_module_load(struct kr_module *module, const char *name, const char *path)
{
    if (module == NULL || name == NULL) {
        return kr_error(EINVAL);
    }

    /* Initialize, keep userdata */
    void *data = module->data;
    memset(module, 0, sizeof(struct kr_module));
    module->data = data;
    module->name = strdup(name);
    if (module->name == NULL) {
        return kr_error(ENOMEM);
    }

    /* Search for module library, use current namespace if not found. */
    if (load_library(module, name, path) != 0) {
        /* Expand HOME env variable, as the linker may not expand it. */
        auto_free char *local_path = kr_strcatdup(2, getenv("HOME"), "/.local/lib/kdns_modules");
        if (load_library(module, name, local_path) != 0) {
            if (load_library(module, name, MODULEDIR) != 0) {
                module->lib = RTLD_DEFAULT;
            }
        }
    }

    /* Try to load module ABI. */
    int ret = load_sym_c(module, KR_MODULE_API);
    if (ret == 0 && module->init) {
        ret = module->init(module);
    }
    if (ret != 0) {
        kr_module_unload(module);
    }

    return ret;
}
Ejemplo n.º 21
0
/*
 * Load Scorpio bitbases from |egbb_dir|, with the specified cache size.
 * We also need to find a compatible shared library in the directory.
 */
bool load_scorpio_bb(char* egbb_dir, int cache_size_bytes)
{
    if (!cache_size_bytes) cache_size_bytes = EGBB_DEFAULT_CACHE_SIZE;
    char path[1024];
    egbb_is_loaded = false;
    if (lib) unload_library(lib);

    strncpy(path, egbb_dir, 1000);
    strcat(path, EGBB_NAME);
    lib = load_library(path);
    if (!lib) {
        strncpy(path, egbb_dir, 1000);
        strcat(path, EGBB_NAME2);
        lib = load_library(path);
    }
    if (!lib) {
        strncpy(path, egbb_dir, 1000);
        strcat(path, EGBB64_NAME);
        lib = load_library(path);
    }
    if (!lib) {
        strncpy(path, egbb_dir, 1000);
        strcat(path, EGBB64_NAME2);
        lib = load_library(path);
    }
    if (!lib) {
        printf("info string Failed to load egbb from %s.\n", egbb_dir);
        return false;
    }

    load_egbb_fn load_egbb = (load_egbb_fn)load_function(lib, "load_egbb_5men");
    probe_egbb_internal = (probe_egbb_fn)load_function(lib, "probe_egbb_5men");
    load_egbb(egbb_dir, cache_size_bytes, SMART_LOAD);
    egbb_is_loaded = true;
    return true;
}
void Disassembler::decode(nmethod* nm, outputStream* st) {
#ifndef CORE
  st = st ? st : tty;

  st->print_cr("Decoding compiled method " INTPTR_FORMAT ":", nm);
  st->print("Code:");
  st->cr();
  
  if (!load_library()) {
    st->print_cr("Could not load disassembler");
    return;
  }
  sparc_env env(nm, st);
  unsigned char* p   = nm->instructions_begin();
  unsigned char* end = nm->instructions_end();
  assert ((((intptr_t)p | (intptr_t)end) % sizeof(int) == 0), "misaligned insn addr");

  unsigned char *p1 = p;
  int total_bucket_count = 0;
  while (p1 < end && p1) {
    unsigned char *p0 = p1;
    ++p1;
    address bucket_pc = FlatProfiler::bucket_start_for(p1);
    if (bucket_pc != NULL && bucket_pc > p0 && bucket_pc <= p1)
      total_bucket_count += FlatProfiler::bucket_count_for(p0);
  }

  while (p < end && p) {
    if (p == nm->entry_point())                     st->print_cr("[Entry Point]");
    if (p == nm->verified_entry_point())            st->print_cr("[Verified Entry Point]");
    if (p == nm->exception_begin())                 st->print_cr("[Exception Handler]");
    if (p == nm->stub_begin())                      st->print_cr("[Stub Code]");
    if (p == nm->interpreter_entry_point_or_null()) st->print_cr("[Interpreter Entry Point]");
    unsigned char* p0 = p;
    st->print("  " INTPTR_FORMAT ": ", p);
    p = decode_instruction(p, &env);
    nm->print_code_comment_on(st, 40, p0, p);
    st->cr();
    // Output pc bucket ticks if we have any
    address bucket_pc = FlatProfiler::bucket_start_for(p);
    if (bucket_pc != NULL && bucket_pc > p0 && bucket_pc <= p) {
      int bucket_count = FlatProfiler::bucket_count_for(p0);
      tty->print_cr("%3.1f%% [%d]", bucket_count*100.0/total_bucket_count, bucket_count);
      tty->cr();
    } 
  }
#endif
}
Ejemplo n.º 23
0
int set_function_pointers(void)
{
    if (FILTERING_ENABLED() && multi_get_opt_filterlibpath == NULL) {
        // -x option was specified i.e. filtering was enabled but -y option i.e. filterlibpath was not specified.
        fprintf(stderr, "-x <num> -y <filterlib-path>: -x and -y options must be used together\n");
        return 1;
    }
    if (FILTERING_ENABLED()) {
        // Filtering is enabled.
        if (NULL == load_library(multi_get_opt_filterlib)) {
            return 1;
        }
    }

    return 0;
}
Ejemplo n.º 24
0
void *get_flib(char *flibname)
{
    struct fliblist_s *flib = head;

    if (strcmp(flibname, "default") == 0)
        return head;
    while (flib != NULL) {
        if (strcmp(flib->flibname, flibname) == 0)
            return flib;
        flib = flib->next;
    }
    if (flib == NULL) {
        flib = load_library(flibname);
    }
    
    return (void *) flib;
}
Ejemplo n.º 25
0
inline void get_shared_documents_folder(std::string &s)
{
   s.clear();
   void *hAdvapi = load_library("Advapi32.dll");
   if (hAdvapi){
      library_unloader unloader(hAdvapi);
      //  Pointer to function RegOpenKeyA
      RegOpenKeyEx_t pRegOpenKey =
         (RegOpenKeyEx_t)get_proc_address(hAdvapi, "RegOpenKeyExA");
      if (pRegOpenKey){
         //  Pointer to function RegCloseKey
         RegCloseKey_t pRegCloseKey =
            (RegCloseKey_t)get_proc_address(hAdvapi, "RegCloseKey");
         if (pRegCloseKey){
            //  Pointer to function RegQueryValueA
            RegQueryValueEx_t pRegQueryValue =
               (RegQueryValueEx_t)get_proc_address(hAdvapi, "RegQueryValueExA");
            if (pRegQueryValue){
               //Open the key
               void *key;
               if ((*pRegOpenKey)( hkey_local_machine
                                 , "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"
                                 , 0
                                 , key_query_value
                                 , &key) == 0){
                  reg_closer key_closer(pRegCloseKey, key);

                  //Obtain the value
                  unsigned long size;
                  unsigned long type;
                  const char *const reg_value = "Common AppData";
                  long err = (*pRegQueryValue)( key, reg_value, 0, &type, 0, &size);
                  if(!err){
                     //Size includes terminating NULL
                     s.resize(size);
                     err = (*pRegQueryValue)( key, reg_value, 0, &type, (unsigned char*)(&s[0]), &size);
                     if(!err)
                        s.erase(s.end()-1);
                     (void)err;
                  }
               }
            }
         }
      }
   }
}
Ejemplo n.º 26
0
void main() {
	load_library("/lib/core");
	get_lcd_lock();
	get_keypad_lock();
	screen = screen_allocate();

	flush_keys();
	main_menu();

	initialize();
	game_running = true;

	while (1) {
		draw();
		update();
	}
}
Ejemplo n.º 27
0
Archivo: plugin.c Proyecto: jheinen/gr
void gks_drv_plugin(int fctid, int dx, int dy, int dimx, int *ia, int lr1, double *r1, int lr2, double *r2, int lc,
                    char *chars, void **ptr)
{
  static const char *name = NULL;
  static void (*entry)(ENTRY_ARGS) = NULL;
  const char *env;

  if (name == NULL)
    {
      name = NAME;
      if ((env = gks_getenv("GKS_PLUGIN")) != NULL) name = env;

      *(void **)(&entry) = load_library(name);
    }

  if (entry != NULL) (*entry)(fctid, dx, dy, dimx, ia, lr1, r1, lr2, r2, lc, chars, ptr);
}
Ejemplo n.º 28
0
SmartPtr<X3aAnalyzer>
X3aAnalyzerLoader::load_dynamic_analyzer (SmartPtr<X3aAnalyzerLoader> &self)
{
    XCAM_ASSERT (self.ptr () == this);

    SmartPtr<X3aAnalyzer> analyzer;
    XCam3ADescription *desc = (XCam3ADescription*)load_library (get_lib_path ());

    analyzer = new DynamicAnalyzer (desc, self);
    if (!analyzer.ptr ()) {
        XCAM_LOG_WARNING ("create DynamicAnalyzer from lib failed");
        close_handle ();
        return NULL;
    }

    XCAM_LOG_INFO ("analyzer(%s) created from 3a lib", XCAM_STR (analyzer->get_name()));
    return analyzer;
}
Ejemplo n.º 29
0
vanilla::native_library_cache::fptr vanilla::native_library_cache::get_function(
    std::string const& library, std::string const& name)
{
    // If the library is not already cached then try to load it.
    auto iter = _cache.find(library);
    if(iter == _cache.end())
        iter = _cache.insert(std::make_pair(library, load_library(library))).first;
    
    // Load the function from the library.
    try
    {
        return retrieve_function_symbol(iter->second, name);
    }
    catch(error::native_symbol_not_found_error& e)
    {
        BOOST_THROW_EXCEPTION(e << error::native_library_name(library));
    }
}
Ejemplo n.º 30
0
struct module *load_module(char *name)
    //@ requires kernel_state() &*& [?f]string(name, ?cs);
    //@ ensures kernel_state() &*& [f]string(name, cs) &*& kernel_module(result);
{
    struct library *lib = load_library(name);
    module_init *init = 0;
    module_dispose *dispose = 0;
    struct module *m;
    if (lib == 0) abort();
    init = library_lookup_symbol_module_init_func(lib);
    if (init == 0) abort();
    dispose = init();
    m = malloc(sizeof(struct module));
    if (m == 0) abort();
    m->library = lib;
    m->dispose = dispose;
    //@ close kernel_module(m);
    return m;
}