void TestOutputPlug( HWND hWnd ) { WINAMPPLUGINPROP tmpProp; WIN32_FIND_DATA sFF; HANDLE hFind = NULL; CUString strPluginDir( g_config.GetAppPath() + _W( "\\Plugins\\out_*.dll" ) ); LTRACE2( _T( "Scanning for plugins using mask %s" ) , strPluginDir ); CUStringConvert strCnv; hFind = FindFirstFile( strCnv.ToT( strPluginDir ), &sFF); g_strWinampExt = _T(""); // setup the Output module Window Handle g_OutModule.hMainWindow = hWnd; // setup the Output Module Instance Handle g_OutModule.hDllInstance = NULL; while ( NULL != hFind && hFind != INVALID_HANDLE_VALUE ) { if ( ! ( sFF.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) ) { CUStringConvert strCnv; CUString strFullName( g_config.GetAppPath() + _W( "\\Plugins\\" ) + CUString( sFF.cFileName ) ); LTRACE2( _T( "Getting plugin %s" ), strCnv.ToT( strFullName )); tmpProp.hDll = NULL; tmpProp.hDll = CDexLoadLibrary( strFullName ); if ( tmpProp.hDll ) { WINAMPGETOUTMODULE pGetMod = (WINAMPGETOUTMODULE) GetProcAddress( tmpProp.hDll, "winampGetOutModule" ); // call "winampGetInModule" DLL function Out_Module* pOutModule = pGetMod(); } // scan for next file if ( NULL != hFind && !FindNextFile( hFind, &sFF) ) { FindClose( hFind ); hFind = NULL; } } } }
bool BrainUtil::IsProcessRunning(const CString &strProcessName, bool bCompareNameOnly) { // Get the list of process identifiers. DWORD dwProcesses[2048]; DWORD dwSizeNeeded = 0; DWORD dwProcessesCount = 0; if ( !EnumProcesses( dwProcesses, sizeof(dwProcesses), &dwSizeNeeded ) ) { return false; } dwProcessesCount = dwSizeNeeded / sizeof(DWORD); CString strToCheck = strProcessName; strToCheck.MakeLower(); for(int i=0; i<(int)dwProcessesCount; i++ ) { if( dwProcesses[i] != 0 ) { HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, dwProcesses[i]); if(hProcess) { HMODULE hModule = NULL; dwSizeNeeded = 0; TCHAR cName[MAX_PATH]; if(EnumProcessModules(hProcess, &hModule, sizeof(DWORD), &dwSizeNeeded) ) { if(GetModuleFileNameEx(hProcess, hModule, cName, MAX_PATH ) != 0) { CString strFullName(cName); // C:\Windows\SysWOW64\vmnat.exe CString strProcName = strFullName; if(bCompareNameOnly) { int pos = strFullName.ReverseFind('\\'); if(-1 != pos) strProcName = strFullName.Right(strFullName.GetLength() - pos - 1); } strProcName.MakeLower(); if(strProcName == strToCheck) return true; } } CloseHandle(hProcess); } } } return false; }
void WriteFileToRegistry(const char * const pFilePath) { HKEY hKey = OpenRegistryKey("RegistryTest"); std::string strSubName = "Part"; std::string strSizeName = "Size"; size_t ulIndex = 1; auto splitFile = SplitFile(pFilePath); for (size_t i = 0; i < splitFile.size(); ++i) { std::string strFullName(strSubName + std::to_string(ulIndex)); WriteRegistryKeyString(hKey, strFullName.c_str(), splitFile[i].data(), READ_WRITE_SIZE); ++ulIndex; } CloseHandle(hKey); }
void InitWinAmpPlugins( HWND hWnd ) { WINAMPPLUGINPROP tmpProp; WIN32_FIND_DATA sFF; HANDLE hFind = NULL; CUString strPluginDir( g_config.GetAppPath() + _W( "\\Plugins\\in_*.dll" ) ); LTRACE2( _T( "Scanning for plugins using mask %s"), strPluginDir ); CUStringConvert strCnv; hFind = FindFirstFile( strCnv.ToT( strPluginDir ), &sFF); g_strWinampExt = _W(""); // setup the Output module Window Handle g_OutModule.hMainWindow = hWnd; // setup the Output Module Instance Handle g_OutModule.hDllInstance = NULL; while ( NULL != hFind && hFind != INVALID_HANDLE_VALUE ) { if ( ! ( sFF.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) ) { CUStringConvert strCnv; CUString strFullName( g_config.GetAppPath() + _W( "\\Plugins\\" ) + CUString( sFF.cFileName ) ); LTRACE2( _T( "Getting plugin %s" ), strFullName ); tmpProp.hDll = NULL; tmpProp.hDll = CDexLoadLibrary( strFullName ); if ( tmpProp.hDll ) { WINAMPGETINMODULE2 pGetMod = (WINAMPGETINMODULE2) GetProcAddress( tmpProp.hDll, "winampGetInModule2" ); // call "winampGetInModule2" DLL function tmpProp.pModule = pGetMod(); // set the file name tmpProp.strFileName = sFF.cFileName; // setup window handler tmpProp.pModule->hMainWindow = hWnd; tmpProp.pModule->hDllInstance = tmpProp.hDll; tmpProp.pModule->Init( ); tmpProp.strExt = CUString( tmpProp.pModule->FileExtensions, CP_UTF8 ); if ( 0 != tmpProp.pModule->UsesOutputPlug ) { if ( !g_strWinampExt.IsEmpty() ) g_strWinampExt += _W( ";" ); g_strWinampExt+= tmpProp.strExt; LTRACE2( _T( "Adding plugin %s to list" ), sFF.cFileName ); gs_vWinAmpProps.push_back( tmpProp ); } else { tmpProp.pModule->Quit( ); LTRACE2( _T( "Plugin (%s) NOT added, since it does not use the output plugin" ), sFF.cFileName ); } } // scan for next file if ( NULL != hFind && !FindNextFile( hFind, &sFF) ) { FindClose( hFind ); hFind = NULL; } } } }