%orig found outside of hook or subclass when using Tweak.xmi

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’ve never used rpetrich’s fork, but don’t you need a %end to pair with %hookf?

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);

What’s the crash log?

as far as I remember.
gethostname is only a wrapper around syscall, which makes it too short for MSHF to work. Try fishhook.

(You can locate this function using dladdr and check if it’s indeed too short

thanks for letting me know this information. :"D