Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorUnderground78 <underground78@users.sourceforge.net>2013-05-18 14:10:48 +0400
committerUnderground78 <underground78@users.sourceforge.net>2013-05-18 19:59:24 +0400
commit1cc04dcabba2ee79d9325c4b5ae1c7f7eb477df8 (patch)
treeb4e0a17214e5c233bd1b034da41e14b5f090b352 /src
parent8f6ae9a9d7c5c6d26bdf970220077f4f3628534e (diff)
MiniDump: Code simplification.
Diffstat (limited to 'src')
-rw-r--r--src/mpc-hc/MiniDump.cpp41
1 files changed, 14 insertions, 27 deletions
diff --git a/src/mpc-hc/MiniDump.cpp b/src/mpc-hc/MiniDump.cpp
index 8ae11cfa7..06f15542f 100644
--- a/src/mpc-hc/MiniDump.cpp
+++ b/src/mpc-hc/MiniDump.cpp
@@ -96,7 +96,7 @@ LONG WINAPI CMiniDump::UnhandledExceptionFilter(_EXCEPTION_POINTERS* lpTopLevelE
HMODULE hDll = nullptr;
TCHAR szResult[800];
szResult[0] = _T('\0');
- CString strDumpPath;
+ CPath dumpPath;
if (!m_bMiniDumpEnabled) {
return retval;
@@ -107,31 +107,18 @@ LONG WINAPI CMiniDump::UnhandledExceptionFilter(_EXCEPTION_POINTERS* lpTopLevelE
if (hDll != nullptr) {
MINIDUMPWRITEDUMP pMiniDumpWriteDump = (MINIDUMPWRITEDUMP)::GetProcAddress(hDll, "MiniDumpWriteDump");
- if (pMiniDumpWriteDump != nullptr) {
- if (!AfxGetMyApp()->IsIniValid()) {
- HRESULT hr = SHGetFolderPath(nullptr, CSIDL_APPDATA, nullptr, 0, strDumpPath.GetBuffer(MAX_PATH));
- if (FAILED(hr)) {
- FreeLibrary(hDll);
- return retval;
- }
-
- strDumpPath.ReleaseBuffer();
- strDumpPath.Append(_T("\\Media Player Classic\\"));
-
- // Check that the folder actually exists
- if (!FileExists(strDumpPath)) {
- VERIFY(CreateDirectory(strDumpPath, nullptr));
- }
-
- strDumpPath.Append(AfxGetApp()->m_pszExeName);
- strDumpPath.Append(_T(".exe"));
- } else {
- strDumpPath = GetProgramPath(true);
+ if (pMiniDumpWriteDump != nullptr && AfxGetMyApp()->GetAppSavePath(dumpPath)) {
+ // Check that the folder actually exists
+ if (!FileExists(dumpPath)) {
+ VERIFY(CreateDirectory(dumpPath, nullptr));
}
- strDumpPath.AppendFormat(_T(".%d.%d.%d.%d.dmp"), MPC_VERSION_NUM);
+
+ CString strDumpName = AfxGetApp()->m_pszExeName;
+ strDumpName.AppendFormat(_T(".exe.%d.%d.%d.%d.dmp"), MPC_VERSION_NUM);
+ dumpPath.Append(strDumpName);
// create the file
- HANDLE hFile = ::CreateFile(strDumpPath, GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, CREATE_ALWAYS,
+ HANDLE hFile = ::CreateFile(dumpPath, GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, nullptr);
if (hFile != INVALID_HANDLE_VALUE) {
@@ -144,15 +131,15 @@ LONG WINAPI CMiniDump::UnhandledExceptionFilter(_EXCEPTION_POINTERS* lpTopLevelE
// write the dump
bDumpCreated = pMiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &ExInfo, nullptr, nullptr);
if (bDumpCreated) {
- _stprintf_s(szResult, _countof(szResult), ResStr(IDS_MPC_CRASH), strDumpPath);
+ _stprintf_s(szResult, _countof(szResult), ResStr(IDS_MPC_CRASH), dumpPath);
retval = EXCEPTION_EXECUTE_HANDLER;
} else {
- _stprintf_s(szResult, _countof(szResult), ResStr(IDS_MPC_MINIDUMP_FAIL), strDumpPath, GetLastError());
+ _stprintf_s(szResult, _countof(szResult), ResStr(IDS_MPC_MINIDUMP_FAIL), dumpPath, GetLastError());
}
::CloseHandle(hFile);
} else {
- _stprintf_s(szResult, _countof(szResult), ResStr(IDS_MPC_MINIDUMP_FAIL), strDumpPath, GetLastError());
+ _stprintf_s(szResult, _countof(szResult), ResStr(IDS_MPC_MINIDUMP_FAIL), dumpPath, GetLastError());
}
}
FreeLibrary(hDll);
@@ -162,7 +149,7 @@ LONG WINAPI CMiniDump::UnhandledExceptionFilter(_EXCEPTION_POINTERS* lpTopLevelE
switch (MessageBox(nullptr, szResult, _T("MPC-HC - Mini Dump"), bDumpCreated ? MB_YESNO : MB_OK)) {
case IDYES:
ShellExecute(nullptr, _T("open"), BUGS_URL, nullptr, nullptr, SW_SHOWDEFAULT);
- ExploreToFile(strDumpPath);
+ ExploreToFile(dumpPath);
break;
case IDNO:
retval = EXCEPTION_CONTINUE_SEARCH; // rethrow the exception to make easier attaching a debugger