Index: src/ch/CrashDlg.cpp =================================================================== diff -u --- src/ch/CrashDlg.cpp (revision 0) +++ src/ch/CrashDlg.cpp (revision a1df59e4b47f6d8c347f3cff6cfd1a83cd0ec848) @@ -0,0 +1,71 @@ +// CrashDlg.cpp : implementation file +// + +#include "stdafx.h" +#include "ch.h" +#include "CrashDlg.h" +#include "version.h" + +#define IDS_CRASH_TITLE _T("Application crashed") +#define IDS_STATIC_INFO _T("Copy Handler encountered an internal problem and will be closed.\n\nIf you want to help correct this problem in the future releases of program you can send the crash information to the author of this program.") +#define IDS_VERSIONINFO_STATIC _T("Program version:") +#define IDS_LOCATIONINFO_STATIC _T("Crash dump location:") +#define IDS_LOCATION_STATIC _T("Error encountered while trying to create crash dump") +#define IDS_OK _T("&Send the crash information") +#define IDS_CANCEL _T("&Do not send") + +// CCrashDlg dialog + +IMPLEMENT_DYNAMIC(CCrashDlg, CHLanguageDialog) + +CCrashDlg::CCrashDlg(bool bResult, PCTSTR pszFilename, CWnd* pParent /*=NULL*/) + : CDialog(CCrashDlg::IDD, pParent), + m_bResult(bResult), + m_strFilename(pszFilename) +{ +} + +CCrashDlg::~CCrashDlg() +{ +} + +void CCrashDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + DDX_Control(pDX, IDC_VERSION_STATIC, m_ctlVersion); + DDX_Control(pDX, IDC_LOCATION_EDIT, m_ctlLocation); + DDX_Control(pDX, IDOK, m_ctlOKButton); + DDX_Control(pDX, IDC_STATIC_INFO, m_ctlInfo); + DDX_Control(pDX, IDC_VERSIONINFO_STATIC, m_ctlVersionInfo); + DDX_Control(pDX, IDC_LOCATIONINFO_STATIC, m_ctlLocationInfo); + DDX_Control(pDX, IDCANCEL, m_ctlCancelButton); +} + + +BEGIN_MESSAGE_MAP(CCrashDlg, CDialog) +END_MESSAGE_MAP() + + +// CCrashDlg message handlers + +BOOL CCrashDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + SetWindowText(IDS_CRASH_TITLE); + m_ctlInfo.SetWindowText(IDS_STATIC_INFO); + m_ctlVersionInfo.SetWindowText(IDS_VERSIONINFO_STATIC); + m_ctlVersion.SetWindowText(PRODUCT_FULL_VERSION); + m_ctlLocationInfo.SetWindowText(IDS_LOCATIONINFO_STATIC); + if(m_bResult) + m_ctlLocation.SetWindowText(m_strFilename); + else + m_ctlLocation.SetWindowText(IDS_LOCATION_STATIC); + + m_ctlOKButton.SetWindowText(IDS_OK); + m_ctlCancelButton.SetWindowText(IDS_CANCEL); + m_ctlOKButton.EnableWindow(m_bResult); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} Index: src/ch/CrashDlg.h =================================================================== diff -u --- src/ch/CrashDlg.h (revision 0) +++ src/ch/CrashDlg.h (revision a1df59e4b47f6d8c347f3cff6cfd1a83cd0ec848) @@ -0,0 +1,36 @@ +#pragma once +#include "afxwin.h" + + +// CCrashDlg dialog + +class CCrashDlg : public CDialog +{ + DECLARE_DYNAMIC(CCrashDlg) + +public: + CCrashDlg(bool bResult, PCTSTR pszFilename, CWnd* pParent = NULL); // standard constructor + virtual ~CCrashDlg(); + + virtual BOOL OnInitDialog(); + +// Dialog Data + enum { IDD = IDD_CRASH_DIALOG }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + + DECLARE_MESSAGE_MAP() + +protected: + bool m_bResult; + CString m_strFilename; +public: + CStatic m_ctlVersion; + CEdit m_ctlLocation; + CButton m_ctlOKButton; + CStatic m_ctlInfo; + CStatic m_ctlVersionInfo; + CStatic m_ctlLocationInfo; + CButton m_ctlCancelButton; +}; Index: src/ch/ch.cpp =================================================================== diff -u -r4e2dd94e077c0462949fe72a7940295eea8423fa -ra1df59e4b47f6d8c347f3cff6cfd1a83cd0ec848 --- src/ch/ch.cpp (.../ch.cpp) (revision 4e2dd94e077c0462949fe72a7940295eea8423fa) +++ src/ch/ch.cpp (.../ch.cpp) (revision a1df59e4b47f6d8c347f3cff6cfd1a83cd0ec848) @@ -24,6 +24,9 @@ #include "CfgProperties.h" #include "MainWnd.h" #include "..\common\ipcstructs.h" +#include +#include "CrashDlg.h" +#include "version.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -190,8 +193,58 @@ // CCopyHandlerApp initialization #include "charvect.h" +LONG WINAPI MyUnhandledExceptionFilter(struct _EXCEPTION_POINTERS* ExceptionInfo) +{ + // Step1 - should not fail - prepare some more unique crash name, create under the path where ch data exists + TCHAR szPath[_MAX_PATH]; + HRESULT hResult = SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, szPath); + if(FAILED(hResult)) + _tcscpy(szPath, _T("c:\\")); + + CString strPath(szPath); + // make sure to create the required directories if they does not exist + strPath += _T("\\Copy Handler"); + CreateDirectory(strPath, NULL); + strPath += _T("\\Dumps"); + CreateDirectory(strPath, NULL); + + // current date + SYSTEMTIME st; + GetLocalTime(&st); + + TCHAR szName[_MAX_PATH]; + _sntprintf(szName, _MAX_PATH, _T("%s\\ch_crashdump_%hu-%hu-%hu_%hu_%hu_%hu_%hu.dmp"), (PCTSTR)strPath, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); + szPath[_MAX_PATH - 1] = _T('\0'); + + // Step 2 - create the crash dump in case anything happens later + bool bResult = false; + HANDLE hFile = CreateFile(szName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if(hFile != INVALID_HANDLE_VALUE) + { + MINIDUMP_EXCEPTION_INFORMATION mei; + mei.ThreadId = GetCurrentThreadId(); + mei.ExceptionPointers = ExceptionInfo; + mei.ClientPointers = TRUE; + + if(MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpWithProcessThreadData, &mei, NULL, NULL)) + bResult = true; + } + + CloseHandle(hFile); + + CCrashDlg dlgCrash(bResult, szName); + if(dlgCrash.DoModal() == IDOK) + { + // TODO: Handle transferring the file to the remote server + } + + return EXCEPTION_EXECUTE_HANDLER; +} + BOOL CCopyHandlerApp::InitInstance() { + SetUnhandledExceptionFilter(&MyUnhandledExceptionFilter); + CWinApp::InitInstance(); m_hMapObject = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(CSharedConfigStruct), _T("CHLMFile")); @@ -221,7 +274,7 @@ m_resManager.Init(AfxGetInstanceHandle()); m_resManager.SetCallback((PFNNOTIFYCALLBACK)MainRouter); m_cfgManager.GetStringValue(PP_PLANGUAGE, szPath, _MAX_PATH); - TRACE("Help path=%s\n", szPath); + TRACE(_T("Help path=%s\n"), szPath); if (!m_resManager.SetLanguage(ExpandPath(szPath))) { TCHAR szData[2048]; @@ -230,6 +283,9 @@ return FALSE; } + // load crash string just in case + m_strCrashInfo = m_resManager.LoadString(IDS_CRASH_STRING); + // for dialogs CLanguageDialog::SetResManager(&m_resManager); Index: src/ch/ch.h =================================================================== diff -u -r4c272b19c74694c428c943011f279ec064fbd894 -ra1df59e4b47f6d8c347f3cff6cfd1a83cd0ec848 --- src/ch/ch.h (.../ch.h) (revision 4c272b19c74694c428c943011f279ec064fbd894) +++ src/ch/ch.h (.../ch.h) (revision a1df59e4b47f6d8c347f3cff6cfd1a83cd0ec848) @@ -87,6 +87,7 @@ // Implementation HANDLE m_hMapObject; TCHAR m_szHelpPath[_MAX_PATH]; // full file path to the help file + CString m_strCrashInfo; // crash info text //{{AFX_MSG(CCopyHandlerApp) //}}AFX_MSG Index: src/ch/ch.rc =================================================================== diff -u -r66e9ad9a512cec46d691cb1ba012424dc7ac8897 -ra1df59e4b47f6d8c347f3cff6cfd1a83cd0ec848 --- src/ch/ch.rc (.../ch.rc) (revision 66e9ad9a512cec46d691cb1ba012424dc7ac8897) +++ src/ch/ch.rc (.../ch.rc) (revision a1df59e4b47f6d8c347f3cff6cfd1a83cd0ec848) @@ -549,47 +549,18 @@ CONTROL "Support:",IDC_CONTACTSUPPORT_STATICEX,"STATICEX",0x50,185,55,68,8 END - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,28,43,1507 - PRODUCTVERSION 1,28,43,1507 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x29L -#else - FILEFLAGS 0x28L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L +IDD_CRASH_DIALOG DIALOGEX 0, 0, 316, 138 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Application crashed" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "Comments", "Program for copying files/folders" - VALUE "CompanyName", " " - VALUE "FileDescription", "Copy Handler v.1.28-dev" - VALUE "FileVersion", "1.28.43.1507" - VALUE "InternalName", "Copy Handler" - VALUE "LegalCopyright", "Copyright (C) 2001-2007 J�zef Starosczyk" - VALUE "LegalTrademarks", " " - VALUE "OriginalFilename", "COPY HANDLER.EXE" - VALUE "PrivateBuild", " " - VALUE "ProductName", "Copy Handler v.1.28-dev" - VALUE "ProductVersion", "1.28.43.1507" - VALUE "SpecialBuild", " " - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END + LTEXT "",IDC_STATIC_INFO,7,7,302,33 + PUSHBUTTON "",IDCANCEL,259,117,50,14 + PUSHBUTTON "",IDOK,150,117,102,14 + LTEXT "",IDC_VERSIONINFO_STATIC,20,49,83,8 + LTEXT "",IDC_LOCATIONINFO_STATIC,20,65,83,8 + LTEXT "",IDC_VERSION_STATIC,119,49,190,8 + EDITTEXT IDC_LOCATION_EDIT,119,65,190,46,ES_MULTILINE | ES_READONLY | NOT WS_BORDER END @@ -728,6 +699,14 @@ TOPMARGIN, 7 BOTTOMMARGIN, 143 END + + IDD_CRASH_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 309 + TOPMARGIN, 7 + BOTTOMMARGIN, 131 + END END #endif // APSTUDIO_INVOKED @@ -775,7 +754,7 @@ "#define _AFX_NO_PROPERTY_RESOURCES\r\n" "\r\n" "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" + "#if defined(_WIN32) || defined(_WIN64)\r\n" "LANGUAGE 9, 1\r\n" "#pragma code_page(1252)\r\n" "#endif\r\n" @@ -801,6 +780,7 @@ IDS_UNREGISTERERR_STRING "Encountered error while trying to unregister library chext.dll\nError #%lu (%s)." IDS_HELPERR_STRING "Cannot open html help file:\n%s\n" + IDS_CRASH_STRING "Copy Handler encountered an internal problem and will be closed.\n\nIf you want to help correct this problem in the future releases of program you can send the crash information to the author of this program." END STRINGTABLE @@ -1317,7 +1297,7 @@ #define _AFX_NO_PROPERTY_RESOURCES #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 +#if defined(_WIN32) || defined(_WIN64) LANGUAGE 9, 1 #pragma code_page(1252) #endif Index: src/ch/ch.vc90.vcproj =================================================================== diff -u -r4c272b19c74694c428c943011f279ec064fbd894 -ra1df59e4b47f6d8c347f3cff6cfd1a83cd0ec848 --- src/ch/ch.vc90.vcproj (.../ch.vc90.vcproj) (revision 4c272b19c74694c428c943011f279ec064fbd894) +++ src/ch/ch.vc90.vcproj (.../ch.vc90.vcproj) (revision a1df59e4b47f6d8c347f3cff6cfd1a83cd0ec848) @@ -76,7 +76,7 @@ /> @@ -348,16 +348,16 @@ /> @@ -423,7 +423,7 @@ BrowseInformation="0" WarningLevel="4" SuppressStartupBanner="true" - DebugInformationFormat="3" + DebugInformationFormat="4" /> @@ -851,6 +858,7 @@ Name="VCCustomBuildTool" Description="Compiling resources $(InputPath)" CommandLine=""$(SolutionDir)\tools\exe2lng.exe" "$(InputPath)" "$(InputDir)scripts\header.lng" "$(InputDir)chtmp.rc" "$(ProjectDir)langs\english.lng" "$(InputDir)resource.h" "$(VCInstallDir)atlmfc\include\afxres.h" rc.exe /l 0x409 /d "NDEBUG" /d "_AFXDLL" /fo"$(OutDir)\$(InputName).res" "$(InputDir)chtmp.rc" del "$(InputDir)\chtmp.rc" copy "$(ProjectDir)langs\english.lng" "$(OutDir)\langs\english.lng" " + AdditionalDependencies="ch.rc2;version.h" Outputs="$(OutDir)\$(InputName).res" /> @@ -860,6 +868,10 @@ > + + @@ -1003,47 +1015,47 @@ /> + + @@ -1254,7 +1270,7 @@ /> + Index: src/ch/res/ch.rc2 =================================================================== diff -u -re701ed2460c2558eeefab55a1f3ed1d2c89a56c0 -ra1df59e4b47f6d8c347f3cff6cfd1a83cd0ec848 --- src/ch/res/ch.rc2 (.../ch.rc2) (revision e701ed2460c2558eeefab55a1f3ed1d2c89a56c0) +++ src/ch/res/ch.rc2 (.../ch.rc2) (revision a1df59e4b47f6d8c347f3cff6cfd1a83cd0ec848) @@ -1,13 +1,55 @@ // -// SYSTEMTRAY.RC2 - resources Microsoft Visual C++ does not edit directly +// ch.rc2 - resources Microsoft Visual C++ does not edit directly // #ifdef APSTUDIO_INVOKED #error this file is not editable by Microsoft Visual C++ #endif //APSTUDIO_INVOKED +#include "version.h" ///////////////////////////////////////////////////////////////////////////// // Add manually edited resources here... +///////////////////////////////////////////////////////////////////////////// +// +// Version +// +VS_VERSION_INFO VERSIONINFO + FILEVERSION PRODUCT_VERSION1, PRODUCT_VERSION2, PRODUCT_VERSION3, PRODUCT_VERSION4 + PRODUCTVERSION PRODUCT_VERSION1, PRODUCT_VERSION2, PRODUCT_VERSION3, PRODUCT_VERSION4 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x29L +#else + FILEFLAGS 0x28L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Program for copying files/folders" + VALUE "CompanyName", " " + VALUE "FileDescription", PRODUCT_FULL_VERSION + VALUE "FileVersion", PRODUCT_VERSION + VALUE "InternalName", PRODUCT_NAME + VALUE "LegalCopyright", COPYRIGHT_INFO + VALUE "LegalTrademarks", " " + VALUE "OriginalFilename", "Copy Handler.EXE" + VALUE "PrivateBuild", " " + VALUE "ProductName", PRODUCT_FULL_VERSION + VALUE "ProductVersion", PRODUCT_VERSION + VALUE "SpecialBuild", " " + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + ///////////////////////////////////////////////////////////////////////////// Index: src/ch/resource.h =================================================================== diff -u -r66e9ad9a512cec46d691cb1ba012424dc7ac8897 -ra1df59e4b47f6d8c347f3cff6cfd1a83cd0ec848 --- src/ch/resource.h (.../resource.h) (revision 66e9ad9a512cec46d691cb1ba012424dc7ac8897) +++ src/ch/resource.h (.../resource.h) (revision a1df59e4b47f6d8c347f3cff6cfd1a83cd0ec848) @@ -55,6 +55,7 @@ #define IDD_SHORTCUTEDIT_DIALOG 208 #define IDD_RECENTEDIT_DIALOG 209 #define IDC_ABOUTBOX 210 +#define IDD_CRASH_DIALOG 212 #define IDC_PROGRAM_STATIC 1000 #define IDC_ADDFILE_BUTTON 1002 #define IDC_STATUS_LIST 1003 @@ -288,6 +289,14 @@ #define IDC_LICENSE_STATICEX 1267 #define IDC_CONTACTAUTHOR_STATICEX 1268 #define IDC_CONTACTSUPPORT_STATICEX 1269 +#define IDC_SEND_CRASHDUMP_BUTTON 1272 +#define IDC_STATIC00 1275 +#define IDC_STATIC_INFO 1275 +#define IDC_VERSION_STATIC 1276 +#define IDC_VERSIONINFO_STATIC 1278 +#define IDC_LOCATIONINFO_STATIC 1279 +#define IDC_EDIT1 1280 +#define IDC_LOCATION_EDIT 1280 #define IDS_APPNAME_STRING 5000 #define IDS_PRIORITY0_STRING 5001 #define IDS_PRIORITY1_STRING 5002 @@ -316,6 +325,7 @@ #define IDS_UNREGISTEROK_STRING 6003 #define IDS_UNREGISTERERR_STRING 6004 #define IDS_HELPERR_STRING 6005 +#define IDS_CRASH_STRING 6006 #define IDS_OTFSEARCHINGFORFILES_STRING 7000 #define IDS_OTFMISSINGCLIPBOARDINPUT_STRING 7001 #define IDS_OTFADDINGCLIPBOARDFILE_STRING 7002 @@ -631,9 +641,9 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 212 +#define _APS_NEXT_RESOURCE_VALUE 213 #define _APS_NEXT_COMMAND_VALUE 32816 -#define _APS_NEXT_CONTROL_VALUE 1268 +#define _APS_NEXT_CONTROL_VALUE 1281 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif