mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Disallowed plugins in ProgramPath\ (instead of ProgramPath\Plugins\)
This commit is contained in:
parent
96959d62f1
commit
cfd50acd3c
@ -120,58 +120,23 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring pluginName = parser.ReadString(section, L"Plugin", L"");
|
const std::wstring& plugin = parser.ReadString(section, L"Plugin", L"");
|
||||||
|
std::wstring pluginFile = Rainmeter->GetPluginPath();
|
||||||
size_t pos = pluginName.rfind(L'.');
|
size_t pos = plugin.rfind(L'\\');
|
||||||
if (pos == std::wstring::npos)
|
|
||||||
{
|
|
||||||
pluginName += L".dll";
|
|
||||||
}
|
|
||||||
|
|
||||||
pos = pluginName.rfind(L'\\');
|
|
||||||
if (pos != std::wstring::npos)
|
if (pos != std::wstring::npos)
|
||||||
{
|
{
|
||||||
pluginName.insert(0, L"..\\");
|
pluginFile.append(plugin, pos, plugin.length() - pos);
|
||||||
}
|
}
|
||||||
pluginName.insert(0, Rainmeter->GetPluginPath());
|
else
|
||||||
|
|
||||||
// Canonicalize the path (Workaround for C# plugins)
|
|
||||||
{
|
{
|
||||||
pos = 0;
|
pluginFile += plugin;
|
||||||
while ((pos = pluginName.find(L"\\\\", pos)) != std::wstring::npos)
|
|
||||||
{
|
|
||||||
pluginName.erase(pos, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
WCHAR buffer[MAX_PATH];
|
|
||||||
if (PathCanonicalize(buffer, pluginName.c_str()))
|
|
||||||
{
|
|
||||||
pluginName = buffer;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LogWithArgs(LOG_WARNING, L"Plugin: Failed to canonicalize plugin path: %s", pluginName.c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Plugin = CSystem::RmLoadLibrary(pluginName.c_str());
|
m_Plugin = CSystem::RmLoadLibrary(pluginFile.c_str());
|
||||||
if (m_Plugin == NULL)
|
if (m_Plugin == NULL)
|
||||||
{
|
{
|
||||||
// Try to load from Rainmeter's folder
|
LogWithArgs(LOG_ERROR, L"Plugin: \"%s\" not found", pluginFile.c_str());
|
||||||
pos = pluginName.rfind(L'\\');
|
return;
|
||||||
if (pos != std::wstring::npos)
|
|
||||||
{
|
|
||||||
std::wstring pluginName2 = Rainmeter->GetPath();
|
|
||||||
pluginName2.append(pluginName, pos + 1, pluginName.length() - (pos + 1));
|
|
||||||
|
|
||||||
m_Plugin = CSystem::RmLoadLibrary(pluginName2.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_Plugin == NULL)
|
|
||||||
{
|
|
||||||
LogWithArgs(LOG_ERROR, L"Plugin: \"%s\" not found", pluginName.c_str());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FARPROC initializeFunc = GetProcAddress(m_Plugin, "Initialize");
|
FARPROC initializeFunc = GetProcAddress(m_Plugin, "Initialize");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user