大神!帮忙看看~frida-objc- implementation

const hook = ObjC.类名.方法;
Interceptor.attach(hook.implementation, {
onEnter() {

const origImp = hook.implementation
console.log("方法的地址:" + origImp);//返回的是方法的地址吗?

}

你可以试着问问豆包或者DeepSeek

是的

hook完,自己动态调试一下。
再不清楚的话,就自己写个demo,去调试自己的demo。
这些属于基本功,自己去夯实。

为啥获取到的地址,超出了模块的地址范围?直接提示无法跳转到地址!

有没有可能是其他模块的。要不系统学习下?

这个地址也有可能是指针地址啊~地址本身和指针地址是有区别的!

你这么有想法那肯定是你说得对,Frida文档肯定是错的。IMP交换本身就是个骗局。

下面这段代码如果你研究不明白,建议重新学习iOS中函数地址计算

function hook_specific_method_of_class(className, funcName, baseAddress) {
    var hook = ObjC.classes[className][funcName];
    console.log(hook.implementation);
    console.log(`函数偏移:0x${(hook.implementation-baseAddress).toString(16)}`);
}

// Frida脚本:获取主Mach-O的起始内存地址
function getMainMachOBaseAddress() {
    // 枚举所有模块
    const modules = Process.enumerateModules();
    if (modules.length === 0) {
        console.log("未找到任何模块");
        return null;
    }
    
    // 主Mach-O通常是第一个模块(名称为App的可执行文件名)
    const mainModule = modules[0];
    console.log(`主Mach-O名称:${mainModule.name}`);
    console.log(`主Mach-O起始内存地址:0x${mainModule.base.toString(16)}`);
    
    return mainModule.base;
}

// 执行并获取地址
const base = getMainMachOBaseAddress();

//Your class name  and function name here
hook_specific_method_of_class("ViewController", "- viewDidLoad", base);

1 个赞