通过内存地址替换方法

发布于 2024-12-04 04:09:14 字数 118 浏览 3 评论 0原文

我想知道是否有任何方法可以通过内存地址来混合方法。 例如: 我有一个指向方法 0xFFFFFF 的指针。 我的应用程序中有一个方法。 我想用我的方法替换指针。有没有办法可以在 Objective-C 中替换这个指针。谢谢。

I was wondering if there was any way to swizzle a method by a memory address.
For example:
I have a pointer to a method 0xFFFFFF.
I have an method in my application.
I want to replace the pointer with the my method. Is there way that I could replace this pointer in Objective-C. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

送你一个梦 2024-12-11 04:09:14

你说的是注射。

看看 mach_inject

以及mach_inject。 com/StarProject/StarRuntime" rel="nofollow">Starruntime

和应用程序增强器。

You are talking about injection.

Take a look at mach_inject

also Starruntime

and Application Enhancer.

等风来 2024-12-11 04:09:14

您正在寻找 method_setImplementation(Method m, IMP imp)

不过,您必须首先使用 class_getInstanceMethodclass_getClasssMethod 解析选择器的方法>

You're looking for method_setImplementation(Method m, IMP imp)

You have to have resolved the Method for your selector first though, using class_getInstanceMethod or class_getClasssMethod

行至春深 2024-12-11 04:09:14

您可以使用“performSelector”:

[object performSelector:@selector(doSomething)];

选择器可以存储在变量中。

You could use "performSelector":

[object performSelector:@selector(doSomething)];

The selector can be stored in a variable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文