#include "stdafx.h"
#include <atlpath.h>
#include "../../include/MiniDumper.h"
#include "../../include/DumpCommon.h"
using namespace Proud;
const int _MAX_PATH2 = 8192;
#define _COUNTOF(array) (sizeof(array)/sizeof(array[0]))
void GetDumpFilePath(LPWSTR output)
{
WCHAR path[_MAX_PATH2];
WCHAR drive[_MAX_PATH2];
WCHAR dir[_MAX_PATH2];
WCHAR fname[_MAX_PATH2];
WCHAR ext[_MAX_PATH2];
WCHAR module_file_name[_MAX_PATH2];
GetModuleFileNameW(NULL, module_file_name, _COUNTOF(module_file_name));
_tsplitpath_s(module_file_name, drive, _MAX_PATH2, dir, _MAX_PATH2, fname, _MAX_PATH2, ext, _MAX_PATH2);
_tmakepath_s(path, _MAX_PATH2, drive, dir, L"", L"");
wsprintf(output, L"%s%s.DMP", path, fname);
};
void AccessViolation()
{
int* a = 0;
*a = 1;
}
// void wmain(int argc, wchar_t* argv[])
int main(int argc, char* argv[])
{
int nRetCode = 0;
int *data = 0;
int menu = 0;
WCHAR dumpFileName[_MAX_PATH2] = { 0, };
GetDumpFilePath(dumpFileName);
CMiniDumpParameter parameter;
parameter.m_dumpFileName = dumpFileName;
parameter.m_miniDumpType = SmallMiniDumpType;
switch (CMiniDumper::Instance().Startup(parameter))
{
case MiniDumpAction_AlarmCrash:
// 오류 발생으로 새로운 프로세스에서 덤프 파일을 생성한 후, 이 값이 return이 됩니다.
// 생성된 덤프 파일을 메일로 보내거나 에러 창을 보이는 등 유저가 덤프 파일 생성 후, 처리해야할 작업을 처리해주시면 됩니다.
// A dump file is created at a new process due to error occurrence and then this value will be returned.
// After a user create a dump file, do works that need to be done such as sending a created dump file by email or showing an error window.
// 因出现错误,在新的process中生成转储文件后该值将被返还。
// 将生成的转储文件以邮件的形式发送,或可以看到 Error对话框的用户生成转存文件后,处理应处理的事即可
// エラー発生により新しいプロセスからダンプファイルを生成した後、この値がreturnされます。
// 生成されたダンプファイルをメールで送ったり、エラーメッセージが提示されるなどユーザーがダンプファイル生成後、処理すべきの作業をしてください。
...
return nRetCode;
case MiniDumpAction_DoNothing:
// 유저 호출로 새로운 프로세스에서 덤프 파일을 생성한 후, 이 값이 반환됩니다.
// 이 경우에는 아무것도 하지 말아야합니다.
// After creating a dump file at a new process by calling a user, this value will be returned.
// In this case, you should not do anything.
// 因用户呼叫,在新的process中生成转储文件后,该值将被返还。
// 在这种情况,不要做任何事情。.
// ユーザー呼び出しにより新しいプロセスからダンプファイルを生成した後、この値が返還されます。
// この場合何もしないでください。
...
return nRetCode;
default:
// MiniDumpAction_None
// 일반적으로 앱 실행 시, 이 값이 반환됩니다.
// 여기서는 일반적으로 처리해야할 일을 처리해주시면 됩니다.
// When executing apps, this value will be returned.
// In this case, do works that generally need to be done.
// 一般运行App时,该值将被返还。
//在这里处理一般应处理的事情即可。
// 一般的にアプリ実行後、この値が返還されます。
// ここでは一般的に処理すべきの事を処理してください。
...
break;
}
while (1)
{
puts("MENU: 1. Access Violation('a')");
printf("> ");
menu = getchar();
switch (menu)
{
case 'a':
AccessViolation();
break;
default:
break;
}
}
return 0;
}
#include "stdafx.h"
#include <atlpath.h>
#include "../../include/DumpCommon.h"
#include "../../include/MiniDumper.h"
using namespace Proud;
class CIExceptionLoggerDelegate : public IExceptionLoggerDelegate
{
public:
virtual String GetDumpDirectory()
{
return L"";
}
};
CIExceptionLoggerDelegate g_loggerInfo;
void AccessViolation()
{
try
{
int* a = 0;
// 이 루틴은 크래쉬를 의도적으로 발생시킵니다.
// This routine incurs crash on purpose.
// 该例程将会故意造成崩溃。
// このルーティンはクラッシュを意図的に発生させます
*a = 1;
}
catch (...) // catch(...) syntax itself is the usable C++ keyword!
{
// 因以上try語句發生碰撞時
// 程序沒有結束,運行點會到這裏。
// 另一方面,錯誤日誌會被exception logger保留爲文件。
// When crash occurs by the above try syntax,
// the execution point moves to here without terminating the program.
// At the same time, exception logger leaves an error log file.
}
}
void main(int argc, char* argv[])
{
int menu = 0;
CExceptionLogger::Instance().Init(&g_loggerInfo);
while (1)
{
puts("MENU: 1. Access Violation('a')");
printf("> ");
menu = getchar();
switch (menu)
{
case 'a':
AccessViolation();
break;
default:
break;
}
}
}