From 4bd8e7db7d983e4e3e88dc97aa4a8c8e42dbc3dd Mon Sep 17 00:00:00 2001 From: spx Date: Thu, 9 Feb 2012 08:57:20 +0000 Subject: [PATCH] Added workaround for loading C# plugins. (For some reason, C# x86 plugin with uncanonicalized path is not loaded correctly in Win7 32bit/WOW64.) http://rainmeter.net/forum/viewtopic.php?f=18&t=239&start=30#p56921 http://rainmeter.net/forum/viewtopic.php?f=18&t=239&start=80#p64237 --- Library/MeasurePlugin.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Library/MeasurePlugin.cpp b/Library/MeasurePlugin.cpp index aef5ab99..2f7e3fae 100644 --- a/Library/MeasurePlugin.cpp +++ b/Library/MeasurePlugin.cpp @@ -144,7 +144,26 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section) } pluginName.insert(0, Rainmeter->GetPluginPath()); - m_Plugin = CSystem::RmLoadLibrary(pluginName.c_str(), NULL); + // Canonicalize the path (Workaround for C# plugins) + { + pos = 0; + 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()); if (m_Plugin == NULL) { // Try to load from Rainmeter's folder @@ -154,7 +173,7 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section) std::wstring pluginName2 = Rainmeter->GetPath(); pluginName2.append(pluginName, pos + 1, pluginName.length() - (pos + 1)); - m_Plugin = CSystem::RmLoadLibrary(pluginName2.c_str(), NULL); + m_Plugin = CSystem::RmLoadLibrary(pluginName2.c_str()); } if (m_Plugin == NULL)