ios中针对objc_msgSend hook后已经获取了x0类名称和x1方法名。如何获取x1方法所在的具体地址呢?(不是方法名称的地址,而是是方法定义的地址–调用函数地址)
IMP getIMPFromString(NSString *className, NSString *methodName) {
// 获取Class对象
Class targetClass = NSClassFromString(className);
if (!targetClass) {
NSLog(@"Error: Class %@ not found", className);
return NULL;
}
// 获取SEL (Selector)
SEL selector = NSSelectorFromString(methodName);
if (!selector) {
NSLog(@"Error: Method %@ not found", methodName);
return NULL;
}
// 检查方法是否存在
Method method = class_getInstanceMethod(targetClass, selector);
if (!method) {
// 尝试类方法
method = class_getClassMethod(targetClass, selector);
if (!method) {
NSLog(@"Error: Method %@ not found in class %@", methodName, className);
return NULL;
}
}
// 获取IMP
IMP imp = method_getImplementation(method);
return imp;
}
请问!这个用frida 脚本怎么实现?