diff --git a/sourcemm/CPlugin.cpp b/sourcemm/CPlugin.cpp index 2996f2b..ee4077d 100644 --- a/sourcemm/CPlugin.cpp +++ b/sourcemm/CPlugin.cpp @@ -368,7 +368,7 @@ CPluginManager::CPlugin *CPluginManager::_Load(const char *file, PluginId source if (!pl->m_Lib) { if (error) - UTIL_Format(error, maxlen, "%s", dlerror()); + UTIL_Format(error, maxlen, "[%d]", GetLastError()); pl->m_Status = Pl_Error; } else { CreateInterfaceFn pfn = (CreateInterfaceFn)(dlsym(pl->m_Lib, PL_EXPOSURE_C)); diff --git a/sourcemm/oslink.cpp b/sourcemm/oslink.cpp index cee64a3..9c8ec16 100644 --- a/sourcemm/oslink.cpp +++ b/sourcemm/oslink.cpp @@ -16,17 +16,29 @@ #include "oslink.h" #ifdef __linux #include -#include #endif +#include #if defined __WIN32__ || defined _WIN32 || defined WIN32 const char *dlerror() { static char buf[1024]; - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR) &buf, 0, NULL); + DWORD num; + + num = GetLastError(); + + if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + num, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + buf, + sizeof(buf), + NULL) + == 0) + { + _snprintf(buf, sizeof(buf), "unknown error %x", num); + } + return buf; } #endif