447832dd81
* Updated the GameApplication to mount the engine.pak This allows loading the autoexec.cfg and bootstrap.game.<config>.<platform>.setreg from the engine.pak files The engine.pak is searched for in the following order: <ExecutableDirectory>/engine.pak, followed by <ProjectCacheRoot>/engine.pak Removed a lot of unused APIs from the AZ::IO::Archive feature suite Updated many of the AZ::IO::Archive classes to use AZ::IO::Path internally. The logic to search for files within an Archive has been updated to use AZ::IO::Path and to remove case-insensitve string comparisons Somehow removed the CryFile dependency on anything Cry Updated the Settings Registry to support reading from the FileIOBase and therefore Archive files in the GameLauncher via the `SetUseFileIO` function Removed AzFramework Dependency on md5 3rdParty library Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Linux build fix Added an include of <stdio.h> before the <rapidxml/rapidxml.h> include as it usesnprintf. Added `static` to the constexpr constants in ExtractFileDescription in SettingsRegistryImpl.cpp to fix clang compile issue Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated the case used to mount the Engine PAK file in the GameApplication to be Engine.pak to match the other locations where it is mounted Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated the proper FFont call to FileIOBase::Size to supply the correct integer type of AZ::u64 instead of size_t This fixes building on platforms where size_t is type defined to be unsigned long Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Fixed segmentation fault in Archive::Unregister when outputing the filename of the Archive file being closed Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Fix calls to OpenPack in the Legacy LevelSystem The LevelSystem was calling the incorrect overload of OpenPack that accepts BindRoot for the mounted level.pak instead of the overload that that passes a memory block object. This was causing the level pak files to be mounted using an invalid directory, causing file accesses inside the level pak to fail. Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated the error messages in the ZipDir CacheFactory class to use AZ_Warning directly Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated the ArchiveFileIO m_trackedFiles container to store mapped type as an AZ::IO::Path Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
139 lines
4.4 KiB
C++
139 lines
4.4 KiB
C++
/*
|
|
* Copyright (c) Contributors to the Open 3D Engine Project.
|
|
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
*
|
|
*/
|
|
|
|
|
|
// Description : Support for Windows Error Reporting (WER)
|
|
|
|
|
|
#include "CrySystem_precompiled.h"
|
|
|
|
#ifdef WIN32
|
|
|
|
#include "System.h"
|
|
#include <AzCore/PlatformIncl.h>
|
|
#include <tchar.h>
|
|
#include "errorrep.h"
|
|
#include "ISystem.h"
|
|
|
|
#include <DbgHelp.h>
|
|
|
|
static WCHAR szPath[MAX_PATH + 1];
|
|
static WCHAR szFR[] = L"\\System32\\FaultRep.dll";
|
|
|
|
WCHAR* GetFullPathToFaultrepDll(void)
|
|
{
|
|
UINT rc = GetSystemWindowsDirectoryW(szPath, ARRAYSIZE(szPath));
|
|
if (rc == 0 || rc > ARRAYSIZE(szPath) - ARRAYSIZE(szFR) - 1)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
wcscat_s(szPath, szFR);
|
|
return szPath;
|
|
}
|
|
|
|
|
|
typedef BOOL (WINAPI * MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType,
|
|
CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
|
|
CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
|
|
CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam
|
|
);
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
LONG WINAPI CryEngineExceptionFilterMiniDump(struct _EXCEPTION_POINTERS* pExceptionPointers, const char* szDumpPath, MINIDUMP_TYPE DumpType)
|
|
{
|
|
// note: In debug mode, this dll is loaded on startup anyway, so this should not incur an additional load unless it crashes
|
|
// very early during startup.
|
|
|
|
fflush(nullptr); // according to MSDN on fflush, calling fflush on null flushes all buffers.
|
|
HMODULE hndDBGHelpDLL = LoadLibraryA("DBGHELP.DLL");
|
|
|
|
if (!hndDBGHelpDLL)
|
|
{
|
|
CryLogAlways("Failed to record DMP file: Could not open DBGHELP.DLL");
|
|
return EXCEPTION_CONTINUE_SEARCH;
|
|
}
|
|
|
|
MINIDUMPWRITEDUMP dumpFnPtr = (MINIDUMPWRITEDUMP)::GetProcAddress(hndDBGHelpDLL, "MiniDumpWriteDump");
|
|
if (!dumpFnPtr)
|
|
{
|
|
CryLogAlways("Failed to record DMP file: Unable to find MiniDumpWriteDump in DBGHELP.DLL");
|
|
return EXCEPTION_CONTINUE_SEARCH;
|
|
}
|
|
|
|
AZStd::wstring szDumpPathW;
|
|
AZStd::to_wstring(szDumpPathW, szDumpPath);
|
|
HANDLE hFile = ::CreateFileW(szDumpPathW.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
if (hFile == INVALID_HANDLE_VALUE)
|
|
{
|
|
CryLogAlways("Failed to record DMP file: could not open file '%s' for writing - error code: %d", szDumpPath, GetLastError());
|
|
return EXCEPTION_CONTINUE_SEARCH;
|
|
}
|
|
|
|
_MINIDUMP_EXCEPTION_INFORMATION ExInfo;
|
|
ExInfo.ThreadId = ::GetCurrentThreadId();
|
|
ExInfo.ExceptionPointers = pExceptionPointers;
|
|
ExInfo.ClientPointers = NULL;
|
|
|
|
BOOL bOK = dumpFnPtr(GetCurrentProcess(), GetCurrentProcessId(), hFile, DumpType, &ExInfo, NULL, NULL);
|
|
::CloseHandle(hFile);
|
|
|
|
if (bOK)
|
|
{
|
|
CryLogAlways("Successfully recorded DMP file: '%s'", szDumpPath);
|
|
return EXCEPTION_EXECUTE_HANDLER; // SUCCESS! you can execute your handlers now
|
|
}
|
|
else
|
|
{
|
|
CryLogAlways("Failed to record DMP file: '%s' - error code: %d", szDumpPath, GetLastError());
|
|
}
|
|
|
|
return EXCEPTION_CONTINUE_SEARCH;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
LONG WINAPI CryEngineExceptionFilterWER(struct _EXCEPTION_POINTERS* pExceptionPointers)
|
|
{
|
|
if (g_cvars.sys_WER > 1)
|
|
{
|
|
AZ::IO::FixedMaxPath dumpPath{ "@log@/CE2Dump.dmp" };
|
|
if (auto fileIoBase = AZ::IO::FileIOBase::GetInstance(); fileIoBase != nullptr)
|
|
{
|
|
dumpPath = fileIoBase->ResolvePath(dumpPath, "@log@/CE2Dump.dmp");
|
|
}
|
|
|
|
MINIDUMP_TYPE mdumpValue = (MINIDUMP_TYPE)(MiniDumpNormal);
|
|
if (g_cvars.sys_WER > 1)
|
|
{
|
|
mdumpValue = (MINIDUMP_TYPE)(g_cvars.sys_WER - 2);
|
|
}
|
|
|
|
return CryEngineExceptionFilterMiniDump(pExceptionPointers, dumpPath.c_str(), mdumpValue);
|
|
}
|
|
|
|
LONG lRet = EXCEPTION_CONTINUE_SEARCH;
|
|
WCHAR* psz = GetFullPathToFaultrepDll();
|
|
if (psz)
|
|
{
|
|
HMODULE hFaultRepDll = LoadLibraryW(psz);
|
|
if (hFaultRepDll)
|
|
{
|
|
pfn_REPORTFAULT pfn = (pfn_REPORTFAULT)GetProcAddress(hFaultRepDll, "ReportFault");
|
|
if (pfn)
|
|
{
|
|
pfn(pExceptionPointers, 0);
|
|
lRet = EXCEPTION_EXECUTE_HANDLER;
|
|
}
|
|
FreeLibrary(hFaultRepDll);
|
|
}
|
|
}
|
|
return lRet;
|
|
}
|
|
|
|
#endif // WIN32
|