void SteamLoader::Initialize() { if (IsSteamRunning(true)) { std::wstring steamDllPath = GetSteamDllPath(); std::wstring steamDirectory = steamDllPath.substr(0, steamDllPath.rfind(L'\\')); // add Steam to the process path static wchar_t pathBuffer[65536]; GetEnvironmentVariable(L"PATH", pathBuffer, sizeof(pathBuffer)); wcscat(pathBuffer, L";"); wcscat(pathBuffer, steamDirectory.c_str()); SetEnvironmentVariable(L"PATH", pathBuffer); // oh you wanted this to work on old win7? ehhh AddDllDirectory(steamDirectory.c_str()); // load steamclient*.dll m_hSteamClient = LoadLibrary(steamDllPath.c_str()); // load the Steam overlay, if 'rtsshooks64.dll' is not present if (GetModuleHandleW(L"rtsshooks64.dll") == nullptr) { LoadGameOverlayRenderer(steamDllPath); } } }
void MainWindow::loadModules() { const QString appDirPath = QApplication::applicationDirPath(); const QDir dir(appDirPath + "/modules"); const QDir sharedDir(appDirPath + "/shared"); const auto modules = dir.entryList(QDir::Dirs, QDir::Name); auto& factory = DocumentFactory::instance(); // Just to make sure it is created here and now #ifdef WIN32 SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); QString sharedDirPath = sharedDir.absolutePath(); auto sharedDllDir = AddDllDirectory(sharedDirPath.toStdWString().c_str()); #endif for (const auto& module : modules) { if (module.startsWith(".")) continue; QDir moduleDir = dir; moduleDir.cd(module); QString dirPath = moduleDir.absolutePath(); factory.setModuleDirPath(dirPath.toStdString()); #ifdef WIN32 auto moduleDllDir = AddDllDirectory(dirPath.toStdWString().c_str()); #endif QFileInfo file(moduleDir, module); QString path = file.absoluteFilePath(); QLibrary lib(path); lib.load(); #ifdef WIN32 RemoveDllDirectory(moduleDllDir); #endif } #ifdef WIN32 RemoveDllDirectory(sharedDllDir); #endif }
HMODULE LoadCoreClr() { errno_t errno = 0; TCHAR szCoreClrDirectory[MAX_PATH]; DWORD dwCoreClrDirectory = GetEnvironmentVariableW(L"CORECLR_DIR", szCoreClrDirectory, MAX_PATH); HMODULE hCoreCLRModule = nullptr; if (dwCoreClrDirectory != 0) { WCHAR wszClrPath[MAX_PATH]; wszClrPath[0] = L'\0'; errno = wcscpy_s(wszClrPath, _countof(wszClrPath), szCoreClrDirectory); CHECK_RETURN_VALUE_FAIL_EXIT_VIA_FINISHED(errno); if (wszClrPath[wcslen(wszClrPath) - 1] != L'\\') { errno = wcscat_s(wszClrPath, _countof(wszClrPath), L"\\"); CHECK_RETURN_VALUE_FAIL_EXIT_VIA_FINISHED(errno); } errno = wcscat_s(wszClrPath, _countof(wszClrPath), L"coreclr.dll"); CHECK_RETURN_VALUE_FAIL_EXIT_VIA_FINISHED(errno); // Add the core clr directory to the list of dll search paths AddDllDirectory(szCoreClrDirectory); // Modify the default dll flags so that dependencies can be found in this path SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_USER_DIRS); // Continue loading as usual hCoreCLRModule = ::LoadLibraryExW(wszClrPath, NULL, 0); } if (hCoreCLRModule == nullptr) { // This is used when developing #if AMD64 hCoreCLRModule = ::LoadLibraryExW(L"..\\..\\..\\artifacts\\build\\ProjectK\\Runtime\\amd64\\coreclr.dll", NULL, 0); #else hCoreCLRModule = ::LoadLibraryExW(L"..\\..\\..\\artifacts\\build\\ProjectK\\Runtime\\x86\\coreclr.dll", NULL, 0); #endif } if (hCoreCLRModule == nullptr) { // Try the relative location based in install hCoreCLRModule = ::LoadLibraryExW(L"coreclr.dll", NULL, 0); } Finished: return hCoreCLRModule; }
void pluginInit( QObject *parent ) { auto teamSpeakPlugin = Driver::TeamSpeakPlugin::singleton(); Log::setSink( teamSpeakPlugin ); // for debugging purposes // Log::setSink( new Log::FileLogger( "C:/temp/tessumod_plugin.log" ) ); Log::logQtMessages(); QString dataPath = teamSpeakPlugin->getPluginDataPath(); QString dataPathNative = QDir::toNativeSeparators( dataPath ); dllSearchCookie = AddDllDirectory( (wchar_t*)dataPathNative.utf16() ); auto iniSettingsFile = new Driver::IniSettingsFile( parent ); auto openALBackend = new Driver::OpenALBackend( dataPath, parent ); auto openALBackendTest = new Driver::OpenALBackend( dataPath, parent ); auto openALConfFile = new Driver::OpenALConfFile( dataPath, parent ); auto wotConnector = new Driver::WotConnector( parent ); auto userStorage = new Storage::UserStorage( parent ); auto cameraStorage = new Storage::CameraStorage( parent ); auto adapterStorage = new Storage::AdapterStorage( parent ); auto settingsStorage = new Storage::SettingsStorage( iniSettingsFile, parent ); auto useCaseFactory = new UseCase::UseCaseFactory( parent ); useCaseFactory->userStorage = userStorage; useCaseFactory->cameraStorage = cameraStorage; useCaseFactory->settingsStorage = settingsStorage; useCaseFactory->adapterStorage = adapterStorage; adapterStorage->setAudio( Entity::BuiltInBackend, new Adapter::AudioAdapter( teamSpeakPlugin->createAudioBackend(), dataPath, parent ) ); adapterStorage->setAudio( Entity::OpenALBackend, new Adapter::AudioAdapter( openALBackend, dataPath, parent ) ); adapterStorage->setTestAudio( Entity::BuiltInBackend, new Adapter::AudioAdapter( teamSpeakPlugin->createAudioBackend(), dataPath, parent ) ); adapterStorage->setTestAudio( Entity::OpenALBackend, new Adapter::AudioAdapter( openALBackendTest, dataPath, parent ) ); adapterStorage->setVoiceChat( new Adapter::VoiceChatAdapter( teamSpeakPlugin, useCaseFactory, parent ) ); adapterStorage->setGameData( new Adapter::GameDataAdapter( wotConnector, useCaseFactory, parent ) ); adapterStorage->setUi( new Adapter::UiAdapter( useCaseFactory, openALConfFile, parent ) ); teamSpeakPlugin->setAudioSink( openALBackend ); QTimer *setupTimer = new QTimer( parent ); setupTimer->setSingleShot( true ); setupTimer->setInterval( 0 ); setupTimer->start(); QObject::connect( setupTimer, &QTimer::timeout, [=] { teamSpeakPlugin->initialize(); wotConnector->initialize(); useCaseFactory->applicationInitialize(); openALConfFile->start(); } ); }