]> git.saurik.com Git - apple/dyld.git/blob - testing/kernel-cache-tests/auxkc-vtable-metaclass-patching/metaclass.h
dyld-832.7.1.tar.gz
[apple/dyld.git] / testing / kernel-cache-tests / auxkc-vtable-metaclass-patching / metaclass.h
1
2 #ifndef METACLASS_H
3 #define METACLASS_H
4
5 #define NULL 0
6 #define APPLE_KEXT_OVERRIDE
7
8 #define OSDeclareCommonStructors(className, dispatch) \
9 private: \
10 static const OSMetaClass * const superClass; \
11 public: \
12 static const OSMetaClass * const metaClass; \
13 static class MetaClass : public OSMetaClass { \
14 public: \
15 MetaClass(); \
16 virtual OSObject *alloc() const APPLE_KEXT_OVERRIDE;\
17 } gMetaClass; \
18 friend class className ::MetaClass; \
19 protected: \
20 className (const OSMetaClass *); \
21 virtual ~ className () APPLE_KEXT_OVERRIDE;
22
23 #define _OSDeclareAbstractStructors(className, dispatch) \
24 OSDeclareCommonStructors(className, dispatch); \
25 private: \
26 className (void); /* Make primary constructor private in abstract */ \
27 protected:
28
29 #define OSDeclareAbstractStructorsWithDispatch(className) \
30 _OSDeclareAbstractStructors(className, dispatch)
31
32 #define OSMetaClassDefineReservedUsed(className, index)
33 #define OSMetaClassDefineReservedUnused(className, index) \
34 void className ::_RESERVED ## className ## index () { }
35
36 #define OSMetaClassDeclareReservedUsed(className, index)
37 #define OSMetaClassDeclareReservedUnused(className, index) \
38 private: \
39 virtual void _RESERVED ## className ## index ()
40
41 #define _OSDeclareDefaultStructors(className, dispatch) \
42 OSDeclareCommonStructors(className, dispatch); \
43 public: \
44 className (void); \
45 protected:
46
47 #define OSDeclareDefaultStructors(className) \
48 _OSDeclareDefaultStructors(className, )
49
50 #define OSDefineMetaClassWithInit(className, superclassName, init) \
51 /* Class global data */ \
52 className ::MetaClass className ::gMetaClass; \
53 const OSMetaClass * const className ::metaClass = \
54 & className ::gMetaClass; \
55 const OSMetaClass * const className ::superClass = \
56 & superclassName ::gMetaClass; \
57 /* Class member functions */ \
58 className :: className(const OSMetaClass *meta) \
59 : superclassName (meta) { } \
60 className ::~ className() { } \
61 /* The ::MetaClass constructor */ \
62 className ::MetaClass::MetaClass() { init; }
63
64 #define OSDefineDefaultStructors(className, superclassName) \
65 OSObject * className ::MetaClass::alloc() const { return new className; } \
66 className :: className () : superclassName (&gMetaClass) { }
67
68 #define OSDefineMetaClassAndStructorsWithInit(className, superclassName, init) \
69 OSDefineMetaClassWithInit(className, superclassName, init) \
70 OSDefineDefaultStructors(className, superclassName)
71
72 #define OSDefineMetaClassAndStructors(className, superclassName) \
73 OSDefineMetaClassAndStructorsWithInit(className, superclassName, )
74
75
76 class OSMetaClassBase
77 {
78 public:
79 virtual ~OSMetaClassBase();
80
81 // Add a placeholder we can find later
82 virtual void placeholder();
83
84 // Virtual Padding
85 #ifdef METACLASS_BASE_USED
86 OSMetaClassDeclareReservedUsed(OSMetaClassBase, 4);
87 virtual int metaclassBaseUsed4();
88 OSMetaClassDeclareReservedUsed(OSMetaClassBase, 5);
89 virtual int metaclassBaseUsed5();
90 OSMetaClassDeclareReservedUsed(OSMetaClassBase, 6);
91 virtual int metaclassBaseUsed6();
92 OSMetaClassDeclareReservedUsed(OSMetaClassBase, 7);
93 virtual int metaclassBaseUsed7();
94 #else
95 virtual void _RESERVEDOSMetaClassBase4();
96 virtual void _RESERVEDOSMetaClassBase5();
97 virtual void _RESERVEDOSMetaClassBase6();
98 virtual void _RESERVEDOSMetaClassBase7();
99 #endif
100 };
101
102 class OSMetaClass : public OSMetaClassBase {
103 public:
104 virtual ~OSMetaClass();
105 // Virtual Padding functions for MetaClass's
106 OSMetaClassDeclareReservedUnused(OSMetaClass, 0);
107 OSMetaClassDeclareReservedUnused(OSMetaClass, 1);
108 OSMetaClassDeclareReservedUnused(OSMetaClass, 2);
109 OSMetaClassDeclareReservedUnused(OSMetaClass, 3);
110 OSMetaClassDeclareReservedUnused(OSMetaClass, 4);
111 OSMetaClassDeclareReservedUnused(OSMetaClass, 5);
112 OSMetaClassDeclareReservedUnused(OSMetaClass, 6);
113 OSMetaClassDeclareReservedUnused(OSMetaClass, 7);
114 };
115
116 #endif // METACLASS_H