summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-01-12 16:38:48 +0100
committerHaru <haru@dotalux.com>2015-01-12 18:31:37 +0100
commitfe00cc320396bc7ac301a22592b718792ae49adf (patch)
treea254d300f90f85b7d3c202325cad76715b26c404 /src
parente53d7e97068b404591170436e27aa5f85b079358 (diff)
downloadhercules-fe00cc320396bc7ac301a22592b718792ae49adf.tar.gz
hercules-fe00cc320396bc7ac301a22592b718792ae49adf.tar.bz2
hercules-fe00cc320396bc7ac301a22592b718792ae49adf.tar.xz
hercules-fe00cc320396bc7ac301a22592b718792ae49adf.zip
Added detailed error message when a plugin fails to load
- This helps figuring out why a plugin can't be loaded (especially on linux systems.) - Special thanks to Dastgir. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src')
-rw-r--r--src/common/HPM.c5
-rw-r--r--src/common/HPM.h2
2 files changed, 5 insertions, 2 deletions
diff --git a/src/common/HPM.c b/src/common/HPM.c
index 92b9702d4..c361ad31c 100644
--- a/src/common/HPM.c
+++ b/src/common/HPM.c
@@ -141,8 +141,9 @@ struct hplugin *hplugin_load(const char* filename) {
plugin = HPM->create();
- if( !( plugin->dll = plugin_open(filename) ) ){
- ShowWarning("HPM:plugin_load: failed to load '"CL_WHITE"%s"CL_RESET"', skipping...\n", filename);
+ if (!(plugin->dll = plugin_open(filename))) {
+ char buf[1024];
+ ShowWarning("HPM:plugin_load: failed to load '"CL_WHITE"%s"CL_RESET"' (error: %s), skipping...\n", filename, plugin_geterror(buf));
HPM->unload(plugin);
return NULL;
}
diff --git a/src/common/HPM.h b/src/common/HPM.h
index 4e1aa5beb..973bc6cca 100644
--- a/src/common/HPM.h
+++ b/src/common/HPM.h
@@ -19,6 +19,7 @@
#define plugin_open(x) LoadLibraryA(x)
#define plugin_import(x,y,z) (z)GetProcAddress((x),(y))
#define plugin_close(x) FreeLibrary(x)
+ #define plugin_geterror(buf) (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, buf, sizeof(buf), NULL) ? buf : "Unknown error")
#define DLL_EXT ".dll"
#define DLL HINSTANCE
@@ -31,6 +32,7 @@
#endif // RTLD_DEEPBIND
#define plugin_import(x,y,z) (z)dlsym((x),(y))
#define plugin_close(x) dlclose(x)
+ #define plugin_geterror(buf) ((void)buf, dlerror())
#if defined CYGWIN
#define DLL_EXT ".dll"