示例#1
0
int obs_open_module(obs_module_t *module, const char *path,
                    const char *data_path)
{
    struct obs_module mod = {0};
    int errorcode;

    if (!module || !path || !obs)
        return MODULE_ERROR;

    mod.module = os_dlopen(path);
    if (!mod.module) {
        blog(LOG_WARNING, "Module '%s' not found", path);
        return MODULE_FILE_NOT_FOUND;
    }

    errorcode = load_module_exports(&mod, path);
    if (errorcode != MODULE_SUCCESS)
        return errorcode;

    mod.bin_path  = bstrdup(path);
    mod.file      = strrchr(mod.bin_path, '/');
    mod.file      = (!mod.file) ? mod.bin_path : (mod.file + 1);
    mod.data_path = bstrdup(data_path);
    mod.next      = obs->first_module;

    *module = bmemdup(&mod, sizeof(mod));
    obs->first_module = (*module);
    mod.set_pointer(*module);

    if (mod.set_locale)
        mod.set_locale(obs->locale);

    return MODULE_SUCCESS;
}
示例#2
0
文件: module.c 项目: DenielX/psptools
int load_module_info (struct prx *p)
{
  struct prx_modinfo *info;
  uint32 offset;
  p->modinfo = NULL;
  if (p->phnum > 0)
    offset = p->programs[0].paddr & 0x7FFFFFFF;
  else {
    error (__FILE__ ": can't find module info for PRX");
    return 0;
  }

  info = (struct prx_modinfo *) xmalloc (sizeof (struct prx_modinfo));
  p->modinfo = info;

  info->attributes = read_uint16_le (&p->data[offset]);
  info->version = read_uint16_le (&p->data[offset+2]);
  info->name = (const char *) &p->data[offset+4];
  info->gp = read_uint32_le (&p->data[offset+32]);
  info->expvaddr = read_uint32_le (&p->data[offset+36]);
  info->expvaddrbtm = read_uint32_le (&p->data[offset+40]);
  info->impvaddr = read_uint32_le (&p->data[offset+44]);
  info->impvaddrbtm = read_uint32_le (&p->data[offset+48]);

  info->imports = NULL;
  info->exports = NULL;

  if (!check_module_info (p)) return 0;

  if (!load_module_imports (p)) return 0;
  if (!load_module_exports (p)) return 0;

  return 1;
}