LibraryLoader* LoaderContainer::FindModule(const char* sName, const char* sCurrentDir, bool bLoadSymbols) { if (CURL::IsFullPath(sName)) { // Has a path, just try to load return LoadDll(sName, bLoadSymbols); } if (sCurrentDir) { // in the path of the parent dll? std::string strPath = sCurrentDir; strPath += sName; LibraryLoader* pLoader = LoadDll(strPath.c_str(), bLoadSymbols); if (pLoader) return pLoader; } // in environment variable? StringArray vecEnv; StringUtils::SplitString(ENV_PATH, ";", vecEnv); LibraryLoader* pDll = NULL; for (int i = 0; i < (int)vecEnv.size(); ++i) { std::string strPath = vecEnv[i]; strPath += '/'; #ifdef LOGALL LOGDEBUG("Searching for the dll %s in directory %s", sName, strPath.c_str()); #endif strPath += sName; // Have we already loaded this dll if ((pDll = GetModule(strPath.c_str())) != NULL) return pDll; if ((pDll = LoadDll(strPath.c_str(), bLoadSymbols)) != NULL) return pDll; } // can't find it in any of our paths - could be a system dll if ((pDll = LoadDll(sName, bLoadSymbols)) != NULL) return pDll; LOGDEBUG("Dll %s was not found in path", sName); return NULL; }
void ActivationContextLoader::Initialise(const CStdString& sManifest) { if (CGeneral::FileExists(sManifest)) { m_sManifest = sManifest; } else { CPath path; path.Combine(GetModulePath(), sManifest); m_sManifest = path; } try { // Don't do anything if we're not at least running on xp m_bShouldLoadActivationContext = ShouldLoadActivationContext(); if (m_bShouldLoadActivationContext) { LoadDll(); if (!IsActivationContextAlreadyActiveForManifest()) { LoadAC(); } } } catch (std::exception & e) { CStdString sError = CA2T(e.what()); LOG_WS_ERROR(sError); } }
bool UCUnitTest::Start(bool bIsNeedLogin) { if (!LoadDll()) return false; int iRet = m_fpeSDKClientPlatform_Init(); if (0 != iRet) { return false; } SetUCSignalRecvCB(); m_fpConfig("10.170.103.52:8081"); m_fpSetLang("2052"); if (bIsNeedLogin) { if (!Login()) { return false; } } return true; }
bool CAddonDll::LoadSettings() { if (m_settingsLoaded) return true; if (!LoadDll()) return false; ADDON_StructSetting** sSet; std::vector<DllSetting> vSet; unsigned entries = m_pDll->GetSettings(&sSet); DllUtils::StructToVec(entries, &sSet, &vSet); m_pDll->FreeSettings(); if (vSet.size()) { // regenerate XML doc m_addonXmlDoc.Clear(); TiXmlElement node("settings"); m_addonXmlDoc.InsertEndChild(node); for (unsigned i=0; i < entries; i++) { DllSetting& setting = vSet[i]; m_addonXmlDoc.RootElement()->InsertEndChild(MakeSetting(setting)); } CAddon::SettingsFromXML(m_addonXmlDoc, true); } else return CAddon::LoadSettings(); m_settingsLoaded = true; CAddon::LoadUserSettings(); return true; }
ADDON_STATUS CAddonDll::Create(ADDON_TYPE type, void* funcTable, void* info) { /* ensure that a previous instance is destroyed */ Destroy(); if (!funcTable) return ADDON_STATUS_PERMANENT_FAILURE; CLog::Log(LOGDEBUG, "ADDON: Dll Initializing - %s", Name().c_str()); m_initialized = false; if (!LoadDll()) return ADDON_STATUS_PERMANENT_FAILURE; /* Check requested instance version on add-on */ if (!CheckAPIVersion(type)) return ADDON_STATUS_PERMANENT_FAILURE; /* Check versions about global parts on add-on (parts used on all types) */ for (unsigned int id = ADDON_GLOBAL_MAIN; id <= ADDON_GLOBAL_MAX; ++id) { if (!CheckAPIVersion(id)) return ADDON_STATUS_PERMANENT_FAILURE; } /* Load add-on function table (written by add-on itself) */ m_pDll->GetAddon(funcTable); /* Allocate the helper function class to allow crosstalk over helper libraries */ m_pHelpers = new CAddonInterfaces(this); /* Call Create to make connections, initializing data or whatever is needed to become the AddOn running */ ADDON_STATUS status = m_pDll->Create(m_pHelpers->GetCallbacks(), info); if (status == ADDON_STATUS_OK) { m_initialized = true; } else if (status == ADDON_STATUS_NEED_SETTINGS) { status = TransferSettings(); if (status == ADDON_STATUS_OK) m_initialized = true; else new CAddonStatusHandler(ID(), status, "", false); } else { // Addon failed initialization CLog::Log(LOGERROR, "ADDON: Dll %s - Client returned bad status (%i) from Create and is not usable", Name().c_str(), status); std::string heading = StringUtils::Format("%s: %s", CAddonInfo::TranslateType(Type(), true).c_str(), Name().c_str()); HELPERS::ShowOKDialogLines(CVariant{ heading }, CVariant{ 24070 }, CVariant{ 24071 }); } return status; }
ADDON_STATUS CAddonDll::Create(void* funcTable, void* info) { /* ensure that a previous instance is destroyed */ Destroy(); if (!funcTable) return ADDON_STATUS_PERMANENT_FAILURE; CLog::Log(LOGDEBUG, "ADDON: Dll Initializing - %s", Name().c_str()); m_initialized = false; if (!LoadDll()) return ADDON_STATUS_PERMANENT_FAILURE; /* Load add-on function table (written by add-on itself) */ m_pDll->GetAddon(funcTable); if (!CheckAPIVersion()) return ADDON_STATUS_PERMANENT_FAILURE; /* Allocate the helper function class to allow crosstalk over helper libraries */ m_pHelpers = new CAddonInterfaces(this); /* Call Create to make connections, initializing data or whatever is needed to become the AddOn running */ ADDON_STATUS status = m_pDll->Create(m_pHelpers->GetCallbacks(), info); if (status == ADDON_STATUS_OK) { m_initialized = true; } else if ((status == ADDON_STATUS_NEED_SETTINGS) || (status == ADDON_STATUS_NEED_SAVEDSETTINGS)) { m_needsavedsettings = (status == ADDON_STATUS_NEED_SAVEDSETTINGS); if ((status = TransferSettings()) == ADDON_STATUS_OK) m_initialized = true; else new CAddonStatusHandler(ID(), status, "", false); } else { // Addon failed initialization CLog::Log(LOGERROR, "ADDON: Dll %s - Client returned bad status (%i) from Create and is not usable", Name().c_str(), status); CGUIDialogOK* pDialog = g_windowManager.GetWindow<CGUIDialogOK>(WINDOW_DIALOG_OK); if (pDialog) { std::string heading = StringUtils::Format("%s: %s", TranslateType(Type(), true).c_str(), Name().c_str()); pDialog->SetHeading(CVariant{heading}); pDialog->SetLine(1, CVariant{24070}); pDialog->SetLine(2, CVariant{24071}); pDialog->Open(); } } return status; }
DWORD CSendTSTCPDllUtil::Initialize() { if( LoadDll() == FALSE ){ return ERR_INIT; } m_iID = pfnInitializeDLL(); if( m_iID == -1 ){ return ERR_INIT; } return NO_ERR; }
//DLLの初期化 //戻り値: // エラーコード //引数: // asyncMode [IN]TRUE:非同期モード、FALSE:同期モード DWORD CEpgDataCap3Util::Initialize( BOOL asyncFlag ) { if( LoadDll() == FALSE ){ return ERR_INIT; } DWORD err = pfnInitializeEP3(asyncFlag, &id); if( err != NO_ERR ){ id = 0; } return err; }
void* DynamicLibrary::FindSymbol(const std::string& funcName) { if (!Library) { Library = LoadDll(Path.c_str()); } void* func = (void*)GetProcAddress((HMODULE)Library, funcName.c_str()); if (!func) { std::string msg; // TODO GetWindows error string. THROW_ERROR3(UnableToFundSymbolInTheLibrary, funcName, Path, msg); } return func; }
ADDON_STATUS CAddonDll::Create(KODI_HANDLE firstKodiInstance) { CLog::Log(LOGDEBUG, "ADDON: Dll Initializing - %s", Name().c_str()); m_initialized = false; if (!LoadDll()) { return ADDON_STATUS_PERMANENT_FAILURE; } /* Check versions about global parts on add-on (parts used on all types) */ for (unsigned int id = ADDON_GLOBAL_MAIN; id <= ADDON_GLOBAL_MAX; ++id) { if (!CheckAPIVersion(id)) return ADDON_STATUS_PERMANENT_FAILURE; } /* Allocate the helper function class to allow crosstalk over helper add-on headers */ if (!InitInterface(firstKodiInstance)) return ADDON_STATUS_PERMANENT_FAILURE; /* Call Create to make connections, initializing data or whatever is needed to become the AddOn running */ ADDON_STATUS status = m_pDll->Create(&m_interface, nullptr); if (status == ADDON_STATUS_OK) { m_initialized = true; } else if (status == ADDON_STATUS_NEED_SETTINGS) { if ((status = TransferSettings()) == ADDON_STATUS_OK) m_initialized = true; else new CAddonStatusHandler(ID(), status, "", false); } else { // Addon failed initialization CLog::Log(LOGERROR, "ADDON: Dll %s - Client returned bad status (%i) from Create and is not usable", Name().c_str(), status); // @todo currently a copy and paste from other function and becomes improved. std::string heading = StringUtils::Format("%s: %s", CAddonInfo::TranslateType(Type(), true).c_str(), Name().c_str()); HELPERS::ShowOKDialogLines(CVariant{ heading }, CVariant{ 24070 }, CVariant{ 24071 }); } return status; }
IDirect3D9* WINAPI Direct3DCreate9(UINT nSDKVersion) { // Log Log("Direct3DCreate9(%d)\n", nSDKVersion); // Load DLL if(!LoadDll()) return NULL; // Create real interface IDirect3D9* pD3D = g_pfnDirect3DCreate9(nSDKVersion); if(!pD3D) return NULL; // Create and return proxy interface BaseDirect3D9* pWrapper = new BaseDirect3D9(pD3D); return pWrapper; }
// // Send a command to the DLL injected in Lightroom's address space // (and load the DLL first if it hasn't been loaded yet) // DWORD CLightroom::executeCommand( DWORD command ) { if( !LoadDll() ) return E_UNEXPECTED; DWORD exitCode = 0; // Call our entry point and pass in the command DWORD threadId = 0; HANDLE hRemoteThread = CreateRemoteThread( hProcess, NULL, 0, ( LPTHREAD_START_ROUTINE )pRemoteEntryPoint, ( LPVOID )command, 0, &threadId ); if( hRemoteThread ) { WaitForSingleObject( hRemoteThread, INFINITE ); // Probably doesn't need to be an infinite wait... GetExitCodeThread( hRemoteThread, &exitCode ); CloseHandle( hRemoteThread ); } return exitCode; }
int _tmain(int argc, _TCHAR* argv[]) { if(argc < 3) { printf("Usage: %s program.exe library.dll\n", argv[0]); return 0; } OutputDebugString("Starting up"); if(IsWindowsNT()) { //unsigned long pid = GetTargetProcessIdFromProcname((char *)"guiTest.exe"); unsigned long pid = GetTargetProcessIdFromProcname(argv[1]); if(pid == 0) { MessageBox(0, "Process not found", "Error!", 0); return 0; } printf("PID: %u\n", pid); LoadDll(argv[1], argv[2]); } else { MessageBox(0, "Your system does not support this method", "Error!", 0); } return 0; }
ImageType::ImageType(const unsigned id, const CMString& file, const int index, const IcoTypeEnum type) : ImageBase(id) { m_bmp = NULL; m_pPropertyItem = NULL; m_nCurrentFrame = 0; m_nFrameCount = 0; if (!InitGdiPlus()) return; switch (type) { case icoDll: { const HMODULE hModule = LoadDll(file); if (hModule != NULL) { HICON hIcon = (HICON)LoadImage(hModule, MAKEINTRESOURCE(-index), IMAGE_ICON, 0, 0, 0); m_bmp = new Gdiplus::Bitmap(hIcon); DestroyIcon(hIcon); } } break; case icoFile: m_bmp = new Gdiplus::Bitmap(T2W_SM(file.c_str())); break; default: HICON hIcon = NULL; ExtractIconEx(file.c_str(), index, NULL, &hIcon, 1); m_bmp = new Gdiplus::Bitmap(hIcon); DestroyIcon(hIcon); break; } if (m_bmp->GetLastStatus() != Gdiplus::Ok) { delete m_bmp; m_bmp = NULL; return; } }
IconType::IconType(const unsigned id, const CMString& file, const int index, const IcoTypeEnum type) : ImageBase(id) { m_SmileyIcon = NULL; switch (type) { case icoDll: { const HMODULE hModule = LoadDll(file); if (hModule != NULL) m_SmileyIcon = (HICON)LoadImage(hModule, MAKEINTRESOURCE(-index), IMAGE_ICON, 0, 0, 0); } break; case icoFile: m_SmileyIcon = (HICON)LoadImage(NULL, file.c_str(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE); break; default: ExtractIconEx(file.c_str(), index, NULL, &m_SmileyIcon, 1); break; } }
BOOL CDlldemoDlg::OnInitDialog() { CDialog::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon //m_cesku.EnableWindow(FALSE); // TODO: Add extra initialization here //********初始化默认设置 m_sku = ""; m_drstr = "BTP-2200E(P)"; m_time = 1000; m_date = CTime::GetCurrentTime(); LoadDll(); db = NULL; int rc = sqlite3_open("data.db", &db); if( rc ){ fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db)); sqlite3_close(db); exit(1); } char **errMsg = NULL; rc = sqlite3_exec(db, "CREATE TABLE IF NOT EXISTS packed_shipment(shipmentId varchar(14), operator varchar(10), dateTime varchar(20));", NULL, NULL, errMsg); CString m_version = ""; m_version.Format("一切正常,DLL版本号-----%d",BPLA_GetVersion()); SetDlgItemText(IDC_STATICPRINTSTATUS,m_version); m_buttonprintaddress.EnableWindow(FALSE); UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control }
bool BoxeeAuthenticator::Init() { CStdString serverUrlPrefix = BOXEE::BXConfiguration::GetInstance().GetURLParam("Boxee.Server","http://app.boxee.tv"); CStdString version = g_infoManager.GetVersion(); CStdString platform; #if defined(_LINUX) && !defined(__APPLE__) platform = "linux"; #elif defined(__APPLE__) if(CSysInfo::IsAppleTV()) { platform = "atv"; } else { platform = "mac"; } #elif defined(_WIN32) platform = "win"; #endif CStdString pathToCookieJar = BOXEE::BXCurl::GetCookieJar(); CStdString pathToAppsDir = _P("special://home/apps/"); CStdString strUrl = serverUrlPrefix; strUrl += "/ping?bxlibauth_ver="; if (LoadDll()) { const char* currentVersion = _AuthVersion(); CLog::Log(LOGDEBUG, "Checking for new authenticator version. current: %s", currentVersion); strUrl += currentVersion; UnloadDll(); } else { CLog::Log(LOGDEBUG, "No authenticator dll found. downloading"); strUrl += "0"; } BOXEE::BXCurl curl; if (!curl.HttpHEAD(strUrl)) { return false; } if (curl.GetLastRetCode() == 200) { CLog::Log(LOGDEBUG, "Downloading authenticator dll"); // Download the file CStdString TempFileName = "special://temp/AuthenticatorDll.bin"; TempFileName = _P(TempFileName); if (!curl.HttpDownloadFile(strUrl, TempFileName, "")) { CLog::Log(LOGERROR, "Unable to download authenticator dll"); XFILE::CFile::Delete(TempFileName); return false; } // Rename the downloaded file CStdString DllFileName = GetDllFilename(); XFILE::CFile::Delete(DllFileName); XFILE::CFile::Rename(TempFileName, DllFileName); } if (LoadDll()) { const char* currentVersion = _AuthVersion(); CLog::Log(LOGDEBUG, "Using authenticator version %s", currentVersion); _AuthInit(platform.c_str(), version.c_str(), pathToCookieJar.c_str(), pathToAppsDir.c_str(), serverUrlPrefix.c_str()); return true; } else { CLog::Log(LOGWARNING, "Cannot load authenticator dll"); return false; } }
CReader::CReader() { LoadDll(); }
bool CTimidityCodec::Init(const std::string& filename, unsigned int filecache, int& channels, int& samplerate, int& bitspersample, int64_t& totaltime, int& bitrate, AEDataFormat& format, std::vector<AEChannel>& channellist) { if (m_soundfont.empty()) return false; if (!LoadDll(m_usedLibName)) return false; if (!REGISTER_DLL_SYMBOL(Timidity_Init)) return false; if (!REGISTER_DLL_SYMBOL(Timidity_Cleanup)) return false; if (!REGISTER_DLL_SYMBOL(Timidity_GetLength)) return false; if (!REGISTER_DLL_SYMBOL(Timidity_LoadSong)) return false; if (!REGISTER_DLL_SYMBOL(Timidity_FreeSong)) return false; if (!REGISTER_DLL_SYMBOL(Timidity_FillBuffer)) return false; if (!REGISTER_DLL_SYMBOL(Timidity_Seek)) return false; if (!REGISTER_DLL_SYMBOL(Timidity_ErrorMsg)) return false; int res; if (m_soundfont.find(".sf2") != std::string::npos) res = Timidity_Init(48000, 16, 2, m_soundfont.c_str(), nullptr); // real soundfont else res = Timidity_Init(48000, 16, 2, nullptr, m_soundfont.c_str()); // config file if (res != 0) return false; kodi::vfs::CFile file; if (!file.OpenFile(filename)) return false; int len = file.GetLength(); uint8_t* data = new uint8_t[len]; if (!data) return false; file.Read(data, len); const char* tempfile = tmpnam(nullptr); FILE* f = fopen(tempfile,"wb"); if (!f) { delete[] data; return false; } fwrite(data, 1, len, f); fclose(f); delete[] data; m_song = Timidity_LoadSong((char*)tempfile); unlink(tempfile); if (!m_song) return false; m_pos = 0; channels = 2; samplerate = 48000; bitspersample = 16; totaltime = Timidity_GetLength(m_song); format = AE_FMT_S16NE; channellist = { AE_CH_FL, AE_CH_FR }; bitrate = 0; return true; }
// //////////////////////////////////////////////////////////////////////////// void DllLoader::PostCreate() { if (dll_load_flags_ & LoadOnCreation) LoadDll(); }
void Win2kUser32Dll::Load() { LoadDll(szDllName); }