本文整理汇总了C++中NSLookupSymbolInModule函数的典型用法代码示例。如果您正苦于以下问题:C++ NSLookupSymbolInModule函数的具体用法?C++ NSLookupSymbolInModule怎么用?C++ NSLookupSymbolInModule使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NSLookupSymbolInModule函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例3: NSLookupSymbolInModule
void *dlsym(void *myModule, char *mySymbolName)
{
NSSymbol mySymbol;
mySymbol = NSLookupSymbolInModule((NSModule)myModule, mySymbolName);
return NSAddressOfSymbol(mySymbol);
}
示例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);
}
示例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 */
示例6: getmachosym
void*
getmachosym(NSModule library, const char* symname)
{
NSSymbol sym = NSLookupSymbolInModule(library, symname);
if(sym)
return NSAddressOfSymbol(sym);
return 0;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}