diff -r c05bc47b2ecd -r 77c6b0da24ec sourcemm/metamod_oslink.cpp --- a/sourcemm/metamod_oslink.cpp Thu Jan 10 18:19:32 2008 +0000 +++ b/sourcemm/metamod_oslink.cpp Thu Jan 10 19:05:59 2008 +0000 @@ -27,19 +27,31 @@ #include "metamod_oslink.h" #include +#include #ifdef __linux #include -#include #endif #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