我正在使用 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);
}