diff --git a/common/include/Utilities/Path.h b/common/include/Utilities/Path.h index 351e99d851..f5274c9a8a 100644 --- a/common/include/Utilities/Path.h +++ b/common/include/Utilities/Path.h @@ -53,6 +53,7 @@ public: void Clear() { wxFileName::Clear(); } + wxCharBuffer ToUTF8() const { return GetPath().ToUTF8(); } wxCharBuffer ToAscii() const { return GetPath().ToAscii(); } wxString ToString() const { return GetPath(); } @@ -130,6 +131,7 @@ namespace Path extern wxString Normalize( const wxString& srcpath ); extern wxString Normalize( const wxDirName& srcpath ); + extern wxString MakeAbsolute( const wxString& srcpath ); extern wxString Combine( const wxString& srcPath, const wxString& srcFile ); extern wxString Combine( const wxDirName& srcPath, const wxFileName& srcFile ); diff --git a/common/src/Utilities/PathUtils.cpp b/common/src/Utilities/PathUtils.cpp index 800576b76e..668f26df9c 100644 --- a/common/src/Utilities/PathUtils.cpp +++ b/common/src/Utilities/PathUtils.cpp @@ -121,6 +121,13 @@ wxString Path::Normalize( const wxDirName& src ) return wxDirName(src).Normalize().ToString(); } +wxString Path::MakeAbsolute( const wxString& src ) +{ + wxFileName absolute( src ); + absolute.MakeAbsolute(); + return absolute.GetFullPath(); +} + // Concatenates two pathnames together, inserting delimiters (backslash on win32) // as needed! Assumes the 'dest' is allocated to at least g_MaxPath length. // diff --git a/pcsx2/gui/AppCorePlugins.cpp b/pcsx2/gui/AppCorePlugins.cpp index 6fb1b1d1a9..ee151560ec 100644 --- a/pcsx2/gui/AppCorePlugins.cpp +++ b/pcsx2/gui/AppCorePlugins.cpp @@ -418,6 +418,8 @@ protected: int EnumeratePluginsInFolder( const wxDirName& searchpath, wxArrayString* dest ) { + if (!searchpath.Exists()) return 0; + ScopedPtr placebo; wxArrayString* realdest = dest; if( realdest == NULL ) @@ -432,8 +434,23 @@ int EnumeratePluginsInFolder( const wxDirName& searchpath, wxArrayString* dest ) wxString pattern( L"*%s*" ); #endif - return searchpath.Exists() ? - wxDir::GetAllFiles( searchpath.ToString(), realdest, wxsFormat( pattern, wxDynamicLibrary::GetDllExt()), wxDIR_FILES ) : 0; + wxDir::GetAllFiles( searchpath.ToString(), realdest, pxsFmt( pattern, wxDynamicLibrary::GetDllExt()), wxDIR_FILES ); + + // SECURITY ISSUE: (applies primarily to Windows, but is a good idea on any platform) + // The search folder order for plugins can vary across operating systems, and in some poorly designed + // cases (old versions of windows), the search order is a security hazard because it does not + // search where you might really expect. In our case wedo not want *any* searching. The only + // plugins we want to load are the ones we found in the directly the user specified, so make + // sure all paths are FULLY QUALIFIED ABSOLUTE PATHS. + // + // (for details, read: http://msdn.microsoft.com/en-us/library/ff919712.aspx ) + + for (uint i=0; iGetCount(); ++i ) + { + (*realdest)[i] = Path::MakeAbsolute((*realdest)[i]); + } + + return realdest->GetCount(); } // Posts a message to the App to reload plugins. Plugins are loaded via a background thread diff --git a/pcsx2/gui/Panels/PluginSelectorPanel.cpp b/pcsx2/gui/Panels/PluginSelectorPanel.cpp index d4772a462e..57ce696985 100644 --- a/pcsx2/gui/Panels/PluginSelectorPanel.cpp +++ b/pcsx2/gui/Panels/PluginSelectorPanel.cpp @@ -634,8 +634,24 @@ void Panels::PluginSelectorPanel::OnConfigure_Clicked( wxCommandEvent& evt ) if( ConfigureFnptr configfunc = (ConfigureFnptr)dynlib.GetSymbol( tbl_PluginInfo[pid].GetShortname() + L"configure" ) ) { + wxWindowDisabler disabler; ScopedCoreThreadPause paused_core( new SysExecEvent_SaveSinglePlugin(pid) ); + if (!CorePlugins.AreLoaded()) + { + typedef void (CALLBACK* SetDirFnptr)( const char* dir ); + + if( SetDirFnptr func = (SetDirFnptr)dynlib.GetSymbol( tbl_PluginInfo[pid].GetShortname() + L"setSettingsDir" ) ) + { + func( GetSettingsFolder().ToUTF8() ); + } + + if( SetDirFnptr func = (SetDirFnptr)dynlib.GetSymbol( tbl_PluginInfo[pid].GetShortname() + L"setLogDir" ) ) + { + func( GetLogFolder().ToUTF8() ); + } + } + configfunc(); } }