]> git.saurik.com Git - cydia.git/blobdiff - Substrate.hpp
Avoid counting a package as "lost" multiple times.
[cydia.git] / Substrate.hpp
index 9826b567398be84c4d0c06ad5cf2b9fd049665e6..57e89fbb5b80ebd5726d32fb7dcaea2053590f25 100644 (file)
@@ -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