%orig 在钩子或子类之外找到

逆向工程 ios
2021-07-10 12:40:51

我正在使用 Rpetrich 的 Theos 存储库,并且tweak.xmi用于对多个文件进行调整以便于管理。

除了一件事,我可以成功构建和运行:我不能使用 hookf. 在此之前,当我将所有源代码放在 one 中时tweak.x,一切正常。但是现在,每次编译时,都会遇到这个错误:

error: %orig found outside of hook or subclass 

我的钩子的一个例子是:

%hookf(int, uname, struct utsname *value) {
    int ret = %orig;
    strcpy(value->machine, getModelIdentifier());
    strcpy(value->nodename, getHostname());
    return ret;
}

更新:

这是我的调整,使用 MSHookFunction

#import "substrate.h"

static int (*original_gethostname)(char *, size_t);

static int replace_gethostname(char *value, size_t valueLen) {
    int ret = gethostname(value, valueLen);
    if (value) strcpy(value, "thao");
    return ret;
}

%ctor {
    %init(_ungrouped)
    MSHookFunction((void*)gethostname, (void*)replace_gethostname, (void**)&original_gethostname);
}
1个回答

您应该尝试一下较新的theos/theos,也许它已经修复了这个错误。


*.xmi/*.xi支持被破坏(似乎仍然是),主要开发人员不鼓励使用它,并且包含源文件而不是头文件无论如何都很奇怪如果您只想将钩子分离到不同的文件中,只需将所有*.xm/*.x和 放入 _FILES 设置中:

tweakname_FILES = first.x second.x third.x