如何从函数地址或类中找到CFBundleRef
是否可以从Carbon中的函数地址或类名获取Bundle引用(CFBundleRef)??
中有函数,
NSBundle myBundle = [NSBundle bundleForClass:(Class)<SOME_CLASS>];
我知道 Objective-C和 Windows API
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCTSTR)<SOME_FUNCTION>, &outModule);
在 Mac 上有类似的 C++ 或任何其他方法吗?
谢谢, 阿比奈。
Is it possible to get the Bundle reference (CFBundleRef) from a function address or a class name in Carbon..??
I know there are functions in Objective-C
NSBundle myBundle = [NSBundle bundleForClass:(Class)<SOME_CLASS>];
and with Windows API
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCTSTR)<SOME_FUNCTION>, &outModule);
Is there anything similar or any other method with C++ on a mac??
Thanks,
Abhinay.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 在
CFBundle 上运行的 Core Foundation 函数
获取对导出给定函数名称的包的包引用:
并且由于
CFBundleGetDataPointerForName()
返回指向给定符号名称的数据指针一个包,我相信它也可以用于类名称,因为类是使用符号名称_OBJC_CLASS_$_
导出的,例如_OBJC_CLASS_$ _NSArray
。据我所知,没有任何函数允许您通过指定函数地址来检查包是否导出函数。
You can use the Core Foundation functions that operate on
CFBundle
to get the bundle reference to the bundle that exports a given function name:And since
CFBundleGetDataPointerForName()
returns a data pointer to a given symbol name in a bundle, I believe it can be used for class names as well since a class is exported with a symbol name_OBJC_CLASS_$_<className>
, e.g._OBJC_CLASS_$_NSArray
.As far as I can tell, there’s no function that allows to you to inspect whether a bundle exports a function by specifying the function address.