有一个demo游戏,有导出函数il2cpp_domain_get,函数原型是DO_API( Il2CppDomain*, il2cpp_domain_get, () );
通过dlsym获取函数地址,然后构造函数原型后调用该函数,返回0,请问一下是什么原因啊?
void* get_method_addr(char* method){
void* method_addr = NULL;
void* handle = dlopen(NULL,RTLD_LAZY);
if (handle)
{
method_addr = (void*)dlsym(handle,method);
if(method_addr)
NSLog(@" get %@ addr success at %lld!",[NSString stringWithUTF8String:method],(long long)method_addr);
else {
NSLog(@" get %@ addr error !",[NSString stringWithUTF8String:method]);
}
}
else {
NSLog(@"dlopen error !");
}
return method_addr;
}
Il2CppDomain* il2cpp_domain_get(){
void* il2cpp_domain_get_addr = get_method_addr(“il2cpp_domain_get”);
Il2CppDomain* result = ((Il2CppDomain*(*)())il2cpp_domain_get_addr)();
return result;
}
void main(){
Il2CppDomain* domain = il2cpp_domain_get();
}
返回的domain为0,想问一下问题在哪里?