• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ NSLookupSymbolInModule函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中NSLookupSymbolInModule函数的典型用法代码示例。如果您正苦于以下问题:C++ NSLookupSymbolInModule函数的具体用法?C++ NSLookupSymbolInModule怎么用?C++ NSLookupSymbolInModule使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NSLookupSymbolInModule函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: NSLookupSymbolInModule

static void *dlsym(void *handle, char *function)
{
  NSSymbol symbol =
    NSLookupSymbolInModule(((struct pike_dl_handle *)handle)->module,
			   function);
  return symbol?NSAddressOfSymbol(symbol):NULL;
}
开发者ID:ajinkya007,项目名称:pike-1,代码行数:7,代码来源:dynamic_load.c


示例2: NSLookupAndBindSymbol

/* used by dlsym to find the symbol */
void *dlsymIntern(void *handle, const char *symbol)
{
  NSSymbol nssym = NULL;
  if (handle == (void *)-1)
  { /* Global context */
    if (NSIsSymbolNameDefined(symbol))
      nssym = NSLookupAndBindSymbol(symbol);
  }
  else
  {
    if (is_mach_header(handle))
    { /* library */
      if (NSIsSymbolNameDefinedInImage((struct mach_header *)handle, symbol))
        nssym = NSLookupSymbolInImage((struct mach_header *)handle, symbol,
                        NSLOOKUPSYMBOLINIMAGE_OPTION_BIND
                        | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
    }
    else /* bundle */
      nssym = NSLookupSymbolInModule((NSModule)handle, symbol);
  }
  if (!nssym)
  {
    error(0, "Symbol \"%s\" Not found", symbol);
    return NULL;
  }
  return NSAddressOfSymbol(nssym);
}
开发者ID:jkeuffer,项目名称:pari,代码行数:28,代码来源:darwin.c


示例3: NSLookupSymbolInModule

void *dlsym(void *myModule, char *mySymbolName)
{
  NSSymbol mySymbol;

  mySymbol = NSLookupSymbolInModule((NSModule)myModule, mySymbolName);
  return NSAddressOfSymbol(mySymbol);
}
开发者ID:mishan,项目名称:thinksynth,代码行数:7,代码来源:nsmodule_dl.cpp


示例4: NSLookupSymbolInImage

static void *GetSymbol(void *handle, const char *symbol)
{
	NSSymbol sym;

	/* We have to use a different lookup approach for images and modules */
	if((((struct mach_header *)handle)->magic == MH_MAGIC) ||
	   (((struct mach_header *)handle)->magic == MH_CIGAM))
	{
		if(NSIsSymbolNameDefinedInImage((struct mach_header *)handle, symbol))
		{
			sym = NSLookupSymbolInImage((struct mach_header *)handle, symbol,
						NSLOOKUPSYMBOLINIMAGE_OPTION_BIND |
						NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
		}
		else
		{
			sym = 0;
		}
	}
	else
	{
		sym = NSLookupSymbolInModule((NSModule)handle, symbol);
	}

	/* Did we find the symbol? */
	if(sym == 0)
	{
		return 0;
	}

	/* Convert the symbol into the address that we require */
	return (void *)NSAddressOfSymbol(sym);
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:33,代码来源:dynlib.c


示例5: switch

/* ggDarwinDLSym implements a "dlsym" wrapper
 */
void *ggDarwinDLSym(gg_dlhand handle, const char *symbol)
{
	void *nsaddr = NULL;
	NSSymbol nssymbol = 0;
	struct gg_dlhand_darwin_t *darwin_module;

	darwin_module = (struct gg_dlhand_darwin_t *)handle;

	switch (darwin_module->nsmodule_flags) {
	case NSLINKMODULE_OPTION_NONE:
		nssymbol = NSLookupAndBindSymbol(symbol);
		break;

	case NSLINKMODULE_OPTION_PRIVATE:
		nssymbol = NSLookupSymbolInModule(darwin_module->nsmodule,
				symbol);
		break;

	}	/* switch */

	nsaddr = NSAddressOfSymbol(nssymbol);

	/* no error handling needed here. The error handlers
	 * are called, when an error occurs.
	 */

	return nsaddr;
}	/* ggDarwinDLSym */
开发者ID:Nekrofage,项目名称:DoomRPi,代码行数:30,代码来源:dl_darwin.c


示例6: getmachosym

void*
getmachosym(NSModule library, const char* symname)
{
    NSSymbol    sym = NSLookupSymbolInModule(library, symname);
    if(sym)
        return NSAddressOfSymbol(sym);
    return 0;
}
开发者ID:martindemello,项目名称:felix,代码行数:8,代码来源:flx_dynlink.cpp


示例7: ll_sym

static lua_CFunction ll_sym (lua_State *L, void* lib, const char* sym) {
  NSSymbol nss = NSLookupSymbolInModule((NSModule)lib, sym);
  if (nss == nullptr) {
    lua_pushfstring(L, "symbol " LUA_QS " not found", sym);
    return nullptr;
  }
  return (lua_CFunction)NSAddressOfSymbol(nss);
}
开发者ID:Isaacssv552,项目名称:ufoai,代码行数:8,代码来源:loadlib.cpp


示例8: dyld_dlsym

static void * dyld_dlsym(void * hand, const char * name)
{
        NSSymbol sym=NSLookupSymbolInModule((NSModule)hand, name);
	void * addr = NULL;
	dyld_error_set=0;
	if (sym) addr=(void*)NSAddressOfSymbol(sym);
	if (!addr) dyld_error_set=1;
        return addr;
}
开发者ID:cention-nazri,项目名称:libdbi,代码行数:9,代码来源:dbi_main.c


示例9: find_sym_addr

 static void*
find_sym_addr(NS_pair *p, const char *name)
{
	NSSymbol nss;

	if (nss = NSLookupSymbolInModule(p->m, name))
		return NSAddressOfSymbol(nss);
	return 0;
	}
开发者ID:BRAINSia,项目名称:calatk,代码行数:9,代码来源:funcadd1.c


示例10: caml_dlsym

void * caml_dlsym(void * handle, char * name)
{
  NSSymbol sym;
  char _name[1000] = "_";
  strncat (_name, name, 998);
  dlerror_string = NULL;
  sym = NSLookupSymbolInModule((NSModule)handle, _name);
  if (sym != NULL) return NSAddressOfSymbol(sym);
  else return NULL;
}
开发者ID:avsm,项目名称:ocaml-community,代码行数:10,代码来源:unix.c


示例11: str_len

void *dlsym(void *handle, const char *symbol)
{
	int sym_len = str_len(symbol);
	void *value = NULL;
	char *malloc_sym = NULL;
	NSSymbol *nssym = 0;
	malloc_sym = malloc(sym_len + 2);
	if (malloc_sym)
	{
		sprintf(malloc_sym, "_%s", symbol);
		/* If the handle is -1, if is the app global context */
		if (handle == (void *)-1)
		{
			/* Global context, use NSLookupAndBindSymbol */
			if (NSIsSymbolNameDefined(malloc_sym))
			{
				nssym = NSLookupAndBindSymbol(malloc_sym);
			}
		}
		/* Now see if the handle is a struch mach_header* or not, use NSLookupSymbol in image
		   for libraries, and NSLookupSymbolInModule for bundles */
		else
		{
			/* Check for both possible magic numbers depending on x86/ppc byte order */
			if ((((struct mach_header *)handle)->magic == MH_MAGIC) ||
				(((struct mach_header *)handle)->magic == MH_CIGAM))
			{
				if (NSIsSymbolNameDefinedInImage((struct mach_header *)handle, malloc_sym))
				{
					nssym = NSLookupSymbolInImage((struct mach_header *)handle,
												  malloc_sym,
												  NSLOOKUPSYMBOLINIMAGE_OPTION_BIND
												  | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
				}

			}
			else
			{
				nssym = NSLookupSymbolInModule(handle, malloc_sym);
			}
		}
		if (!nssym)
		{
			error(0, "Symbol \"%s\" Not found", symbol);
		}
		value = NSAddressOfSymbol(nssym);
		free(malloc_sym);
	}
	else
	{
		error(-1, "Unable to allocate memory");
	}
	return value;
}
开发者ID:darcyg,项目名称:chaosircd,代码行数:54,代码来源:dlfcn_darwin.c


示例12: snprintf

static void *dlsym(void *handle, const char *symbol)
{
  char		_symbol[256];
  NSSymbol	*nsSymbol= 0;

  snprintf(_symbol, sizeof(_symbol), "_%s", symbol);

  dprintf((stderr, "dlsym: looking for %s (%s) in %d\n", symbol, _symbol, (int)handle));

  if (!handle)
    {
      dprintf((stderr, "dlsym: setting app context for this handle\n"));
      handle= DL_APP_CONTEXT;
    }

  if (DL_APP_CONTEXT == handle)
    {
      dprintf((stderr, "dlsym: looking in app context\n"));
      if (NSIsSymbolNameDefined(_symbol))
	nsSymbol= NSLookupAndBindSymbol(_symbol);
    }
  else
    {
      if ((  (MH_MAGIC == ((struct mach_header *)handle)->magic))	/* ppc */
	  || (MH_CIGAM == ((struct mach_header *)handle)->magic))	/* 386 */
	{
	  if (NSIsSymbolNameDefinedInImage((struct mach_header *)handle, _symbol))
	    {
	      nsSymbol= NSLookupSymbolInImage
		((struct mach_header *)handle,
		 _symbol,
		 NSLOOKUPSYMBOLINIMAGE_OPTION_BIND
		 /*| NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR*/);
	      dprintf((stderr, "dlsym: bundle (image) lookup returned %p\n", nsSymbol));
	    }
	  else
	    dprintf((stderr, "dlsym: bundle (image) symbol not defined\n"));
	}
      else
	{
	  nsSymbol= NSLookupSymbolInModule(handle, _symbol);
	  dprintf((stderr, "dlsym: dylib (module) lookup returned %p\n", nsSymbol));
	}
    }

  if (!nsSymbol)
    {
      dlSetError("symbol not found: %s", _symbol);
      return 0;
    }

  return NSAddressOfSymbol(nsSymbol);
}
开发者ID:Adorkable-forkable,项目名称:Scratch.app.for.iOS,代码行数:53,代码来源:dlfcn-dyld.c


示例13: buf

static void *wx_darwin_dlsym(void *handle, const char *symbol)
{
    // as on many other systems, C symbols have prepended underscores under
    // Darwin but unlike the normal dlopen(), NSLookupSymbolInModule() is not
    // aware of this
    wxCharBuffer buf(strlen(symbol) + 1);
    char *p = buf.data();
    p[0] = '_';
    strcpy(p + 1, symbol);

    NSSymbol nsSymbol = NSLookupSymbolInModule((NSModule)handle, p );
    return nsSymbol ? NSAddressOfSymbol(nsSymbol) : NULL;
}
开发者ID:beanhome,项目名称:dev,代码行数:13,代码来源:dlunix.cpp


示例14: strcpy

void *vmddlsym( void *handle, const char *symname ) {
    char *realsymname;
    NSModule module;
    NSSymbol sym;
    /* Hack around the leading underscore in the symbol name */
    realsymname = (char *)malloc(strlen(symname)+2);
    strcpy(realsymname, "_");
    strcat(realsymname, symname);
    module = (NSModule)handle;
    sym = NSLookupSymbolInModule(module, realsymname);
    free(realsymname);
    if (sym)
        return (void *)(NSAddressOfSymbol(sym));
    return NULL;
}
开发者ID:yupinov,项目名称:gromacs,代码行数:15,代码来源:vmddlopen.c


示例15: findSharedSymbol

int 
findSharedSymbol (void *object, const char *symbol, void *pointerAddress) {
  NSModule module = object;
  char name[strlen(symbol) + 2];
  snprintf(name, sizeof(name), "_%s", symbol);
  {
    NSSymbol sym = NSLookupSymbolInModule(module, name);
    if (sym) {
      void **address = pointerAddress;
      *address = NSAddressOfSymbol(sym);
      return 1;
    }
  }
  return 0;
}
开发者ID:mlang,项目名称:brltty,代码行数:15,代码来源:dynld_dyld.c


示例16: vm_sym

/* A function called through the vtable to get the address of
   a symbol loaded from a particular module.  */
static void *
vm_sym (lt_user_data loader_data, lt_module module, const char *name)
{
  NSSymbol *nssym = 0;
  const mach_header *mh = (const mach_header *) module;
  char saveError[256] = "Symbol not found";

  if (module == (lt_module) -1)
    {
      void *address, *unused;
      _dyld_lookup_and_bind (name, (unsigned long*) &address, &unused);
      return address;
    }

  if (mh->magic == LT__MAGIC)
    {
      if (lt__image_symbol_p && lt__image_symbol)
	{
	  if (lt__image_symbol_p (mh, name))
	    {
	      nssym = lt__image_symbol (mh, name, LT__SYMLOOKUP_OPTS);
	    }
	}

    }
  else
    {
      nssym = NSLookupSymbolInModule (module, name);
    }

  if (!nssym)
    {
      strncpy (saveError, dylderror (LT__STRERROR (SYMBOL_NOT_FOUND)), 255);
      saveError[255] = 0;
      if (!mh)
	{
	  mh = (mach_header *)lt__nsmodule_get_header (module);
	}
      nssym = lt__linkedlib_symbol (name, mh);
    }

  if (!nssym)
    {
      LT__SETERRORSTR (saveError);
    }

  return nssym ? NSAddressOfSymbol (nssym) : 0;
}
开发者ID:kam-zhang,项目名称:kamOwnInformation,代码行数:50,代码来源:dyld.c


示例17: main

int main()
{
// NSCreateObjectFileImageFromMemory is only available on Mac OS X - not iPhone OS
#if __MAC_OS_X_VERSION_MIN_REQUIRED
    NSObjectFileImage ofi;
    if ( NSCreateObjectFileImageFromFile("test.bundle", &ofi) != NSObjectFileImageSuccess ) {
        FAIL("NSCreateObjectFileImageFromFile failed");
        return 1;
    }

    NSModule mod = NSLinkModule(ofi, "test.bundle", NSLINKMODULE_OPTION_NONE);
    if ( mod == NULL ) {
        FAIL("NSLinkModule failed");
        return 1;
    }

    NSSymbol sym = NSLookupSymbolInModule(mod, "_checkdata");
    if ( sym == NULL ) {
        FAIL("NSLookupSymbolInModule failed");
        return 1;
    }

    CheckFunc func = NSAddressOfSymbol(sym);
    if ( !func() ) {
        FAIL("NSAddressOfSymbol failed");
        return 1;
    }

    if ( !NSUnLinkModule(mod, NSUNLINKMODULE_OPTION_KEEP_MEMORY_MAPPED) ) {
        FAIL("NSUnLinkModule failed");
        return 1;
    }

    if ( !NSDestroyObjectFileImage(ofi) ) {
        FAIL("NSDestroyObjectFileImage failed");
        return 1;
    }

    // call function again, even though bundle is unloaded
    func();
#endif

    PASS("bundle-basic");
    return 0;
}
开发者ID:johndpope,项目名称:dyld,代码行数:45,代码来源:main.c


示例18: Unload

DWORD OSXPluginInstance::Load(const char *fname)
{
  if (fname==NULL || fname[0]==0)
    return FF_FAIL;

  Unload();
  
  if (NSCreateObjectFileImageFromFile(fname, &m_ffImage)!=NSObjectFileImageSuccess)
    return FF_FAIL;

  NSModule m_ffModule =
    NSLinkModule(
      m_ffImage,
      fname,
      NSLINKMODULE_OPTION_NONE);
      
  if (m_ffModule==NULL)
  {
    Unload(); //to undo NSCreateObjectFileImageFromFile
    return FF_FAIL;
  }
  
  NSSymbol s = NSLookupSymbolInModule(m_ffModule, "_plugMain");
  if (s==NULL)
  {
    Unload();//to undo NSLinkModule and NSCreateObjectFileImageFromFile
    return FF_FAIL;
  }
  
	FF_Main_FuncPtr pFreeFrameMain = (FF_Main_FuncPtr)NSAddressOfSymbol(s);

	if (pFreeFrameMain==NULL)
  {
    Unload(); //to undo same
    return FF_FAIL;
  }
  
  m_ffPluginMain = pFreeFrameMain;
  
  DWORD rval = InitPluginLibrary();
  if (rval!=FF_SUCCESS)
    return rval;
  
  return FF_SUCCESS;
}
开发者ID:6301158,项目名称:ofx-dev,代码行数:45,代码来源:OSXPluginInstance.cpp


示例19: defined

/**
 * Looks up a symbol from a dynamically loaded library
 *
 * This function queries a loaded library for a symbol specified in a
 * string, and returns a pointer to it. We don't check for dlerror() or
 * similar functions, since we want a non-NULL symbol anyway.
 *
 * @param handle handle to the module
 * @param psz_function function name
 * @return NULL on error, or the address of the symbol
 */
static void *module_Lookup( module_handle_t handle, const char *psz_function )
{
#if defined(HAVE_DL_DYLD)
    char psz_call[strlen( psz_function ) + 2];
    psz_call[0] = '_';
    memcpy( psz_call + 1, psz_function, sizeof( psz_call ) - 1 );

    NSSymbol sym = NSLookupSymbolInModule( handle, psz_call );
    return NSAddressOfSymbol( sym );

#elif defined(HAVE_DL_BEOS)
    void * p_symbol;
    if( B_OK == get_image_symbol( handle, psz_function,
                                  B_SYMBOL_TYPE_TEXT, &p_symbol ) )
    {
        return p_symbol;
    }
    else
    {
        return NULL;
    }

#elif defined(HAVE_DL_WINDOWS) && defined(UNDER_CE)
    wchar_t wide[strlen( psz_function ) + 1];
    size_t i = 0;
    do
        wide[i] = psz_function[i]; /* UTF-16 <- ASCII */
    while( psz_function[i++] );

    return (void *)GetProcAddress( handle, wide );

#elif defined(HAVE_DL_WINDOWS) && defined(WIN32)
    return (void *)GetProcAddress( handle, (char *)psz_function );

#elif defined(HAVE_DL_DLOPEN)
    return dlsym( handle, psz_function );

#elif defined(HAVE_DL_SHL_LOAD)
    void *p_sym;
    shl_findsym( &handle, psz_function, TYPE_UNDEFINED, &p_sym );
    return p_sym;

#endif
}
开发者ID:MisTelochka,项目名称:vlc,代码行数:55,代码来源:os.c


示例20: alloca

void *resolve_link_symbol( void *info, const char *name )
{
  char *temp;
  NSModule mp = (NSModule)info;
  void *addr;
  NSSymbol sym;

  temp = alloca( strlen( name ) + 2 );
  sprintf( temp, "_%s", name );

  sym = NSLookupSymbolInModule( mp, temp );
  if (!sym) {
    return NULL;
  }

  addr = NSAddressOfSymbol( sym );

  return addr;
}
开发者ID:Fuhuiang,项目名称:rscheme,代码行数:19,代码来源:dynlink.c



注:本文中的NSLookupSymbolInModule函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ NSS_NoDB_Init函数代码示例发布时间:2022-05-30
下一篇:
C++ NSLinkModule函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap