1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 /** @HTML */ 29 30 #ifndef _OSL_MODULE_H_ 31 #define _OSL_MODULE_H_ 32 33 # include <rtl/ustring.h> 34 # include <rtl/tencinfo.h> 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 #ifdef SAL_DLLPREFIX 41 #define SAL_MODULENAME(name) SAL_DLLPREFIX name SAL_DLLEXTENSION 42 #else 43 #define SAL_MODULENAME(name) name SAL_DLLEXTENSION 44 #endif 45 46 #if defined(SAL_W32) || defined(SAL_OS2) 47 #define SAL_MODULENAME_WITH_VERSION(name, version) name version SAL_DLLEXTENSION 48 49 #elif defined(SAL_UNX) 50 #if defined(MACOSX) 51 #define SAL_MODULENAME_WITH_VERSION(name, version) SAL_DLLPREFIX name ".dylib." version 52 #else 53 #define SAL_MODULENAME_WITH_VERSION(name, version) SAL_DLLPREFIX name SAL_DLLEXTENSION "." version 54 #endif 55 56 #endif 57 58 #define SAL_LOADMODULE_DEFAULT 0x00000 59 #define SAL_LOADMODULE_LAZY 0x00001 60 #define SAL_LOADMODULE_NOW 0x00002 61 #define SAL_LOADMODULE_GLOBAL 0x00100 62 63 typedef void* oslModule; 64 65 /** Generic Function pointer type that will be used as symbol address. 66 @see osl_getFunctionSymbol. 67 @see osl_getModuleURLFromFunctionAddress. 68 */ 69 typedef void ( SAL_CALL *oslGenericFunction )( void ); 70 71 /** Load a shared library or module. 72 @param strModuleName denotes the name of the module to be loaded. 73 @return NULL if the module could not be loaded, otherwise a handle to the module. 74 */ 75 oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 nRtldMode); 76 77 /** Load a module located relative to some other module. 78 79 @param baseModule 80 must point to a function that is part of the code of some loaded module; 81 must not be NULL. 82 83 @param relativePath 84 a relative URL; must not be NULL. 85 86 @param mode 87 the SAL_LOADMODULE_xxx flags. 88 89 @return 90 a non-NULL handle to the loaded module, or NULL if an error occurred. 91 92 @since UDK 3.2.8 93 */ 94 oslModule SAL_CALL osl_loadModuleRelative( 95 oslGenericFunction baseModule, rtl_uString * relativePath, sal_Int32 mode); 96 97 /** Retrieve the handle of an already loaded module. 98 99 This function can be used to search for a function symbol in the process address space. 100 Do not use the returned handle as an argument to osl_unloadModule. On Unix platforms, 101 pModuleName gets ignored and the special handle RTLD_DEFAULT is returned. 102 103 @param pModuleName 104 [in] denotes the name of the module to search for. Ignored on Unix 105 106 @param pResult 107 [out] a pointer to a oslModule that is updated with the requested module handle 108 on success. 109 110 @return 111 sal_True if the module handle could be retrieved and has been copied to *pResult. 112 sal_False if the module has not been loaded yet. 113 114 @see osl_getFunctionSymbol 115 @see osl_getAsciiFunctionSymbol 116 */ 117 sal_Bool SAL_CALL osl_getModuleHandle(rtl_uString *pModuleName, oslModule *pResult); 118 119 /** Release the module 120 */ 121 void SAL_CALL osl_unloadModule(oslModule Module); 122 123 /** lookup the specified symbol name. 124 @return address of the symbol or NULL if lookup failed. 125 */ 126 void* SAL_CALL osl_getSymbol( oslModule Module, rtl_uString *strSymbolName); 127 128 /** Lookup the specified function symbol name. 129 130 osl_getFunctionSymbol is an alternative function for osl_getSymbol. 131 Use Function pointer as symbol address to conceal type conversion. 132 133 @param Module 134 [in] the handle of the Module. 135 136 @param ustrFunctionSymbolName 137 [in] Name of the function that will be looked up. 138 139 @return 140 <dl> 141 <dt>Function address.</dt> 142 <dd>on success</dd> 143 <dt>NULL</dt> 144 <dd>lookup failed or the parameter are invalid.</dd> 145 </dl> 146 147 @see osl_getSymbol 148 @see osl_getAsciiFunctionSymbol 149 */ 150 oslGenericFunction SAL_CALL osl_getFunctionSymbol( oslModule Module, rtl_uString *ustrFunctionSymbolName ); 151 152 /** Lookup the specified function symbol name. 153 154 osl_getAsciiFunctionSymbol is an alternative function for osl_getFunctionSymbol. 155 It expects the C-style function name string to contain ascii characters only. 156 157 @param Module 158 [in] a module handle as returned by osl_loadModule or osl_getModuleHandle 159 160 @param pFunctionSymbolName 161 [in] Name of the function that will be looked up. 162 163 @return 164 <dl> 165 <dt>Function address.</dt> 166 <dd>on success</dd> 167 <dt>NULL</dt> 168 <dd>lookup failed or the parameter are invalid.</dd> 169 </dl> 170 171 @see osl_getModuleHandle 172 @see osl_getFunctionSymbol 173 */ 174 oslGenericFunction SAL_CALL osl_getAsciiFunctionSymbol(oslModule Module, const sal_Char *pSymbol); 175 176 177 /** Lookup URL of module which is mapped at the specified address. 178 @param pv specifies an address in the process memory space. 179 @param pustrURL receives the URL of the module that is mapped at pv. 180 @return sal_True on success, sal_False if no module can be found at the specified address. 181 */ 182 sal_Bool SAL_CALL osl_getModuleURLFromAddress( void *pv, rtl_uString **pustrURL ); 183 184 /** Lookup URL of module which is mapped at the specified function address. 185 186 osl_getModuleURLFromFunctionAddress is an alternative function for osl_getModuleURLFromAddress. 187 Use Function pointer as symbol address to conceal type conversion. 188 189 @param pf 190 [in] function address in oslGenericFunction format. 191 192 @param pustrFunctionURL 193 [out] receives the URL of the module that is mapped at pf. 194 195 @return 196 <dl> 197 <dt>sal_True</dt> 198 <dd>on success</dd> 199 <dt>sal_False</dt> 200 <dd>no module can be found at the specified function address or parameter is somewhat invalid.</dd> 201 </dl> 202 203 @see osl_getModuleURLFromAddress 204 */ 205 sal_Bool SAL_CALL osl_getModuleURLFromFunctionAddress( oslGenericFunction pf, rtl_uString **pustrFunctionURL ); 206 207 #ifdef __cplusplus 208 } 209 #endif 210 211 #endif /* _OSL_MODULE_H_ */ 212