简体   繁体   中英

iOS tweak doesn't load

I'm developing a small tweak that changes some files in /var/preferences . Here is my constructor:

%ctor
{
    NSLog(@"\n\n\n Tweak Loading... \n\n\n ");

    NSError *error = [[NSError alloc] init];
    BOOL success = [[NSFileManager defaultManager] copyItemAtPath:somePath toPath:someOtherPath error:&error];
    if (success)
    {
        NSLog(@"\n\n\n Success:) \n\n\n ");
    } else {
        NSLog(@"\n\n\n Failure! \n\n\n ");
    }

    //Method hook initialization
    %init;
}

As /var/preferences/ is not accessible for mobile user the tweak should be loaded in a root process. With a little bit search I found out that wifid has root privileges. So I changed my filter to com.apple.wifid filter for bundle identifiers.

After I restarted wifid daemon nothing happens and the tweak isn't loaded. I thought it's a problem with this specific daemon so I wrote a simple command line tool for test that has a runloop in it (it's just like a launch daemon instead it doesn't have a plist to run at startup). Then I modified the plist to this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Filter</key>
    <dict>
        <key>Executables</key>
        <array>
            <string>myExecutableName</string>
        </array>
    </dict>
</dict>
</plist>

Again nothing happens and the tweak is not loaded. How can I solve this problem? Why doesn't this tweak load in those processes?

It's a really "dirty" solution to hook into a root process like wifid just for the sake of running a (seemingly) unrelated task as root. Like creker said, you could instead run your task as a LaunchDaemon, or even run your task inside an app that runs as root. Either way makes more sense than hooking into an existing process to do something that does not seem to be related to the process.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM