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:
parent
4941565f18
commit
9daa32243d
@ -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));
|
||||
|
@ -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(),
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user