I am using Rpetrich’s Theos repository and I’m using tweak.xmi for making tweak on multiple files for easier in management.
I can build and run successfully except one thing: I cannot use hookf. Before that, when I put all source code inside one tweak.x, everything works normal. But now, everytime I compile, I meet this error:
error: %orig found outside of hook or subclass
One example of my hook is:
%hookf(int, uname, struct utsname *value) {
int ret = %orig; // error at this line.
strcpy(value->machine, getModelIdentifier());
strcpy(value->nodename, getHostname());
return ret;
}
I have rechecked. I have put %hookf pair with %end put error is same. Moreover I use original Theos’ repository I compile error because original theos doesn’t support Tweak.xmi ;( As I read in this Discusstion
I have moved from hookf to MSHookFunction. I can compile and run successfully. The hook works. But I don’t know why all my apps crash when running. here is one example:
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, [SystemInfo getHostName]);
return ret;
}
MSHookFunction((void*)gethostname, (void*)replace_gethostname, (void**)&original_gethostname);