[Application]

- Added some codes to avoid loading a dll from current directory.

[Library]
- Added new functions to avoid loading a dll from current directory. (CSystem::RmSetDllDirectory(), CSystem::RmLoadLibrary())
This commit is contained in:
spx
2010-09-11 19:39:45 +00:00
parent 3aa4673019
commit 3da0aa3f4c
11 changed files with 252 additions and 82 deletions

View File

@ -18,6 +18,7 @@
#include "StdAfx.h"
#include "Rainmeter.h"
#include "System.h"
#include "MeterWindow.h"
#include "Measure.h"
#include "resource.h"
@ -360,12 +361,8 @@ void ScanPlugins()
// Try to get the version and author
std::wstring tmpSz = Rainmeter->GetPluginPath() + fileData.cFileName;
UINT oldMode = SetErrorMode(0);
SetErrorMode(oldMode | SEM_FAILCRITICALERRORS); // Prevent the system from displaying message box
SetLastError(ERROR_SUCCESS);
HMODULE dll = LoadLibrary(tmpSz.c_str());
DWORD err = GetLastError();
SetErrorMode(oldMode); // Reset
DWORD err = 0;
HMODULE dll = CSystem::RmLoadLibrary(tmpSz.c_str(), &err, true);
if (dll)
{
GETPLUGINAUTHOR GetAuthorFunc = (GETPLUGINAUTHOR)GetProcAddress(dll, "GetPluginAuthor");