Modified: trunk/Tools/WinLauncher/WinLauncher.cpp (156910 => 156911)
--- trunk/Tools/WinLauncher/WinLauncher.cpp 2013-10-04 20:35:24 UTC (rev 156910)
+++ trunk/Tools/WinLauncher/WinLauncher.cpp 2013-10-04 20:37:53 UTC (rev 156911)
@@ -33,6 +33,7 @@
#include "DOMDefaultImpl.h"
#include "PrintWebUIDelegate.h"
#include "WinLauncherLibResource.h"
+#include "WinLauncherReplace.h"
#include <WebKit/WebKitCOMAPI.h>
#include <wtf/ExportMacros.h>
#include <wtf/Platform.h>
@@ -47,9 +48,11 @@
#include <commctrl.h>
#include <commdlg.h>
#include <comutil.h>
+#include <dbghelp.h>
#include <functional>
#include <objbase.h>
#include <shellapi.h>
+#include <shlobj.h>
#include <shlwapi.h>
#include <string>
#include <vector>
@@ -180,7 +183,8 @@
if (FAILED(hr))
errorDescription = L"Failed to load page and to localize error description.";
- ::MessageBoxW(0, static_cast<LPCWSTR>(errorDescription), L"Error", MB_APPLMODAL | MB_OK);
+ if (_wcsicmp(errorDescription, L"Cancelled"))
+ ::MessageBoxW(0, static_cast<LPCWSTR>(errorDescription), L"Error", MB_APPLMODAL | MB_OK);
return S_OK;
}
@@ -408,11 +412,40 @@
return true;
}
+void createCrashReport(EXCEPTION_POINTERS* exceptionPointers)
+{
+ wchar_t appDataDirectory[MAX_PATH];
+ if (FAILED(SHGetFolderPathW(0, CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE, 0, 0, appDataDirectory)))
+ return;
-#if USE(CF)
-extern "C" void _CFRunLoopSetWindowsMessageQueueMask(CFRunLoopRef, uint32_t, CFStringRef);
+ std::wstring directory = std::wstring(appDataDirectory) + L"\\WinLauncher";
+ if (::SHCreateDirectoryEx(0, directory.c_str(), 0) != ERROR_SUCCESS
+ && ::GetLastError() != ERROR_FILE_EXISTS
+ && ::GetLastError() != ERROR_ALREADY_EXISTS)
+ return;
+
+ std::wstring fileName = directory + L"\\CrashReport.dmp";
+ HANDLE miniDumpFile = ::CreateFile(fileName.c_str(), GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
+
+ if (miniDumpFile && miniDumpFile != INVALID_HANDLE_VALUE) {
+
+ MINIDUMP_EXCEPTION_INFORMATION mdei;
+ mdei.ThreadId = ::GetCurrentThreadId();
+ mdei.ExceptionPointers = exceptionPointers;
+ mdei.ClientPointers = 0;
+
+#ifdef _DEBUG
+ MINIDUMP_TYPE dumpType = MiniDumpWithFullMemory;
+#else
+ MINIDUMP_TYPE dumpType = MiniDumpNormal;
#endif
+ ::MiniDumpWriteDump(::GetCurrentProcess(), ::GetCurrentProcessId(), miniDumpFile, dumpType, &mdei, 0, 0);
+ ::CloseHandle(miniDumpFile);
+ processCrashReport(fileName.c_str());
+ }
+}
+
extern "C" __declspec(dllexport) int WINAPI dllLauncherEntryPoint(HINSTANCE, HINSTANCE, LPTSTR, int nCmdShow)
{
#ifdef _CRTDBG_MAP_ALLOC
@@ -539,8 +572,7 @@
if (FAILED(hr))
goto exit;
- _bstr_t defaultHTML(L"<p style=\"background-color: #00FF00\">Testing</p><img id=\"webkit logo\" src="" alt=\"Face\"><div style=\"border: solid blue; background: white;\" contenteditable=\"true\">div with blue border</div><ul><li>foo<li>bar<li>baz</ul>");
- frame->loadHTMLString(defaultHTML.GetBSTR(), 0);
+ frame->loadHTMLString(_bstr_t(defaultHTML).GetBSTR(), 0);
}
hr = gWebViewPrivate->setTransparent(usesLayeredWebView());
@@ -568,18 +600,20 @@
if (requestedURL.length())
loadURL(requestedURL.GetBSTR());
+#pragma warning(disable:4509)
+
// Main message loop:
+ __try {
+ while (GetMessage(&msg, 0, 0, 0)) {
#if USE(CF)
- _CFRunLoopSetWindowsMessageQueueMask(CFRunLoopGetMain(), QS_ALLINPUT | QS_ALLPOSTMESSAGE, kCFRunLoopDefaultMode);
- CFRunLoopRun();
-#else
- while (GetMessage(&msg, NULL, 0, 0)) {
- if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
+ CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true);
+#endif
+ if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
}
- }
-#endif
+ } __except(createCrashReport(GetExceptionInformation()), EXCEPTION_EXECUTE_HANDLER) { }
exit:
gPrintDelegate->Release();
Added: trunk/Tools/WinLauncher/WinLauncherReplace.h (0 => 156911)
--- trunk/Tools/WinLauncher/WinLauncherReplace.h (rev 0)
+++ trunk/Tools/WinLauncher/WinLauncherReplace.h 2013-10-04 20:37:53 UTC (rev 156911)
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2013 Alex Christensen. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// This file is to make it easier for users to manage changes to the internals of WinLauncher
+
+const wchar_t* defaultHTML = L"<p style=\"background-color: #00FF00\">Testing</p><img id=\"webkit logo\" src="" alt=\"Face\"><div style=\"border: solid blue; background: white;\" contenteditable=\"true\">div with blue border</div><ul><li>foo<li>bar<li>baz</ul>";
+
+void processCrashReport(const wchar_t* fileName) { ::MessageBox(0, fileName, L"Crash Report", MB_OK); }