bool LoadJVMLibrary() { std::string dllName(jvmPath); std::string binDir = dllName + "\\bin"; std::string serverDllName = binDir + "\\server\\jvm.dll"; std::string clientDllName = binDir + "\\client\\jvm.dll"; if ((bServerJVM && FileExists(serverDllName)) || !FileExists(clientDllName)) { dllName = serverDllName; } else { dllName = clientDllName; } SetCurrentDirectoryA(binDir.c_str()); // ensure that we can find msvcr100.dll which is located in jre/bin directory hJVM = LoadLibraryA(dllName.c_str()); if (hJVM) { pCreateJavaVM = (JNI_createJavaVM) GetProcAddress(hJVM, "JNI_CreateJavaVM"); } if (!pCreateJavaVM) { char buf[_MAX_PATH]; sprintf(buf, "Failed to load JVM DLL %s", dllName.c_str()); MessageBoxA(NULL, buf, "Error Launching IntelliJ Platform", MB_OK); return false; } return true; }
bool LoadJVMLibrary() { std::string dllName(jvmPath); std::string binDir = dllName + "\\bin"; std::string serverDllName = binDir + "\\server\\jvm.dll"; std::string clientDllName = binDir + "\\client\\jvm.dll"; if ((bServerJVM && FileExists(serverDllName)) || !FileExists(clientDllName)) { dllName = serverDllName; } else { dllName = clientDllName; } // ensure we can find msvcr100.dll which is located in jre/bin directory; jvm.dll depends on it. SetCurrentDirectoryA(binDir.c_str()); hJVM = LoadLibraryA(dllName.c_str()); if (hJVM) { pCreateJavaVM = (JNI_createJavaVM) GetProcAddress(hJVM, "JNI_CreateJavaVM"); } if (!pCreateJavaVM) { std::string jvmError = "Failed to load JVM DLL "; jvmError += dllName.c_str(); jvmError += "\n" "If you already have a " BITS_STR " JDK installed, define a JAVA_HOME variable in " "Computer > System Properties > System Settings > Environment Variables."; std::string error = LoadStdString(IDS_ERROR_LAUNCHING_APP); MessageBoxA(NULL, jvmError.c_str(), error.c_str(), MB_OK); return false; } return true; }
bool LoadJVMLibrary() { std::string dllName(jvmPath); std::string serverDllName = dllName + "\\bin\\server\\jvm.dll"; std::string clientDllName = dllName + "\\bin\\client\\jvm.dll"; if ((bServerJVM && FileExists(serverDllName)) || !FileExists(clientDllName)) { hJVM = LoadLibraryA(serverDllName.c_str()); } else { hJVM = LoadLibraryA(clientDllName.c_str()); } if (hJVM) { pCreateJavaVM = (JNI_createJavaVM) GetProcAddress(hJVM, "JNI_CreateJavaVM"); } if (!pCreateJavaVM) { char buf[_MAX_PATH]; sprintf(buf, "Failed to load JVM DLL %s", dllName.c_str()); MessageBoxA(NULL, buf, "Error Launching IntelliJ Platform", MB_OK); return false; } return true; }
RemoteVSTClient::RemoteVSTClient(CFBundleRef bundle, audioMasterCallback theMaster, AEffect *theEffect, bool showGUI) : RemotePluginClient(theMaster, theEffect) { m_bundle = bundle; m_audioMaster = theMaster; pid_t child; SInt32 errorCode; CFDataRef data; CFURLRef configUrl = CFBundleCopyResourceURL(bundle, CFSTR("config"), CFSTR("plist"), NULL); if (configUrl == 0) { return; } CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, configUrl, &data, NULL, NULL, &errorCode); m_props = (CFDictionaryRef) CFPropertyListCreateFromXMLData( kCFAllocatorDefault, data, kCFPropertyListImmutable, NULL); std::string dllName(CFStringGetCStringPtr(get_path_prop(CFSTR("plugin-name")), NULL)); std::string arg = dllName + "," + getFileIdentifiers(); if (showGUI) arg = "-g " + arg; const char *argStr = arg.c_str(); CFURLRef server_url = CFBundleCopyResourceURL(m_bundle, CFSTR("dssi-vst-server.exe"), CFSTR("so"), NULL); if (server_url != NULL) { CFStringRef server_path = CFURLCopyFileSystemPath(server_url, kCFURLPOSIXPathStyle); if (server_path != NULL) { const char *c_server_path = CFStringGetCStringPtr(server_path, NULL); CFStringRef wine_path = (CFStringRef) CFDictionaryGetValue(m_props, CFSTR("wine-path")); if (wine_path != NULL) { const char *c_wine_path = CFStringGetCStringPtr(wine_path, NULL); std::cerr << "RemoteVSTClient: executing " << c_server_path << "\n"; // if no dispaly environment guess... // setenv("DISPLAY", ":0", 0); setenv("DYLD_FALLBACK_LIBRARY_PATH", "/usr/X11/lib:/usr/lib", 0); if ((child = fork()) < 0) { cleanup(); throw((std::string)"Fork failed"); } else if (child == 0) { // child process if (execlp(c_wine_path, "wine", c_server_path, argStr, NULL)) { perror("Exec failed"); exit(1); } } syncStartup(); return; } } } cleanup(); throw((std::string)"Failed to find dssi-vst-server executable"); return; }
void *open(const char *filename) { std::string dllName(filename); # if defined(__GNUG__) return dlopen(filename, RTLD_LAZY); # elif defined(_MSC_VER) convert_name(dllName); std::cout << dllName << std::endl; return LoadLibrary(CStringW(dllName.c_str())); # else # error G++ or MS compiler required # endif }
CarlaInstrument::CarlaInstrument(InstrumentTrack* const instrumentTrack, const Descriptor* const descriptor, const bool isPatchbay) : Instrument(instrumentTrack, descriptor), kIsPatchbay(isPatchbay), fHandle(NULL), fDescriptor(isPatchbay ? carla_get_native_patchbay_plugin() : carla_get_native_rack_plugin()), fMidiEventCount(0) { fHost.handle = this; fHost.uiName = NULL; fHost.uiParentId = 0; // figure out prefix from dll filename QString dllName(carla_get_library_filename()); #if defined(CARLA_OS_LINUX) fHost.resourceDir = strdup(QString(dllName.split("/lib/carla")[0] + "/share/carla/resources/").toUtf8().constData()); #else fHost.resourceDir = NULL; #endif fHost.get_buffer_size = host_get_buffer_size; fHost.get_sample_rate = host_get_sample_rate; fHost.is_offline = host_is_offline; fHost.get_time_info = host_get_time_info; fHost.write_midi_event = host_write_midi_event; fHost.ui_parameter_changed = host_ui_parameter_changed; fHost.ui_custom_data_changed = host_ui_custom_data_changed; fHost.ui_closed = host_ui_closed; fHost.ui_open_file = host_ui_open_file; fHost.ui_save_file = host_ui_save_file; fHost.dispatcher = host_dispatcher; std::memset(&fTimeInfo, 0, sizeof(NativeTimeInfo)); fTimeInfo.bbt.valid = true; // always valid fHandle = fDescriptor->instantiate(&fHost); Q_ASSERT(fHandle != NULL); if (fHandle != NULL && fDescriptor->activate != NULL) fDescriptor->activate(fHandle); // we need a play-handle which cares for calling play() InstrumentPlayHandle * iph = new InstrumentPlayHandle( this, instrumentTrack ); Engine::mixer()->addPlayHandle( iph ); connect(Engine::mixer(), SIGNAL(sampleRateChanged()), this, SLOT(sampleRateChanged())); }
bool AMDCounters::Init(ApiType apiType, void *pContext) { #if DISABLED(RDOC_WIN32) && DISABLED(RDOC_LINUX) return false; #else std::string dllName("GPUPerfAPI"); switch(apiType) { case ApiType::Dx11: dllName += "DX11"; break; case ApiType::Dx12: dllName += "DX12"; break; case ApiType::Ogl: dllName += "GL"; break; case ApiType::Vk: dllName += "VK"; break; default: RDCWARN( "AMD GPU performance counters could not be initialized successfully. " "Unsupported API type specified"); return false; } #if ENABLED(RDOC_WIN32) #if ENABLED(RDOC_X64) dllName += "-x64"; #endif dllName += ".dll"; #else dllName = "lib" + dllName; dllName += ".so"; #endif // first try in the plugin location it will be in distributed builds std::string dllPath = LocatePluginFile("amd/counters", dllName.c_str()); void *module = Process::LoadModule(dllPath.c_str()); if(module == NULL) { module = Process::LoadModule(dllName.c_str()); } if(module == NULL) { RDCWARN( "AMD GPU performance counters could not be initialized successfully. " "Are you missing the DLLs?"); return false; } GPA_GetFuncTablePtrType getFuncTable = (GPA_GetFuncTablePtrType)Process::GetFunctionAddress(module, "GPA_GetFuncTable"); m_pGPUPerfAPI = new GPAApi(); if(getFuncTable) { getFuncTable((void **)&m_pGPUPerfAPI); } else { delete m_pGPUPerfAPI; RDCERR("Failed to get GPA function table. Invalid dynamic library?"); return false; } GPA_Logging_Type loggingType = GPA_LOGGING_ERROR; #if ENABLED(RDOC_DEVEL) loggingType = GPA_LOGGING_ERROR_AND_MESSAGE; #endif GPA_Status status = m_pGPUPerfAPI->GPA_RegisterLoggingCallback(loggingType, GPA_LoggingCallback); if(AMD_FAILED(status)) { GPA_ERROR("Failed to initialize logging", status); return false; } status = m_pGPUPerfAPI->GPA_Initialize(); if(AMD_FAILED(status)) { GPA_ERROR("Initialization failed", status); delete m_pGPUPerfAPI; m_pGPUPerfAPI = NULL; return false; } status = m_pGPUPerfAPI->GPA_OpenContext( pContext, GPA_OPENCONTEXT_HIDE_SOFTWARE_COUNTERS_BIT | GPA_OPENCONTEXT_CLOCK_MODE_PEAK_BIT); if(AMD_FAILED(status)) { GPA_WARNING("Open context for counters failed", status); m_pGPUPerfAPI->GPA_Destroy(); delete m_pGPUPerfAPI; m_pGPUPerfAPI = NULL; return false; } m_Counters = EnumerateCounters(); return true; #endif }
static std::string sGetProcessPath() { #if EE_PLATFORM == EE_PLATFORM_MACOSX char exe_file[PATH_MAX + 1]; CFBundleRef mainBundle = CFBundleGetMainBundle(); if (mainBundle) { CFURLRef mainURL = CFBundleCopyBundleURL(mainBundle); if (mainURL) { int ok = CFURLGetFileSystemRepresentation ( mainURL, (Boolean) true, (UInt8*)exe_file, PATH_MAX ); if (ok) { return std::string(exe_file) + "/"; } } } return "./"; #elif EE_PLATFORM == EE_PLATFORM_LINUX char exe_file[PATH_MAX + 1]; int size; size = readlink("/proc/self/exe", exe_file, PATH_MAX); if (size < 0) { return "./"; } else { exe_file[size] = '\0'; return std::string(dirname(exe_file)) + "/"; } #elif EE_PLATFORM == EE_PLATFORM_WIN #ifdef UNICODE // Get path to executable: char szDrive[_MAX_DRIVE]; char szDir[_MAX_DIR]; char szFilename[_MAX_DIR]; char szExt[_MAX_DIR]; std::wstring dllName( _MAX_DIR, 0 ); GetModuleFileName(0, &dllName[0], _MAX_PATH); std::string dllstrName( String( dllName ).ToUtf8() ); #ifdef EE_COMPILER_MSVC _splitpath_s( dllstrName.c_str(), szDrive, _MAX_DRIVE, szDir, _MAX_DIR, szFilename, _MAX_DIR, szExt, _MAX_DIR ); #else _splitpath(szDllName, szDrive, szDir, szFilename, szExt); #endif return std::string( szDrive ) + std::string( szDir ); #else // Get path to executable: TCHAR szDllName[_MAX_PATH]; TCHAR szDrive[_MAX_DRIVE]; TCHAR szDir[_MAX_DIR]; TCHAR szFilename[_MAX_DIR]; TCHAR szExt[_MAX_DIR]; GetModuleFileName(0, szDllName, _MAX_PATH); #ifdef EE_COMPILER_MSVC _splitpath_s(szDllName, szDrive, _MAX_DRIVE, szDir, _MAX_DIR, szFilename, _MAX_DIR, szExt, _MAX_DIR ); #else _splitpath(szDllName, szDrive, szDir, szFilename, szExt); #endif return std::string(szDrive) + std::string(szDir); #endif #elif EE_PLATFORM == EE_PLATFORM_BSD int mib[4]; mib[0] = CTL_KERN; mib[1] = KERN_PROC; mib[2] = KERN_PROC_PATHNAME; mib[3] = -1; char buf[1024]; size_t cb = sizeof(buf); sysctl(mib, 4, buf, &cb, NULL, 0); return FileSystem::FileRemoveFileName( std::string( buf ) ); #elif EE_PLATFORM == EE_PLATFORM_SOLARIS return FileRemoveFileName( std::string( getexecname() ) ); #elif EE_PLATFORM == EE_PLATFORM_HAIKU image_info info; int32 cookie = 0; while ( B_OK == get_next_image_info( 0, &cookie, &info ) ) { if ( info.type == B_APP_IMAGE ) break; } return FileSystem::FileRemoveFileName( std::string( info.name ) ); #elif EE_PLATFORM == EE_PLATFORM_ANDROID if ( NULL != Window::cEngine::instance() && NULL != Window::cEngine::instance()->GetCurrentWindow() ) return Window::cEngine::instance()->GetCurrentWindow()->GetExternalStoragePath(); return "/sdcard/"; #else #warning Sys::GetProcessPath() not implemented on this platform. ( will return "./" ) return "./"; #endif }
ZExport(ZSqlLink*) ZSqlLink::connect( const char* aDatabase, // db name (ORACLE, DB2, ...) const char* aConnection, // connection/datastore name const char* aUsername, // users name const char* aPassword, // user password int aMaxCursor) // cursor pool size { ZFUNCTRACE_DEVELOP("ZSqlLink::connect(const char*, const char*, const char*, const char*, int)"); #if ZC_WIN || ZC_OS2 #if ZC_IBM ZString dllName(ZString("Z")+aDatabase+"I"); #endif #if ZC_MICROSOFT ZString dllName(ZString("Z")+aDatabase+"M"); #endif #if ZC_BORLAND ZString dllName(ZString("Z")+aDatabase+"B"); #endif #if ZC_GNU ZString dllName(ZString("Z")+aDatabase+"G"); #endif dllName.lowerCase(); #endif // ZC_WIN || ZC_OS2 #if ZC_UNIXFAM ZString db(aDatabase); ZString dllName( ZString("libZ") +db.subString(1,1).upperCase() +db.subString(2).lowerCase() +"G.so." +ZString(ZC_MAJOR_VERSION) ); #endif // ZC_UNIXFAM // check if allready loaded Dll* d = dlls; while (d) { if (d->iName == dllName) break; d = d->iPrev; } // while if (!d) { ZDynamicLinkLibrary* dll = new ZDynamicLinkLibrary(dllName.constBuffer()); d = dlls = new Dll(dllName, dll, dlls); } // if ZSqlLink* (*connectTo)(const char*, const char*, const char*, int); connectTo = (ZSqlLink* (*)(const char*, const char*, const char*, int)) d->iDll->procAddress( #if ZC_WIN || ZC_OS2 #if ZC_IBM "ZSqlConnectTo__FPCcN21i" #endif #if ZC_BORLAND "@ZSqlConnectTo$qpxct1t1i" #endif #if ZC_MICROSOFT "?ZSqlConnectTo@@YAPAVZSqlLink@@PBD00H@Z" #endif #if ZC_GNU "ZSqlConnectTo__FPCcN21i" #endif #endif // ZC_WIN || ZC_OS2 #if ZC_UNIXFAM "ZSqlConnectTo__FPCcN20i" #endif // ZC_UNIXFAM ); return (*connectTo)(aConnection, aUsername, aPassword, aMaxCursor); } // connect