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