~ubuntu-branches/ubuntu/lucid/mumble/lucid-security

« back to all changes in this revision

Viewing changes to overlay_macx/overlay/mach_override.h

  • Committer: Bazaar Package Importer
  • Author(s): Thorvald Natvig, Patrick Matthäi, Thorvald Natvig
  • Date: 2009-11-11 23:33:38 UTC
  • mfrom: (9.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20091111233338-yrojdl25rlm0f2zy
Tags: 1.2.0~beta1-1
[ Patrick Matthäi ]
* Do not build with missing libcap2-dev on kfreebsd-*.
* Merge 1.1.8-3 and 1.1.8-4 changelog.
* Merge remaining changes from the 1.1.8 branch.
* Also install the menu icon for the mumble-11x package.
* Extend the long description of the mumble-11x package. Thanks lintian.

[ Thorvald Natvig ]
* New upstream beta release.
* Update get-orig-source.
* Update dependencies.
* Let the qmake script find the celt/speex libraries on its own.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
/***************************************************************************//**
9
9
        @mainpage       mach_override
10
10
        @author         Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
11
 
        
 
11
 
12
12
        This package, coded in C to the Mach API, allows you to override ("patch")
13
13
        program- and system-supplied functions at runtime. You can fully replace
14
14
        functions with your implementations, or merely head- or tail-patch the
15
15
        original implementations.
16
 
        
 
16
 
17
17
        Use it by #include'ing mach_override.h from your .c, .m or .mm file(s).
18
 
        
 
18
 
19
19
        @todo   Discontinue use of Carbon's MakeDataExecutable() and
20
20
                        CompareAndSwap() calls and start using the Mach equivalents, if they
21
21
                        exist. If they don't, write them and roll them in. That way, this
49
49
#include <mach/error.h>
50
50
 
51
51
#ifdef  __cplusplus
52
 
        extern  "C"     {
 
52
extern  "C"     {
53
53
#endif
54
54
 
55
 
/**
56
 
        Returned if the function to be overrided begins with a 'mfctr' instruction.
57
 
*/
 
55
        /**
 
56
                Returned if the function to be overrided begins with a 'mfctr' instruction.
 
57
        */
58
58
#define err_cannot_override     (err_local|1)
59
59
 
60
 
/***************************************************************************//**
61
 
        Dynamically overrides the function implementation referenced by
62
 
        originalFunctionSymbolName with the implentation pointed to by
63
 
        overrideFunctionAddress. Optionally returns a pointer to a "reentry island"
64
 
        which, if jumped to, will resume the original implementation.
65
 
        
66
 
        @param  originalFunctionSymbolName              ->      Required symbol name of the
67
 
                                                                                                function to override (with
68
 
                                                                                                overrideFunctionAddress).
69
 
                                                                                                Remember, C function name
70
 
                                                                                                symbols are prepended with an
71
 
                                                                                                underscore.
72
 
        @param  originalFunctionLibraryNameHint ->      Optional name of the library
73
 
                                                                                                which contains
74
 
                                                                                                originalFunctionSymbolName. Can
75
 
                                                                                                be NULL, but this may result in
76
 
                                                                                                the wrong function being
77
 
                                                                                                overridden and/or a crash.
78
 
        @param  overrideFunctionAddress                 ->      Required address to the
79
 
                                                                                                overriding function.
80
 
        @param  originalFunctionReentryIsland   <-      Optional pointer to pointer to
81
 
                                                                                                the reentry island. Can be NULL.
82
 
        @result                                                                 <-      err_cannot_override if the
83
 
                                                                                                original function's
84
 
                                                                                                implementation begins with the
85
 
                                                                                                'mfctr' instruction.
86
 
 
87
 
        ***************************************************************************/
88
 
         
89
 
    mach_error_t
90
 
mach_override(
91
 
    char *originalFunctionSymbolName,
92
 
    const char *originalFunctionLibraryNameHint,
93
 
    const void *overrideFunctionAddress,
94
 
    void **originalFunctionReentryIsland );
95
 
 
96
 
/************************************************************************************//**
97
 
        Dynamically overrides the function implementation referenced by
98
 
        originalFunctionAddress with the implentation pointed to by overrideFunctionAddress.
99
 
        Optionally returns a pointer to a "reentry island" which, if jumped to, will resume
100
 
        the original implementation.
101
 
        
102
 
        @param  originalFunctionAddress                 ->      Required address of the function to
103
 
                                                                                                override (with overrideFunctionAddress).
104
 
        @param  overrideFunctionAddress                 ->      Required address to the overriding
105
 
                                                                                                function.
106
 
        @param  originalFunctionReentryIsland   <-      Optional pointer to pointer to the
107
 
                                                                                                reentry island. Can be NULL.
108
 
        @result                                                                 <-      err_cannot_override if the original
109
 
                                                                                                function's implementation begins with
110
 
                                                                                                the 'mfctr' instruction.
111
 
 
112
 
        ************************************************************************************/
113
 
 
114
 
    mach_error_t
115
 
mach_override_ptr(
116
 
        void *originalFunctionAddress,
117
 
    const void *overrideFunctionAddress,
118
 
    void **originalFunctionReentryIsland );
119
 
 
120
 
/************************************************************************************//**
121
 
        
122
 
 
123
 
        ************************************************************************************/
124
 
 
 
60
        /***************************************************************************//**
 
61
                Dynamically overrides the function implementation referenced by
 
62
                originalFunctionSymbolName with the implentation pointed to by
 
63
                overrideFunctionAddress. Optionally returns a pointer to a "reentry island"
 
64
                which, if jumped to, will resume the original implementation.
 
65
 
 
66
                @param  originalFunctionSymbolName              ->      Required symbol name of the
 
67
                                                                                                        function to override (with
 
68
                                                                                                        overrideFunctionAddress).
 
69
                                                                                                        Remember, C function name
 
70
                                                                                                        symbols are prepended with an
 
71
                                                                                                        underscore.
 
72
                @param  originalFunctionLibraryNameHint ->      Optional name of the library
 
73
                                                                                                        which contains
 
74
                                                                                                        originalFunctionSymbolName. Can
 
75
                                                                                                        be NULL, but this may result in
 
76
                                                                                                        the wrong function being
 
77
                                                                                                        overridden and/or a crash.
 
78
                @param  overrideFunctionAddress                 ->      Required address to the
 
79
                                                                                                        overriding function.
 
80
                @param  originalFunctionReentryIsland   <-      Optional pointer to pointer to
 
81
                                                                                                        the reentry island. Can be NULL.
 
82
                @result                                                                 <-      err_cannot_override if the
 
83
                                                                                                        original function's
 
84
                                                                                                        implementation begins with the
 
85
                                                                                                        'mfctr' instruction.
 
86
 
 
87
                ***************************************************************************/
 
88
 
 
89
        mach_error_t
 
90
        mach_override(
 
91
            char *originalFunctionSymbolName,
 
92
            const char *originalFunctionLibraryNameHint,
 
93
            const void *overrideFunctionAddress,
 
94
            void **originalFunctionReentryIsland);
 
95
 
 
96
        /************************************************************************************//**
 
97
                Dynamically overrides the function implementation referenced by
 
98
                originalFunctionAddress with the implentation pointed to by overrideFunctionAddress.
 
99
                Optionally returns a pointer to a "reentry island" which, if jumped to, will resume
 
100
                the original implementation.
 
101
 
 
102
                @param  originalFunctionAddress                 ->      Required address of the function to
 
103
                                                                                                        override (with overrideFunctionAddress).
 
104
                @param  overrideFunctionAddress                 ->      Required address to the overriding
 
105
                                                                                                        function.
 
106
                @param  originalFunctionReentryIsland   <-      Optional pointer to pointer to the
 
107
                                                                                                        reentry island. Can be NULL.
 
108
                @result                                                                 <-      err_cannot_override if the original
 
109
                                                                                                        function's implementation begins with
 
110
                                                                                                        the 'mfctr' instruction.
 
111
 
 
112
                ************************************************************************************/
 
113
 
 
114
        mach_error_t
 
115
        mach_override_ptr(
 
116
            void *originalFunctionAddress,
 
117
            const void *overrideFunctionAddress,
 
118
            void **originalFunctionReentryIsland);
 
119
 
 
120
        /************************************************************************************//**
 
121
 
 
122
 
 
123
                ************************************************************************************/
 
124
 
125
125
#ifdef  __cplusplus
126
126
 
127
127
#define MACH_OVERRIDE( ORIGINAL_FUNCTION_RETURN_TYPE, ORIGINAL_FUNCTION_NAME, ORIGINAL_FUNCTION_ARGS, ERR )                     \
148
148
                                                                                                                                                                                                                                        \
149
149
                err = mach_override_class__##ORIGINAL_FUNCTION_NAME::override((void*)ORIGINAL_FUNCTION_NAME);                           \
150
150
        }
151
 
 
 
151
 
152
152
#endif
153
153
 
154
154
#ifdef  __cplusplus
155
 
        }
 
155
}
156
156
#endif
157
157
#endif  //      _mach_override_
 
 
b'\\ No newline at end of file'