mirror of
https://github.com/mangosfour/server.git
synced 2025-12-18 01:37:01 +00:00
[Sync] Project sync
This commit is contained in:
parent
f1c9e0f94b
commit
86690df496
22 changed files with 1731 additions and 385 deletions
|
|
@ -61,7 +61,7 @@ WheatyExceptionReport::WheatyExceptionReport() // Constructor
|
|||
WheatyExceptionReport::~WheatyExceptionReport()
|
||||
{
|
||||
if (m_previousFilter)
|
||||
SetUnhandledExceptionFilter(m_previousFilter);
|
||||
{ SetUnhandledExceptionFilter(m_previousFilter); }
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
|
|
@ -74,7 +74,7 @@ LONG WINAPI WheatyExceptionReport::WheatyUnhandledExceptionFilter(
|
|||
GetModuleFileName(0, module_folder_name, MAX_PATH);
|
||||
TCHAR* pos = _tcsrchr(module_folder_name, '\\');
|
||||
if (!pos)
|
||||
return 0;
|
||||
{ return 0; }
|
||||
pos[0] = '\0';
|
||||
++pos;
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ LONG WINAPI WheatyExceptionReport::WheatyUnhandledExceptionFilter(
|
|||
if (!CreateDirectory(crash_folder_path, NULL))
|
||||
{
|
||||
if (GetLastError() != ERROR_ALREADY_EXISTS)
|
||||
return 0;
|
||||
{ return 0; }
|
||||
}
|
||||
|
||||
SYSTEMTIME systime;
|
||||
|
|
@ -110,34 +110,34 @@ LONG WINAPI WheatyExceptionReport::WheatyUnhandledExceptionFilter(
|
|||
}
|
||||
|
||||
if (m_previousFilter)
|
||||
return m_previousFilter(pExceptionInfo);
|
||||
{ return m_previousFilter(pExceptionInfo); }
|
||||
else
|
||||
return EXCEPTION_EXECUTE_HANDLER/*EXCEPTION_CONTINUE_SEARCH*/;
|
||||
{ return EXCEPTION_EXECUTE_HANDLER/*EXCEPTION_CONTINUE_SEARCH*/; }
|
||||
}
|
||||
|
||||
BOOL WheatyExceptionReport::_GetProcessorName(TCHAR* sProcessorName, DWORD maxcount)
|
||||
{
|
||||
if (!sProcessorName)
|
||||
return FALSE;
|
||||
{ return FALSE; }
|
||||
|
||||
HKEY hKey;
|
||||
LONG lRet;
|
||||
lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"),
|
||||
0, KEY_QUERY_VALUE, &hKey);
|
||||
if (lRet != ERROR_SUCCESS)
|
||||
return FALSE;
|
||||
{ return FALSE; }
|
||||
TCHAR szTmp[2048];
|
||||
DWORD cntBytes = sizeof(szTmp);
|
||||
lRet = ::RegQueryValueEx(hKey, _T("ProcessorNameString"), NULL, NULL,
|
||||
(LPBYTE)szTmp, &cntBytes);
|
||||
if (lRet != ERROR_SUCCESS)
|
||||
return FALSE;
|
||||
{ return FALSE; }
|
||||
::RegCloseKey(hKey);
|
||||
sProcessorName[0] = '\0';
|
||||
// Skip spaces
|
||||
TCHAR* psz = szTmp;
|
||||
while (iswspace(*psz))
|
||||
++psz;
|
||||
{ ++psz; }
|
||||
_tcsncpy(sProcessorName, psz, maxcount);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -154,7 +154,7 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax)
|
|||
{
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
if (!::GetVersionEx((OSVERSIONINFO*)&osvi))
|
||||
return FALSE;
|
||||
{ return FALSE; }
|
||||
}
|
||||
*szVersion = _T('\0');
|
||||
TCHAR wszTmp[128];
|
||||
|
|
@ -167,21 +167,21 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax)
|
|||
{
|
||||
default: // 2
|
||||
if (osvi.wProductType == VER_NT_WORKSTATION)
|
||||
_tcsncat(szVersion, _T("Windows 8 "), cntMax);
|
||||
{ _tcsncat(szVersion, _T("Windows 8 "), cntMax); }
|
||||
else
|
||||
_tcsncat(szVersion, _T("Windows Server 2012 "), cntMax);
|
||||
{ _tcsncat(szVersion, _T("Windows Server 2012 "), cntMax); }
|
||||
break;
|
||||
case 1:
|
||||
if (osvi.wProductType == VER_NT_WORKSTATION)
|
||||
_tcsncat(szVersion, _T("Windows 7 "), cntMax);
|
||||
{ _tcsncat(szVersion, _T("Windows 7 "), cntMax); }
|
||||
else
|
||||
_tcsncat(szVersion, _T("Windows Server 2008 R2 "), cntMax);
|
||||
{ _tcsncat(szVersion, _T("Windows Server 2008 R2 "), cntMax); }
|
||||
break;
|
||||
case 0:
|
||||
if (osvi.wProductType == VER_NT_WORKSTATION)
|
||||
_tcsncat(szVersion, _T("Windows Vista "), cntMax);
|
||||
{ _tcsncat(szVersion, _T("Windows Vista "), cntMax); }
|
||||
else
|
||||
_tcsncat(szVersion, _T("Windows Server 2008 "), cntMax);
|
||||
{ _tcsncat(szVersion, _T("Windows Server 2008 "), cntMax); }
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
|
@ -235,9 +235,9 @@ void WheatyExceptionReport::PrintSystemInfo()
|
|||
SystemInfo.dwNumberOfProcessors, MemoryStatus.dwTotalPhys / 0x400, MemoryStatus.dwAvailPhys / 0x400, MemoryStatus.dwTotalPageFile / 0x400);
|
||||
|
||||
if (_GetWindowsVersion(sString, countof(sString)))
|
||||
_tprintf(_T("\r\n*** Operation System ***\r\n%s\r\n"), sString);
|
||||
{ _tprintf(_T("\r\n*** Operation System ***\r\n%s\r\n"), sString); }
|
||||
else
|
||||
_tprintf(_T("\r\n*** Operation System:\r\n<unknown>\r\n"));
|
||||
{ _tprintf(_T("\r\n*** Operation System:\r\n<unknown>\r\n")); }
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
@ -251,7 +251,7 @@ void WheatyExceptionReport::printTracesForAllThreads()
|
|||
// Take a snapshot of all running threads
|
||||
hThreadSnap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
|
||||
if (hThreadSnap == INVALID_HANDLE_VALUE)
|
||||
return;
|
||||
{ return; }
|
||||
|
||||
// Fill in the size of the structure before using it.
|
||||
te32.dwSize = sizeof(THREADENTRY32);
|
||||
|
|
@ -456,12 +456,12 @@ BOOL WheatyExceptionReport::GetLogicalAddress(
|
|||
MEMORY_BASIC_INFORMATION mbi;
|
||||
|
||||
if (!VirtualQuery(addr, &mbi, sizeof(mbi)))
|
||||
return FALSE;
|
||||
{ return FALSE; }
|
||||
|
||||
DWORD_PTR hMod = (DWORD_PTR)mbi.AllocationBase;
|
||||
|
||||
if (!GetModuleFileName((HMODULE)hMod, szModule, len))
|
||||
return FALSE;
|
||||
{ return FALSE; }
|
||||
|
||||
// Point to the DOS header in memory
|
||||
PIMAGE_DOS_HEADER pDosHdr = (PIMAGE_DOS_HEADER)hMod;
|
||||
|
|
@ -476,8 +476,8 @@ BOOL WheatyExceptionReport::GetLogicalAddress(
|
|||
// Iterate through the section table, looking for the one that encompasses
|
||||
// the linear address.
|
||||
for (unsigned i = 0;
|
||||
i < pNtHdr->FileHeader.NumberOfSections;
|
||||
++i, ++pSection)
|
||||
i < pNtHdr->FileHeader.NumberOfSections;
|
||||
++i, ++pSection)
|
||||
{
|
||||
DWORD_PTR sectionStart = pSection->VirtualAddress;
|
||||
DWORD_PTR sectionEnd = sectionStart
|
||||
|
|
@ -561,9 +561,9 @@ void WheatyExceptionReport::WriteStackDetails(
|
|||
SymFunctionTableAccess64,
|
||||
SymGetModuleBase64,
|
||||
0))
|
||||
break;
|
||||
{ break; }
|
||||
if (0 == sf.AddrFrame.Offset) // Basic sanity check to make sure
|
||||
break; // the frame is OK. Bail if not.
|
||||
{ break; } // the frame is OK. Bail if not.
|
||||
#ifdef _M_IX86
|
||||
_tprintf(_T("%08X %08X "), sf.AddrPC.Offset, sf.AddrFrame.Offset);
|
||||
#endif
|
||||
|
|
@ -577,10 +577,10 @@ void WheatyExceptionReport::WriteStackDetails(
|
|||
// Get the name of the function for this stack frame entry
|
||||
CSymbolInfoPackage sip;
|
||||
if (SymFromAddr(
|
||||
m_hProcess, // Process handle of the current process
|
||||
sf.AddrPC.Offset, // Symbol address
|
||||
&symDisplacement, // Address of the variable that will receive the displacement
|
||||
&sip.si)) // Address of the SYMBOL_INFO structure (inside "sip" object)
|
||||
m_hProcess, // Process handle of the current process
|
||||
sf.AddrPC.Offset, // Symbol address
|
||||
&symDisplacement, // Address of the variable that will receive the displacement
|
||||
&sip.si)) // Address of the SYMBOL_INFO structure (inside "sip" object)
|
||||
{
|
||||
_tprintf(_T("%hs+%I64X"), sip.si.Name, symDisplacement);
|
||||
}
|
||||
|
|
@ -642,10 +642,10 @@ WheatyExceptionReport::EnumerateSymbolsCallback(
|
|||
__try
|
||||
{
|
||||
if (FormatSymbolValue(pSymInfo, (STACKFRAME*)UserContext,
|
||||
szBuffer, sizeof(szBuffer)))
|
||||
_tprintf(_T("\t%s\r\n"), szBuffer);
|
||||
szBuffer, sizeof(szBuffer)))
|
||||
{ _tprintf(_T("\t%s\r\n"), szBuffer); }
|
||||
}
|
||||
__except (1)
|
||||
__except(1)
|
||||
{
|
||||
_tprintf(_T("punting on symbol %s\r\n"), pSymInfo->Name);
|
||||
}
|
||||
|
|
@ -668,13 +668,13 @@ bool WheatyExceptionReport::FormatSymbolValue(
|
|||
|
||||
// Indicate if the variable is a local or parameter
|
||||
if (pSym->Flags & IMAGEHLP_SYMBOL_INFO_PARAMETER)
|
||||
pszCurrBuffer += sprintf(pszCurrBuffer, "Parameter ");
|
||||
{ pszCurrBuffer += sprintf(pszCurrBuffer, "Parameter "); }
|
||||
else if (pSym->Flags & IMAGEHLP_SYMBOL_INFO_LOCAL)
|
||||
pszCurrBuffer += sprintf(pszCurrBuffer, "Local ");
|
||||
{ pszCurrBuffer += sprintf(pszCurrBuffer, "Local "); }
|
||||
|
||||
// If it's a function, don't do anything.
|
||||
if (pSym->Tag == 5) // SymTagFunction from CVCONST.H from the DIA SDK
|
||||
return false;
|
||||
{ return false; }
|
||||
|
||||
DWORD_PTR pVariable = 0; // Will point to the variable's data in memory
|
||||
|
||||
|
|
@ -754,7 +754,7 @@ char* WheatyExceptionReport::DumpTypeIndex(
|
|||
&dwChildrenCount);
|
||||
|
||||
if (!dwChildrenCount) // If no children, we're done
|
||||
return pszCurrBuffer;
|
||||
{ return pszCurrBuffer; }
|
||||
|
||||
// Prepare to get an array of "TypeIds", representing each of the children.
|
||||
// SymGetTypeInfo(TI_FINDCHILDREN) expects more memory than just a
|
||||
|
|
@ -783,7 +783,7 @@ char* WheatyExceptionReport::DumpTypeIndex(
|
|||
{
|
||||
// Add appropriate indentation level (since this routine is recursive)
|
||||
for (unsigned j = 0; j <= nestingLevel + 1; ++j)
|
||||
pszCurrBuffer += sprintf(pszCurrBuffer, "\t");
|
||||
{ pszCurrBuffer += sprintf(pszCurrBuffer, "\t"); }
|
||||
|
||||
// Recurse for each of the child types
|
||||
bool bHandled2;
|
||||
|
|
@ -840,9 +840,9 @@ char* WheatyExceptionReport::FormatOutputValue(char* pszCurrBuffer,
|
|||
{
|
||||
// Format appropriately (assuming it's a 1, 2, or 4 bytes (!!!)
|
||||
if (length == 1)
|
||||
pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", *(PBYTE)pAddress);
|
||||
{ pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", *(PBYTE)pAddress); }
|
||||
else if (length == 2)
|
||||
pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", *(PWORD)pAddress);
|
||||
{ pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", *(PWORD)pAddress); }
|
||||
else if (length == 4)
|
||||
{
|
||||
if (basicType == btFloat)
|
||||
|
|
@ -861,7 +861,7 @@ char* WheatyExceptionReport::FormatOutputValue(char* pszCurrBuffer,
|
|||
*(PDWORD)pAddress);
|
||||
}
|
||||
else
|
||||
pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", *(PDWORD)pAddress);
|
||||
{ pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", *(PDWORD)pAddress); }
|
||||
}
|
||||
else if (length == 8)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue