X-Git-Url: https://git.saurik.com/patcyh.git/blobdiff_plain/ec4c25d4140e861d6860310466d5baff59381aa1..ca46d3603426879bcb80ceca8147fc281dcbbeca:/patch.hpp diff --git a/patch.hpp b/patch.hpp index 658333e..e108eb4 100644 --- a/patch.hpp +++ b/patch.hpp @@ -22,6 +22,8 @@ #ifndef PATCH_HPP #define PATCH_HPP +#include + #include #include @@ -30,7 +32,6 @@ #include -#define INSTALLD "/usr/libexec/installd" #define LIBUICACHE "/usr/lib/libpatcyh.dylib" static void *(*$memmem)(const void *, size_t, const void *, size_t) = reinterpret_cast(dlsym(RTLD_DEFAULT, "memmem")); @@ -100,13 +101,13 @@ static bool PatchInstall(bool uninstall, void *data) { return true; } -static bool PatchInstall(bool uninstall, bool abort) { +static bool Patch(const std::string &path, const std::string &service, bool uninstall, bool abort) { if (!abort && system("ldid --") != 0) { fprintf(stderr, "this package requires ldid to be installed\n"); return false; } - int fd(open(INSTALLD, O_RDWR)); + int fd(open(path.c_str(), O_RDWR)); if (fd == -1) return false; @@ -139,12 +140,22 @@ static bool PatchInstall(bool uninstall, bool abort) { munmap(data, size); if (changed) { - system("ldid -s "INSTALLD""); - system("cp -af "INSTALLD" "INSTALLD"_"); - system("mv -f "INSTALLD"_ "INSTALLD""); + system(("ldid -s " + path + "").c_str()); + system(("cp -af " + path + " " + path + "_").c_str()); + system(("mv -f " + path + "_ " + path + "").c_str()); + system(("launchctl stop " + service + "").c_str()); } return true; } + +static bool PatchInstall(bool uninstall, bool abort) { + return Patch("/usr/libexec/installd", "com.apple.mobile.installd", uninstall, abort); +} + +static bool PatchLaunch(bool uninstall, bool abort) { + return Patch("/usr/libexec/lsd", "com.apple.lsd", uninstall, abort); +} + #endif//PATCH_HPP