xref: /aoo41x/main/sal/inc/osl/module.h (revision ca2659a9)
19eab2a37SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
39eab2a37SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
49eab2a37SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
59eab2a37SAndrew Rist  * distributed with this work for additional information
69eab2a37SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
79eab2a37SAndrew Rist  * to you under the Apache License, Version 2.0 (the
89eab2a37SAndrew Rist  * "License"); you may not use this file except in compliance
99eab2a37SAndrew Rist  * with the License.  You may obtain a copy of the License at
109eab2a37SAndrew Rist  *
119eab2a37SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
129eab2a37SAndrew Rist  *
139eab2a37SAndrew Rist  * Unless required by applicable law or agreed to in writing,
149eab2a37SAndrew Rist  * software distributed under the License is distributed on an
159eab2a37SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169eab2a37SAndrew Rist  * KIND, either express or implied.  See the License for the
179eab2a37SAndrew Rist  * specific language governing permissions and limitations
189eab2a37SAndrew Rist  * under the License.
199eab2a37SAndrew Rist  *
209eab2a37SAndrew Rist  *************************************************************/
219eab2a37SAndrew Rist 
229eab2a37SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir /** @HTML */
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #ifndef _OSL_MODULE_H_
27cdf0e10cSrcweir #define _OSL_MODULE_H_
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #	include <rtl/ustring.h>
30cdf0e10cSrcweir #	include <rtl/tencinfo.h>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #ifdef __cplusplus
33cdf0e10cSrcweir extern "C" {
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #ifdef SAL_DLLPREFIX
37cdf0e10cSrcweir #define SAL_MODULENAME(name) SAL_DLLPREFIX name SAL_DLLEXTENSION
38cdf0e10cSrcweir #else
39cdf0e10cSrcweir #define SAL_MODULENAME(name) name SAL_DLLEXTENSION
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #if defined(SAL_W32) || defined(SAL_OS2)
43cdf0e10cSrcweir #define SAL_MODULENAME_WITH_VERSION(name, version) name version SAL_DLLEXTENSION
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #elif defined(SAL_UNX)
46cdf0e10cSrcweir #if defined(MACOSX)
47cdf0e10cSrcweir #define SAL_MODULENAME_WITH_VERSION(name, version) SAL_DLLPREFIX name ".dylib." version
48cdf0e10cSrcweir #else
49cdf0e10cSrcweir #define SAL_MODULENAME_WITH_VERSION(name, version) SAL_DLLPREFIX name SAL_DLLEXTENSION "." version
50cdf0e10cSrcweir #endif
51cdf0e10cSrcweir 
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir 
54cdf0e10cSrcweir #define SAL_LOADMODULE_DEFAULT    0x00000
55cdf0e10cSrcweir #define SAL_LOADMODULE_LAZY       0x00001
56cdf0e10cSrcweir #define SAL_LOADMODULE_NOW        0x00002
57cdf0e10cSrcweir #define SAL_LOADMODULE_GLOBAL     0x00100
58cdf0e10cSrcweir 
59cdf0e10cSrcweir typedef void* oslModule;
60cdf0e10cSrcweir 
61cdf0e10cSrcweir /** Generic Function pointer type that will be used as symbol address.
62cdf0e10cSrcweir     @see osl_getFunctionSymbol.
63cdf0e10cSrcweir     @see osl_getModuleURLFromFunctionAddress.
64cdf0e10cSrcweir */
65cdf0e10cSrcweir typedef void ( SAL_CALL *oslGenericFunction )( void );
66cdf0e10cSrcweir 
67cdf0e10cSrcweir /** Load a shared library or module.
68cdf0e10cSrcweir     @param strModuleName denotes the name of the module to be loaded.
69*ca2659a9SHerbert Dürr     @param nRtldMode mode defined by logically OR-ing of SAL_LOADMODULE_* flags.
70cdf0e10cSrcweir     @return NULL if the module could not be loaded, otherwise a handle to the module.
71cdf0e10cSrcweir */
72cdf0e10cSrcweir oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 nRtldMode);
73*ca2659a9SHerbert Dürr /** Load a shared library or module.
74*ca2659a9SHerbert Dürr     @param pModuleName denotes the name of the module to be loaded.
75*ca2659a9SHerbert Dürr     @param nRtldMode mode defined by logically OR-ing of SAL_LOADMODULE_* flags.
76*ca2659a9SHerbert Dürr     @return NULL if the module could not be loaded, otherwise a handle to the module.
77*ca2659a9SHerbert Dürr */
78*ca2659a9SHerbert Dürr oslModule SAL_CALL osl_loadAsciiModule( const sal_Char* pModuleName, sal_Int32 nRtldMode);
79cdf0e10cSrcweir 
80cdf0e10cSrcweir /** Load a module located relative to some other module.
81cdf0e10cSrcweir 
82cdf0e10cSrcweir     @param baseModule
83cdf0e10cSrcweir     must point to a function that is part of the code of some loaded module;
84cdf0e10cSrcweir     must not be NULL.
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     @param relativePath
87cdf0e10cSrcweir     a relative URL; must not be NULL.
88cdf0e10cSrcweir 
89*ca2659a9SHerbert Dürr     @param nRtldMode mode defined by logically OR-ing of SAL_LOADMODULE_* flags.
90cdf0e10cSrcweir 
91cdf0e10cSrcweir     @return
92cdf0e10cSrcweir     a non-NULL handle to the loaded module, or NULL if an error occurred.
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     @since UDK 3.2.8
95cdf0e10cSrcweir */
96cdf0e10cSrcweir oslModule SAL_CALL osl_loadModuleRelative(
97*ca2659a9SHerbert Dürr     oslGenericFunction baseModule, rtl_uString* relativePath, sal_Int32 nRtldMode);
98*ca2659a9SHerbert Dürr /** Load a module located relative to some other module.
99*ca2659a9SHerbert Dürr 
100*ca2659a9SHerbert Dürr     @param baseModule
101*ca2659a9SHerbert Dürr     must point to a function that is part of the code of some loaded module;
102*ca2659a9SHerbert Dürr     must not be NULL.
103*ca2659a9SHerbert Dürr 
104*ca2659a9SHerbert Dürr     @param relativePath
105*ca2659a9SHerbert Dürr     a relative URL; must not be NULL.
106*ca2659a9SHerbert Dürr 
107*ca2659a9SHerbert Dürr     @param nRtldMode mode defined by logically OR-ing of SAL_LOADMODULE_* flags.
108*ca2659a9SHerbert Dürr 
109*ca2659a9SHerbert Dürr     @return
110*ca2659a9SHerbert Dürr     a non-NULL handle to the loaded module, or NULL if an error occurred.
111*ca2659a9SHerbert Dürr */
112*ca2659a9SHerbert Dürr oslModule SAL_CALL osl_loadAsciiModuleRelative(
113*ca2659a9SHerbert Dürr     oslGenericFunction baseModule, const sal_Char* relativePath, sal_Int32 nRtldMode);
114cdf0e10cSrcweir 
115cdf0e10cSrcweir /** Retrieve the handle of an already loaded module.
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     This function can be used to search for a function symbol in the process address space.
118cdf0e10cSrcweir     Do not use the returned handle as an argument to osl_unloadModule. On Unix platforms,
119cdf0e10cSrcweir     pModuleName gets ignored and the special handle RTLD_DEFAULT is returned.
120cdf0e10cSrcweir 
121cdf0e10cSrcweir     @param pModuleName
122cdf0e10cSrcweir     [in] denotes the name of the module to search for. Ignored on Unix
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     @param pResult
125cdf0e10cSrcweir     [out] a pointer to a oslModule that is updated with the requested module handle
126cdf0e10cSrcweir     on success.
127cdf0e10cSrcweir 
128cdf0e10cSrcweir     @return
129cdf0e10cSrcweir     sal_True if the module handle could be retrieved and has been copied to *pResult.
130cdf0e10cSrcweir     sal_False if the module has not been loaded yet.
131cdf0e10cSrcweir 
132cdf0e10cSrcweir     @see osl_getFunctionSymbol
133cdf0e10cSrcweir     @see osl_getAsciiFunctionSymbol
134cdf0e10cSrcweir */
135cdf0e10cSrcweir sal_Bool SAL_CALL osl_getModuleHandle(rtl_uString *pModuleName, oslModule *pResult);
136cdf0e10cSrcweir 
137cdf0e10cSrcweir /** Release the module
138cdf0e10cSrcweir */
139cdf0e10cSrcweir void SAL_CALL osl_unloadModule(oslModule Module);
140cdf0e10cSrcweir 
141cdf0e10cSrcweir /** lookup the specified symbol name.
142cdf0e10cSrcweir     @return address of the symbol or NULL if lookup failed.
143cdf0e10cSrcweir */
144cdf0e10cSrcweir void* SAL_CALL osl_getSymbol( oslModule Module, rtl_uString *strSymbolName);
145cdf0e10cSrcweir 
146cdf0e10cSrcweir /** Lookup the specified function symbol name.
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     osl_getFunctionSymbol is an alternative function for osl_getSymbol.
149cdf0e10cSrcweir     Use Function pointer as symbol address to conceal type conversion.
150cdf0e10cSrcweir 
151cdf0e10cSrcweir     @param Module
152cdf0e10cSrcweir     [in] the handle of the Module.
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     @param ustrFunctionSymbolName
155cdf0e10cSrcweir     [in] Name of the function that will be looked up.
156cdf0e10cSrcweir 
157cdf0e10cSrcweir     @return
158cdf0e10cSrcweir     <dl>
159cdf0e10cSrcweir     <dt>Function address.</dt>
160cdf0e10cSrcweir     <dd>on success</dd>
161cdf0e10cSrcweir     <dt>NULL</dt>
162cdf0e10cSrcweir     <dd>lookup failed or the parameter are invalid.</dd>
163cdf0e10cSrcweir     </dl>
164cdf0e10cSrcweir 
165cdf0e10cSrcweir     @see osl_getSymbol
166cdf0e10cSrcweir     @see osl_getAsciiFunctionSymbol
167cdf0e10cSrcweir */
168cdf0e10cSrcweir oslGenericFunction SAL_CALL osl_getFunctionSymbol( oslModule Module, rtl_uString *ustrFunctionSymbolName );
169cdf0e10cSrcweir 
170cdf0e10cSrcweir /** Lookup the specified function symbol name.
171cdf0e10cSrcweir 
172cdf0e10cSrcweir     osl_getAsciiFunctionSymbol is an alternative function for osl_getFunctionSymbol.
173cdf0e10cSrcweir     It expects the C-style function name string to contain ascii characters only.
174cdf0e10cSrcweir 
175cdf0e10cSrcweir     @param Module
176cdf0e10cSrcweir     [in] a module handle as returned by osl_loadModule or osl_getModuleHandle
177cdf0e10cSrcweir 
178*ca2659a9SHerbert Dürr     @param pSymbolName
179cdf0e10cSrcweir     [in] Name of the function that will be looked up.
180cdf0e10cSrcweir 
181cdf0e10cSrcweir     @return
182cdf0e10cSrcweir     <dl>
183cdf0e10cSrcweir     <dt>Function address.</dt>
184cdf0e10cSrcweir     <dd>on success</dd>
185cdf0e10cSrcweir     <dt>NULL</dt>
186cdf0e10cSrcweir     <dd>lookup failed or the parameter are invalid.</dd>
187cdf0e10cSrcweir     </dl>
188cdf0e10cSrcweir 
189cdf0e10cSrcweir     @see osl_getModuleHandle
190cdf0e10cSrcweir     @see osl_getFunctionSymbol
191cdf0e10cSrcweir */
192*ca2659a9SHerbert Dürr oslGenericFunction SAL_CALL osl_getAsciiFunctionSymbol(oslModule Module, const sal_Char *pSymbolName);
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 
195cdf0e10cSrcweir /** Lookup URL of module which is mapped at the specified address.
196cdf0e10cSrcweir     @param pv specifies an address in the process memory space.
197cdf0e10cSrcweir     @param pustrURL receives the URL of the module that is mapped at pv.
198cdf0e10cSrcweir     @return sal_True on success, sal_False if no module can be found at the specified address.
199cdf0e10cSrcweir */
200cdf0e10cSrcweir sal_Bool SAL_CALL osl_getModuleURLFromAddress( void *pv, rtl_uString **pustrURL );
201cdf0e10cSrcweir 
202cdf0e10cSrcweir /** Lookup URL of module which is mapped at the specified function address.
203cdf0e10cSrcweir 
204cdf0e10cSrcweir     osl_getModuleURLFromFunctionAddress is an alternative function for osl_getModuleURLFromAddress.
205cdf0e10cSrcweir     Use Function pointer as symbol address to conceal type conversion.
206cdf0e10cSrcweir 
207cdf0e10cSrcweir     @param pf
208cdf0e10cSrcweir     [in] function address in oslGenericFunction format.
209cdf0e10cSrcweir 
210cdf0e10cSrcweir     @param pustrFunctionURL
211cdf0e10cSrcweir     [out] receives the URL of the module that is mapped at pf.
212cdf0e10cSrcweir 
213cdf0e10cSrcweir     @return
214cdf0e10cSrcweir     <dl>
215cdf0e10cSrcweir     <dt>sal_True</dt>
216cdf0e10cSrcweir     <dd>on success</dd>
217cdf0e10cSrcweir     <dt>sal_False</dt>
218cdf0e10cSrcweir     <dd>no module can be found at the specified function address or parameter is somewhat invalid.</dd>
219cdf0e10cSrcweir     </dl>
220cdf0e10cSrcweir 
221cdf0e10cSrcweir     @see osl_getModuleURLFromAddress
222cdf0e10cSrcweir */
223cdf0e10cSrcweir sal_Bool SAL_CALL osl_getModuleURLFromFunctionAddress( oslGenericFunction pf, rtl_uString **pustrFunctionURL );
224cdf0e10cSrcweir 
225cdf0e10cSrcweir #ifdef __cplusplus
226cdf0e10cSrcweir }
227cdf0e10cSrcweir #endif
228cdf0e10cSrcweir 
229cdf0e10cSrcweir #endif  /* _OSL_MODULE_H_  */
230