Core/CrashHandler: Log GetLastError() id if no description is found

Log the System Error id returned by GetLastError() in case FormatMessage() doesn't find a proper description for that message.
This commit is contained in:
jackpoz
2014-04-08 22:01:56 +02:00
parent 92a71b45aa
commit 37e6a3e1d2

View File

@@ -29,15 +29,23 @@
inline LPTSTR ErrorMessage(DWORD dw)
{
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL);
return (LPTSTR)lpMsgBuf;
DWORD formatResult = FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL);
if (formatResult != 0)
return (LPTSTR)lpMsgBuf;
else
{
LPTSTR msgBuf = (LPTSTR)LocalAlloc(LPTR, 30);
sprintf(msgBuf, "Unknown error: %u", dw);
return msgBuf;
}
}
//============================== Global Variables =============================