1*9eab2a37SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9eab2a37SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9eab2a37SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9eab2a37SAndrew Rist * distributed with this work for additional information 6*9eab2a37SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9eab2a37SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9eab2a37SAndrew Rist * "License"); you may not use this file except in compliance 9*9eab2a37SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*9eab2a37SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*9eab2a37SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9eab2a37SAndrew Rist * software distributed under the License is distributed on an 15*9eab2a37SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9eab2a37SAndrew Rist * KIND, either express or implied. See the License for the 17*9eab2a37SAndrew Rist * specific language governing permissions and limitations 18*9eab2a37SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*9eab2a37SAndrew Rist *************************************************************/ 21*9eab2a37SAndrew Rist 22*9eab2a37SAndrew 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. 69cdf0e10cSrcweir @return NULL if the module could not be loaded, otherwise a handle to the module. 70cdf0e10cSrcweir */ 71cdf0e10cSrcweir oslModule SAL_CALL osl_loadModule(rtl_uString *strModuleName, sal_Int32 nRtldMode); 72cdf0e10cSrcweir 73cdf0e10cSrcweir /** Load a module located relative to some other module. 74cdf0e10cSrcweir 75cdf0e10cSrcweir @param baseModule 76cdf0e10cSrcweir must point to a function that is part of the code of some loaded module; 77cdf0e10cSrcweir must not be NULL. 78cdf0e10cSrcweir 79cdf0e10cSrcweir @param relativePath 80cdf0e10cSrcweir a relative URL; must not be NULL. 81cdf0e10cSrcweir 82cdf0e10cSrcweir @param mode 83cdf0e10cSrcweir the SAL_LOADMODULE_xxx flags. 84cdf0e10cSrcweir 85cdf0e10cSrcweir @return 86cdf0e10cSrcweir a non-NULL handle to the loaded module, or NULL if an error occurred. 87cdf0e10cSrcweir 88cdf0e10cSrcweir @since UDK 3.2.8 89cdf0e10cSrcweir */ 90cdf0e10cSrcweir oslModule SAL_CALL osl_loadModuleRelative( 91cdf0e10cSrcweir oslGenericFunction baseModule, rtl_uString * relativePath, sal_Int32 mode); 92cdf0e10cSrcweir 93cdf0e10cSrcweir /** Retrieve the handle of an already loaded module. 94cdf0e10cSrcweir 95cdf0e10cSrcweir This function can be used to search for a function symbol in the process address space. 96cdf0e10cSrcweir Do not use the returned handle as an argument to osl_unloadModule. On Unix platforms, 97cdf0e10cSrcweir pModuleName gets ignored and the special handle RTLD_DEFAULT is returned. 98cdf0e10cSrcweir 99cdf0e10cSrcweir @param pModuleName 100cdf0e10cSrcweir [in] denotes the name of the module to search for. Ignored on Unix 101cdf0e10cSrcweir 102cdf0e10cSrcweir @param pResult 103cdf0e10cSrcweir [out] a pointer to a oslModule that is updated with the requested module handle 104cdf0e10cSrcweir on success. 105cdf0e10cSrcweir 106cdf0e10cSrcweir @return 107cdf0e10cSrcweir sal_True if the module handle could be retrieved and has been copied to *pResult. 108cdf0e10cSrcweir sal_False if the module has not been loaded yet. 109cdf0e10cSrcweir 110cdf0e10cSrcweir @see osl_getFunctionSymbol 111cdf0e10cSrcweir @see osl_getAsciiFunctionSymbol 112cdf0e10cSrcweir */ 113cdf0e10cSrcweir sal_Bool SAL_CALL osl_getModuleHandle(rtl_uString *pModuleName, oslModule *pResult); 114cdf0e10cSrcweir 115cdf0e10cSrcweir /** Release the module 116cdf0e10cSrcweir */ 117cdf0e10cSrcweir void SAL_CALL osl_unloadModule(oslModule Module); 118cdf0e10cSrcweir 119cdf0e10cSrcweir /** lookup the specified symbol name. 120cdf0e10cSrcweir @return address of the symbol or NULL if lookup failed. 121cdf0e10cSrcweir */ 122cdf0e10cSrcweir void* SAL_CALL osl_getSymbol( oslModule Module, rtl_uString *strSymbolName); 123cdf0e10cSrcweir 124cdf0e10cSrcweir /** Lookup the specified function symbol name. 125cdf0e10cSrcweir 126cdf0e10cSrcweir osl_getFunctionSymbol is an alternative function for osl_getSymbol. 127cdf0e10cSrcweir Use Function pointer as symbol address to conceal type conversion. 128cdf0e10cSrcweir 129cdf0e10cSrcweir @param Module 130cdf0e10cSrcweir [in] the handle of the Module. 131cdf0e10cSrcweir 132cdf0e10cSrcweir @param ustrFunctionSymbolName 133cdf0e10cSrcweir [in] Name of the function that will be looked up. 134cdf0e10cSrcweir 135cdf0e10cSrcweir @return 136cdf0e10cSrcweir <dl> 137cdf0e10cSrcweir <dt>Function address.</dt> 138cdf0e10cSrcweir <dd>on success</dd> 139cdf0e10cSrcweir <dt>NULL</dt> 140cdf0e10cSrcweir <dd>lookup failed or the parameter are invalid.</dd> 141cdf0e10cSrcweir </dl> 142cdf0e10cSrcweir 143cdf0e10cSrcweir @see osl_getSymbol 144cdf0e10cSrcweir @see osl_getAsciiFunctionSymbol 145cdf0e10cSrcweir */ 146cdf0e10cSrcweir oslGenericFunction SAL_CALL osl_getFunctionSymbol( oslModule Module, rtl_uString *ustrFunctionSymbolName ); 147cdf0e10cSrcweir 148cdf0e10cSrcweir /** Lookup the specified function symbol name. 149cdf0e10cSrcweir 150cdf0e10cSrcweir osl_getAsciiFunctionSymbol is an alternative function for osl_getFunctionSymbol. 151cdf0e10cSrcweir It expects the C-style function name string to contain ascii characters only. 152cdf0e10cSrcweir 153cdf0e10cSrcweir @param Module 154cdf0e10cSrcweir [in] a module handle as returned by osl_loadModule or osl_getModuleHandle 155cdf0e10cSrcweir 156cdf0e10cSrcweir @param pFunctionSymbolName 157cdf0e10cSrcweir [in] Name of the function that will be looked up. 158cdf0e10cSrcweir 159cdf0e10cSrcweir @return 160cdf0e10cSrcweir <dl> 161cdf0e10cSrcweir <dt>Function address.</dt> 162cdf0e10cSrcweir <dd>on success</dd> 163cdf0e10cSrcweir <dt>NULL</dt> 164cdf0e10cSrcweir <dd>lookup failed or the parameter are invalid.</dd> 165cdf0e10cSrcweir </dl> 166cdf0e10cSrcweir 167cdf0e10cSrcweir @see osl_getModuleHandle 168cdf0e10cSrcweir @see osl_getFunctionSymbol 169cdf0e10cSrcweir */ 170cdf0e10cSrcweir oslGenericFunction SAL_CALL osl_getAsciiFunctionSymbol(oslModule Module, const sal_Char *pSymbol); 171cdf0e10cSrcweir 172cdf0e10cSrcweir 173cdf0e10cSrcweir /** Lookup URL of module which is mapped at the specified address. 174cdf0e10cSrcweir @param pv specifies an address in the process memory space. 175cdf0e10cSrcweir @param pustrURL receives the URL of the module that is mapped at pv. 176cdf0e10cSrcweir @return sal_True on success, sal_False if no module can be found at the specified address. 177cdf0e10cSrcweir */ 178cdf0e10cSrcweir sal_Bool SAL_CALL osl_getModuleURLFromAddress( void *pv, rtl_uString **pustrURL ); 179cdf0e10cSrcweir 180cdf0e10cSrcweir /** Lookup URL of module which is mapped at the specified function address. 181cdf0e10cSrcweir 182cdf0e10cSrcweir osl_getModuleURLFromFunctionAddress is an alternative function for osl_getModuleURLFromAddress. 183cdf0e10cSrcweir Use Function pointer as symbol address to conceal type conversion. 184cdf0e10cSrcweir 185cdf0e10cSrcweir @param pf 186cdf0e10cSrcweir [in] function address in oslGenericFunction format. 187cdf0e10cSrcweir 188cdf0e10cSrcweir @param pustrFunctionURL 189cdf0e10cSrcweir [out] receives the URL of the module that is mapped at pf. 190cdf0e10cSrcweir 191cdf0e10cSrcweir @return 192cdf0e10cSrcweir <dl> 193cdf0e10cSrcweir <dt>sal_True</dt> 194cdf0e10cSrcweir <dd>on success</dd> 195cdf0e10cSrcweir <dt>sal_False</dt> 196cdf0e10cSrcweir <dd>no module can be found at the specified function address or parameter is somewhat invalid.</dd> 197cdf0e10cSrcweir </dl> 198cdf0e10cSrcweir 199cdf0e10cSrcweir @see osl_getModuleURLFromAddress 200cdf0e10cSrcweir */ 201cdf0e10cSrcweir sal_Bool SAL_CALL osl_getModuleURLFromFunctionAddress( oslGenericFunction pf, rtl_uString **pustrFunctionURL ); 202cdf0e10cSrcweir 203cdf0e10cSrcweir #ifdef __cplusplus 204cdf0e10cSrcweir } 205cdf0e10cSrcweir #endif 206cdf0e10cSrcweir 207cdf0e10cSrcweir #endif /* _OSL_MODULE_H_ */ 208