LibraryLoader* DllLoaderContainer::LoadDll(const char* sName, bool bLoadSymbols) { #ifdef LOGALL CLog::Log(LOGDEBUG, "Loading dll %s", sName); #endif LibraryLoader* pLoader; #ifdef _LINUX if (strstr(sName, ".so") != NULL || strstr(sName, ".vis") != NULL || strstr(sName, ".xbs") != NULL || strstr(sName, ".mvis") != NULL || strstr(sName, ".dylib") != NULL || strstr(sName, ".framework") != NULL || strstr(sName, ".pvr") != NULL) pLoader = new SoLoader(sName, bLoadSymbols); else #elif defined(_WIN32) if (1) pLoader = new Win32DllLoader(sName); else #endif pLoader = new DllLoader(sName, m_bTrack, false, bLoadSymbols); if (!pLoader) { CLog::Log(LOGERROR, "Unable to create dll %s", sName); return NULL; } if (!pLoader->Load()) { delete pLoader; return NULL; } return pLoader; }
//to do LibraryLoader* LoaderContainer::LoadDll(const char* sName, bool bLoadSymbols) { #ifdef LOGALL LOGDEBUG("Loading dll %s", sName); #endif LibraryLoader* pLoader = new Win32DllLoader(sName); if (!pLoader) { LOGERR("Unable to create dll %s", sName); return NULL; } if (!pLoader->Load()) { delete pLoader; return NULL; } #ifdef LOGALL LOGDEBUG("Dll %s has been succesfully loaded.", sName); #endif return pLoader; }
extern "C" HMODULE WINAPI dllGetModuleHandleA(LPCSTR lpModuleName) { /* If the file name extension is omitted, the default library extension .dll is appended. The file name string can include a trailing point character (.) to indicate that the module name has no extension. The string does not have to specify a path. When specifying a path, be sure to use backslashes (\), not forward slashes (/). The name is compared (case independently) If this parameter is NULL, GetModuleHandle returns a handle to the file used to create the calling process (.exe file). */ if( lpModuleName == NULL ) return NULL; char* strModuleName = new char[strlen(lpModuleName) + 5]; strcpy(strModuleName, lpModuleName); if (strrchr(strModuleName, '.') == 0) strcat(strModuleName, ".dll"); //CLog::Log(LOGDEBUG, "GetModuleHandleA(%s) .. looking up", lpModuleName); LibraryLoader *p = DllLoaderContainer::GetModule(strModuleName); delete []strModuleName; if (p) { //CLog::Log(LOGDEBUG, "GetModuleHandleA('%s') => 0x%x", lpModuleName, h); return (HMODULE)p->GetHModule(); } CLog::Log(LOGDEBUG, "GetModuleHandleA('%s') failed", lpModuleName); return NULL; }
bool Win32DllLoader::NeedsHooking(const char *dllName) { LibraryLoader *loader = DllLoaderContainer::GetModule(dllName); if (loader) { // may have hooked this already (we can have repeats in the import table) for (unsigned int i = 0; i < m_referencedDlls.size(); i++) { if (loader->GetHModule() == m_referencedDlls[i]) return false; } } std::wstring strdllNameW; g_charsetConverter.utf8ToW(CSpecialProtocol::TranslatePath(dllName), strdllNameW, false); HMODULE hModule = GetModuleHandleW(strdllNameW.c_str()); if (hModule == NULL) return false; wchar_t filepathW[MAX_PATH]; GetModuleFileNameW(hModule, filepathW, MAX_PATH); std::string dllPath; g_charsetConverter.wToUTF8(filepathW, dllPath); // compare this filepath with some special directories std::string xbmcPath = CSpecialProtocol::TranslatePath("special://xbmc"); std::string homePath = CSpecialProtocol::TranslatePath("special://home"); std::string tempPath = CSpecialProtocol::TranslatePath("special://temp"); return (StringUtils::StartsWith(dllPath, xbmcPath) || StringUtils::StartsWith(dllPath, homePath) || StringUtils::StartsWith(dllPath, tempPath)); }
bool Win32DllLoader::NeedsHooking(const char *dllName) { LibraryLoader *loader = DllLoaderContainer::GetModule(dllName); if (loader) { // may have hooked this already (we can have repeats in the import table) for (unsigned int i = 0; i < m_referencedDlls.size(); i++) { if (loader->GetHModule() == m_referencedDlls[i]) return false; } } CStdStringW strdllNameW; g_charsetConverter.utf8ToW(_P(dllName), strdllNameW, false); HMODULE hModule = GetModuleHandleW(strdllNameW.c_str()); wchar_t filepathW[MAX_PATH]; GetModuleFileNameW(hModule, filepathW, MAX_PATH); CStdString dllPath; g_charsetConverter.wToUTF8(filepathW, dllPath); // compare this filepath with some special directories CStdString xbmcPath = _P("special://xbmc"); CStdString homePath = _P("special://home"); CStdString tempPath = _P("special://temp"); return ((strncmp(xbmcPath.c_str(), dllPath.c_str(), xbmcPath.GetLength()) == 0) || (strncmp(homePath.c_str(), dllPath.c_str(), homePath.GetLength()) == 0) || (strncmp(tempPath.c_str(), dllPath.c_str(), tempPath.GetLength()) == 0)); }
extern "C" DWORD WINAPI dllGetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize) { if (NULL == hModule) { strncpy(lpFilename, "xbmc.xbe", nSize); CLog::Log(LOGDEBUG, "GetModuleFileNameA(%p, %p, %u) => '%s'\n", hModule, lpFilename, nSize, lpFilename); return 8; } LibraryLoader* dll = DllLoaderContainer::GetModule(hModule); if( !dll ) { CLog::Log(LOGERROR, "%s - Invalid hModule specified", __FUNCTION__); return 0; } char* sName = dll->GetFileName(); if (sName) { strncpy(lpFilename, sName, nSize); return strlen(lpFilename); } return 0; }
LibraryLoader* DllLoaderContainer::LoadDll(const char* sName, bool bLoadSymbols) { #ifdef LOGALL CLog::Log(LOGDEBUG, "Loading dll %s", sName); #endif LibraryLoader* pLoader; #ifdef TARGET_POSIX pLoader = new SoLoader(sName, bLoadSymbols); #elif defined(TARGET_WINDOWS) pLoader = new Win32DllLoader(sName, false); #else pLoader = new DllLoader(sName, m_bTrack, false, bLoadSymbols); #endif if (!pLoader) { CLog::Log(LOGERROR, "Unable to create dll %s", sName); return NULL; } if (!pLoader->Load()) { delete pLoader; return NULL; } return pLoader; }
void Project::slotNewProject() { QString fileName = QFileDialog::getSaveFileName(this, tr("New Project"), "", tr("Qucs Projects (*.xpro)")); if(!fileName.isEmpty()) { if(QString(QFileInfo(fileName).suffix()).isEmpty()) { fileName = fileName + ".xpro"; } //First we create the folder structure where files are to be placed QFileInfo fileInfo = QFileInfo(fileName); QDir filePath = QDir(fileInfo.absolutePath() + "/" + fileInfo.baseName()); if(!filePath.exists()) { filePath.setPath(fileInfo.absolutePath()); filePath.mkdir(fileInfo.baseName()); } fileName = fileInfo.absolutePath() + "/" + fileInfo.baseName() + "/" + fileInfo.fileName(); //Then we create the library/project LibraryLoader *library = LibraryLoader::instance(); if(library->newLibrary(fileName)) { slotCloseProject(); setCurrentLibrary(fileName); projectLibrary = library->library(m_libraryName); projectLibrary->saveLibrary(); qDebug() << "Succesfully created library!"; m_projectsSidebar->plugLibrary(m_libraryName, "root"); } } }
extern "C" DWORD WINAPI dllGetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize) { if (NULL == hModule) { #ifdef _WIN32 return GetModuleFileNameA(hModule, lpFilename, nSize); #else CLog::Log(LOGDEBUG, "%s - No hModule specified", __FUNCTION__); return 0; #endif } LibraryLoader* dll = DllLoaderContainer::GetModule(hModule); if( !dll ) { CLog::Log(LOGERROR, "%s - Invalid hModule specified", __FUNCTION__); return 0; } char* sName = dll->GetFileName(); if (sName) { strncpy(lpFilename, sName, nSize); return strlen(lpFilename); } return 0; }
extern "C" HMODULE __stdcall dllLoadLibraryExtended(LPCSTR lib_file, LPCSTR sourcedll) { char libname[MAX_PATH + 1] = {}; char libpath[MAX_PATH + 1] = {}; LibraryLoader* dll = NULL; /* extract name */ const char* p = strrchr(lib_file, PATH_SEPARATOR_CHAR); if (p) strcpy(libname, p+1); else strcpy(libname, lib_file); if( libname[0] == '\0' ) return NULL; /* extract path */ getpath(libpath, lib_file); CLog::Log(LOGDEBUG, "LoadLibraryA('%s')", libname); if (sourcedll) { /* also check for invalid paths wich begin with a \ */ if( libpath[0] == '\0' || libpath[0] == PATH_SEPARATOR_CHAR ) { /* use calling dll's path as base address for this call */ getpath(libpath, sourcedll); /* mplayer has all it's dlls in a codecs subdirectory */ if (strstr(sourcedll, "mplayer.dll")) strcat(libpath, "codecs\\"); } } /* if we still don't have a path, use default path */ if( libpath[0] == '\0' ) strcpy(libpath, DEFAULT_DLLPATH); /* msdn docs state */ /* "If no file name extension is specified in the lpFileName parameter, the default library extension .dll is appended. */ /* However, the file name string can include a trailing point character (.) to indicate that the module name has no extension." */ if( strrchr(libname, '.') == NULL ) strcat(libname, ".dll"); else if( libname[strlen(libname)-1] == '.' ) libname[strlen(libname)-1] = '\0'; dll = DllLoaderContainer::LoadModule(libname, libpath); if (dll) { CLog::Log(LOGDEBUG, "LoadLibrary('%s') returning: %p", libname, (void*)dll); return (HMODULE)dll->GetHModule(); } CLog::Log(LOGERROR, "LoadLibrary('%s') failed", libname); return NULL; }
void *xbp_dlsym(void *handle, const char *symbol) { LibraryLoader *pDll = (LibraryLoader*)handle; CLog::Log(LOGDEBUG,"%s - load symbol %s", __FUNCTION__, symbol); void *f = NULL; if (pDll && pDll->ResolveExport(symbol, &f)) return f; return NULL; }
void Project::slotCloseProject() { if(projectLibrary) { m_projectsSidebar->unPlugLibrary(m_libraryName, "root"); LibraryLoader *library = LibraryLoader::instance(); library->unload(m_libraryName); projectLibrary = 0; m_libraryFileName = ""; m_libraryName = ""; } }
int xbp_dlclose(void *handle) { #ifdef HAS_PYTHON LibraryLoader *pDll = (LibraryLoader*)handle; CLog::Log(LOGDEBUG,"%s - releasing python library %s", __FUNCTION__, pDll->GetName()); g_pythonParser.UnregisterExtensionLib(pDll); DllLoaderContainer::ReleaseModule(pDll); return 0; #else CLog::Log(LOGDEBUG,"Cannot release python lib because python isnt being used!"); return NULL; #endif }
extern "C" int __stdcall dllFreeLibrary(HINSTANCE hLibModule) { LibraryLoader* dllhandle = DllLoaderContainer::GetModule(hLibModule); if( !dllhandle ) { CLog::Log(LOGERROR, "%s - Invalid hModule specified",__FUNCTION__); return 1; } // to make sure systems dlls are never deleted if (dllhandle->IsSystemDll()) return 1; DllLoaderContainer::ReleaseModule(dllhandle); return 1; }
bool Win32DllLoader::NeedsHooking(const char *dllName) { if ( !StringUtils::EndsWithNoCase(dllName, "libdvdcss-2.dll") && !StringUtils::EndsWithNoCase(dllName, "libdvdnav.dll")) return false; LibraryLoader *loader = DllLoaderContainer::GetModule(dllName); if (loader) { // may have hooked this already (we can have repeats in the import table) for (unsigned int i = 0; i < m_referencedDlls.size(); i++) { if (loader->GetHModule() == m_referencedDlls[i]) return false; } } return true; }
void DllLoaderContainer::UnloadPythonDlls() { // unload all dlls that python24.dll could have loaded for (int i = 0; m_dlls[i] != NULL && i < m_iNrOfDlls; i++) { char* name = m_dlls[i]->GetName(); if (strstr(name, ".pyd") != NULL) { LibraryLoader* pDll = m_dlls[i]; ReleaseModule(pDll); i = 0; } } // last dll to unload, python24.dll for (int i = 0; m_dlls[i] != NULL && i < m_iNrOfDlls; i++) { char* name = m_dlls[i]->GetName(); #ifdef HAVE_LIBPYTHON2_6 if (strstr(name, "python26.dll") != NULL) #else if (strstr(name, "python24.dll") != NULL) #endif { LibraryLoader* pDll = m_dlls[i]; pDll->IncrRef(); while (pDll->DecrRef() > 1) pDll->DecrRef(); // since we freed all python extension dlls first, we have to remove any associations with them first DllTrackInfo* info = tracker_get_dlltrackinfo_byobject((DllLoader*) pDll); if (info != NULL) { info->dllList.clear(); } ReleaseModule(pDll); break; } } }
void Project::slotOpenProject(QString fileName) { if(fileName == 0) { fileName = QFileDialog::getOpenFileName(this, tr("Open Project"), "", tr("Qucs Projects (*.xpro)")); } if(!fileName.isEmpty()) { LibraryLoader *library = LibraryLoader::instance(); if(library->load(fileName)) { slotCloseProject(); setCurrentLibrary(fileName); projectLibrary = library->library(m_libraryName); qDebug() << "Succesfully loaded library!"; m_projectsSidebar->plugLibrary(m_libraryName, "root"); } } }
void ImportParseTreeTraverser::traverse(Node* tree, ClassSpaceSymbolTable& classes, LibraryLoader& l, ErrorTracker& errors, std::string importpath) { switch(tree->node_type) { case NT_PROGRAM: case NT_IMPORTSET: case NT_IMPORT: for(int i = 0; i < tree->subnodes; i++) { traverse(tree->node_data.nodes[i], classes, l, errors, importpath); } break; case NT_IMPORTPATH: // TODO use actual path if(!l.loadImport(tree->node_data.string, importpath, classes)) { errors.addError(new SemanticError(BAD_IMPORT, "Could not import class by name " + string(tree->node_data.string), tree)); } break; //case NT_IMPORTTARGET: //throw "Not supported yet"; } }
extern "C" void tracker_library_free_all(DllTrackInfo* pInfo) { // unloading unloaded dll's if (!pInfo->dllList.empty()) { CSingleLock lock(g_trackerLock); CLog::Log(LOGDEBUG,"%s: Detected %"PRIdS" unloaded dll's", pInfo->pDll->GetFileName(), pInfo->dllList.size()); for (DllListIter it = pInfo->dllList.begin(); it != pInfo->dllList.end(); ++it) { LibraryLoader* pDll = DllLoaderContainer::GetModule((HMODULE)*it); if( !pDll) { CLog::Log(LOGERROR, "%s - Invalid module in tracker", __FUNCTION__); return; } if (!pDll->IsSystemDll()) { if (strlen(pDll->GetFileName()) > 0) CLog::Log(LOGDEBUG," : %s", pDll->GetFileName()); } } // now unload the dlls for (DllListIter it = pInfo->dllList.begin(); it != pInfo->dllList.end(); ++it) { LibraryLoader* pDll = DllLoaderContainer::GetModule((HMODULE)*it); if( !pDll) { CLog::Log(LOGERROR, "%s - Invalid module in tracker", __FUNCTION__); return; } if (!pDll->IsSystemDll()) { dllFreeLibrary((HMODULE)pDll->GetHModule()); } } } }
bool python_load_dll(LibraryLoader& dll) { bool bResult; bResult = ( dll.ResolveExport(DLL_FUNCTION(PyEval_ReleaseLock)) && dll.ResolveExport(DLL_FUNCTION(PyEval_AcquireLock)) && dll.ResolveExport(DLL_FUNCTION(PyThreadState_Get)) && dll.ResolveExport(DLL_FUNCTION(PyRun_SimpleString)) && dll.ResolveExport(DLL_FUNCTION(PyEval_InitThreads)) && dll.ResolveExport(DLL_FUNCTION(PyEval_ThreadsInitialized)) && dll.ResolveExport(DLL_FUNCTION(Py_Initialize)) && dll.ResolveExport(DLL_FUNCTION(Py_IsInitialized)) && dll.ResolveExport(DLL_FUNCTION(Py_Finalize)) && dll.ResolveExport(DLL_FUNCTION(Py_NewInterpreter)) && dll.ResolveExport(DLL_FUNCTION(Py_EndInterpreter)) && dll.ResolveExport(DLL_FUNCTION(PyThreadState_Swap)) && dll.ResolveExport(DLL_FUNCTION(PyErr_SetString)) && dll.ResolveExport(DLL_FUNCTION(PyThreadState_New)) && dll.ResolveExport(DLL_FUNCTION(PyErr_Print)) && dll.ResolveExport(DLL_FUNCTION(PyErr_Occurred)) && dll.ResolveExport(DLL_FUNCTION(PyRun_SimpleFile)) && dll.ResolveExport(DLL_FUNCTION(PySys_SetPath)) && dll.ResolveExport(DLL_FUNCTION(Py_GetPath)) && dll.ResolveExport(DLL_FUNCTION(PyThreadState_Delete)) && dll.ResolveExport(DLL_FUNCTION(PyThreadState_Clear)) && dll.ResolveExport(DLL_VA_FUNCTION(Py_BuildValue)) && dll.ResolveExport(DLL_FUNCTION(PyType_IsSubtype)) && dll.ResolveExport(DLL_VA_FUNCTION(PyArg_ParseTupleAndKeywords)) && dll.ResolveExport(DLL_FUNCTION(PyString_AsString)) && dll.ResolveExport(DLL_FUNCTION(Py_AddPendingCall)) && dll.ResolveExport(DLL_VA_FUNCTION(PyObject_CallMethod)) && dll.ResolveExport(DLL_FUNCTION(PyList_GetItem)) && dll.ResolveExport(DLL_FUNCTION(PyList_Size)) && dll.ResolveExport(DLL_FUNCTION(PyList_New)) && dll.ResolveExport(DLL_FUNCTION(PyList_Append)) && dll.ResolveExport(DLL_FUNCTION(_PyObject_New)) && dll.ResolveExport(DLL_FUNCTION(PyLong_AsLong)) && dll.ResolveExport(DLL_FUNCTION(PyLong_AsLongLong)) && dll.ResolveExport(DLL_VA_FUNCTION(PyErr_Format)) && #ifndef _LINUX dll.ResolveExport(DLL_FUNCTION(PyUnicodeUCS2_AsUTF8String)) && dll.ResolveExport(DLL_FUNCTION(PyUnicodeUCS2_DecodeUTF8)) && #else dll.ResolveExport(DLL_FUNCTION(PyUnicodeUCS4_AsUTF8String)) && dll.ResolveExport(DLL_FUNCTION(PyUnicodeUCS4_DecodeUTF8)) && #endif dll.ResolveExport(DLL_FUNCTION(Py_MakePendingCalls)) && dll.ResolveExport(DLL_FUNCTION(PyEval_SaveThread)) && dll.ResolveExport(DLL_FUNCTION(PyEval_RestoreThread)) && dll.ResolveExport(DLL_FUNCTION(PyLong_FromLong)) && dll.ResolveExport(DLL_FUNCTION(PyModule_AddStringConstant)) && dll.ResolveExport(DLL_FUNCTION(PyModule_AddObject)) && dll.ResolveExport(DLL_FUNCTION(Py_InitModule4)) && dll.ResolveExport(DLL_FUNCTION(PyInt_AsLong)) && dll.ResolveExport(DLL_FUNCTION(PyFloat_AsDouble)) && dll.ResolveExport(DLL_FUNCTION(PyString_FromString)) && dll.ResolveExport(DLL_FUNCTION(PyBool_FromLong)) && dll.ResolveExport(DLL_FUNCTION(PyModule_AddIntConstant)) && dll.ResolveExport(DLL_VA_FUNCTION(PyObject_CallFunction)) && dll.ResolveExport(DLL_FUNCTION(PyDict_SetItemString)) && dll.ResolveExport(DLL_FUNCTION(PyDict_New)) && dll.ResolveExport(DLL_FUNCTION(PyModule_GetDict)) && dll.ResolveExport(DLL_FUNCTION(PyImport_Import)) && dll.ResolveExport(DLL_FUNCTION(PyFloat_FromDouble)) && dll.ResolveExport(DLL_FUNCTION(PyInt_FromLong)) && dll.ResolveExport(DLL_FUNCTION(PyDict_GetItemString)) && //dll.ResolveExport(DLL_FUNCTION(PyDict_GetItem)) && //dll.ResolveExport(DLL_FUNCTION(PyDict_Keys)) && dll.ResolveExport(DLL_FUNCTION(PyDict_Next)) && dll.ResolveExport(DLL_FUNCTION(PyDict_Size)) && dll.ResolveExport(DLL_FUNCTION(PyType_Ready)) && dll.ResolveExport(DLL_FUNCTION(PyType_GenericNew)) && dll.ResolveExport(DLL_FUNCTION(PyTuple_New)) && dll.ResolveExport(DLL_FUNCTION(PyTuple_SetItem)) && dll.ResolveExport(DLL_VA_FUNCTION(PyArg_Parse)) && dll.ResolveExport(DLL_VA_FUNCTION(PyArg_ParseTuple)) && dll.ResolveExport(DLL_FUNCTION(PySys_SetArgv)) && dll.ResolveExport(DLL_FUNCTION(PyObject_RichCompare)) && dll.ResolveExport(DLL_OBJECT_DATA(PyExc_SystemExit)) && dll.ResolveExport(DLL_OBJECT_DATA(PyExc_SystemError)) && dll.ResolveExport(DLL_OBJECT_DATA(PyExc_ValueError)) && dll.ResolveExport(DLL_OBJECT_DATA(PyExc_Exception)) && dll.ResolveExport(DLL_OBJECT_DATA(PyExc_TypeError)) && dll.ResolveExport(DLL_OBJECT_DATA(PyExc_KeyboardInterrupt)) && dll.ResolveExport(DLL_OBJECT_DATA(PyExc_RuntimeError)) && dll.ResolveExport(DLL_OBJECT_DATA(PyExc_ReferenceError)) && dll.ResolveExport(DLL_OBJECT_DATA(_Py_NoneStruct)) && dll.ResolveExport(DLL_OBJECT_DATA(_Py_NotImplementedStruct)) && dll.ResolveExport(DLL_OBJECT_DATA(_Py_TrueStruct)) && dll.ResolveExport(DLL_OBJECT_DATA(_Py_ZeroStruct)) && dll.ResolveExport(DLL_OBJECT_DATA(PyString_Type)) && dll.ResolveExport(DLL_OBJECT_DATA(PyList_Type)) && dll.ResolveExport(DLL_OBJECT_DATA(PyLong_Type)) && dll.ResolveExport(DLL_OBJECT_DATA(PyInt_Type)) && dll.ResolveExport(DLL_OBJECT_DATA(PyUnicode_Type)) && dll.ResolveExport(DLL_OBJECT_DATA(PyTuple_Type)) && dll.ResolveExport(DLL_OBJECT_DATA(PyDict_Type)) && dll.ResolveExport(DLL_FUNCTION(PyErr_Fetch)) && dll.ResolveExport(DLL_FUNCTION(PyImport_AddModule)) && dll.ResolveExport(DLL_FUNCTION(PyImport_ImportModule)) && dll.ResolveExport(DLL_FUNCTION(PyObject_Str)) && dll.ResolveExport(DLL_FUNCTION(PyRun_File)) && dll.ResolveExport(DLL_FUNCTION(PyErr_Clear)) && dll.ResolveExport(DLL_FUNCTION(PyObject_SetAttrString)) && dll.ResolveExport(DLL_FUNCTION(PyErr_ExceptionMatches)) && #if (defined USE_EXTERNAL_PYTHON) && (defined HAVE_LIBPYTHON2_6) dll.ResolveExport(DLL_FUNCTION(PyRun_SimpleStringFlags)) && dll.ResolveExport(DLL_FUNCTION(PyRun_StringFlags)) && dll.ResolveExport(DLL_FUNCTION(PyRun_FileExFlags)) && #endif dll.ResolveExport(DLL_FUNCTION(PyRun_String))); return bResult; }
extern "C" FARPROC __stdcall dllGetProcAddress(HMODULE hModule, LPCSTR function) { uintptr_t loc = (uintptr_t)_ReturnAddress(); void* address = NULL; LibraryLoader* dll = DllLoaderContainer::GetModule(hModule); if( !dll ) { CLog::Log(LOGERROR, "%s - Invalid hModule specified",__FUNCTION__); return NULL; } /* how can somebody get the stupid idea to create such a stupid function */ /* where you never know if the given pointer is a pointer or a value */ if( HIGH_WORD(function) == 0 && LOW_WORD(function) < 1000) { if( dll->ResolveOrdinal(LOW_WORD(function), &address) ) { CLog::Log(LOGDEBUG, "%s(%p(%s), %d) => %p", __FUNCTION__, hModule, dll->GetName(), LOW_WORD(function), address); } else if( dll->IsSystemDll() ) { char ordinal[5]; sprintf(ordinal, "%d", LOW_WORD(function)); address = (void*)create_dummy_function(dll->GetName(), ordinal); /* add to tracklist if we are tracking this source dll */ DllTrackInfo* track = tracker_get_dlltrackinfo(loc); if( track ) tracker_dll_data_track(track->pDll, (uintptr_t)address); CLog::Log(LOGDEBUG, "%s - created dummy function %s!%s",__FUNCTION__, dll->GetName(), ordinal); } else { address = NULL; CLog::Log(LOGDEBUG, "%s(%p(%s), '%s') => %p",__FUNCTION__ , hModule, dll->GetName(), function, address); } } else { if( dll->ResolveExport(function, &address) ) { CLog::Log(LOGDEBUG, "%s(%p(%s), '%s') => %p",__FUNCTION__ , hModule, dll->GetName(), function, address); } else { DllTrackInfo* track = tracker_get_dlltrackinfo(loc); /* some dll's require us to always return a function or it will fail, other's */ /* decide functionallity depending on if the functions exist and may fail */ if( dll->IsSystemDll() && track && stricmp(track->pDll->GetName(), "CoreAVCDecoder.ax") == 0 ) { address = (void*)create_dummy_function(dll->GetName(), function); tracker_dll_data_track(track->pDll, (uintptr_t)address); CLog::Log(LOGDEBUG, "%s - created dummy function %s!%s", __FUNCTION__, dll->GetName(), function); } else { address = NULL; CLog::Log(LOGDEBUG, "%s(%p(%s), '%s') => %p", __FUNCTION__, hModule, dll->GetName(), function, address); } } } return (FARPROC)address; }