开发者

Replacing Methods by Memory Address

开发者 https://www.devze.com 2023-04-04 05:05 出处:网络
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 0x开发者_开发技巧FFFFFF.

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 0x开发者_开发技巧FFFFFF. 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.


You are talking about injection.

Take a look at mach_inject

also Starruntime

and Application Enhancer.


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


You could use "performSelector":

[object performSelector:@selector(doSomething)];

The selector can be stored in a variable.

0

精彩评论

暂无评论...
验证码 换一张
取 消