diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2017-02-16 00:07:10 -0800 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2017-02-16 00:07:10 -0800 |
commit | 68df8c0b7bacec286d4798408b5a110bdac88986 (patch) | |
tree | dc33f6ec33efea7da01ff83ec8c7092414dfbed6 /Substrate.hpp | |
parent | 03ef79ee43de8ebf2ddfeb53c30ad3a12bfce517 (diff) |
Put CydiaURLCache/NSURLConnection hook in CyteKit.
Diffstat (limited to 'Substrate.hpp')
-rw-r--r-- | Substrate.hpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Substrate.hpp b/Substrate.hpp index 9826b56..57e89fb 100644 --- a/Substrate.hpp +++ b/Substrate.hpp @@ -31,8 +31,21 @@ static inline Type_ &MSHookIvar(id self, const char *name) { return *reinterpret_cast<Type_ *>(pointer); } +#define MSClassHook(name) \ + @class name; \ + static Class $ ## name = objc_getClass(#name); + #define MSHook(type, name, args...) \ static type (*_ ## name)(args); \ static type $ ## name(args) +#define CYHook(Type, Code, Name) \ +static struct Type ## $ ## Code { Type ## $ ## Code() { \ + Method Type ## $ ## Code(class_getInstanceMethod($ ## Type, @selector(Name))); \ + if (Type ## $ ## Code != NULL) { \ + _ ## Type ## $ ## Code = reinterpret_cast<decltype(_ ## Type ## $ ## Code)>(method_getImplementation(Type ## $ ## Code)); \ + method_setImplementation(Type ## $ ## Code, reinterpret_cast<IMP>(&$ ## Type ## $ ## Code)); \ + } \ +} } Type ## $ ## Code; + #endif//Substrate_HPP |