1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2025-02-26 19:54:14 +01:00

fixed FormatMessage() being used totally wrong on win32

--HG--
branch : sourcemm-1.4.3
extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/branches/sourcemm-1.4.3%40610
This commit is contained in:
David Anderson 2008-01-10 16:54:04 +00:00
parent 4941565f18
commit 9daa32243d
2 changed files with 18 additions and 6 deletions

View File

@ -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));

View File

@ -16,17 +16,29 @@
#include "oslink.h"
#ifdef __linux
#include <errno.h>
#include <stdio.h>
#endif
#include <stdio.h>
#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(),
DWORD num;
num = GetLastError();
if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
num,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &buf, 0, NULL);
buf,
sizeof(buf),
NULL)
== 0)
{
_snprintf(buf, sizeof(buf), "unknown error %x", num);
}
return buf;
}
#endif